[fix][client] Fix StateMachineImpl::Shutdown deadlock and DiskCacheManager CHECK crash - #1048
Open
chuandew wants to merge 1 commit into
Open
[fix][client] Fix StateMachineImpl::Shutdown deadlock and DiskCacheManager CHECK crash#1048chuandew wants to merge 1 commit into
chuandew wants to merge 1 commit into
Conversation
…tex before join; replace CHECK_RUNNING with early return in DiskCacheManager background tasks
Wine93
approved these changes
Aug 10, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Aug 10, 2026
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.
What
Two independent bugs found during shutdown-path code review (triggered by dingo-client SIGSEGV analysis):
StateMachineImpl::Shutdown() deadlock —
Shutdown()holdsmutex_while callingexecution_queue_join(), butProcessEvent()(drained by the queue) also needsmutex_. Classic lock-reversal deadlock when StateEvents are still queued at shutdown time.DiskCacheManager CHECK_RUNNING crash —
TaskThreadPool::Stop()does not drain its queue; workers execute remaining tasks afterrunning_is set to false.CleanupExpire()andCheckFreeSpace()useCHECK_RUNNING, which aborts (SIGABRT) in this window.Changes
src/cache/iutil/state_machine_impl.cc: Releasemutex_beforeexecution_queue_stop/join—ProcessEventcan drain queued events without deadlock.src/cache/local/disk_cache_manager.cc: ReplaceCHECK_RUNNINGwith early-return inCleanupExpire()andCheckFreeSpace()— safe no-op when manager is already shutting down.Test
DiskHealthChecker*: 5/5 PASSDiskCacheManagerTest.StartAndShutdownIdempotent: 10/10 PASS (stable crash before fix)LocalFileSystem*+DiskCacheWatcher*: 4/4 PASSDiskCacheManagerTest.*(all 19): 18/19 PASS (1 pre-existing flakyEvictionIsPerShardIndependent, same rate on unmodified code)