Repository navigation
Conversation
Internal second-model review: 14 rounds, 93 findings adjudicated (click to expand)Every round of this PR was reviewed cold by an independent model against the resulting code, then Accepted and fixed (selected: the ones that changed behaviour)❌ DDL validation was not reached for ❌ A definition read back from stored metadata must not be re-rejected. A table created before ❌ A projection directory that stops being probeable detached the whole base part. The load ❌ ❌ An ancestor directory named ❌ ❌ A mutation of such a part failed outright, in both mutation tasks. ❌ Two write paths reported the refusal as a bare
Declined, with evidence💡 Four findings were declined and recorded terminally, each refuted against source or measured Known limitation, disclosed💡 For a part in this degraded state, operations that clone or freeze it still fail. A no-op This was reviewed as a defect four times, adopted as a fix item for a full round, and declined only It is left for a separate change because the fix belongs in the generic freeze/backup walk, which NotesMutation arms were run and recorded for every behavioural claim, with each arm's served Build ID |
Pre-PR validation gate
Regression sweep: 189 projection-related tests in both arms, built from this branch with only the fix reverted. Zero regressions, zero tests present in one arm only. 50 of 50 randomized runs pass with no Scoping the consistency-check guard is proved live in both directions by its own mutations, and the base-file case asserts the error names the offending base file rather than merely that some error occurred. Restoring the wider errno-only condition reddens both base-file arms at exactly the assertion that the misleading "A projection directory" line must be absent, leaving the other four cases green. Scanning the whole reported path again instead of the part-relative tail reddens exactly and only the arm whose data directory has an ancestor ending in Each backup guard is proved live by its own mutation. Reverting the consistency-check guard alone reddens the default The integration test is proved live by two further mutations rather than assumed live. Putting the broken-projection record back after the placeholder construction detaches the base part again on both granularity shapes, and restoring the placeholder's earlier part type aborts the server during load. Reverting the removal-path guard reddens the drop assertion on both unprobeable cases and leaves both legacy cases green. Each mutation reddens the shape it is meant to guard, and each restored file relinks to a bit-identical binary. Mutation testing: reverting the fresh-definition predicate alone leaves the test green because the second check independently covers that case; removing both makes it fail; removing the second check alone exposed a vacuous test row, which was then rewritten. Further mutations were run one at a time against hand-built legacy fixtures, since a fixed server cannot create an over-long name: restoring the earlier gate loses a restore with |
|
cc @CurtizJ @scanhex12, could you review this? A projection name longer than a path component was accepted at DDL and then every write failed with a bare |
|
Workflow [PR], commit [7011c23] Summary: ❌
AI ReviewSummaryThis PR adds a DDL-time length check for projection names and improves the error surfaced when a legacy over-limit projection hits Findings
Tests
Final Verdict
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 78/86 (90.70%) · Uncovered code |
|
@groeneai why do you need such a large PR to fix the issue? |
|
Fair question. The diff is 20 files, +1267 -87, but 789 of the 1267 added lines (62%) are tests in new files, and another 72 added lines under The length rejection itself is small: 53 added lines across five existing files, plus a new 161-line helper. The rest is what a fixed server needs in order to still open a table whose projection name is already too long, because the name is rejected only for fresh CREATE-like input (an Two of those legacy paths were pre-existing bugs that I had to fix rather than work around:
The remaining If you would still rather review it in two pieces, the natural cut is the DDL rejection (9 files, +354 -5) and the legacy-name handling (11 files, +913 -82). Both would target The |
| /// The reserve must leave a usable name length; an unsigned wrap below would report a huge limit | ||
| /// instead of rejecting the name. | ||
| static_assert(NAME_MAX > reserved); | ||
| return NAME_MAX - reserved; |
There was a problem hiding this comment.
maxProjectionNameLength is derived from the compile-time NAME_MAX, but the contract of this change is “reject the names that the target data path cannot materialize later”. That still fails on mounts whose _PC_NAME_MAX is lower than NAME_MAX (we already use pathconf for table-name validation in DatabaseOnDisk::checkTableNameLengthUnlocked). On such disks CREATE will still accept a projection name that later dies with ENAMETOOLONG on the first write, so the original bug remains for those storage paths. This needs to use the selected data path / disk limit instead of the libc fallback constant.
There was a problem hiding this comment.
Not applying this, for one architectural and one empirical reason.
The check has no disk to probe. computeMaxTableNameLength can probe because a database's metadata directory is a single, known, already-existing path. Neither holds here. checkNameLength runs inside getProjectionFromAST, reached from getTablePropertiesAndNormalizeCreateQuery (InterpreterCreateQuery.cpp:756-823), which is metadata-only: grepping its body for getStoragePolicy|DiskPtr|getDisk|storage_policy returns nothing. The storage, its policy and its disks are built later, in doCreateTable -> StorageFactory::get (:1992, :2089). The ALTER path has the same shape: AlterCommand::apply takes (StorageInMemoryMetadata &, ContextPtr) and StorageInMemoryMetadata has no disk or policy member at all.
And there is no single target disk even after resolution: parts spread over every disk of the policy, the disk for a new part is picked per-INSERT by a reservation (MergeTreeDataWriter.cpp:864-899), and the disk set is mutable after DDL (storage_policy and disk are ALTER-able, MergeTreeData.cpp:5565-5572, plus MOVE PART TO DISK and TTL moves). A DDL-time probe cannot be sound over a set that changes after the check. That is also why #113072 legitimately differs rather than one of us being wrong: StorageLog holds one const DiskPtr disk fixed for the table's lifetime (StorageLog.h:144), so there the probe has a well-defined subject.
Both constructible low-budget mounts refute the premise. I built them and measured:
| mount | pathconf(_PC_NAME_MAX) |
behavior at the boundary |
|---|---|---|
msdos |
72 | silently truncates: a 256-char request landed as 8 chars, mkdir rc=0 throughout, never ENAMETOOLONG |
vfat |
1530 | enforces 255: OK to 255, errno 36 from 256 |
The mount that under-reports never raises the error this would guard against, and the one that does raise it over-reports its budget by 6x, so trusting pathconf there would raise the accepted limit and re-admit the names this change exists to reject. Neither can host a MergeTree disk anyway: part commit hardlinks (DataPartStorageOnDiskBase.cpp:454) and link() fails EPERM on both.
A disk with a genuinely lower budget is still covered, just not by the DDL gate: the four write-path sites and the load probe translate the backend's own refusal into ARGUMENT_OUT_OF_BOUND and impose no length policy, so the first write reports a named error rather than the bare Code: 1001 this issue is about.
…omments `Style check` / `catch_all` failed on 6943f31: the trailing `catch (...)` of `isBestEffortDetachError` returns false without logging, rethrowing or saving the exception, and the rule requires an explicit comment containing `Ok` on such a block. The discard is correct here - the function only classifies an exception its caller still owns and rethrows - so the resolution is the comment, using the wording ClickHouse#113044 established for the same classifier shape. Also brought the comments this PR adds back within the <=3-lines-per-block convention. Several blocks had grown across review rounds into rationale that the commit messages and the linked issue already carry (why the pre/post-move boundary exists, why only non-retryable errors may escape into a worker future, what each injected failpoint models); those now state just the local invariant a reader needs at that spot. 41 comment lines removed, no behavior change. The blocks left over the budget are the ones 6943f31 added minutes ago as its answer to a review thread, so they are left as written.
CI finish ledger - cea0b1eCI is fully finished on this head: 175 check-runs, 0 incomplete, No failures. 161 success, 14 skipped (the six Session id: cron:our-pr-ci-monitor:20260804-003000 Corrected: the heading of this comment first named |
Internal second-model review (round 17, final) - 4 findings adjudicated, 0 blockersIndependent cold review plus a second-model gate on Fixed this round (was a blocker): the CREATE boundary re-validated a full-definition
💡 Also verified independently: the reserve arithmetic (255 - 41 = 214) against every name the Session id: cron:clickhouse-review-slot-8:20260808-174200 |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-7:20260808-165400 |
| /// full-definition ATTACH on a `Replicated` secondary `getLoadingStrictnessLevel` tests | ||
| /// `attach` first and so returns ATTACH, not SECONDARY_CREATE. Test the transaction instead, | ||
| /// as `AlterCommand::apply` does for ADD_PROJECTION. | ||
| bool projection_definition_is_fresh = is_fresh_definition; |
There was a problem hiding this comment.
This non-initial guard is only proven manually right now. The new stateless coverage exercises the initiator-side CREATE / full-definition ATTACH, but nothing in-tree replays the same definition onto a Replicated database follower, or through the sibling AlterCommand::apply path for ADD PROJECTION. If the ZooKeeperMetadataTransaction / SharedDatabaseCatalog detection regresses, CI will stay green while a follower starts rejecting a definition that the initiator already accepted.
| projection_part_storage->createDirectories(); | ||
| try | ||
| { | ||
| projection_part_storage->createDirectories(); |
There was a problem hiding this comment.
These ENAMETOOLONG translations only fire on a legacy table that already carries an over-limit projection name, and the new 04682_projection_name_length* tests can no longer construct that state. That means removing this catch, or the sibling one in MergeTask, still leaves the suite green while the user-visible ARGUMENT_OUT_OF_BOUND fix silently disappears. Please keep a small integration fixture that seeds a legacy over-limit projection off-line and then exercises INSERT plus a merge/materialization path.
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction. Object file sizes8 object files changed (+47.10 KiB total), 1 added.
737 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units13 translation units recompiled, 58 s compile time in total, 10 of them have a recent master baseline. |
A projection name is used raw as a path component, and longer names are derived from it (`<name>.proj`, `<name>_<block_num>.tmp_proj`, `delete_tmp_<name>_<n>.tmp_proj`). Nothing bounded it, so a name with no room left for those was accepted at DDL time and then every INSERT, mutation and MATERIALIZE PROJECTION failed with an untyped Code 1001 that named neither the projection nor a limit, leaving the table writable only after guessing what was wrong. Fresh definitions are now rejected at 214 bytes, which is NAME_MAX minus the longest suffix the code derives, and the filesystem's own refusal is translated at the two sites that create a projection directory so an existing table reports the projection and the limit instead. A definition read back from stored metadata is exempt, so tables created before this check keep loading, and so is a definition replayed onto a Replicated or Shared Catalog secondary, which would otherwise diverge from an initiator that had already accepted it. The integration test seeds the legacy shape by rewriting the stored definition through the database disk; part directories are never touched. Closes: ClickHouse#112714
b7b9c75 to
7011c23
Compare
|
Both findings were right, and my earlier reason for declining them was wrong. Fixed in 7011c23. I had said such a fixture would need part fabrication that the "no data part intervention in functional
Two asks I am not acting on, with the measurements rather than an argument: Follower replay. I wrote this test and then deleted it, because it passed with the non-initial guard Projection sub-merge translation. Also probed rather than assumed. A planted 244-character name is |
CI finish ledger - 7011c23CI is fully finished on this head: 175 check-runs, 0 queued/in progress,
None of the three is caused by this PR. The Session id: cron:our-pr-ci-monitor:20260809-023000 |
|
I think the solution is much simpler than this. Thanks for your try. |
|
Both closes taken as final, and I am not reopening either PR. The defect is still live on master at Your review on #112741 asked for a check against One measurement first, because it changes the constant.
So a 250 bound still accepts names of 245 to 250 at DDL that then fail at materialize time. Bounding on the widest derived form instead of Same question for the |
|
Correcting my own "Known limitation, disclosed" note above, which is now wrong in both directions. I said a part in that degraded state still fails The cause is I also could not reach the state from any supported operation. |
Closes: #112714
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Rejects a projection name that is too long to fit a filesystem path component, instead of accepting it at
CREATE TABLEand then failing everyINSERTwith an emptystd::exception. A table whose projection name is already over the limit keeps loading and keeps its rows readable, and now reports a message naming the projection and the limit.Description
A projection materializes into a directory inside the part directory, and the code derives longer names from it by plain concatenation:
<name>.proj,<name>_<block_num>.tmp_proj,delete_tmp_<name>_<n>.tmp_proj. Nothing bounded the name, so an over-long one was accepted atCREATE TABLEand the table became permanently unwritable. TheENAMETOOLONGarrives as astd::filesystem::filesystem_error, not aDB::Exception, so its text was lost and users saw onlyCode: 1001 (STD_EXCEPTION).The boundary is 244, not the 250 that
NAME_MAX - strlen(".proj")suggests: at 245 a plainINSERTstill succeeds and every mutation andMATERIALIZE PROJECTIONthen fails forever, on the<name>_1.tmp_projcomponent. The limit reserves for the longest derived form, giving 214, measured on the raw name since it never goes throughescapeForFileName.The check runs at the two MergeTree DDL boundaries (
registerStorageMergeTreeandALTER ... ADD PROJECTION) for CREATE-like input only, so stored metadata is exempt: an existing over-long table still loads with its rows intact, andReplicated/ Shared Catalog secondaries replay without diverging.ADD PROJECTION IF NOT EXISTSon such a table stays a no-op, and a duplicate still reportsILLEGAL_PROJECTION, not the length error.At runtime no length policy is added: the two remaining sites, both guarding a real directory creation, only translate the backend's own refusal into
ARGUMENT_OUT_OF_BOUND, and only when the projection component itself exceedsNAME_MAX, so a genuinePATH_MAXfailure under a deep data root still reports itself.Scope boundary: the DDL check is pure string arithmetic, so it covers every disk. The improved runtime message covers
DiskLocal;local_plain-family disks keep master's raw error.This PR was much larger before: #111816 made
DiskLocal's existence probes returnfalseforENAMETOOLONGinstead of throwing, removing the need for the read/load/remove/backup tolerance half and the integration suite pinning it.Defect B from the same issue, long
Logcolumn names, is #113072.