Commit bc5ccad
[SPARK-51660][CORE] Gracefully handle when MDC is not supported
### What changes were proposed in this pull request?
This improves the handling when MDC is not supported. The previous handling only works when one task runs on an executor. After this fix multiple tasks can run on an executor when MDC is not supported.
### Why are the changes needed?
In #35141 it added handling to gracefully handle when MDC is not available. It catches NoSuchFieldError, which is thrown during MDC initialization. This will work for the first task. If a second task runs it will not throw a NoSuchFieldError. Instead it throws NoClassDefFoundError. Then the job will hang indefinitely. This improves the fix so it works for all tasks instead of just the first one.
### Does this PR introduce _any_ user-facing change?
Yes, it fixes a bug. It also changes a log message to include the exception for easier debugging.
### How was this patch tested?
I tested it manually in spark-shell by manually throwing `NoSuchFieldError`. It logs this message and does not hang.
```
25/03/28 14:11:48 INFO Executor: MDC is not supported.
java.lang.NoSuchFieldError: this is a test
at org.apache.spark.executor.Executor.liftedTree1$1(Executor.scala:118)
at org.apache.spark.executor.Executor.mdcIsSupported$lzycompute(Executor.scala:114)
at org.apache.spark.executor.Executor.mdcIsSupported(Executor.scala:113)
at org.apache.spark.executor.Executor.org$apache$spark$executor$Executor$$setMDCForTask(Executor.scala:948)
at org.apache.spark.executor.Executor$TaskRunner.run(Executor.scala:584)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
```
### Was this patch authored or co-authored using generative AI tooling?
No
Closes #50452 from robreeves/SPARK-51660.
Authored-by: Rob Reeves <roreeves@linkedin.com>
Signed-off-by: Mridul Muralidharan <mridul<at>gmail.com>1 parent 1fa05b8 commit bc5ccad
File tree
1 file changed
+18
-7
lines changed- core/src/main/scala/org/apache/spark/executor
1 file changed
+18
-7
lines changedLines changed: 18 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
933 | 933 | | |
934 | 934 | | |
935 | 935 | | |
936 | | - | |
| 936 | + | |
937 | 937 | | |
938 | 938 | | |
939 | 939 | | |
940 | | - | |
941 | | - | |
942 | 940 | | |
943 | 941 | | |
944 | 942 | | |
945 | 943 | | |
946 | | - | |
| 944 | + | |
947 | 945 | | |
948 | 946 | | |
949 | | - | |
950 | | - | |
951 | 947 | | |
952 | 948 | | |
953 | 949 | | |
| |||
1318 | 1314 | | |
1319 | 1315 | | |
1320 | 1316 | | |
1321 | | - | |
| 1317 | + | |
1322 | 1318 | | |
1323 | 1319 | | |
1324 | 1320 | | |
| |||
1327 | 1323 | | |
1328 | 1324 | | |
1329 | 1325 | | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
1330 | 1341 | | |
1331 | 1342 | | |
1332 | 1343 | | |
| |||
0 commit comments