Skip to content

fix(sync): foreground and a network return wake the core's scheduler, never ahead of a retry delay - #4809

Merged
datlechin merged 2 commits into
mainfrom
fix/sync-wake
Dec 1, 2026
Merged

datlechin merged 2 commits into
mainfrom
fix/sync-wake

Conversation

@datlechin

Copy link
Copy Markdown
Member

Summary

  • Core: SyncService::wake(why) over the FFI, through SyncHost::wake: returns at once and asks each running engine's scheduler for a pass. The scheduler runs it soon, folds repeated wakes into one pass, never runs two at once, and holds it until any retry delay it keeps has passed (Retry-After, backoff after 429/503/5xx, CloudKit throttle).
  • Core: a network return ends a hold only when the last failure was a network failure, since no server answer named that wait (core ADR 0044: a pull runs when the network returns).
  • Core: a poll that falls due goes before queued wakes and covers them, so journal wakes never hold the poll off and a long hold ends in one pass.
  • Core: a wake starts TablePro Sync again when its start failed for a reason that passes, as sync_now did.
  • Mac: with iCloud off (TablePro Sync, or the team scopes alone), coming to the front and the network's return wake the open service. The network monitor runs for the coordinator's whole life.
  • Mac: while iCloud runs, its foreground, network-return, journal and CloudKit-notice passes go through the wake too, so they wait out CloudKit's retry-after. Launch, account change and Sync Now still run at once. Every network return reaches the scheduler, during a pass too.
  • Mac: a pass the scheduler ran on a wake saves the CloudKit subscription once it confirmed the account.
  • Windows: SyncHost.NudgeAsync becomes SyncHost.Wake over TableProSync.Wake, so foreground and network return no longer skip the server's retry delay. Bindings regenerated.
  • Linux: no TablePro Sync scheduler, nothing to wire.
  • Tests changed on purpose: SyncProviderCoordinatorTests activationIsHeldForTheInterval, journalReachesTheEngineAndDebouncesAPass and noticeWakesTheScheduler (was noticeAsksForAPass) now expect a wake, not a pass.

Test plan

  • core/crates/sync/tests/engine/wake.rs: a wake runs a pass at once; many wakes run one; a wake during a pass starts no second; a wake inside Retry-After waits it out; a network return ends only a network failure's wait; endless journal wakes do not hold off the poll.
  • core/crates/ffi/src/sync/tests.rs: a wake's pass finds a new team long before the 60 s poll.
  • SyncProviderCoordinatorTests: iCloud off wakes the open service on activation and network return; no open service opens none; a network return wakes the scheduler during a pass; a scheduled pass saves the subscription.
  • SyncHostTests and interop SyncTests: the Windows wake reaches the open engine and returns at once after a close.
  • Local: tablepro-sync engine 216, sync-host 15, ffi sync 73, clippy clean; Mac build and 101 tests; Windows model tests 1513 and interop sync tests 9 on macOS.

… never ahead of a retry delay

Mac and Windows asked for these passes with sync_now, which skipped the scheduler's Retry-After and backoff; the Mac asked only while iCloud ran.
@datlechin
datlechin merged commit 610ef86 into main Dec 1, 2026
31 of 34 checks passed
@datlechin
datlechin deleted the fix/sync-wake branch December 1, 2026 18:46
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.

1 participant