Repository navigation
Synchronize database lease and snapshot timing tests - #1195
Conversation
There was a problem hiding this comment.
ℹ️ Two non-blocking test coverage findings.
Approach
Using a fixture clock and synchronizing on the provider’s writer semaphore addresses the timing races while retaining the real libSQL client and SQLite backing.
Reviewed changes
- Lease clocks. Renewal uses the runtime clock for admission, the compare-and-swap budget, and the response deadline. Lease fences use the runtime’s Unix time.
- Writer contention. The remote fixture holds a provider transaction until the renewal queues. The guild fixture holds the commit while it checks same-generation renewal.
- Snapshot and reconnect tests. The remote tests exercise rollback, stream cleanup, and lease renewal after a stalled read or connection reset.
All 324 tests passed locally across the remote stream, guild data, and database compatibility modules.
Non-blocking
- P2 · The direct snapshot test stalls during
describe. Thequery_rowcase armsstall_ownedbefore libSQL prepares the query. The transaction-scopeddescribeconsumes the one-shot stall, so rollback and renewal assertions can pass without the direct query opening a cursor. Match the stall on/v3/cursorandSELECT 1before signaling the test. Direct snapshot test · Provider stall predicate · Pinned libSQL preparation code - P2 · Two renewal deadline boundaries lack regression coverage. The zero-request test expires the clock before admission, and the stalled-snapshot test expires it after the CAS reaches the provider. Add deterministic cases for a renewal that expires while waiting for the dedicated connection and for an applied CAS whose response is observed at the deadline. Those cases would catch regressions in the worker and post-response checks. Admission test · Worker and response checks
gpt-6.2-sol | 𝕏
|
Addressed both findings in c086c56. Tracing the earlier head showed the direct snapshot test stalled during libSQL’s describe request. The direct and prepared tests now both reach the transaction’s SELECT 1 cursor. Matching a different cursor made the direct test fail at the read deadline assertion. The lease cases now exercise both post-admission boundaries in the committed suite. A renewal that expires in the queue sends zero HTTP requests. When SQLite applies the CAS and the reply is observed exactly at the deadline, the caller receives a late-completion error and the test verifies the stored update. Disabling each boundary check made its corresponding test fail. All 325 database module and runtime cases and 128 focused repetitions passed. |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed commit c086c56 since the prior Pullfrog review.
- Targeted the snapshot cursor. Both snapshot cases stall the transaction’s
SELECT 1cursor request and verify rollback and lease recovery. - Covered expiry in the connection queue. The fixture holds the dedicated lease connection through the deadline and verifies that the renewal sends zero HTTP requests.
- Covered late completion. The fixture advances the clock at CAS operation entry and verifies that the caller reports late completion even though the update persists in SQLite.
I verified the changes by source inspection. The Rust core and remote database CI jobs were still running when I submitted this review. Rust core · Remote database
gpt-6.2-sol | 𝕏

Changes
Addresses the core database portion of #666. The original compiler run reported 23 real-clock reads and four sleeps across 12 tests. Lease tests now advance the fixture’s clock and wait for a renewal to queue behind the actual provider writer. The cursor tests stall a real read, check the rollback and connection state, and verify that the lease renews before expiry. The production paths still read the monotonic clock for authority and Unix time for the stored lease fence.
The lease compare-and-swap still checks its deadline at admission, when the database operation runs, and after the response. The public renewal API and the flake allowlist are unchanged.
Verification
bf3a825. All 324 tests in the affected guild database, remote-stream and database-runtime modules passed on the initial PR revision. Formatting, root all-target Clippy with warnings denied, scoped Dylint and the contracts preflight passed. Dylint reported zero inherited core findings.The direct and prepared snapshot tests now both stall the transaction’s actual SELECT 1 cursor. The renewal tests cover expiry before admission, expiry while queued with zero requests, and an applied SQLite update whose response arrives at the deadline. All 325 database module and runtime tests and 128 focused repetitions passed. Three fault injections independently broke the cursor selection, queue check and late-response check, and the corresponding tests caught all three.
Reviewed commit:
c086c56415621ca7f9fd483efd14bc2d7b1f6c3e.Summary by Sourcery
Make database lease and snapshot timing checks deterministic while preserving deadline enforcement.
Bug Fixes:
Enhancements:
Tests: