Skip to content

Serialize concurrent increments and unless_exist writes - #321

Open
ydah wants to merge 2 commits into
rails:mainfrom
ydah:fix-atomic-cache-writes
Open

ydah wants to merge 2 commits into
rails:mainfrom
ydah:fix-atomic-cache-writes

Conversation

@ydah

@ydah ydah commented Oct 14, 2026

Copy link
Copy Markdown

Concurrent unless_exist writes to a missing key can all succeed, and concurrent increments can lose updates because SELECT ... FOR UPDATE has no row to lock.

Insert a placeholder before locking and reading the entry. Keep it within the transaction, replace it on write, and remove it when the block returns no value. A zero byte size distinguishes placeholders from valid empty values.

ydah added 2 commits October 14, 2026 14:01
Warm schema metadata before the workers start and use a GVL-releasing busy handler for Rails 7.2 SQLite connections. Restore the configured timeout after each worker finishes.
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