From 21668af7784255cff8c30530231f5eb266b52010 Mon Sep 17 00:00:00 2001 From: aien Date: Wed, 14 Oct 2026 15:04:20 -0500 Subject: [PATCH 1/2] fix(kv-store): eliminate unpaused attach_waiter and shutdown step races in worker_tests Hold or pause follow-up loads in worker_late_attach_after_dispatch_is_counted_and_released and coalesced_waiters_are_bounded before calling attach_waiter so the background aien-kv-worker thread cannot dispatch, complete, and reap the load before the test thread attaches its second waiter on loaded CI runners. Also widen the virtual publish window and step size in worker_shutdown_lets_jobs_past_fsync_publish under single-core contention. Closes #518 --- crates/aien-kv-store/tests/worker_tests.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/aien-kv-store/tests/worker_tests.rs b/crates/aien-kv-store/tests/worker_tests.rs index 26640f78..a0cf05c7 100644 --- a/crates/aien-kv-store/tests/worker_tests.rs +++ b/crates/aien-kv-store/tests/worker_tests.rs @@ -670,7 +670,10 @@ fn worker_late_attach_after_dispatch_is_counted_and_released() { assert_eq!(w.worker.load_in_flight(&k), None); // The count is released with the job: a fresh load takes one waiter again. + // Hold the second load at the store so the worker thread cannot finish and + // reap `job2` before `attach_waiter` runs on a loaded runner. let mem2 = Mem::new(2, 0xEE); + w.fake.script(JobScript::fault(Fault::Hold)); let job2 = w .worker .submit_load_coalesced(k, &h, || mem2.dest(2).0, c) @@ -678,11 +681,13 @@ fn worker_late_attach_after_dispatch_is_counted_and_released() { let LoadTicket::Started(job2) = job2 else { panic!("a fresh load after the first closed: {job2:?}"); }; + wait_for("dispatch", || w.dispatched(job2)); assert_eq!( w.worker.attach_waiter(job2, d), Ok(()), "the late waiter's count was released when its job closed" ); + assert!(w.fake.release(job2), "the second held load starts"); let v = w.collect(2); assert_eq!(terminals(&v).len(), 2); assert_eq!(w.worker.stats().attach_refused_total, 1); @@ -1177,6 +1182,7 @@ fn coalesced_waiters_are_bounded() { // When a job ends its waiters leave the total. w.resume(); w.settle(); + w.worker.pause_dispatch(); let k = w.inject(60); let (_, h) = w.chunk(60); let mem = Mem::new(2, 0xEE); @@ -1186,6 +1192,8 @@ fn coalesced_waiters_are_bounded() { .unwrap() .job(); assert_eq!(w.worker.attach_waiter(job, Incarnation::seq(77)), Ok(())); + w.resume(); + w.settle(); } #[test] @@ -1319,10 +1327,11 @@ fn shutdown_with_stalled_fsync_returns_by_deadline_and_reports_unfinished() { #[test] fn worker_shutdown_lets_jobs_past_fsync_publish() { let w = rig(); - w.fake.script(JobScript::latency(100, 500_000)); + w.fake.script(JobScript::latency(100, 50_000_000)); let j = w.store(1).unwrap(); w.resume(); wait_for("file synced", || w.fake.now_us() >= 300); + w.step.store(10_000_000, Ordering::SeqCst); let rep = w.worker.shutdown(2000); assert_eq!(rep.published, 1, "{rep:?}"); assert!(rep.unfinished.is_empty()); From 933ad88ad188fb852696e64913dc3a0d69f95a96 Mon Sep 17 00:00:00 2001 From: aien Date: Wed, 14 Oct 2026 15:05:50 -0500 Subject: [PATCH 2/2] chore(crumb): recompile root .crumb after worker_tests edit (#518) --- .crumb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.crumb b/.crumb index fd47135d..8edd3b05 100644 --- a/.crumb +++ b/.crumb @@ -101,7 +101,7 @@ }, { "digest": "07f19c8d7013a03659eb514ccf94dd7ff76f2ff3ce3736cc3bb11c156ed30e1c", - "last_commit": "cc36bc72", + "last_commit": "43537272", "name": "scripts", "purpose": "" }, @@ -119,14 +119,14 @@ } ], "children_root": "sha256:235c8241a95dae8b28714acb8c85e84f60a3227c48d4d2f94ba498bdfed9b2f9", - "compiled_at": "2026-10-14T15:09:35Z", + "compiled_at": "2026-10-14T20:05:50Z", "compiler": "crumb-compile/1", - "digest": "sha256:77bb7bb9d01d7767359bacc46facf352c31aba364f1fb213a8ae5dd32afe7583", + "digest": "sha256:ed3f89333e66a502395d561b6728f432138e8c0e96142d8de55dfb0f2abc4ea6", "evidence_files": 439, "evidence_root": "sha256:342c5ebcb210cb45fa14616a90393f4872b4a086c7e58810a03aef42064ea1df", "files": 4359, - "generated_at_commit": "afc55ff0be82a0ea86faabf07daad39215aca105", - "source_tree": "sha256:4ae0ddf3f1f13ee606ab4ab8db9c8c8c63fb13fda6236be5fe84d3a10c38304b" + "generated_at_commit": "21668af7784255cff8c30530231f5eb266b52010", + "source_tree": "sha256:bbfa1403053969da74b8aa03db2724169dfc765ae7f56055f31216f0f2f2f63c" } }, "history": [],