Skip to content

Wait for writer recovery before testing backup export - #1196

Merged
jatmn merged 2 commits into
mainfrom
fix/queue-666-backup-recovery-ready
Dec 5, 2026
Merged

jatmn merged 2 commits into
mainfrom
fix/queue-666-backup-recovery-ready

Conversation

@jatmn

@jatmn jatmn commented Dec 5, 2026 •

Copy link
Copy Markdown
Owner

Backup export after writer startup

The read-only API integration test claimed the real bot writer lease and immediately submitted a backup export. The lease claim spawns startup recovery. If the writer received the export before recovery finished, it correctly refused the write pause and the test failed. Hosted failure

The fixture now awaits the existing recovery completion notification before submitting its first export. The API test enables the bot’s existing test-support feature to access that notification. The waiter registers before reading the recovery flag, so it also handles recovery finishing before the wait begins. The production write gate and every existing export, restore, rollback and lease assertion are preserved.

Verification

  • Holding startup recovery at its first queue read reproduced the original refusal. Removing the wait tripped the control before recovery was released. With recovery held for 2.5 seconds, the fixture stayed pending, then completed the export and restore successfully after release.
  • The named API integration passed 20 serial and 12 concurrent runs on the final commit. All 27 bot recovery tests passed. These tests use real SQLite and a loopback writer link, with both service states hosted by the test process.
  • Formatting, API Clippy with and without default features, bot Clippy, workspace Dylint, contracts and service boundaries passed. Workspace Dylint reported the same 167 inherited findings recorded on the base (27 core and 140 updater), all tracked under test: audit CI history for flaky tests and fix them #666. The existing per-test CI deadline continues to bound the scenario.

After review, the recovery wait also uses the CI runner’s 180-second limit when invoked directly with Cargo. Holding recovery indefinitely produced the startup-specific error at that limit. The same test passed when recovery was released after 2.5 seconds. The final test passed 20 serial and 12 concurrent runs, API Clippy in both feature configurations, API Dylint, formatting and contracts.

Part of #666. Tested commit 2feccd55ef2eecfea5f496169fcdd5702457715e on bf3a825.

Summary by Sourcery

Bug Fixes:

  • Wait for bot startup recovery to finish before the backup export integration test submits its first export, preventing a timing-dependent refusal.

@jatmn
jatmn marked this pull request as ready for review December 5, 2026 22:39
sourcery-ai[bot]
sourcery-ai Bot previously approved these changes Dec 5, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

pullfrog[bot]
pullfrog Bot previously approved these changes Dec 5, 2026

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ Approved with one non-blocking finding for local test runs.

Approach Waiting for the writer’s recovery flag before submitting the export directly addresses the startup race observed in CI. Original CI failure

Reviewed changes I traced writer lease acquisition, recovery completion, and the backup test’s first request.

  • Backup integration test. Waits for writer recovery before the first export through the read-only API.
  • Recovery notification. Exposes the existing waiter under the bot’s test-support feature. The waiter subscribes before checking the recovery flag, so it also handles recovery that completes before the wait starts.

The backup integration test passed in hosted CI. Formatting and service-boundary checks passed locally. Hosted API test run

Non-blocking

  • A persistent recovery error can hang a direct cargo test run. Startup recovery retries database errors while the writer holds its lease, so the new fixture wait can stay pending indefinitely outside CI’s test runner. Give this wait a generous timeout with a message identifying startup recovery as the stalled step. Fixture wait

Pullfrog  | Fix it ➔ | View workflow run | Using gpt-6.2-sol | 𝕏

@jatmn
jatmn dismissed stale reviews from pullfrog[bot] and sourcery-ai[bot] via 2feccd5 December 5, 2026 22:51
@jatmn

jatmn commented Dec 5, 2026

Copy link
Copy Markdown
Owner Author

Addressed review 6206626197 in 2feccd5. Direct cargo test now reports a startup-recovery timeout if the writer never becomes ready. I used the CI runner’s 180-second budget. A deliberately held recovery produced the expected error after 180.63 seconds, and releasing recovery after 2.5 seconds passed the full export and restore test. The updated fixture also passed 20 serial and 12 concurrent runs.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sourcery assessment

Approved.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes I reviewed the follow-up commit 2feccd5.

  • Bounded startup recovery. Added a 180-second deadline to the backup integration fixture’s recovery wait. If recovery stalls during a direct cargo test run, the test now fails with a message that identifies the stalled step.

Formatting and diff whitespace checks passed. The API integration test was not rerun locally for this review. The hosted API jobs were still running when checked. Default features · No default features

Pullfrog  | View workflow run | Using gpt-6.2-sol | 𝕏

@jatmn
jatmn merged commit 9f15fd9 into main Dec 5, 2026
22 checks passed
@jatmn
jatmn deleted the fix/queue-666-backup-recovery-ready branch December 5, 2026 23:05
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