This is an automated email from the ASF dual-hosted git repository.

zaynt4606 pushed a commit to branch branch-0.7
in repository https://gitbox.apache.org/repos/asf/celeborn.git


The following commit(s) were added to refs/heads/branch-0.7 by this push:
     new e3374dc533 [CELEBORN-2510] Fix ThreadStackTrace.toString dropping 
blockedByThreadId
e3374dc533 is described below

commit e3374dc533696650359355d1ba706b062df52234
Author: yew1eb <[email protected]>
AuthorDate: Thu Nov 5 01:37:16 2026 +0800

    [CELEBORN-2510] Fix ThreadStackTrace.toString dropping blockedByThreadId
    
    ### 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.Object20ad9418owned by 
"holder-thread"
    ```
    After:
    ```
    "blocked-thread" Id=30 BLOCKED on java.lang.Object20ad9418 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.Object20ad9418 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?
    
    - [x] 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.
    
    Closes #3907 from yew1eb/fix-thread-stack-trace-blocked-by-thread-id.
    
    Authored-by: yew1eb <[email protected]>
    Signed-off-by: zhengtao <[email protected]>
    
    
    (cherry picked from commit f52398793fb772c30aa420ac860e4d4e6a38c082)
    Signed-off-by: zhengtao <[email protected]>
    
    Co-Authored-By: Codex <[email protected]>
    AI-Model: gpt-6
    AI-Contributed/Feature: 0/4
    AI-Contributed/UT: 0/0
---
 .../src/main/scala/org/apache/celeborn/common/util/ThreadUtils.scala  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/common/src/main/scala/org/apache/celeborn/common/util/ThreadUtils.scala 
b/common/src/main/scala/org/apache/celeborn/common/util/ThreadUtils.scala
index d745e8b088..3a41b89004 100644
--- a/common/src/main/scala/org/apache/celeborn/common/util/ThreadUtils.scala
+++ b/common/src/main/scala/org/apache/celeborn/common/util/ThreadUtils.scala
@@ -463,9 +463,9 @@ case class ThreadStackTrace(
       s""""$threadName" Id=$threadId $threadState""")
     lockName.foreach(lock => sb.append(s" on $lock"))
     lockOwnerName.foreach {
-      owner => sb.append(s"""owned by "$owner"""")
+      owner => sb.append(s""" owned by "$owner"""")
     }
-    blockedByThreadId.foreach(id => s" Id=$id")
+    blockedByThreadId.foreach(id => sb.append(s" Id=$id"))
     if (suspended) sb.append(" (suspended)")
     if (inNative) sb.append(" (in native)")
     sb.append('\n')

Reply via email to