Repository navigation
fix(test): stop the file-handle leak aborting the operator suite, seed the interval spec - #7800
Conversation
…d the interval spec
Backport auto-label reportThis
|
Automated Reviewer SuggestionsBased on the
|
|
| config | throughput | MB/s | latency | max Δ latest / 7d | |
|---|---|---|---|---|---|
| 🔴 | bs=10 sw=10 sl=64 | 381 | 0.232 | 24,839/38,701/38,701 us | 🟢 -37.9% / 🔴 +148.9% |
| 🔴 | bs=100 sw=10 sl=64 | 805 | 0.491 | 123,802/133,602/133,602 us | 🟢 -20.5% / 🔴 +22.6% |
| ⚪ | bs=1000 sw=10 sl=64 | 915 | 0.558 | 1,094,690/1,166,233/1,166,233 us | ⚪ within ±5% / 🔴 +11.5% |
Baseline details
Latest main 54fba31 from same runner
| config | metric | PR | latest main | 7d avg | Δ latest | Δ 7d |
|---|---|---|---|---|---|---|
| bs=10 sw=10 sl=64 | throughput | 381 tuples/sec | 399 tuples/sec | 771.42 tuples/sec | -4.5% | -50.6% |
| bs=10 sw=10 sl=64 | MB/s | 0.232 MB/s | 0.244 MB/s | 0.471 MB/s | -4.9% | -50.7% |
| bs=10 sw=10 sl=64 | p50 | 24,839 us | 23,078 us | 12,757 us | +7.6% | +94.7% |
| bs=10 sw=10 sl=64 | p95 | 38,701 us | 62,308 us | 15,551 us | -37.9% | +148.9% |
| bs=10 sw=10 sl=64 | p99 | 38,701 us | 62,308 us | 19,296 us | -37.9% | +100.6% |
| bs=100 sw=10 sl=64 | throughput | 805 tuples/sec | 824 tuples/sec | 983.07 tuples/sec | -2.3% | -18.1% |
| bs=100 sw=10 sl=64 | MB/s | 0.491 MB/s | 0.503 MB/s | 0.6 MB/s | -2.4% | -18.2% |
| bs=100 sw=10 sl=64 | p50 | 123,802 us | 117,513 us | 102,799 us | +5.4% | +20.4% |
| bs=100 sw=10 sl=64 | p95 | 133,602 us | 168,136 us | 109,018 us | -20.5% | +22.6% |
| bs=100 sw=10 sl=64 | p99 | 133,602 us | 168,136 us | 121,110 us | -20.5% | +10.3% |
| bs=1000 sw=10 sl=64 | throughput | 915 tuples/sec | 931 tuples/sec | 1,012 tuples/sec | -1.7% | -9.6% |
| bs=1000 sw=10 sl=64 | MB/s | 0.558 MB/s | 0.568 MB/s | 0.618 MB/s | -1.8% | -9.7% |
| bs=1000 sw=10 sl=64 | p50 | 1,094,690 us | 1,072,539 us | 1,006,484 us | +2.1% | +8.8% |
| bs=1000 sw=10 sl=64 | p95 | 1,166,233 us | 1,151,019 us | 1,046,167 us | +1.3% | +11.5% |
| bs=1000 sw=10 sl=64 | p99 | 1,166,233 us | 1,151,019 us | 1,074,106 us | +1.3% | +8.6% |
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,525.60,200,128000,381,0.232,24839.02,38701.42,38701.42
1,100,10,64,20,2485.67,2000,1280000,805,0.491,123801.61,133601.99,133601.99
2,1000,10,64,20,21866.00,20000,12800000,915,0.558,1094690.02,1166233.25,1166233.25
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7800 +/- ##
============================================
- Coverage 92.75% 92.73% -0.02%
Complexity 4925 4925
============================================
Files 1244 1237 -7
Lines 52614 51956 -658
Branches 6490 6386 -104
============================================
- Hits 48800 48182 -618
+ Misses 2205 2189 -16
+ Partials 1609 1585 -24
*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:
|
…pache#7804) ### What changes were proposed in this PR? Three error paths that silently lost the information they exist to surface. All were characterized during earlier coverage work and deliberately left unpinned so a fix would not have to fight a test asserting the broken behaviour. **1. `OPVersion.getVersion` no longer returns `null` when `git log` fails.** The `GitAPIException` catch now stores the same `"N/A"` sentinel its `NullPointerException` sibling already did, so the result is non-null *and* memoized — previously the trailing `opMap.get(operatorName)` handed back `null`, which propagated into operator metadata (`LogicalOp.scala:462-466` → `OperatorMetadataGenerator.scala:171`), and every later call re-ran the failing `git log`. `printStackTrace()` is kept. That `"N/A"` is the intended sentinel is corroborated downstream: `agent-service/src/agent/util/workflow-utils.ts:193` already defends with `?? "N/A"`. **2. `InputManager.startInputPortReaderThreads` now passes the cause.** It wrapped a start failure as `new RuntimeException(s"…: ${e.getMessage}")` without `e`, discarding the original stack trace. The reader thread itself already does this correctly (`InputPortMaterializationReaderThread.scala:147`). **3. `PekkoActorRefMappingService.retrieveActorRef`'s catch no longer re-reads the failing value.** It bound `e` but never used it, instead reading `actorService.parent` again to name the parent in its warning — so a **persistently** unreachable parent threw straight out of the handler meant to contain it. The message now omits the parent and passes `e` as the log throwable, matching house style (`WorkflowActor.scala:144`, `SyncExecutionResource.scala:705`). **Why not hoist the read instead:** capturing the parent ref before the `try` was considered and rejected — the read *is* what throws, so hoisting it would let the failure escape `retrieveActorRef` entirely rather than fixing anything. ### All three are pinned, verified in both directions The production files were reverted and restored to confirm each test actually fails without its fix: | Suite | production reverted | with fixes | |---|---|---| | `OPVersionSpec` | **9 passed, 2 failed** | **11 passed** | | `InputManagerSpec` + `PekkoActorRefMappingServiceSpec` | **20 passed, 2 failed** | **22 passed** | The before-state failures are the right ones: - `null was not equal to "N/A"` (both new OPVersion cases) - `null equaled null the original failure must be attached as the cause` - `java.lang.IllegalStateException: parent is unreachable at … PekkoActorRefMappingService.retrieveActorRef` — i.e. thrown *out of* the handler, exactly the predicted failure mode ### On the tests - **OPVersion**: two cases using the existing unborn-HEAD throwaway-repo technique — the `"N/A"` fallback, and that it is *memoized* so a failing `git log` is not retried. - **InputManager**: a `NoOpReaderThread` subclass (no-op `run()`, so no storage is touched) is started and joined, then installed into the private map by reflection — the same technique as the existing `OutputPortStorageWriterThreadSpec.installWriterThread`. `Thread.start()` on a TERMINATED thread then throws `IllegalThreadStateException` deterministically, and the test asserts both the wrapping message and that `getCause` is that exception. - **PekkoActorRefMappingService**: the new case sets the failure counter to `Int.MaxValue` so *every* read throws, not just the first — the existing single-failure test could not have caught this. It also asserts the id remains askable afterwards, i.e. was not wrongly marked queried. Three stale comments were updated rather than left contradicting the new assertions: `OPVersionSpec`'s "Deliberately NOT asserted" paragraph about the null, and the defect notes on the two amber specs. ### Verification - `OPVersionSpec` 11/11; `InputManagerSpec` + `PekkoActorRefMappingServiceSpec` + `InputPortMaterializationReaderThreadSpec` 32/32 (the reader-thread spec included as the nearest neighbour to the `InputManager` change). - Specs were filtered deliberately rather than running the whole `WorkflowOperator` module, because `FileScanSourceOpExecSpec` currently aborts on Windows over a leaked handle — that is being fixed separately in apache#7800. - `scalafmtCheck`, `Test/scalafmtCheck` and `scalafixAll --check` pass for both modules. One pre-existing scalafix *warning* in an untouched file (`OutputManagerSpec.scala:59`, unused suppression) is unrelated. ### Any related issues, documentation, discussions? Closes apache#7803 ### How was this PR tested? ``` sbt "WorkflowOperator/testOnly org.apache.texera.amber.operator.metadata.OPVersionSpec" "WorkflowExecutionService/testOnly org.apache.texera.amber.engine.architecture.messaginglayer.InputManagerSpec org.apache.texera.amber.engine.architecture.common.PekkoActorRefMappingServiceSpec" ``` ``` [info] Tests: succeeded 11, failed 0, canceled 0, ignored 0, pending 0 [info] Tests: succeeded 22, failed 0, canceled 0, ignored 0, pending 0 ``` ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Opus 5)
`"create LargeBinary when reading file with LARGE_BINARY type"` wrapped its whole
body in `catch { case e: Exception => info(...) }`. ScalaTest's `assert` throws
`TestFailedException`, which extends `Exception`, so every assertion inside the try
was swallowed and reported only through `info(...)` -- which the `-u`-only reporter
this build configures does not surface. The test could not fail for any reason.
What it was really tolerating is the environment, in two places: no large-binary
base URI is bound to the test thread, and `LargeBinaryOutputStream.close()` uploads
to S3, which this module's test scope has no endpoint for.
So handle both explicitly instead of catching everything:
- Seed the thread's base URI the way the coordinator does in production (and
`LargeBinaryManagerSpec` does in test), clearing it afterwards, so an unset base
URI can no longer be mistaken for the operator misbehaving.
- Probe S3 reachability up front and `cancel` when it is absent, leaving the scan
itself uncaught -- a catch around the scan would still report a genuine operator
failure as a skip.
- Move the assertions outside the try so their failures propagate.
The drain added for the handle leak stays, and now also drops a throw of its own so
it cannot displace an in-flight failure -- the failure path it guards is reachable
for the first time now that the test can fail.
Verified by mutation: with `s3://` changed to `gs://` the test fails (1 TEST FAILED,
exit 1) where before it passed. Docker is unavailable here, so the assertions were
exercised against a stub S3 endpoint driven through a temporary subclass of this
spec: 7 succeeded, 0 canceled, with the stub observing the real multipart sequence
and the file's bytes. Without an endpoint: 6 succeeded, 1 canceled, 0 aborted.
Full `WorkflowOperator/test`: 290 suites, 0 aborted, 2300 succeeded, 1 canceled.
…ptors (apache#7899) ### What changes were proposed in this PR? Four operator descriptors. 36 tests → 47. Measured with a full-module `WorkflowOperator/jacoco`, one fresh sbt JVM per run, and the same suite-name exclusion on both sides (`FileScanSourceOpExecSpec` aborts inside a git worktree — a worktree's `.git` is a file, so it throws `RepositoryNotFoundException` in `beforeAll` — and since sbt-jacoco runs unforked, a failing test task yields an all-zero report rather than a partial one). | File | Codecov | Missed arms | |---|---|---| | `SQLSourceOpDesc.scala` | 88.9% → **100%** | 11 → **0** | | `RUDFSourceOpDesc.scala` | 80.6% → **100%** | 3 → **0** | | `MachineLearningScorerOpDesc.scala` | 84.8% → **100%** | 4 → **0** | | `ECDFPlotOpDesc.scala` | 85.4% → **87.5%** (its ceiling) | 15 → **12** | | **bundle** | 173/203 = 85.2% → **192/203 = 94.6%** | 48 → **27** | JaCoCo line-hit goes 199/203 → 203/203. **`TimeSeriesOpDesc` was in the original scope and is deliberately absent.** It is worth exactly zero: all five of its partials are Scala's null-safe comparison against a String *literal*, where one arm requires the constant itself to be null. A probe setting every field to null left it unchanged at 23/28. And the null path is a crash rather than a behaviour — `dropnaCols.map(c => pyb"$c")` NPEs inside the `pyb` macro on Base64 of a null string. Pinning it would cement junk. ### Verification 28 mutations, **27 killed, 1 equivalent survivor.** The first draft reported no survivors. Two adversarial reviewers demonstrated **8 survivors** between them, and every one that could be reproduced was real. All are now dead. Representative repairs, each proven by the mutation it now kills: - The JDBC type map pinned 9 of 19 keys; the remaining ten are now covered (`TINYINT`→INTEGER, `FLOAT`/`REAL`→DOUBLE, `BIT`→BOOLEAN, and the rest). - Three error-message assertions used `endWith`, leaving the half of the message that names the failing operator unpinned. They are now exact equalities against the concrete subclass name the spec itself controls. - ECDF argument assertions were presence-only; they now check payloads through the spec's existing Base64 helper, and three index-arithmetic assertions pin the emitted body's order (`pd.to_numeric(` before `px.ecdf(` before `plotly.io.to_html(`). - The scorer's actual and predicted columns were interchangeable; the loose whole-code `include` checks are now line-anchored. **The survivor:** deleting `.withParallelizable(false)` from the else arm of RUDF's worker-count guard. `PhysicalOp.sourcePhysicalOp` already defaults it, so nothing observable changes — an equivalent mutant, not a coverage gap. ### Two reviewer suggestions were refused - One proposed deleting the RUDF single-worker test as vacuous. The premise was half right — the `withParallelizable(false)` call really is unobservable — but the suggested fix would have made the suite **weaker**, since the test pins more than that one call. - Its optional follow-up asked for a production deletion, which this pass forbids. Recorded as a limitation rather than actioned. A collateral claim about the builder's own harness was also left unasserted rather than repeated, on the grounds that it could not be verified from the state the worktree was handed over in. ### A nondeterminism source found along the way The module-wide branch total does not move by exactly the amount these four files account for, and the residual is **not** measurement noise in this bundle: it is `IntervalJoinOpExec.scala`, whose covering spec uses an **unseeded RNG**, so its branch count drifts run to run. That is worth knowing because it makes module-level branch totals unquotable as evidence for any PR touching this module. Seeding that spec is already part of apache#7800. Same-input reproducibility is otherwise good: the final `jacoco.xml` is byte-identical to a reviewer's independently produced report. ### Deliberately not included, with evidence - **`ECDFPlotOpDesc` cannot exceed 42/48.** `javap` on `createPlotlyFigure` shows the three-jump null-safe form, and the `ifnull`-taken arm needs the literal `"sum"` to be null. A probe moved those lines from `cb=3` to `cb=5` with `mb` unchanged — 8 arms, zero lines. Two further lines would need a `hashCode` collision with `"count"` or `"sum"` that is not equal to it: constructible in principle, padding in practice. - **The scorer's last two lines are reachable only through an erasure violation.** The LUB of the two metric list types erases to `java.lang.Enum`, so the lambda bridge's checkcast admits a foreign enum — `List(java.time.DayOfWeek.MONDAY).asInstanceOf[…]` does reach the `case _` throw and takes the file to 33/33. No production route exists, because Jackson rejects an unknown enum name first, so it is excluded. - **The six `require` message strings are lifted to `$anonfun$querySchema$1..6`** and dropped by `SyntheticFilter`; their source lines already read as covered because the closure allocation is attributed to the enclosing method. - One file's headline 100% is worth qualifying: the `foldLeft` body making its only schema-typing decision is a `$anonfun`, so it is not in the tracked denominator either way. Every spec in the bundle carries a JSON round-trip test, per house convention. No descriptor subtype is defined in any spec, because `PythonCodeRawInvalidTextSpec` instantiates every subclass by reflection and a test-only subtype would break it. No production file is touched, and no stray `test_large_binary.txt` was left behind. ### Any related issues, documentation, discussions? Closes apache#7898 ### How was this PR tested? ``` sbt "WorkflowOperator/testOnly org.apache.texera.amber.operator.source.sql.SQLSourceOpDescSpec org.apache.texera.amber.operator.udf.r.RUDFSourceOpDescSpec org.apache.texera.amber.operator.machineLearning.Scorer.MachineLearningScorerOpDescSpec org.apache.texera.amber.operator.visualization.ecdfPlot.ECDFPlotOpDescSpec" ``` ``` [info] Total number of tests run: 47 [info] Tests: succeeded 47, failed 0, canceled 0, ignored 0, pending 0 ``` `Test/scalafmtCheck` and `Test/scalafix --check` both pass. ### Was this PR authored or co-authored using generative AI tooling? Generated-by: Claude Code (Opus 5) --------- Signed-off-by: Xinyuan Lin <xinyual3@uci.edu> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
What changes were proposed in this PR?
Four test-only fixes across 3 spec files. 89 insertions, 25 deletions;
git diff -- '*/src/main/*'is empty.1. A leaked file handle was aborting the operator suite and killing the module's coverage run
The exact mechanism, established by instrumenting the run rather than by inspection: in
"create LargeBinary when reading file with LARGE_BINARY type",createTuplesFromFilethrows mid-mapwithIllegalStateException: LargeBinaryManager.create() requires a base URI, but none was set on the current thread. That abandons theAutoClosingIteratorbefore exhaustion, so its close-on-exhaustion hook never fires.afterAllthen fails withtest_large_binary.txt: The process cannot access the file because it is being used by another process, aborting the suite.The blast radius is the whole module:
jacoco.xml, 1.8 MBSo
WorkflowOperator/jacococould not produce coverage for any file in the module on Windows. POSIXunlinkmasks this on Linux CI.The fix is in the test: the read is wrapped so the iterator is drained in a
finally, firing the close hook on both the success and failure paths.AutoClosingIteratorandcreateTuplesFromFileare untouched — the leak is a test that stops early, not a broken production contract.Also worth recording: the
.zipfixture was stranded too. It only looked fine because.gitignore:10is*.zip;afterAllnever reached it, because the.txtdelete threw first.2.
IntervalOpExecSpecis now deterministicIt imported
scala.util.Random.{nextInt, nextLong}and used them at four sites — input ordering twice, a 1k-row dataset, and the interval constant — soIntervalJoinOpExec's coverage footprint drifted between runs of identical source (CI has reported 2 missed + 14 partial where a local run gave 0 + 13).Now a fixed
Seed, with a freshnew Random(Seed)created at each use site so determinism does not depend on test execution order either. No assertion changed.Verified rather than assumed: instrumented to print every generated input, two runs produced byte-identical output (22 lines, empty
diff), and two fullWorkflowOperator/jacocoruns now give byte-identicalIntervalJoinOpExeccounters and all 110 per-line entries.One observation left alone as out of scope: the 1k test deterministically yields 0 matches, because random 64-bit longs essentially never fall inside a sub-1000-wide window, so
outputTuples.size == bruteForceResultis0 == 0. That was equally true before this change.3.
PveResourceSpec's traversal assertion said something it did not testgetPythonBin(testCuid, "..") shouldBe Noneappeared to pin the guard atPveManager.scala:91, but".."matches the name regex on line 88 (^[A-Za-z0-9._-]+$admits dots), and<VenvRoot>/<cuid>/../pvenormalizes to<VenvRoot>/pve— still under root. TheNonecame from theFiles.existscheck on line 92.Proven, not argued: deleting line 91 produced results identical to baseline (43 run, 37 succeeded, 6 failed, 1 canceled) and the traversal test still passed. Nothing in the spec detects that guard's removal. The production file was reverted afterwards.
Split into two honest cases:
"reject pveNames containing a path separator"keeps"../../../etc"and"foo/bar"— both carry a/, so they genuinely pin the name regex."return None for a dot-only pveName, which has no venv"keeps the".."case and pins what it actually pins: a name with no venv on disk yieldsNone.A comment records that line 91 is unreachable by construction — the regex forbids
/andcuidis anInt— so it is defensive code rather than untested code. The guard is left in place; removing it is a production decision, not a test one.4. The same spec's LARGE_BINARY test could not fail
Listed below as a deferred defect in the first revision of this PR; fixed here instead, since it is the same test and the leak fix above is what makes its failure path reachable at all.
The test wrapped its whole body in
catch { case e: Exception => info(...) }. ScalaTest'sassertthrowsTestFailedException, which extendsException, so every assertion was swallowed and reported only throughinfo(...)— which this build's-u-only reporter (build.sbt:37) does not surface. The test could not fail for any reason.What it was really tolerating is the environment, and in two places rather than one:
LargeBinaryManager.create()→IllegalStateExceptionLargeBinaryOutputStream.close()→IOExceptionThe second one matters more than it looks:
WorkflowOperatoris wired as a plaindependsOn(WorkflowCore)with no testcontainers in its test scope, so there is no configuration of this module in which those assertions could ever have run — not on a developer machine, not in CI.Both are now handled explicitly instead of by catching everything:
LargeBinaryManagerSpecdoes in test (setCurrentBaseUri(baseUriForExecution(eid))), cleared in afinallyso it cannot leak into another suite reusing the thread. That gap stops being an environment gap.cancelwhen it is absent, which leaves the scan itself uncaught. A catch around the scan — even narrowed toIOException— would still report a genuine operator failure as a skip.directoryExistswas rejected as the probe: it throwsNoSuchBucketExceptionon a fresh bucket, which would skip the test on an environment where S3 is present.TestFailedExceptionpropagates.The drain from §1 stays, and now also drops a throw of its own, so it cannot displace an in-flight failure via the
finally.Proven by mutation, not argued: changing
startsWith("s3://")tostartsWith("gs://")now produces1 TEST FAILED, sbt exit 1. Before this change the identical mutation still passed.Worth recording for anyone relying on
cancelfor visibility:-uerases it. A cancelled test is written to the JUnit XML as a plain<testcase>with no<skipped/>child andskipped="0"on the suite — byte-identical to a pass, so Codecov cannot tell "skipped, no S3" from "green". The console summary'scanceled 1names no test. Hence the oneConsole.err.printlnon the cancel path: it is the only channel that reports which test skipped and why.Verification
WorkflowOperator/jacoco: 290 suites, 0 aborted, sbt exit 0, report emitted. 2300 succeeded + 1 cancelled; the cancelled one is §4's test on a machine with no S3 endpoint, which previously counted as a vacuous pass.StorageConfig.s3Endpointat a JDKHttpServerstub, so the real assertions ran rather than copies. 7 succeeded, 0 cancelled, with the stub observing the genuineHEAD→POST ?uploads→PUT ?partNumber=1→POST ?uploadIdsequence carrying the file's bytes. Harness deleted; it is not in this diff.PveResourceSpec: 44 run, 38 succeeded — both reshaped tests pass. The 6 failures are pre-existing and environmental (the mock fabricatesbin/pythonwhilePveManagerlooks forScripts/python.exeon Windows); baseline shows the identical 6.git diff -- '*/src/main/*'is empty; no stranded fixtures (checked withgit status --ignored).WorkflowOperator/Test/scalafmtCheck,WorkflowOperator/scalafixAll --check,WorkflowExecutionService/Test/scalafmtCheck,WorkflowExecutionService/scalafixAll --check.Any related issues, documentation, discussions?
Closes #7799
How was this PR tested?
Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Opus 5)