From 3cdd718f580a8505ba36986a3b395223689e36d5 Mon Sep 17 00:00:00 2001 From: Lee Hannigan <29015211+LeeroyHannigan@users.noreply.github.com> Date: Sat, 14 Nov 2026 18:37:28 +0000 Subject: [PATCH] test(backup): give the spooled test runtimes a 1 s heartbeat 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 --- crates/engine/src/backup/tests.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/backup/tests.rs b/crates/engine/src/backup/tests.rs index 073fced63..2b2123194 100644 --- a/crates/engine/src/backup/tests.rs +++ b/crates/engine/src/backup/tests.rs @@ -14605,7 +14605,7 @@ fn songs_from(from: usize, n: usize) -> Vec { } /// A healthy runtime on `mem` with a spool at `spool` (an S3 store's shape), -/// the job settings and a collector. +/// the job settings at a 1 s heartbeat, and a collector. fn spooled_runtime(mem: &Arc, spool: &std::path::Path) -> BackupRuntime { runtime() .with_store( @@ -14625,7 +14625,16 @@ fn spooled_runtime(mem: &Arc, spool: &std::path::Path) -> BackupRuntim ) .with_manifest_names("bucket".to_owned(), "prefix/".to_owned()), ) - .with_job_settings(job_settings()) + // A 1 s heartbeat, not the 50 ms of `job_settings`: the claim window is + // two periods, and a spooled job's first claim check comes after its + // first beat (a resume's is the takeover's return inside the reconciler + // cycle), the spool entry's open, its fsynced document writes and the + // test's own steps, which a loaded host can stretch past 100 ms and end + // the job as a lost claim before its first download. + .with_job_settings(JobSettings { + heartbeat_interval: Duration::from_secs(1), + ..job_settings() + }) .with_metrics(Arc::new(extenddb_core::metrics::MetricsCollector::new())) }