Skip to content

[fix][client] Fix StateMachineImpl::Shutdown deadlock and DiskCacheManager CHECK crash - #1048

Open
chuandew wants to merge 1 commit into
dingodb:mainfrom
chuandew:investigate/shutdown-segv-20260803
Open

[fix][client] Fix StateMachineImpl::Shutdown deadlock and DiskCacheManager CHECK crash#1048
chuandew wants to merge 1 commit into
dingodb:mainfrom
chuandew:investigate/shutdown-segv-20260803

Conversation

@chuandew

Copy link
Copy Markdown
Member

What

Two independent bugs found during shutdown-path code review (triggered by dingo-client SIGSEGV analysis):

  1. StateMachineImpl::Shutdown() deadlockShutdown() holds mutex_ while calling execution_queue_join(), but ProcessEvent() (drained by the queue) also needs mutex_. Classic lock-reversal deadlock when StateEvents are still queued at shutdown time.

  2. DiskCacheManager CHECK_RUNNING crashTaskThreadPool::Stop() does not drain its queue; workers execute remaining tasks after running_ is set to false. CleanupExpire() and CheckFreeSpace() use CHECK_RUNNING, which aborts (SIGABRT) in this window.

Changes

  • src/cache/iutil/state_machine_impl.cc: Release mutex_ before execution_queue_stop/joinProcessEvent can drain queued events without deadlock.
  • src/cache/local/disk_cache_manager.cc: Replace CHECK_RUNNING with early-return in CleanupExpire() and CheckFreeSpace() — safe no-op when manager is already shutting down.

Test

  • DiskHealthChecker*: 5/5 PASS
  • DiskCacheManagerTest.StartAndShutdownIdempotent: 10/10 PASS (stable crash before fix)
  • LocalFileSystem* + DiskCacheWatcher*: 4/4 PASS
  • DiskCacheManagerTest.* (all 19): 18/19 PASS (1 pre-existing flaky EvictionIsPerShardIndependent, same rate on unmodified code)

…tex before join; replace CHECK_RUNNING with early return in DiskCacheManager background tasks
@chuandew
chuandew added this pull request to the merge queue Aug 10, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants