| author | |
| committer | |
| log | e4896e5afe119be520884ea2909139e167cbf6b9 |
| tree | 9508039504cf1b0d9c4229dab65c22d9f79a68d8 |
| parent | 9ec5dfb963ad9d44a22beefd26d7382f9a45acc2 |
| signature | Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU |
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.51 files changed, 4 insertions(+), 2 deletions(-)
crates/notebook/src/background.rs+4-2| ... | ... | @@ -539,12 +539,14 @@ impl Background { |
| 539 | 539 | .unwrap_or_default() |
| 540 | 540 | } |
| 541 | 541 | |
| 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. | |
| 543 | 545 | pub fn wake(&self) { |
| 544 | 546 | if let Ok(mut watched) = self.0.watched.lock() { |
| 545 | 547 | let now = Instant::now(); |
| 546 | 548 | for watch in &mut watched.sections { |
| 547 | watch.due = now; | |
| 549 | watch.due = watch.due.min(now); | |
| 548 | 550 | watch.current = false; |
| 549 | 551 | } |
| 550 | 552 | } |