mirror of
https://github.com/we-promise/sure.git
synced 2026-07-16 06:45:21 +00:00
A sync marked stale by SyncCleanerJob while its job is still running hits two lost-update paths when that job finishes: - success path: finalize skipped the status transition but still ran perform_post_sync, re-applying transfer matching, rules, and broadcasts for a sync the system had already written off - failure path: the rescue's unguarded fail! silently overwrote the terminal stale status with failed (the in-memory record still read syncing, so the AASM guard never fired) Fix: re-check state under a row lock (with_lock reloads) before failing, and skip post-sync for stale syncs in finalize. Post-sync still runs for failed syncs — that behavior is intentional and covered by existing tests.