Skip to content

test(amber): cover the coordinator WorkerStateUpdatedHandler - #7610

Merged
aglinxinyuan merged 1 commit into
apache:mainfrom
eugenegujing:test/worker-state-updated-handler-spec
Aug 13, 2026
Merged

aglinxinyuan merged 1 commit into
apache:mainfrom
eugenegujing:test/worker-state-updated-handler-spec

Conversation

@eugenegujing

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

This PR adds WorkerStateUpdatedHandlerSpec, the first unit coverage for amber/src/main/scala/org/apache/texera/amber/engine/architecture/coordinator/promisehandlers/WorkerStateUpdatedHandler.scala. The handler had no references anywhere in the test tree. The version-ordered state model it feeds was fixed and tested in #6011, which gave WorkerExecution a spec, but the handler wiring itself was unpinned.

No production code is changed; this is a test-only PR.

The spec drives a real CoordinatorProcessor with no ActorSystem and captures the dispatched client events through the coordinator's output handler. The 20 tests pin the handler's lookup, the update it applies, and the broadcasts it emits:

  • the physical operator is derived from ctx.sender, and the update lands on that worker alone rather than on the operator's other workers or on another operator;
  • reports are ordered by the request's stateVersion, so a stale or re-delivered version is ignored while a strictly newer one applies, and the version each worker carries is its own rather than shared across the operator;
  • a terminal state absorbs every later report, reached both through a COMPLETED report and through a TERMINATED one, and the reports refused this way are still broadcast;
  • only running region executions are consulted, and only the first one owning the operator, while the broadcast statistics span every region execution including completed ones;
  • the skip branch this coverage exists for: when no running region execution owns the sender's operator the report is dropped, yet ExecutionStatsUpdate and RuntimeStatisticsPersist still fire and the reply is still an empty success;
  • both boundaries of the version guard, since lastStateVersion starts at -1 and the comparison is strictly-greater: a first report at -1 is dropped as if stale, and a report at Long.MaxValue freezes a worker even when its state is not terminal.

Two of these record current behavior that a reader may find surprising, and each says so in a comment rather than implying endorsement. An unknown worker of a known operator throws a NullPointerException, because getWorkerExecution is a ConcurrentHashMap.get whose null is dereferenced immediately, and on that path both client broadcasts are lost, which is the opposite of how an unknown operator is handled one branch away. A report carrying the proto default UNINITIALIZED at version 0 is applied invisibly and consumes the first real version, so the worker's genuine first transition is then dropped without a trace. If either is later changed deliberately, the corresponding test turns red and forces that decision to be explicit.

Any related issues, documentation, discussions?

Closes #7607

Related: #6011 introduced the version-ordered state model this handler feeds.

How was this PR tested?

The 20 new tests were run locally, together with the six pre-existing specs in the same package and the wider coordinator package:

sbt "WorkflowExecutionService/testOnly org.apache.texera.amber.engine.architecture.coordinator.promisehandlers.WorkerStateUpdatedHandlerSpec"
  -> Tests: succeeded 20, failed 0

sbt "WorkflowExecutionService/testOnly org.apache.texera.amber.engine.architecture.coordinator.promisehandlers.*"
  -> Suites: completed 7, Tests: succeeded 48, failed 0

sbt "WorkflowExecutionService/testOnly org.apache.texera.amber.engine.architecture.coordinator.*"
  -> Suites: completed 19, Tests: succeeded 171, failed 0

sbt "WorkflowExecutionService/Test/scalafmtCheck"
  -> success

Both positive and negative directions are covered, along with the empty and boundary cases: an applied update and a skipped one, a workflow execution with no region execution at all, the -1 version sentinel, and the Long.MaxValue ceiling.

The assertions were mutation-checked rather than assumed to be meaningful. Mutations were applied one at a time to WorkerStateUpdatedHandler.scala, WorkerExecution.scala and OperatorExecution.scala, and each turned the spec red: dropping either sendToClient call, swapping their order, guarding them behind a non-empty statistics map, replacing getRunningRegionExecutions with all region executions, widening find to filter, deriving the operator from ctx.receiver instead of ctx.sender, computing the statistics snapshot before applying the update, forwarding a constant version to updateState, moving the sentinel off -1, changing the version comparison to <= or !=, adding a state-equality condition to the guard, removing TERMINATED from the terminal check, and returning one shared WorkerExecution for every worker. The production files were restored and verified byte-identical to HEAD afterwards.

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 5)

@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • No candidates found from git blame history.

@github-actions

github-actions Bot commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Benchmark changes need a look

🟢 0 better · 🔴 5 worse · ⚪ 10 noise (<±5%) · 0 without baseline

Compared against main c35bdb1 benchmarked on this same runner, so the delta is largely free of cross-runner hardware noise. The "7d avg" column still reflects the gh-pages dashboard. Treat <±5% as noise unless repeated.

