Handle stale syncs #2257

Merged
zachgoll merged 2 commits from zachgoll/handle-stale-syncs into main 2025-05-18 06:28:21 +08:00
zachgoll commented 2025-05-18 06:09:47 +08:00 (Migrated from github.com)

When code changes are deployed and workers restart, in-process syncs will be aborted and will never be re-run. This causes many syncs to become stuck in pending or syncing status forever.

This PR mitigates the effects of this with a 3-pronged approach:

  • The visible scope makes it so users won't ever see a sync longer than 5 minutes (and most syncs will complete even faster)
  • The sync_later method now marks all prior syncs for that specific syncable record as stale prior to starting a new sync
  • The SyncCleanerJob runs hourly and marks any syncs that became stale as stale
When code changes are deployed and workers restart, in-process syncs will be aborted and will never be re-run. This causes many syncs to become stuck in `pending` or `syncing` status forever. This PR mitigates the effects of this with a 3-pronged approach: - The `visible` scope makes it so users won't ever see a sync longer than 5 minutes (and most syncs will complete even faster) - The `sync_later` method now marks all prior syncs for that specific `syncable` record as `stale` prior to starting a new sync - The `SyncCleanerJob` runs hourly and marks any syncs that became stale as `stale`
Sign in to join this conversation.