authoravatarclover caruso<git@paperclover.net>2026-10-19 16:30:31-07:00
committeravatarclover caruso<git@paperclover.net>2026-10-19 23:39:58-07:00
loge4896e5afe119be520884ea2909139e167cbf6b9
tree9508039504cf1b0d9c4229dab65c22d9f79a68d8
parent9ec5dfb963ad9d44a22beefd26d7382f9a45acc2
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU

fix(notebook): keep a woken background from checking one section over and over

Background::wake set every section due "now", so a wake that came again before a round finished tied them all at the same moment, and the scheduler, which takes the first of equal dues, checked the first section again while the rest waited. Library::flush wakes every 50 ms until each closed section has synced, so on a loaded machine, where a check takes longer than that, it starved every section but the first and timed out: the mobile tests finishing_keeps_offline_copies_and_close_notebook_deletes_them and a_provider_that_lists_but_cannot_open_opens_from_the_offline_copies failed 34 and 6 times in 36 loaded runs of the suite (12 at once, three rounds). A wake now brings forward only sections not yet due, so those waiting keep their place: 0 and 0 in 36. Assisted-by: claude-opus-5.5

1 files changed, 4 insertions(+), 2 deletions(-)

crates/notebook/src/background.rs+4-2
......@@ -539,12 +539,14 @@ impl Background {
539539 .unwrap_or_default()
540540 }
541541
542 /// Reads every section's stamp now, working offline included (Sync Now).
542 /// Reads every section's stamp now, working offline included (Sync Now). A section already
543 /// due keeps its place: waking again while a round runs would otherwise tie every section
544 /// at now, and the first would be checked over and over while the rest waited.
543545 pub fn wake(&self) {
544546 if let Ok(mut watched) = self.0.watched.lock() {
545547 let now = Instant::now();
546548 for watch in &mut watched.sections {
547 watch.due = now;
549 watch.due = watch.due.min(now);
548550 watch.current = false;
549551 }
550552 }