Commit 0d4efb1
committed
Fix race condition in DirectRunner executor shutdown
Previously, in ExecutorServiceParallelExecutor, if an exception
occurred during registry cleanup (such as a timeout inside
DoFn teardown), the pipeline state was transitioned to terminal
before the exception was queued in `visibleUpdates`.
This introduced a race condition where `waitUntilFinish()` could
detect the terminal state and exit successfully before the
exception was offered to the updates queue, swallowing the exception.
This caused tests like `CallTest.givenTeardownTimeout_throwsError`
to fail since they expected the pipeline to throw an exception.
This change swaps the order so that the exception is posted to
`visibleUpdates` before updating the pipeline state to terminal,
ensuring the exception is always propagated.1 parent 464546b commit 0d4efb1
1 file changed
Lines changed: 5 additions & 2 deletions
File tree
- runners/direct-java/src/main/java/org/apache/beam/runners/direct
Lines changed: 5 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
348 | 348 | | |
349 | 349 | | |
350 | 350 | | |
351 | | - | |
| 351 | + | |
352 | 352 | | |
353 | | - | |
| 353 | + | |
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
362 | 365 | | |
363 | 366 | | |
364 | 367 | | |
| |||
0 commit comments