Skip to content

test(backup): give the spooled test runtimes a 1 s heartbeat - #997

Merged
hitesh96db merged 1 commit into
mainfrom
fix/995-spooled-heartbeat
Nov 20, 2026
Merged

hitesh96db merged 1 commit into
mainfrom
fix/995-spooled-heartbeat

Conversation

@LeeroyHannigan

Copy link
Copy Markdown
Collaborator

What

spooled_runtime in crates/engine/src/backup/tests.rs now builds its test runtime with a 1 s heartbeat instead of the 50 ms of job_settings. Every test that calls spooled_runtime gets the 1 s heartbeat. No product code changes.

Why

Closes #995

the_reconciler_resumes_a_dead_manifest_restore_with_its_spool_host failed once in CI on #527 (run 43619839118). Before each store or table access, a job must see a confirmed beat at most two heartbeat periods old. At the 50 ms heartbeat that is 100 ms. A resumed job's first confirmed beat is the takeover's return inside the reconciler cycle. Before the job reads that beat, the cycle finishes its reads and the test runs its assertions. The job also prepares its spool entry with fsynced writes. On a loaded runner this took more than 100 ms, so the job stopped as a lost claim before its first download and loaded nothing.

With a 1 s heartbeat the window is 2 s. a_file_replaced_between_the_two_passes_fails_in_the_load already runs at 1 s for the same reason. The production heartbeat is 15 s.

Testing done

On this host, with the engine's library test binary:

Run Before (main at 95425f5) After
The failing test alone, 200 runs 0 failures 0 failures
The backup::tests module, 20 runs 1 run failed three other spooled tests the same way 0 failures, 431 passed in each run
The failing test with a 150 ms stall after the takeover, to model the loaded runner 10 failures in 10 runs 0 failures in 20 runs
  • The module took 30.53 to 31.66 s per run before and 30.55 to 30.94 s after.
  • a_job_that_learnt_the_record_is_anothers_leaves_its_spool_entry waits for a beat, so it now takes about 1.05 s alone, where it took about 0.1 s.
  • cargo +1.97.0 fmt --all -- --check: no changes.
  • cargo +1.97.0 clippy -p extenddb-engine --all-targets --features extenddb-engine/backup-test-hooks -- -D warnings: no warnings.

Checklist

  • I have read CONTRIBUTING.md
  • All tests pass (cargo test --workspace)
  • Code is formatted (cargo fmt --check)
  • Clippy is clean (cargo clippy -- -W clippy::pedantic)
  • I have added or updated tests for new functionality
  • I have updated documentation if behavior changed
  • Breaking changes are noted below (if any)
  • If this changes the wire protocol, Storage trait, auth model, on-disk
    format, or public CLI surface, an RFC has been accepted or is linked
    below. Otherwise, an ADR captures the decision (link below).

ADR / RFC: n/a


By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.

the_reconciler_resumes_a_dead_manifest_restore_with_its_spool_host failed
once in CI. After wait_for_jobs, bulk_load_files() was empty. The resumed
job stopped as a lost claim before its first download, so it recorded no
load and its task ended.

The engine tests run jobs at the 50 ms heartbeat of job_settings. A job
accepts a last confirmed beat at most two periods old, here 100 ms, before
each store or table access. A resumed job's first confirmed beat is the
takeover's return inside the reconciler cycle. Between that return and the
job's first read of the beat come:

- the rest of the cycle: the maintenance claim re-read, the record,
  progress and target readiness reads, and the spool listing
- the test's own assertions and the 5 ms sleep of wait_for_jobs
- the job's manifest and sidecar reads, the removal of the stale spool
  entry and the fsynced writes of both documents into the new one.

On a loaded runner that span passed 100 ms before the timer's first beat.
The job stopped with "no heartbeat confirmed the claim recently enough to
download data/000002.json.gz". A 150 ms stall of the test thread after the
takeover reproduces the failure on every run. Three other spooled tests
failed the same way in one of 20 runs of the module on a busy host. Each
was a job stopped before its first download.

spooled_runtime now builds its runtime with a 1 s heartbeat, so every
spooled test has a 2 s window. a_file_replaced_between_the_two_passes_fails_in_the_load
already runs at 1 s for the same reason. The production period is 15 s
and the product does not change. With the 150 ms stall in place the test
passed 20 of 20 runs. Without it the test alone passed 200 of 200 runs and
the backup::tests module 20 of 20.

Fixes #995
@hitesh96db
hitesh96db added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 2ef5613 Nov 20, 2026
58 checks passed
@hitesh96db
hitesh96db deleted the fix/995-spooled-heartbeat branch November 20, 2026 01:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky: the_reconciler_resumes_a_dead_manifest_restore_with_its_spool_host loses its 100 ms claim window on a loaded runner

2 participants