Repository navigation
fix(amber): end worker statistics queries at a deadline - #9371
CaroFernando wants to merge 2 commits into
Conversation
Add `newCoordinatorInFlight`, a real `CoordinatorProcessor` with one region in flight, and `SelfMessageCapturingActorService`, which records messages the coordinator schedules to itself (and their cancellation) instead of scheduling them, so a spec can fire them when it chooses. Purely additive: existing helpers are unchanged. Generated-by: Claude Code (Claude Opus 5.5)
A statistics query waited for every worker's reply with no timeout, and its in-flight flag was cleared only on success. One lost reply therefore stalled the query forever, and with it whatever awaited it: `portCompleted` (the region never advanced), `workerExecutionCompleted` (the workflow was never reported finished), and every later poll (stats froze). See apache#6924. - Each query gets a deadline: a `CoordinatorStatisticsQueryDeadline` request the coordinator schedules to itself, the same way its status timer schedules polls, so it is handled on the actor thread. It is withdrawn when the query ends first, so a healthy query sends no extra message. - Replies are applied as they arrive instead of in one batch at the end, so a worker slower than the deadline still gets its statistics updated. - Past the deadline, the remaining layers are still asked, without waiting. - The in-flight flag is released however the query ends, and only by the full-graph query that holds it. - `portCompleted` treats the statistics refresh as best-effort, so a failure in it cannot block the port bookkeeping. The timeout is `constants.statistics-query-reply-timeout` (default 10s). Generated-by: Claude Code (Claude Opus 5.5)
Backport auto-label reportThis
|
Automated Reviewer SuggestionsBased on the
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #9371 +/- ##
============================================
+ Coverage 91.79% 91.94% +0.14%
- Complexity 5019 6422 +1403
============================================
Files 1274 1314 +40
Lines 56301 62795 +6494
Branches 7352 8419 +1067
============================================
+ Hits 51680 57734 +6054
- Misses 2766 3057 +291
- Partials 1855 2004 +149
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
| config | throughput | MB/s | latency | max Δ latest / 7d | |
|---|---|---|---|---|---|
| 🔴 | bs=10 sw=10 sl=64 | 354 | 0.216 | 26,173/41,486/41,486 us | 🟢 -23.5% / 🔴 +186.9% |
| 🔴 | bs=100 sw=10 sl=64 | 806 | 0.492 | 122,333/153,905/153,905 us | 🟢 -8.6% / 🔴 +65.1% |
| 🔴 | bs=1000 sw=10 sl=64 | 956 | 0.583 | 1,029,455/1,182,330/1,182,330 us | 🔴 +8.7% / 🔴 +34.7% |
Baseline details
Latest main b4b0648 from same runner
| config | metric | PR | latest main | 7d avg | Δ latest | Δ 7d |
|---|---|---|---|---|---|---|
| bs=10 sw=10 sl=64 | throughput | 354 tuples/sec | 411 tuples/sec | 927.28 tuples/sec | -13.9% | -61.8% |
| bs=10 sw=10 sl=64 | MB/s | 0.216 MB/s | 0.251 MB/s | 0.566 MB/s | -13.9% | -61.8% |
| bs=10 sw=10 sl=64 | p50 | 26,173 us | 22,498 us | 10,932 us | +16.3% | +139.4% |
| bs=10 sw=10 sl=64 | p95 | 41,486 us | 54,196 us | 14,458 us | -23.5% | +186.9% |
| bs=10 sw=10 sl=64 | p99 | 41,486 us | 54,196 us | 17,274 us | -23.5% | +140.2% |
| bs=100 sw=10 sl=64 | throughput | 806 tuples/sec | 820 tuples/sec | 1,240 tuples/sec | -1.7% | -35.0% |
| bs=100 sw=10 sl=64 | MB/s | 0.492 MB/s | 0.501 MB/s | 0.757 MB/s | -1.8% | -35.0% |
| bs=100 sw=10 sl=64 | p50 | 122,333 us | 114,861 us | 85,781 us | +6.5% | +42.6% |
| bs=100 sw=10 sl=64 | p95 | 153,905 us | 168,470 us | 93,231 us | -8.6% | +65.1% |
| bs=100 sw=10 sl=64 | p99 | 153,905 us | 168,470 us | 116,160 us | -8.6% | +32.5% |
| bs=1000 sw=10 sl=64 | throughput | 956 tuples/sec | 972 tuples/sec | 1,278 tuples/sec | -1.6% | -25.2% |
| bs=1000 sw=10 sl=64 | MB/s | 0.583 MB/s | 0.593 MB/s | 0.78 MB/s | -1.7% | -25.3% |
| bs=1000 sw=10 sl=64 | p50 | 1,029,455 us | 1,028,340 us | 835,630 us | +0.1% | +23.2% |
| bs=1000 sw=10 sl=64 | p95 | 1,182,330 us | 1,087,250 us | 877,570 us | +8.7% | +34.7% |
| bs=1000 sw=10 sl=64 | p99 | 1,182,330 us | 1,087,250 us | 922,624 us | +8.7% | +28.1% |
Raw CSV
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,565.41,200,128000,354,0.216,26173.43,41485.80,41485.80
1,100,10,64,20,2482.44,2000,1280000,806,0.492,122333.45,153905.20,153905.20
2,1000,10,64,20,20928.38,20000,12800000,956,0.583,1029455.30,1182329.90,1182329.90|
Removing release/v1.2: kill and rerun works around it, and the change is too large for a patch release. |
What changes were proposed in this PR?
Root cause. A worker statistics query waited for every reply with no timeout, and its in-flight flag (
globalQueryStatsOngoing) was cleared only on success. A reply can be lost (e.g. a worker stopped during region teardown), and the coordinator never fails a pending request — it just waits. One lost reply therefore stalled the query forever, and with it everything chained on it:CoordinatorStatisticsQueryDeadlinerequest the coordinator schedules to itself, the same way its status timer schedules polls, so it is handled on the actor thread. Withdrawn when the query ends first, so a healthy query sends no extra message.QueryWorkerStatisticsHandler,coordinatorservice.proto,controlcommands.protoQueryWorkerStatisticsHandlerensure), and only by the full-graph query that holds it.QueryWorkerStatisticsHandlerportCompletedtreats the statistics refresh as best-effort, so a coordinator-side failure in it cannot block the port bookkeeping. Failures in the bookkeeping itself are still reported to the worker.PortCompletedHandlerconstants.statistics-query-reply-timeout(default 10000 ms, envCONSTANTS_STATISTICS_QUERY_REPLY_TIMEOUT).application.conf,ApplicationConfigDesign note: deviation from the issue's suggestion. #6924 suggests a
.within(...)per layer..withincompletes the future from a timer thread, so the continuation (the next layer, applying replies, the flag) would run off the coordinator's actor thread and race with it — the problem #6923 describes. The deadline is instead a request the coordinator sends itself, processed on the actor thread like any other input. One deadline per query, rather than per layer, also bounds the total wait to one timeout regardless of the number of layers.Behavior notes for reviewers
forceTerminateisLong.MaxValue).Any related issues, documentation, discussions?
Closes #6924.
Of the three defects listed there, the third (mixed COMPLETED/TERMINATED operators being re-queried) was already fixed on
mainbyExecutionUtils.aggregateStates; this PR addresses the first two. Related: #6916 (closed in favor of #6960, which reorderedportCompleted's reply and the region advance but left the statistics chain unchanged), and #6923 (timer-thread races — the deadline here deliberately avoids completing anything from a timer thread).How was this PR tested?
New and changed unit tests (each fails with its corresponding change reverted):
QueryWorkerStatisticsHandlerSpec(new): a query completes at its deadline when a worker never replies; a reply arriving after the deadline is still applied; upstream layers are still asked after the deadline; a worker answering with an error keeps its last statistics; the flag is released when the coordinator fails mid-query; a filtered query does not release the full-graph query's flag; the deadline is withdrawn once every worker answered; no deadline for a query that asks no worker.WorkerExecutionCompletedHandlerSpec(new): the final refresh completes and forwards statistics to persistence when the worker never answers.PortCompletedHandlerSpec: the port completes and the region advances when the worker never answers the refresh (the Statistics collection can wedge permanently: no timeout on layered query chains and a one-way in-flight flag #6924 scenario) or the refresh fails; a failure in the bookkeeping itself still returns an error reply. The previous test asserting that a failed refresh fails the port is replaced, since that is the behavior being fixed.ApplicationConfigSpec: default of the new setting.Coverage of the two changed handlers (JaCoCo, over the coordinator handler specs):
QueryWorkerStatisticsHandler.scalaPortCompletedHandler.scalaFull Required Checks passed on the fork (workflow dispatch, all stacks), including the real-workflow specs in the
amberjob (DataProcessingSpec,PauseSpec,BatchSizePropagationSpec,ReconfigurationSpec) andamber-integrationagainst Postgres/RustFS/Lakekeeper: https://github.com/CaroFernando/texera/actions/runs/42549302228 (run on the pre-rebase commit; the branch was then rebased ontomainwithout conflicts and the coordinator specs re-run locally). Those runs use the default timeout; the forced-timeout path is covered by the unit tests above.Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 5.5)