[Store] Fix snapshot restore deadlock for unready segments - #4022
Open
waizuichougou wants to merge 1 commit into
Open
[Store] Fix snapshot restore deadlock for unready segments#4022waizuichougou wants to merge 1 commit into
waizuichougou wants to merge 1 commit into
Conversation
waizuichougou
requested review from
00fish0,
Aionw,
Icedcoco,
Libotry,
XucSh,
YiXR,
stmatengss and
ykwd
as code owners
September 11, 2026 02:51
waizuichougou
force-pushed
the
fix/snapshot-restore-deadlock
branch
from
September 11, 2026 03:19
b27fabc to
fc4521d
Compare
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
MasterService::ApplySnapshotState()held aScopedSegmentAccesswhilecalling
UnmountSegment()for unready segments.ScopedSegmentAccessowns the segment manager's non-recursivestd::shared_mutex, andUnmountSegment()acquires the same lock again.When a snapshot contains a segment in a non-OK lifecycle state, snapshot
restore can deadlock permanently while cleaning up that segment.
This change copies unready segment records while holding the segment lock,
releases the accessor, and then unmounts the segments. Unexpected unmount
errors are also logged.
A regression test covers snapshot restore with a
GRACEFULLY_UNMOUNTINGsegment.Module
mooncake-transfer-engine)mooncake-store)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?
Test commands:
cmake --build build --target master_service_test_for_snapshot -j4 ./build/mooncake-store/tests/master_service_test_for_snapshot \ --gtest_filter=MasterServiceSnapshotTest.ApplySnapshotStateUnmountsUnreadySegmentsWithoutDeadlocking ./build/mooncake-store/tests/master_service_test_for_snapshot \ --gtest_filter=MasterServiceSnapshotTest.*Test results:
The focused regression test passed, and all 70
MasterServiceSnapshotTesttests passed.Checklist
clang-formatAI Assistance Disclosure
AI assistance was used for this contribution.