Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/layouts/shortcodes/generated/cluster_configuration.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@
<td>Duration</td>
<td>The shutdown timeout for cluster services like executors.</td>
</tr>
<tr>
<td><h5>cluster.thread-dump.default-mode</h5></td>
<td style="word-wrap: break-word;">"FULL"</td>
<td>String</td>
<td>Default granularity of the JobManager/TaskManager thread-dump REST endpoint when no explicit <code class="highlighter-rouge">mode</code> query parameter is supplied. Allowed values (case-insensitive): <code class="highlighter-rouge">SAFE</code> (stack traces only, negligible JVM pause) and <code class="highlighter-rouge">FULL</code> (adds locked monitors and j.u.c. synchronizers, equivalent to jstack -l; pauses the JVM in a safepoint for a duration that scales with heap size and thread count -- seconds on large TaskManagers). The default is <code class="highlighter-rouge">FULL</code> to preserve historical behavior; operators of large clusters are strongly encouraged to switch to <code class="highlighter-rouge">SAFE</code> to avoid heartbeat timeouts caused by long safepoint pauses.</td>
</tr>
<tr>
<td><h5>cluster.thread-dump.stacktrace-max-depth</h5></td>
<td style="word-wrap: break-word;">50</td>
Expand Down
6 changes: 6 additions & 0 deletions docs/layouts/shortcodes/generated/expert_cluster_section.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@
<td>Boolean</td>
<td>Whether processes should halt on fatal errors instead of performing a graceful shutdown. In some environments (e.g. Java 8 with the G1 garbage collector), a regular graceful shutdown can lead to a JVM deadlock. See <a href="https://issues.apache.org/jira/browse/FLINK-16510">FLINK-16510</a> for details.</td>
</tr>
<tr>
<td><h5>cluster.thread-dump.default-mode</h5></td>
<td style="word-wrap: break-word;">"FULL"</td>
<td>String</td>
<td>Default granularity of the JobManager/TaskManager thread-dump REST endpoint when no explicit <code class="highlighter-rouge">mode</code> query parameter is supplied. Allowed values (case-insensitive): <code class="highlighter-rouge">SAFE</code> (stack traces only, negligible JVM pause) and <code class="highlighter-rouge">FULL</code> (adds locked monitors and j.u.c. synchronizers, equivalent to jstack -l; pauses the JVM in a safepoint for a duration that scales with heap size and thread count -- seconds on large TaskManagers). The default is <code class="highlighter-rouge">FULL</code> to preserve historical behavior; operators of large clusters are strongly encouraged to switch to <code class="highlighter-rouge">SAFE</code> to avoid heartbeat timeouts caused by long safepoint pauses.</td>
</tr>
<tr>
<td><h5>cluster.thread-dump.stacktrace-max-depth</h5></td>
<td style="word-wrap: break-word;">50</td>
Expand Down
20 changes: 20 additions & 0 deletions docs/layouts/shortcodes/generated/rest_v1_dispatcher.html
Original file line number Diff line number Diff line change
Expand Up @@ -1383,6 +1383,16 @@
<tr>
<td colspan="2">Returns the thread dump of the JobManager.</td>
</tr>
<tr>
<td colspan="2">Query parameters</td>
</tr>
<tr>
<td colspan="2">
<ul>
<li><code>mode</code> (optional): Controls how much lock information is collected. Supported values: [SAFE, FULL]. When omitted, cluster.thread-dump.default-mode is used.</li>
</ul>
</td>
</tr>
<tr>
<td colspan="2">
<label>
Expand Down Expand Up @@ -7121,6 +7131,16 @@
</ul>
</td>
</tr>
<tr>
<td colspan="2">Query parameters</td>
</tr>
<tr>
<td colspan="2">
<ul>
<li><code>mode</code> (optional): Controls how much lock information is collected. Supported values: [SAFE, FULL]. When omitted, cluster.thread-dump.default-mode is used.</li>
</ul>
</td>
</tr>
<tr>
<td colspan="2">
<label>
Expand Down
22 changes: 22 additions & 0 deletions docs/static/generated/rest_v1_dispatcher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,15 @@ paths:
get:
description: Returns the thread dump of the JobManager.
operationId: getJobManagerThreadDump
parameters:
- name: mode
in: query
description: "Controls how much lock information is collected. Supported values:\
\ [SAFE, FULL]. When omitted, cluster.thread-dump.default-mode is used."
required: false
style: form
schema:
$ref: "#/components/schemas/ThreadDumpMode"
responses:
"200":
description: The request was successful.
Expand Down Expand Up @@ -1863,6 +1872,14 @@ paths:
required: true
schema:
$ref: "#/components/schemas/ResourceID"
- name: mode
in: query
description: "Controls how much lock information is collected. Supported values:\
\ [SAFE, FULL]. When omitted, cluster.thread-dump.default-mode is used."
required: false
style: form
schema:
$ref: "#/components/schemas/ThreadDumpMode"
responses:
"200":
description: The request was successful.
Expand Down Expand Up @@ -3911,6 +3928,11 @@ components:
type: array
items:
$ref: "#/components/schemas/ThreadInfo"
ThreadDumpMode:
type: string
enum:
- SAFE
- FULL
ThreadInfo:
type: object
properties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,31 @@ public class ClusterOptions {
.withDescription(
"The maximum stacktrace depth of TaskManager and JobManager's thread dump web-frontend displayed.");

@Documentation.Section(Documentation.Sections.EXPERT_CLUSTER)
public static final ConfigOption<String> THREAD_DUMP_DEFAULT_MODE =
key("cluster.thread-dump.default-mode")
.stringType()
.defaultValue("FULL")
.withDescription(
Description.builder()
.text(
"Default granularity of the JobManager/TaskManager thread-dump REST endpoint "
+ "when no explicit %s query parameter is supplied. ",
code("mode"))
.text(
"Allowed values (case-insensitive): %s (stack traces only, negligible JVM pause) "
+ "and %s (adds locked monitors and j.u.c. synchronizers, equivalent "
+ "to jstack -l; pauses the JVM in a safepoint for a duration that "
+ "scales with heap size and thread count -- seconds on large "
+ "TaskManagers). ",
code("SAFE"), code("FULL"))
.text(
"The default is %s to preserve historical behavior; operators of large "
+ "clusters are strongly encouraged to switch to %s to avoid "
+ "heartbeat timeouts caused by long safepoint pauses.",
code("FULL"), code("SAFE"))
.build());

@Documentation.Section(Documentation.Sections.EXPERT_CLUSTER)
public static final ConfigOption<UncaughtExceptionHandleMode> UNCAUGHT_EXCEPTION_HANDLING =
ConfigOptions.key("cluster.uncaught-exception-handling")
Expand Down
10 changes: 8 additions & 2 deletions flink-runtime-web/src/test/resources/rest_api_v1.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,10 @@
"pathParameters" : [ ]
},
"query-parameters" : {
"queryParameters" : [ ]
"queryParameters" : [ {
"key" : "mode",
"mandatory" : false
} ]
},
"request" : {
"type" : "object",
Expand Down Expand Up @@ -5429,7 +5432,10 @@
} ]
},
"query-parameters" : {
"queryParameters" : [ ]
"queryParameters" : [ {
"key" : "mode",
"mandatory" : false
} ]
},
"request" : {
"type" : "object",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,34 @@
[ngModel]="dump"
[nzEditorOption]="editorOptions"
></nz-code-editor>
<flink-addon-compact
[downloadHref]="downloadUrl"
[downloadName]="downloadName"
(reload)="reload()"
></flink-addon-compact>
<div class="thread-dump-toolbar">
<nz-space-compact class="thread-dump-mode-group">
<a
nz-button
nzSize="small"
[nzType]="mode === 'safe' ? 'primary' : 'default'"
nz-tooltip
nzTooltipTitle="Stack traces only, no lock info (jstack without -l). Negligible JVM pause."
(click)="selectMode('safe')"
>
Safe
</a>
<a
nz-button
nzSize="small"
[nzType]="mode === 'full' ? 'primary' : 'default'"
[nzDanger]="true"
nz-tooltip
nzTooltipTitle="Adds locked monitors and j.u.c. synchronizers (jstack -l). Pauses the JVM in a safepoint for a duration that scales with heap size and thread count — seconds on large JMs."
(click)="selectMode('full')"
>
Full
<i nz-icon nzType="exclamation-circle" nzTheme="fill" class="thread-dump-mode-warn"></i>
</a>
</nz-space-compact>
<flink-addon-compact
[downloadHref]="downloadUrl"
[downloadName]="downloadName"
(reload)="reload()"
></flink-addon-compact>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,25 @@
left: 0;
}
}

