Repository navigation
Refuse to migrate an Ordered S3Queue that already uses buckets - #130733
alexey-milovidov merged 1 commit into
Conversation
`ALTER TABLE ... MODIFY SETTING buckets` with `s3queue_migrate_old_metadata_to_buckets = 1` moves the single `processed` node of an old Ordered queue into `buckets/N/processed`. The guard in `ObjectStorageQueueMetadata::alterSettings` refused the migration only when the raw `buckets` setting was above 1. With `buckets` unset the effective bucket count is `processing_threads_num`, which defaults to `max(cores, 16)`, so a default Ordered queue already has that many `buckets/N` nodes and still passed the guard. `migrateToBucketsInKeeper` then failed its `chassert(buckets_num == 1)` in debug builds (`Logical error: 'Buckets: 16'`, found by the AST fuzzer on an `AzureQueue` clone of 05339). A release build has no assertion: it switched the queue to the new bucket count while each new bucket kept only the processed pointer of old bucket 0 or 1, and after a restart the already processed files were ingested again (measured on 26.10.2.103: 64 files, 128 rows). Check the effective count `buckets_num`, which is the precondition the migration asserts. The refusal happens before any Keeper write. 05339 gets a case for a queue created without `buckets` and `processing_threads_num`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review: adjudication log (click to expand)Pre-publication review by an independent model (engine: codex; 0 findings) plus my own review (2 nits).
Severity: ❌ blocker / Session id: cron:clickhouse-review-slot-8:20261111-094400 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-5:20261111-090300 |
|
Workflow [PR], commit [a8cde0d] Summary: ✅
AI ReviewSummaryPR #130733, head Missing context / blind spots
Final VerdictStatus: ✅ Approve. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units9 translation units recompiled, 24 s compile time in total, 9 of them have a recent master baseline. |
…t one bucket The readers of the Ordered Keeper layout treat a queue with at most one bucket as the layout without buckets (last processed file in `<keeper_path>/processed`) and a queue with more buckets as one `buckets/<i>/processed` per bucket (`useBucketsForProcessing`). `ObjectStorageQueueOrderedFileMetadata::migrateToBuckets`, run by `ALTER TABLE ... MODIFY SETTING buckets` under `s3queue_migrate_old_metadata_to_buckets = 1`, disagreed with that: - for a source created with `buckets = 1` it read the pointer from `buckets/0/processed`, which such a queue never writes; - when it found no pointer it returned before creating the `buckets/<i>` nodes, while `migrateToBucketsInKeeper` still switched the queue to the new count. The readers then look for nodes that do not exist: a debug build aborts on `chassert(bucket_exists)` in `tryAcquireBucket`, a release build loops on `Failed to set file processing, error: No node` and never ingests another file (measured on 26.10.2.103); - it migrated to the raw `buckets` value: a target of 1 moved the pointer to `buckets/0/processed` and removed `<keeper_path>/processed`, so after a restart the queue ingests every processed file again (measured on 26.10.2.103: 32 rows for 16 files); a target of 0 created no bucket although the queue then uses `processing_threads_num` buckets. Now `migrateToBucketsInKeeper` passes the new effective bucket count (`getBucketsNum` of the new metadata), and `migrateToBuckets` does nothing when that count is at most 1, creates the bucket nodes before looking for the pointer, and looks for it first in `buckets/0/processed` (where older versions put it after a migration to one bucket, and where the initiator replica has just put it) and then in `<keeper_path>/processed`. The "migrated concurrently by another replica" return is keyed on the source being bucket 0's node, which is what `prev_value != 0` meant before. A `buckets = 1` source whose `processed` node has children (partitioned layout) is now refused with `SUPPORT_IS_DISABLED`, as an unset source already was, instead of being switched to a layout without a pointer. The new test is a new file rather than a 05339 extension, because ClickHouse#130733 extends 05339. Co-Authored-By: Claude Opus 5.5 <[email protected]>
b20d013
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed
ALTER TABLE ... MODIFY SETTING bucketswiths3queue_migrate_old_metadata_to_buckets = 1on an OrderedS3QueueorAzureQueuetable created withoutbuckets. Such a table already spreads its files overprocessing_threads_numbuckets, so the migration rewrote a layout it does not handle, and files that were already processed could be ingested again. TheALTERis now rejected withSUPPORT_IS_DISABLED.Description
Found by the AST fuzzer (
Logical error: 'Buckets: 16', STID 2508-48a2): https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=128397&sha=c73851844138eede9c5cea8e9fc60ecf3e7ee388&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%29On 26.10.2.103 (the same code is in 26.8 and 26.3),
ALTER TABLE q MODIFY SETTING buckets = 2is accepted on an Ordered queue created withoutbuckets, and after a server restart files it had already processed are ingested again (measured: all 64 processed files, 128 rows instead of 64).When
bucketsis unset, the effective bucket count isprocessing_threads_num, which defaults to at least 16, and the queue's Keeper layout already has that manybuckets/Nnodes. Thebucketsbranch ofObjectStorageQueueMetadata::alterSettingschecked only the rawbucketsvalue, so it calledmigrateToBucketsInKeeper, whosechassert(buckets_num == 1)aborts a debug build. A release build switches the queue to 2 buckets while each new bucket keeps only the processed pointer of old bucket 0 or 1. The guard now checks the effective count, which is the precondition the migration asserts.AzureQueueshares this code.Behaviour change: this
ALTERis refused on any Ordered queue whose effective bucket count is above 1, includingbuckets = <current count>, and on queues created before 24.6 withs3queue_processing_threads_numabove 1 (made backward incompatible by #64349). The setting is documented as migration-only.Not changed here: a queue created with
buckets = 1gets no bucket nodes from this migration, which is a separate path inmigrateToBuckets.Validation:
05339_s3queue_ordered_migrate_to_bucketsgets a third case. It fails on master (the debug server aborts) and passes with the fix, 50/50 with randomized settings and 10/10 in the Database Replicated shape.Workflow [PR]
Sync PR [sync-upstream/pr/130733]
Version info
26.11.1.2033-master(included in26.11and later)