Dashboard · Run

config throughput MB/s latency max Δ latest / 7d
🔴 bs=10 sw=10 sl=64 446 0.272 21,636/29,700/29,700 us 🔴 +11.5% / 🔴 +82.1%
🔴 bs=100 sw=10 sl=64 910 0.556 105,138/140,333/140,333 us 🔴 -5.2% / 🔴 +29.7%
⚪ bs=1000 sw=10 sl=64 1,091 0.666 920,363/976,403/976,403 us ⚪ within ±5% / 🟢 -9.2%
Baseline details

Latest main c35bdb1 from same runner

config metric PR latest main 7d avg Δ latest Δ 7d
bs=10 sw=10 sl=64 throughput 446 tuples/sec 473 tuples/sec 775.33 tuples/sec -5.7% -42.5%
bs=10 sw=10 sl=64 MB/s 0.272 MB/s 0.289 MB/s 0.473 MB/s -5.9% -42.5%
bs=10 sw=10 sl=64 p50 21,636 us 19,398 us 12,743 us +11.5% +69.8%
bs=10 sw=10 sl=64 p95 29,700 us 30,746 us 16,310 us -3.4% +82.1%
bs=10 sw=10 sl=64 p99 29,700 us 30,746 us 18,926 us -3.4% +56.9%
bs=100 sw=10 sl=64 throughput 910 tuples/sec 960 tuples/sec 1,001 tuples/sec -5.2% -9.1%
bs=100 sw=10 sl=64 MB/s 0.556 MB/s 0.586 MB/s 0.611 MB/s -5.1% -9.0%
bs=100 sw=10 sl=64 p50 105,138 us 102,956 us 101,399 us +2.1% +3.7%
bs=100 sw=10 sl=64 p95 140,333 us 139,494 us 108,206 us +0.6% +29.7%
bs=100 sw=10 sl=64 p99 140,333 us 139,494 us 118,195 us +0.6% +18.7%
bs=1000 sw=10 sl=64 throughput 1,091 tuples/sec 1,088 tuples/sec 1,026 tuples/sec +0.3% +6.3%
bs=1000 sw=10 sl=64 MB/s 0.666 MB/s 0.664 MB/s 0.626 MB/s +0.3% +6.3%
bs=1000 sw=10 sl=64 p50 920,363 us 919,569 us 996,304 us +0.1% -7.6%
bs=1000 sw=10 sl=64 p95 976,403 us 966,300 us 1,042,531 us +1.0% -6.3%
bs=1000 sw=10 sl=64 p99 976,403 us 966,300 us 1,074,934 us +1.0% -9.2%
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,448.23,200,128000,446,0.272,21635.90,29699.95,29699.95
1,100,10,64,20,2196.78,2000,1280000,910,0.556,105138.32,140333.21,140333.21
2,1000,10,64,20,18338.25,20000,12800000,1091,0.666,920363.08,976403.05,976403.05

@codecov-commenter

codecov-commenter commented Aug 13, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.54%. Comparing base (cb6e5c6) to head (da61899).
⚠️ Report is 12 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7610      +/-   ##
============================================
+ Coverage     87.87%   88.54%   +0.67%     
- Complexity     4275     4341      +66     
============================================
  Files          1176     1178       +2     
  Lines         46890    46909      +19     
  Branches       5228     5229       +1     
============================================
+ Hits          41205    41536     +331     
+ Misses         3961     3612     -349     
- Partials       1724     1761      +37     
Flag Coverage Δ *Carryforward flag
access-control-service 70.00% <ø> (ø) Carriedforward from cb6e5c6
agent-service 98.62% <ø> (ø) Carriedforward from cb6e5c6
amber 84.69% <ø> (+1.81%) ⬆️
computing-unit-managing-service 60.38% <ø> (ø) Carriedforward from cb6e5c6
config-service 65.97% <ø> (ø) Carriedforward from cb6e5c6
file-service 69.05% <ø> (ø) Carriedforward from cb6e5c6
frontend 89.95% <ø> (ø) Carriedforward from cb6e5c6
notebook-migration-service 78.89% <ø> (ø) Carriedforward from cb6e5c6
pyamber 97.47% <ø> (ø) Carriedforward from cb6e5c6
workflow-compiling-service 26.31% <ø> (ø) Carriedforward from cb6e5c6

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Add WorkerStateUpdatedHandlerSpec, covering the sender-scoped state update, the version ordering and terminal absorption, the silent-skip branch, and the client broadcasts.
@eugenegujing
eugenegujing force-pushed the test/worker-state-updated-handler-spec branch from de4c0e3 to da61899 Compare August 13, 2026 00:33
@aglinxinyuan
aglinxinyuan added this pull request to the merge queue Aug 13, 2026
Merged via the queue into apache:main with commit f6a8526 Aug 13, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add unit test coverage for the coordinator WorkerStateUpdatedHandler

3 participants