.thread-dump-toolbar {
position: absolute;
top: 8px;
right: 32px;
z-index: 1;
display: flex;
gap: 8px;
align-items: center;

flink-addon-compact {
position: static;
top: auto;
right: auto;
}
}

.thread-dump-mode-group {
.thread-dump-mode-warn {
margin-left: 4px;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,39 @@ import {
JobManagerModuleConfig
} from '@flink-runtime-web/pages/job-manager/job-manager.config';
import { ConfigService, JobManagerService } from '@flink-runtime-web/services';
import { NzButtonModule } from 'ng-zorro-antd/button';
import { NzCodeEditorModule, EditorOptions } from 'ng-zorro-antd/code-editor';
import { NzIconModule } from 'ng-zorro-antd/icon';
import { NzSpaceModule } from 'ng-zorro-antd/space';
import { NzTooltipModule } from 'ng-zorro-antd/tooltip';

/** See ThreadDumpMode in task-manager-thread-dump.component.ts for semantics. */
type ThreadDumpMode = 'safe' | 'full' | undefined;

@Component({
selector: 'flink-job-manager-thread-dump',
templateUrl: './job-manager-thread-dump.component.html',
styleUrls: ['./job-manager-thread-dump.component.less'],
changeDetection: ChangeDetectionStrategy.OnPush,
imports: [NzCodeEditorModule, AutoResizeDirective, FormsModule, AddonCompactComponent]
imports: [
NzCodeEditorModule,
AutoResizeDirective,
FormsModule,
AddonCompactComponent,
NzButtonModule,
NzIconModule,
NzSpaceModule,
NzTooltipModule
]
})
export class JobManagerThreadDumpComponent implements OnInit, OnDestroy {
public readonly downloadName = `jobmanager_thread_dump`;
public downloadUrl: string;
public editorOptions: EditorOptions;
public dump = '';
public loading = true;
/** See TaskManagerThreadDumpComponent#mode. */
public mode: ThreadDumpMode = undefined;

private readonly destroy$ = new Subject<void>();

Expand All @@ -66,11 +84,24 @@ export class JobManagerThreadDumpComponent implements OnInit, OnDestroy {
this.destroy$.complete();
}

/**
* Switch dump mode. Does NOT auto-reload; user must press the refresh button.
* Download link is updated immediately so a download matches the user's selection.
*/
public selectMode(mode: 'safe' | 'full'): void {
if (this.mode === mode) {
return;
}
this.mode = mode;
this.updateDownloadUrl();
this.cdr.markForCheck();
}

public reload(): void {
this.loading = true;
this.cdr.markForCheck();
this.jobManagerService
.loadThreadDump()
.loadThreadDump(this.mode)
.pipe(
catchError(() => of('')),
takeUntil(this.destroy$)
Expand All @@ -81,4 +112,9 @@ export class JobManagerThreadDumpComponent implements OnInit, OnDestroy {
this.cdr.markForCheck();
});
}

private updateDownloadUrl(): void {
const base = `${this.configService.BASE_URL}/jobmanager/thread-dump`;
this.downloadUrl = this.mode ? `${base}?mode=${this.mode}` : base;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,34 @@
[nzEditorOption]="editorOptions"
(nzEditorInitialized)="nzEditorInitialized($event)"
></nz-code-editor>
<flink-addon-compact
[downloadHref]="downloadUrl"
[downloadName]="downloadName"
(reload)="reload()"
></flink-addon-compact>
<div class="thread-dump-toolbar">
<nz-space-compact class="thread-dump-mode-group">
<a
nz-button
nzSize="small"
[nzType]="mode === 'safe' ? 'primary' : 'default'"
nz-tooltip
nzTooltipTitle="Stack traces only, no lock info (jstack without -l). Negligible JVM pause."
(click)="selectMode('safe')"
>
Safe
</a>
<a
nz-button
nzSize="small"
[nzType]="mode === 'full' ? 'primary' : 'default'"
[nzDanger]="true"
nz-tooltip
nzTooltipTitle="Adds locked monitors and j.u.c. synchronizers (jstack -l). Pauses the JVM in a safepoint for a duration that scales with heap size and thread count — seconds on large TMs."
(click)="selectMode('full')"
>
Full
<i nz-icon nzType="exclamation-circle" nzTheme="fill" class="thread-dump-mode-warn"></i>
</a>
</nz-space-compact>
<flink-addon-compact
[downloadHref]="downloadUrl"
[downloadName]="downloadName"
(reload)="reload()"
></flink-addon-compact>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,28 @@
left: 0;
}
}

.thread-dump-toolbar {
position: absolute;
top: 8px;
right: 32px;
z-index: 1;
display: flex;
gap: 8px;
align-items: center;

// Inner <flink-addon-compact> is also position:absolute by default; neutralize
// it so it stacks naturally to the right of the mode selector inside this flex
// container.
flink-addon-compact {
position: static;
top: auto;
right: auto;
}
}

.thread-dump-mode-group {
.thread-dump-mode-warn {
margin-left: 4px;
}
}
Loading