Skip to content

CI: RavenDbTests host exits right after its run (#6162); split CIMartenNaturalKeys out of CIMartenDistribution (#6163) - #6168

Merged
jeremydmiller merged 2 commits into
mainfrom
ci-6162-6163-ravendb-exit-and-shards
Dec 4, 2026
Merged

jeremydmiller merged 2 commits into
mainfrom
ci-6162-6163-ravendb-exit-and-shards

Conversation

@jeremydmiller

Copy link
Copy Markdown
Member

Closes #6162
Closes #6163

#6162: the RavenDbTests host idles before it is killed

On main, Bobcat's supervisor killed the RavenDbTests host 113s, 114s and 201s after its last test started (runs 47173742063, 47174541236 and 47126586149: "the worker did not exit when asked"). RavenDbTests.LeaderElection was killed the same way, about 12s after its last test started. Two causes, both in DatabaseFixture (src/Persistence/RavenDbTests/message_store_compliance.cs):

  1. Fixture teardown deleted hundreds of databases one at a time. DatabaseFixture is the "raven" collection fixture, a RavenTestDriver, and StartRavenStore() gives nearly every test a fresh database. None of those stores is disposed until xUnit tears the fixture down after the last test. RavenTestDriver.Dispose() then disposes every store it handed out, and disposing each store deletes its database, one request at a time. Locally the run summary came out 60s after the last test. The databases live in the embedded test server, which runs in memory and goes away with the process, so DatabaseFixture.Dispose() no longer deletes them. A test that disposes its own store still deletes its database as before.
  2. The embedded server's graceful shutdown held the process open. The server is stopped from a ProcessExit handler that waits up to GracefulShutdownTimeout before it kills the server. A native sample of the host during the exit window shows the finalizer thread in AppDomain::RaiseExitProcessEvent, blocked on a wait handle. That took 5s with one database and ~30s with a run's worth of them (with fix 1 alone the host printed "Foreground threads were left running, forcing process exit"). The supervisor allows 5s. The server is throwaway, so it now gets GracefulShutdownTimeout = TimeSpan.Zero.

Measured locally (test host run directly, time from the last test result to process exit):

full RavenDbTests one class (message_store_compliance, 102 tests)
before 69s (60.7s to the summary, then 8.6s to exit) 30s after the summary (fix 1 only)
after ~0.3s after the summary 0.3s after the summary

./build.sh CIRavenDb --framework net10.0 under the supervisor: 465 + 50 passed, no worker killed, 8:28 for the target locally.

#6163: shard CIMartenDistribution

Per-job times on green main runs, 2026-12-03:

job 47126586149 47173742063 47174541236
CIMartenDistribution 17:31 17:29 15:07
CIRavenDb 18:28 14:46 15:05
CIMarten 14:13 15:03 9:58
CIEfCore 12:38 11:51 13:33

CIMartenDistribution is split by class, using the RabbitMQ pattern (#6141). The new CIMartenNaturalKeys takes these classes. Per-class times are summed from the [lane 0] -> start lines in the log of run 47173742063:

class (MartenTests.AggregateHandlerWorkflow.) s
natural_key_load_matrix 197.4
natural_key_load_matrix_with_conjoined_tenancy 110.8
natural_key_explicit_key_type 24.6
natural_key_decider_workflow 18.9
natural_key_aggregate_handler_workflow 11.4
natural_key_nullable_mapped_and_batched 8.6
tenant_partitioned_natural_key_aggregate 6.7
natural_key_read_aggregate 6.3
MultiStream.multi_stream_batched_fetches_with_natural_keys 5.0
natural_key_ambiguous_command 3.2
MultiStream.multi_stream_batched_fetches (for balance) 35.9
tenant_partitioned_aggregate_matrix (for balance) 16.2
CIMartenNaturalKeys ~445
CIMartenDistribution (its namespaces minus that list) ~448

CIMartenDistribution is defined as its namespaces minus the CIMartenNaturalKeys list, so a new class in those namespaces still runs there. With ~2.5 minutes of build and docker per job, expect about 10 minutes for each of the two jobs, down from 17.5.

CIRavenDb is not split. The fix for #6162 removes 2-3.5 minutes of idle tail (114s, 113s and 201s) plus the LeaderElection kill. On those three runs the job would have taken about 13:10, 12:50 and 15:00, against 15:05, 14:46 and 18:28. That is about 15 minutes or less, so the job is left whole. If it creeps up again, RavenDbTests and RavenDbTests.LeaderElection are a natural two-way split.

CIEfCore and CIMarten peak at 13:33 and 15:03, so they are not changed here.

The new target is in TESTS_MATRIX (tests.yml), in MartenTests' CI targets in build/LocalGate.cs (which is how TestsMatrixPlan and AffectedGate map it), in build/gates.json (regenerated) and in .claude/docs/test_gates.md.

Verified

  • dotnet build build/build.csproj
  • dotnet build wolverine.slnx -c Release -f net10.0: 0 warnings, 0 errors
  • ./build.sh LocalGateManifest (gates.json regenerated), ./build.sh VerifyCITargetCoverage passes
  • ./build.sh PlanTestsMatrix with the workflow's list: 44 targets, including CIMartenNaturalKeys
  • the full RavenDbTests suite, run directly (480 passed) and through ./build.sh CIRavenDb --framework net10.0 (465 + 50 passed, no kill)

This PR changes build/ and .github/, so its CI runs the full matrix, which checks the new timings.

🤖 Generated with Claude Code

jeremydmiller and others added 2 commits December 4, 2026 00:05
… of idling ~2 minutes

Two things held the RavenDbTests host open after its last test, and Bobcat's supervisor killed it
113-201s later on CI ("the worker did not exit when asked"):

- The "raven" collection fixture (DatabaseFixture, a RavenTestDriver) hands a fresh database to nearly
  every test and none were disposed until xUnit tore the fixture down after the last test.
  RavenTestDriver.Dispose() disposes every store it handed out, and each store's disposal deletes its
  database, one request at a time: 60s locally before the run could even report. The databases live in the
  in-memory embedded test server, which goes away with the process, so DatabaseFixture.Dispose() no longer
  deletes them. Tests that dispose their own store still delete their database as before.
- The embedded server is stopped from a ProcessExit handler that waits up to GracefulShutdownTimeout for a
  graceful shutdown: 5s with one database, ~30s with a run's worth, against the 5s the supervisor gives a
  worker to exit. The throwaway server now gets GracefulShutdownTimeout = 0.

Locally the host now exits ~0.3s after the run summary (was 69s for the full suite), and
`./build.sh CIRavenDb` runs RavenDbTests and RavenDbTests.LeaderElection with no worker killed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CIMartenDistribution ran 17:31 and 17:29 of the 20 minute cap on main (runs 47126586149 and 47173742063),
~15m of it tests. The natural key matrices of AggregateHandlerWorkflow are most of the growth since the
namespace split. CIMartenNaturalKeys takes ten natural key classes plus multi_stream_batched_fetches and
tenant_partitioned_aggregate_matrix for balance (~445s of tests measured from run 47173742063's log);
CIMartenDistribution keeps its namespaces minus that list (~448s), so a new class still runs there. Added to
the TESTS_MATRIX list and MartenTests' CI targets in LocalGate; gates.json regenerated.

CIRavenDb is not split: with GH-6162's fix it loses its ~2-3 minutes of idle tail and should run ~12-15
minutes. CIEfCore (11:51-13:33) and CIMarten (9:58-15:03) are left as they are.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jeremydmiller jeremydmiller added this to the 7.0 milestone Dec 4, 2026
Copilot AI balanced review requested due to automatic review settings December 4, 2026 06:05

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@jeremydmiller
jeremydmiller merged commit 0915cb8 into main Dec 4, 2026
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants