Repository navigation
Conversation
…action modes Applies payloads from many devices concurrently to one WAL database, each on its own connection, with the apply in autocommit, BEGIN, BEGIN IMMEDIATE or BEGIN CONCURRENT, and the SQLite Cloud server's retry policy. Every mode must converge to a serial reference, and under BEGIN IMMEDIATE the apply never returns BUSY. Reports retries, failed requests, BUSY codes, wall and CPU time. Manual only (`make apply-stress`); APPLY_STRESS_SQLITE_DIR builds it against another sqlite3.c, such as the server's. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
test/stress/apply_stress.c, a manual stress test that reproduces the SQLITE_BUSY storm seen when a sync server applies uploads from many devices to one database at the same time.Each device builds payloads that each span several db_versions. One thread per device then applies its payloads concurrently to a shared WAL database file, each on its own connection, in one of four modes:
autocommitSELECT cloudsync_payload_apply(?)on its owndeferredBEGIN; apply; COMMIT— what the SQLite Cloud server does today (implicitBEGIN TRANSACTION)immediateBEGIN IMMEDIATE; apply; COMMITconcurrentBEGIN CONCURRENT; apply; COMMIT— skipped when the linked SQLite lacks itRetries follow the server: up to 1 + 6 attempts per request, a busy COMMIT retried 5 times, and a failed request re-sent after a backoff.
Checks: every mode must converge to a reference database that applied all payloads serially, and in
immediatemode the apply statement must never return BUSY. Retries, failed requests, BUSY codes, wall time and process CPU time are reported.Results
32 devices, 640 payloads, built against the SQLite Cloud server's SQLite 3.54, 5000 ms busy timeout:
All modes converged to the reference.
Why deferred fails: the apply reads before its first write. SQLite calls the busy handler only when the connection holds no transaction, so the read→write upgrade returns SQLITE_BUSY immediately and the busy timeout is never used.
BEGIN IMMEDIATEtakes the write lock before any read, so contention becomes a normal wait.Running it
Manual only: it needs threads and its numbers depend on the machine. It is not part of
make testor CI.All
APPLY_STRESS_*settings are documented in the file header.Test plan
make apply-stresspasses with this repo's SQLite 3.45 (concurrentskipped)make test🤖 Generated with Claude Code