Skip to content

[CELEBORN-2510] Fix ThreadStackTrace.toString dropping blockedByThreadId - #3907

Open
yew1eb wants to merge 1 commit into
apache:mainfrom
yew1eb:fix-thread-stack-trace-blocked-by-thread-id
Open

yew1eb wants to merge 1 commit into
apache:mainfrom
yew1eb:fix-thread-stack-trace-blocked-by-thread-id

Conversation

@yew1eb

@yew1eb yew1eb commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Fix ThreadStackTrace.toString to append (instead of discard) blockedByThreadId, and add the missing leading space before owned by, in common/src/main/scala/org/apache/celeborn/common/util/ThreadUtils.scala.

Before:

"blocked-thread" Id=30 BLOCKED on java.lang.Object@20ad9418owned by "holder-thread"

After:

"blocked-thread" Id=30 BLOCKED on java.lang.Object@20ad9418 owned by "holder-thread" Id=29

Why are the changes needed?

blockedByThreadId.foreach(id => s" Id=$id") returns a String that is never consumed, so it is a no-op and the id of the blocking thread never reaches the thread dump. This defeats the purpose of the class, which is to locate threads that block each other. The output above matches java.lang.management.ThreadInfo.toString() on JDK 9+, verified against a real blocked thread:

"blocked-thread" prio=5 Id=30 BLOCKED on java.lang.Object@20ad9418 owned by "holder-thread" Id=29

The same bug exists in Spark master (core/src/main/scala/org/apache/spark/status/api/v1/api.scala:570); it was inherited when CELEBORN-1697 copied the class from Spark v3.5.1.

Does this PR resolve a correctness bug?

  • Yes

Does this PR introduce any user-facing change?

  • Yes

The text thread dump (/threadDump and logs) now includes the id of the blocking thread and a space before owned by. The JSON endpoint /api/v1/thread_dump is unchanged: it already maps blockedByThreadId explicitly in ApiV1BaseResource.

How was this patch tested?

Verified against a real blocked thread pair: the text dump now prints "blocked-thread" Id=30 BLOCKED on java.lang.Object@... owned by "holder-thread" Id=29, matching java.lang.management.ThreadInfo.toString(). Existing UtilsSuite (34 tests, including getThreadDump) still passes.

@ForVic ForVic left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm minor nit in the pr desc:

the quoted JDK output has prio=5, which only JDK 9+ prints, so “JDK 8” might be off (the part being fixed is the same in both).

@yew1eb

yew1eb commented Oct 29, 2026

Copy link
Copy Markdown
Contributor Author

@ForVic Good catch, thanks! Fixed the PR description — the quoted output is indeed the JDK 9+ format (only 9+ prints prio=). The fixed part (blockedByThreadId no-op + missing space) is identical across JDK versions.

@yew1eb
yew1eb force-pushed the fix-thread-stack-trace-blocked-by-thread-id branch from d3e9929 to 9a46118 Compare November 1, 2026 15:24

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants