[FLINK-39984][runtime][webUI] Dispatch thread dump to ioExecutor and support SAFE/FULL modes#28732
Open
xingsuo-zbz wants to merge 1 commit into
Open
[FLINK-39984][runtime][webUI] Dispatch thread dump to ioExecutor and support SAFE/FULL modes#28732xingsuo-zbz wants to merge 1 commit into
xingsuo-zbz wants to merge 1 commit into
Conversation
…support SAFE/FULL modes
requestThreadDump ran ThreadDumpInfo.dumpAndCreate synchronously on the
RPC main thread and always called ThreadMXBean.dumpAllThreads(true, true).
On busy TaskManagers this stalled the actor mailbox behind the dump AND
paused the JVM in a safepoint long enough to miss heartbeats, causing the
JobManager to fail over an otherwise healthy TM.
- Offload dump construction to ioExecutor via CompletableFuture.supplyAsync,
matching requestLogList and similar RPCs.
- Introduce ThreadDumpMode {SAFE, FULL}. SAFE calls dumpAllThreads(false,
false) (stack traces only); FULL preserves today's (true, true) behavior.
The mode is selected per-request via the new optional query parameter
`?mode=safe|full`; its default is cluster.thread-dump.default-mode
(default FULL, unchanged behavior on upgrade; SAFE recommended for large
clusters).
- Expose a Safe/Full toggle on both thread-dump pages in the Web UI. The
selection does not auto-fetch; the download link tracks it.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Collaborator
Contributor
|
A few minor comments before the review:
|
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 is the purpose of the change
Fixes FLINK-39984. Clicking "Thread Dump" on a JobManager or TaskManager in the Web UI can cause the targeted
process to miss heartbeats and be marked dead by the JobManager, taking down otherwise healthy running jobs. Two
independent issues compound:
synchronously on the RPC main thread. While the dump is being built the actor mailbox does not advance, so heartbeat
replies, task lifecycle messages, and checkpoint coordination all queue up behind it. Other heavy handlers in
TaskExecutor (requestLogList, requestFileUploadByFilePath, updatePartitions) are already offloaded to ioExecutor —
this one was not.
monitors and j.u.c. synchronizers requires walking every thread's lock state inside a single JVM safepoint. On JVMs
with many threads (Netty + RocksDB + async I/O + user threads — 10k+ in production is not uncommon) this takes
seconds to tens of seconds, during which every thread in the JVM (including the heartbeat dispatcher) is paused. If
the safepoint plus mailbox queueing exceeds heartbeat.timeout (default 50 s), the JM triggers an unnecessary
failover.
Offloading alone helps short dumps but not long ones (the safepoint pauses the heartbeat thread regardless of which
executor scheduled the dump). Restricting the safepoint work alone leaves the mailbox stall in place. Both fixes are
needed.
Brief change log
CompletableFuture.supplyAsync, matching the pattern already used by other heavy TE handlers.
ResourceManagerGateway / TaskExecutorGatewayDecoratorBase / NonLeaderRetrievalRestfulGateway.
analysis.
/taskmanagers/{id}/thread-dump via a new ThreadDumpModeQueryParameter and two new MessageParameters classes; unknown
values become HTTP 400.
parameter is supplied. Default is deliberately FULL to preserve the existing on-upgrade behavior; the description
flags SAFE as the recommended value for large clusters. A separate dev@ discussion will decide whether to flip the
default in a future release.
(flink-runtime-web/web-dashboard/.../{job,task}-manager/thread-dump/). Selecting a mode does not auto-fetch; the
user must press the refresh button (avoids surprising the operator when they merely click the toggle). The download
link tracks the current selection so exported dumps match the on-screen content.
Verifying this change
This change added tests and can be verified as follows:
New unit tests
→ IllegalArgumentException, and lower-case serialization.
non-empty dump for null, SAFE, and FULL, and (b) when mode is omitted the request honors
cluster.thread-dump.default-mode (the test overrides it to SAFE and asserts the "Number of locked synchronizers"
section is absent, which only appears in FULL).
Existing tests updated
against the updated snapshot.
Does this pull request potentially affect one of the following parts:
@Public(Evolving): norequest no longer blocks the RPC mailbox and when the operator selects SAFE, the
safepoint pause is short enough not to trip heartbeat.timeout.)
Documentation
cluster.thread-dump.default-modeconfig option.Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Claude Opus 4.7)