Repository navigation
Fix flaky test 04549_sqlite_database_engine_missing_file - #123316
alexey-milovidov merged 2 commits into
Conversation
The test attaches a SQLite database over a missing file and then creates
the file in place with the `sqlite3` CLI. The attached database is visible
to every concurrent test: a query that enumerates all databases (seen in CI:
05034_merge_sibling_const_fold's merge() over system.s3_queue_settings)
reaches DatabaseSQLite::getTablesIterator, which opens the new file and
holds a SQLite shared lock while it reads the schema. The CLI sets no busy
timeout, so its commit fails at once with SQLITE_BUSY ("Error: stepping,
database is locked (5)") and t1 or its row is missing.
Build the file as new.sqlite and rename it into place, as 05219 already
does. No database refers to new.sqlite, so no reader can lock it while it
is written, and a rename within one directory is atomic, so a reader sees
either no file or the complete one. DatabaseSQLite reopens the path on every
metadata operation, so the asserted behaviour (the attached database starts
working once the file appears) is unchanged, and so is the reference.
With 16 concurrent clients reading system.tables and system.s3_queue_settings,
the old test failed 11/50 and 8/50 randomized runs, the new one 0/50.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: 0 findingsPre-publication review by an independent model (engine: codex): no findings, nothing to adjudicate. The diff is test-only (1 file, +5/-1) and the Session id: cron:clickhouse-review-slot-8:20261001-180600 |
|
Workflow [PR], commit [ed18d1f] Summary: ✅ AI ReviewSummaryThis PR makes Final Verdict
|
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
Description
Related: #123286 (the test failed there; that PR does not touch SQLite). No related open issue found.
04549_sqlite_database_engine_missing_filefailed in Stateless tests (amd_debug, distributed plan, s3 storage, parallel) withError: stepping, database is locked (5)and the42row missing.The test attaches a SQLite database over a missing file and then creates the file in place with the
sqlite3CLI. The attached database is visible to every concurrent test, and a query that enumerates all databases opens the new file and holds a shared lock while it reads the schema. In that run the reader was05034_merge_sibling_const_fold, whosemerge()oversystem.s3_queue_settingsiterates every database. The CLI sets no busy timeout, so its write fails at once withSQLITE_BUSY.The test now builds the file as
new.sqliteand renames it into place, as05219_sqlite_database_engine_file_replaced_same_pathalready does. No database refers tonew.sqlite, so nothing can lock it while it is written, and the rename is atomic, so a reader sees either no file or the complete one. The checked behaviour is unchanged: the already-attached database starts working once the file appears..referenceis unchanged.Validation on a debug build, 50 randomized runs per arm, with 16 concurrent clients reading
system.tablesandsystem.s3_queue_settings: the old test failed 11/50 and 8/50, every time withdatabase is locked; the new one passed 50/50. Without the concurrent clients it passed 50/50.Workflow [PR]
Sync PR [sync-upstream/pr/123316]
Version info
26.10.1.1255-master(included in26.10and later)