Skip to content

KAFKA-17932: Avoid shutdown deadlock after metadata faults - #23046

Open
lh0156 wants to merge 1 commit into
apache:trunkfrom
lh0156:agent/KAFKA-17932-shutdown-deadlock
Open

KAFKA-17932: Avoid shutdown deadlock after metadata faults#23046
lh0156 wants to merge 1 commit into
apache:trunkfrom
lh0156:agent/KAFKA-17932-shutdown-deadlock

Conversation

@lh0156

@lh0156 lh0156 commented Aug 2, 2026

Copy link
Copy Markdown

Closes KAFKA-17932

Summary

  • Avoid taking the SharedServer monitor from the metadata loader fault action.
  • Prevent shutdown from deadlocking while SharedServer holds the monitor and waits for the metadata loader event thread.
  • Add a regression test that reproduces the lock-ordering failure and verifies the action completes while the monitor is held.

The metadata loader event handler can invoke the fault action after a metadata loading failure. Shutdown synchronizes on SharedServer and then joins the metadata loader event thread. The previous synchronized fault action inverted that order and could block both threads indefinitely. The metrics fields are volatile and the snapshot disable reason uses an atomic reference, so the action does not need the SharedServer monitor.

Tests

  • ./gradlew :core:test --tests kafka.server.SharedServerTest --no-build-cache --console=plain
  • ./gradlew :core:spotlessCheck --no-build-cache --console=plain
  • git diff --check

The regression test was verified to fail on the base branch with a timeout, then pass after removing the unnecessary monitor acquisition.

Do not acquire the SharedServer monitor from the metadata loader fault action. Shutdown holds this monitor while joining the metadata loader event thread, so acquiring it from that thread can deadlock. Add a regression test that holds the monitor while invoking the action.

Generated-by: OpenAI Codex (GPT-5)
Signed-off-by: Yunseop Eom <62834176+lh0156@users.noreply.github.com>
@github-actions github-actions Bot added triage PRs from the community core Kafka Broker labels Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Kafka Broker triage PRs from the community

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant