Skip to content

[codex] Fix atomic sync gates#1020

Open
jnunemaker wants to merge 2 commits into
mainfrom
atomic-sync-gates
Open

[codex] Fix atomic sync gates#1020
jnunemaker wants to merge 2 commits into
mainfrom
atomic-sync-gates

Conversation

@jnunemaker

Copy link
Copy Markdown
Collaborator

Fixes thundering-herd syncs caused by unsynchronized check-then-act gates in the poll and interval synchronizers. The poll adapter now coordinates in-flight local updates, retries after failed synchronization, and resets sync state after forks; the interval synchronizer now claims each elapsed interval atomically. This keeps concurrent request threads from issuing duplicate remote reads and overlapping local writes for the same sync window. Validated with bundle exec rspec spec/flipper/adapters/poll_spec.rb spec/flipper/adapters/sync/interval_synchronizer_spec.rb and bundle exec rspec spec/flipper/adapters, which passed with the existing 2 sqlite pending examples.

@jnunemaker
jnunemaker marked this pull request as ready for review July 8, 2026 18:42
The bare rescue in synced_adapter only cleared @syncing for StandardError,
so a non-StandardError from the Synchronizer (Interrupt, SignalException,
etc.) would leave @syncing true permanently, deadlocking all subsequent
reads waiting on @sync_condition. Use an ensure with a synced flag so state
is always cleared, bumping @last_synced_at only on success. Mirrors the
ensure-based cleanup already in IntervalSynchronizer#call.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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