Skip to content

Add busy_timeout to verify! method to gracefully handle concurrent write locks - #74

Open
jonyoi wants to merge 1 commit into
fractaledmind:mainfrom
jonyoi:main
Open

Add busy_timeout to verify! method to gracefully handle concurrent write locks#74
jonyoi wants to merge 1 commit into
fractaledmind:mainfrom
jonyoi:main

Conversation

@jonyoi

@jonyoi jonyoi commented Jul 20, 2026

Copy link
Copy Markdown

The Litestream.verify! method opens a direct SQLite3::Database connection to insert a sentinel value and confirm replication. However, because this connection is created outside of Active Record's connection pool, it does not inherit the timeout configuration defined in database.yml.

In production environments with active, concurrent write load, the verification task's sentinel write can hit a momentary lock collision and immediately raise SQLite3::BusyException, causing the verification job to fail.

This PR adds a busy_timeout keyword argument (defaulting to 5000ms) to verify! and applies it to the raw connection before executing schema creation or inserts. This aligns the method's concurrency behaviour with standard Rails SQLite configurations and prevents false-positive job failures.

Changes:

  • Added busy_timeout: 5000 keyword argument to Litestream.verify!.
  • Configured database.busy_timeout = busy_timeout on the raw SQLite3::Database instance.

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