Repository navigation
Conversation
An access entity carrying a Map-valued setting, for example a settings
profile with http_response_headers or additional_table_filters, was
serialized into a form ClickHouse could not read back. CREATE succeeded
with no error, but DiskAccessStorage and ReplicatedAccessStorage re-parse
the stored statement on load, so deserializeAccessEntity threw on the next
startup and took out the whole access storage load, not just that entity.
SettingsProfileElement::init casts the value to the setting's native type,
so a Map setting holds a Field of type Map. ASTSettingsProfileElement
renders it with FieldVisitorToString, whose Map overload emits square
brackets around tuples. ParserSettingsProfileElement reads values with
ParserLiteral, which is scalar-only and cannot open a bracket.
That emitted spelling is not merely unreadable by the access parser, it is
rejected everywhere: SET http_response_headers = [('a','b')] is also a
syntax error, while = {'a':'b'} works. So the write side is at fault.
Emit a Map value as a quoted string holding the setting's canonical text,
which is the spelling the parser already accepts and the one users type.
Custom settings are left alone because castValueUtil returns their value
unchanged, so writing a string would silently change the value's type to
String; verified against a build with that guard removed.
Downgrade is safe: a pre-fix binary reads the new on-disk form correctly,
while it reads the current form as zero rows, so no format versioning is
needed. Entities already stored in the broken form are not repaired, since
they were never parseable.
Closes ClickHouse#114591
Co-Authored-By: Claude Fable 5 <[email protected]>
The round trip oracle compared two statements produced by the same
serializer, so it could only detect disagreement with itself. A mutation
that renders every Map as the string {} keeps both statements identical
and passed all fourteen arms. Four arms now read the re-parsed entity's
value back out of system.settings_profile_elements, which pins the value
that actually survives, including key order and escaping.
Every arm also went through SHOW CREATE, which selects toASTWithNames.
The on-disk <uuid>.sql file and the BACKUP form are written by toAST
instead, and that is the route whose failure takes out the whole access
storage load. Reverting only the toAST call site left all seventeen
SHOW CREATE lines green. The new arm15 writes the entity in one
clickhouse-local process and reads it back in a second one against the
same path, so deserializeAccessEntity really runs, and it prints min and
max as well so the MIN/MAX handling is covered on that route too.
Eleven of the fifteen arms now fail on the parent commit; the remaining
four are controls that pass on both.
Internal second-model reviewI run every change through an independent cold review plus a second model before opening the PR.
Also checked and left alone: |
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-6:20260813-095400 |
|
Workflow [PR], commit [aa04fca] Summary: ✅
AI ReviewSummaryThis PR fixes access-entity serialization for builtin Missing context / blind spots
Final Verdict✅ No review findings on the current diff. LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 16/16 (100.00%) · Uncovered code |
|
cc @vitlibar, could you review this? A profile element holding a Map setting stored its value as |
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. Compile time of recompiled translation units7 translation units recompiled, 9 s compile time in total, 7 of them have a recent master baseline. |
|
@groeneai please merge master into this PR Also the new test is too slow, it hits a limit in the sync PR Fix it |
The test spent almost all of its wall clock in process startup: 89 clickhouse-client invocations accounted for 5.59s of a 6.31s run, while the statements themselves were too cheap to measure. It exceeded the 180s limit in the private sync repository. Each arm now uses two client invocations instead of seven. Statements that produce no output share the invocation with the single SHOW CREATE whose one line is the result, and the reparse half adds --ignore-error so a server that cannot read back its own output still reaches the SHOW CREATE. Cleanup of every entity is one final statement. The assertions are unchanged and the reference file is byte identical. Verified against the same binaries as before: 11 of 15 arms still fail on pre-fix master, and each of the three mutants is still caught by exactly the arms it was caught by previously. 39 client invocations, 11.91s -> 4.54s under clickhouse-test.
…ss-entity-map-setting-serialization
The scalar control arm only compared the serializer with itself, so widening the type check from Map to every builtin setting kept the test green while SHOW CREATE started emitting max_memory_usage = '5000000'. Measured: a binary with that check removed passes every arm. The reparsed value does not catch it either, since the system table column is a String in both cases, so the new arm pins the emitted text. Also corrects the helper comment: those arms take the display route through SHOW CREATE, and arm15 is the one that reaches serializeAccessEntity.
|
Both done in Merged master in (not rebased, since you asked for a merge). On the test: almost all of its wall clock was process startup, not query work. Traced with The assertions are unchanged and the That re-check also turned up a real gap, so there is one new arm: the scalar control only |
CI finish ledger - aa04fcaFull CI run finished with real coverage: 177 leaves, 159 OK, 18 skipped with stated reasons
CIDB reports 0 Session id: cron:our-pr-ci-monitor:20260814-073000 |
Backport #114620 to 26.7: Fix serialization of Map-valued settings in access entities
Backport #114620 to 26.6: Fix serialization of Map-valued settings in access entities
Backport #114620 to 26.5: Fix serialization of Map-valued settings in access entities
Backport #114620 to 26.3: Fix serialization of Map-valued settings in access entities
…ettings in access entities
…ettings in access entities
…ettings in access entities
OTHER: access entity with a Map-valued setting -> entity unloadable after restart. Effect in the production build a394e92: its upstream test(s) 04902_access_entity_map_setting_round_trip fail on it and pass on official 26.8.8.8, run on isolated servers (evidence/fix_ci_20260925/upstream_repro/server_triage_PROD263_vs_UP2688.tsv). Upstream patch unchanged, with its test(s): 04902_access_entity_map_setting_round_trip. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixes a bug where an access entity carrying a
Map-valued setting, such as a settings profile withhttp_response_headersoradditional_table_filters, is stored in a form that ClickHouse cannot read back, leaving the entity permanently unloadable after a restart.Description
Closes: #114591
CREATE SETTINGS PROFILE p SETTINGS http_response_headers = '{...}'succeeds, but the entity is stored ashttp_response_headers = [('k', 'v')], which nothing can parse back. No error appears atCREATEtime, so the entity is permanently unloadable after a restart:The list rebuild drops it silently, reading it back throws, so
SELECTfromsystem.settings_profile_elementsfails while it is present, as doesRESTOREof a backup holding it.Root cause: the value is cast to the setting's native type, so a Map setting holds a
MapField, whichFieldVisitorToStringrenders as an array of tuples; butParserSettingsProfileElementreads values with a scalar-onlyParserLiteraland cannot open a[. That spelling is rejected everywhere,SET http_response_headers = [('a','b')]included, so the write side is wrong.Fix: when a profile element's value, MIN or MAX is a
Mapand the setting is builtin, emit the setting's canonical text as a quoted string. Write side only, no grammar change. Custom settings are excluded becausecastValueUtilreturns their value unchanged, so a string would come back aStringrather than aMap. CoversCREATE USER/ROLE,ALTER ... SETTINGSand MIN/MAX, and transitively BACKUP/RESTORE and both storages.SHOW CREATEnow prints a quoted string rather than[('k', 'v')], intended since the new form is copy-pasteable. Entities already stored in the broken form are not repaired, as they were never parseable; recreate them. Downgrade is safe: a pre-fix binary reads the new form correctly, so no versioning is needed.New test
04902_access_entity_map_setting_round_trip: 11 of its 16 arms fail on pristine master and pass here, covering empty, multi-key and hostile maps plus a two-process on-disk reload.Version info
26.7.5.6,26.6.4.5,26.5.8.7,26.3.20.10