Repository navigation
Add a test for sorter worker threads and sqlite3_backup_init - #307
Merged
utelle merged 1 commit intoNov 10, 2026
Merged
Conversation
threadtest sorts and indexes enough rows that the sorter hands work to worker threads, which open temporary files of their own. It checks that the statements finish, that worker threads really opened such files, and that the files of an encrypted database contain no plaintext. A plaintext database serves as the control. It also checks that another thread can use both connections after sqlite3_backup_init, for compatible databases and for the two cases in which the backup is refused. The CI runs it after the rekeying tests.
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.
A new CI test for two things that need more than one thread to show up.
The first part sorts and indexes enough rows that the sorter hands work to worker threads (PRAGMA threads=4, temp_store=FILE, cache_size=10). With the default of 100000 rows, the worker threads open 12 of the 14 to 16 temporary files. The test checks that the ORDER BY and the CREATE INDEX finish within 60 seconds, that worker threads opened temporary files at all, and that the files of an encrypted database contain no plaintext. The same run on a plaintext database must show the rows in the temporary files, so the check itself is known to see the sorter's data. A VFS below the Multiple Ciphers VFS does the counting.
The second part calls sqlite3_backup_init with both databases encrypted, both plaintext, and the two mixed cases, which are refused. Afterwards a second thread must be able to take the mutexes of both connections with sqlite3_mutex_try, so a mutex left locked shows up as a failure instead of a hang.
The second thread and the timeout use sqlite3ThreadCreate, so the test needs no platform code beyond getting the thread id.
Testing (macOS arm64, flags from Makefile.am):