Repository navigation
Conversation
sssqqeer
requested review from
Aionw,
ShangmingCai,
UNIDY2002,
XucSh,
YiXR,
alogfans,
staryxchen,
stmatengss,
ykwd and
zxpdemonio
as code owners
November 19, 2026 14:28
1 of 8 tasks
…s unmount A client that gracefully unmounts a segment waits out the grace period on one of the four task_thread_pool_ workers, which also run drain and move tasks. With four or more segments unmounting, the client runs no tasks at all. Graceful unmounts are now watched by a DeadlineScheduler with its own thread. The watcher asks the master once a second whether the segment is gone, from the start of the grace period, so a segment the master removes early is noticed early. The master drops a segment without waiting for read leases, so the client still keeps the memory registered for the default lease TTL (10 s) before it unregisters it and runs the cleanup callback. For a segment the master removes when its grace period ends, the release time stays what it was: about grace + 10 s. Client::GracefulUnmountAllAndWait() gracefully unmounts every mounted segment and waits until the watcher has released all of them, or until grace + 10 s + 3 s. RealClient teardown runs this wait while Client is still up, when a shutdown grace period is set. mooncake_client sets it from the new --shutdown_grace_seconds flag, and the Python close() takes grace_period_seconds. Both default to 0, which keeps today's behavior. EGM segments released this way are skipped by the teardown unmount, so their memory is freed instead of being retained as unconfirmed. Signed-off-by: shibin <306219114@qq.com>
A mount that runs during the graceful close lands outside the unmount snapshot. Teardown now stops new mounts and waits for running ones first. The local memory check also covers gracefully unmounting segments, which still hold the objects their drain moves. Signed-off-by: shibin <306219114@qq.com>
sssqqeer
force-pushed
the
store/graceful-close-keeps-moving
branch
from
November 24, 2026 08:01
b0d6d78 to
859db9e
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Part of RFC #5681 (#1883 Milestone 11, "Migration on Store Exit"), Step 3.
Today, every graceful unmount ties up one of the client's four task workers until the grace period ends. Those same workers run the master's drain and move tasks, so once four segments are unmounting, the client can't move any data off itself until the grace period is over. This PR moves that wait to a separate timer thread. The timer checks with the master once a second. Once the master has removed the segment, the client keeps the memory registered for one more lease TTL, so readers that already looked up the objects can finish, and then releases it.
A client also has no graceful way to shut down.
mooncake_clientand the Pythonclose()unmount everything at once, so in-flight reads fail and the data is gone before it can be moved. This PR adds--shutdown_grace_secondstomooncake_clientandgrace_period_secondstoclose(). Both default to 0, which keeps today's behavior. When set, the client gracefully unmounts all of its segments and keeps working as usual (heartbeating, serving reads, running tasks) until every segment is released, at most about 13 s after the grace period ends.Before this change, four segments unmounting at once took every worker, so a move had to wait for the grace period plus 10 s. Now it runs at the client's next task poll, within about a second. With a 5 s grace period,
close()waits about 15 s before it tears down: the 5 s grace period, up to 1 s to notice the removal, and the 10 s lease hold.Suggested Merge Priority
Module
mooncake-transfer-engine)mooncake-store)mooncake-conductor)mooncake-reshard)mooncake-ep)mooncake-pg)mooncake-integration)mooncake-p2p-store)mooncake-wheel)mooncake-common)mooncake-rl)Type of Change
How Has This Been Tested?
Tested on Linux (Debug build, TCP).
Test commands:
Test results:
task_integration_test: 10 passed, 2 of them new.standalone_client_test: 8 passed, 1 of them new.client_integration_test: 36 passed. The graceful unmount and teardown cases ofpybind_client_test: 9 passed. InGracefulUnmountAllServesMovesAndReturnsOnRemoval, the move is created only after the master reports the source segment asGRACEFULLY_UNMOUNTING, and the client completes it about a second later.Checklist
Signed-off-bytrailer certifying the DCO./scripts/code_format.shAI Assistance Disclosure