Skip to content

Cherry pick #120025 to 26.6: Fix unparseable metadata for a NATS table defined only by a named collection - #120236

Merged
robot-clickhouse-ci-1 merged 4 commits into
backport/26.6/120025from
cherrypick/26.6/120025
Sep 16, 2026
Merged

robot-clickhouse-ci-1 merged 4 commits into
backport/26.6/120025from
cherrypick/26.6/120025

Conversation

@robot-ch-test-poll

Copy link
Copy Markdown
Contributor

Original pull-request #120025

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Before you resolve anything

Conflicts are often caused by a prerequisite change that has not been backported yet, rather than by a real divergence. The bot re-tries this cherry-pick against the release branch on every run, so if that is the case here it will merge itself as soon as the prerequisite lands, and you will see a comment saying so. Manual resolution is only needed while the conflict persists.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

groeneai and others added 3 commits September 14, 2026 14:01
…lection

registerStorageNATS called NATSSettings::loadFromQuery unconditionally. With
ENGINE = NATS(collection) and no SETTINGS clause, args.storage_def->settings is
null, and loadFromQuery's else branch attaches an empty ASTSetQuery to the
ASTStorage. ASTStorage::formatImpl emits the keyword for any non-null settings
member, so the definition serialized into the table's metadata file ends in a
bare "SETTINGS ". Re-parsing that file fails with SYNTAX_ERROR, which makes the
table unloadable and aborts the whole database load, so unrelated healthy tables
in the same database become inaccessible too.

Guard the call, exactly as the sibling registrars already do: StorageRabbitMQ.cpp
has the same preceding "else if (!args.storage_def->settings) throw" together
with the guard, and its RabbitMQSettings::loadFromQuery carries the identical
empty-ASTSetQuery branch; StorageKafkaUtils.cpp and StorageDistributed.cpp guard
the same way. Nothing after the call needs settings to be non-null: the later
uses are already inside "if (args.storage_def->settings)". The empty-ASTSetQuery
branch of NATSSettings::loadFromQuery becomes unreachable and is left in place so
that NATS and RabbitMQ stay the same shape.

The shape became reachable when named collections were added in b3ca976;
the unguarded call dates from the original engine in 944a729.

05029_nats_tls_certificate_path_restriction already coded around this defect: its
full-definition ATTACH carried SETTINGS nats_num_consumers = 1 purely so that the
stored definition would parse on the DETACH/ATTACH replay that follows. Removing
that crutch turns the existing block into the regression oracle. The value equalled
the setting's own default and is read nowhere in the certificate provenance logic,
so the block's assertions keep their meaning. Without this fix the short ATTACH
fails with SYNTAX_ERROR (62) where the test expects BAD_ARGUMENTS (36).

Closes #119120
04891_nats_credential_file_path_restriction carried the same
SETTINGS nats_num_consumers = 1 crutch on the full-definition ATTACH whose
metadata the block replays, and a comment stating that a collection-only
definition is stored with an empty SETTINGS clause. The guard added in this
branch makes that comment false, so remove the crutch there too: the block then
covers the fixed shape on the credential-file path as well. The value equalled
the setting's own default and is read nowhere in the credential provenance
logic, so every assertion keeps its meaning. Without the guard the short ATTACH
of that block fails with SYNTAX_ERROR (62) where the test expects
BAD_ARGUMENTS (36).

Both replay blocks now state what the stored definition must carry instead of
describing what it happens to carry, so the property the block exists to check
does not read as an incidental remark.
…adata

Fix unparseable metadata for a NATS table defined only by a named collection
@robot-ch-test-poll robot-ch-test-poll added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Sep 15, 2026
@groeneai

Copy link
Copy Markdown
Collaborator

Conflict resolution for the 26.6 cherry-pick

What conflicted. src/Storages/NATS/StorageNATS.cpp auto-merges clean, so there is no source
conflict. The only conflicts are modify/delete on two regression tests that do not exist on 26.6:
04891_nats_credential_file_path_restriction.sql and
05029_nats_tls_certificate_path_restriction.sql. #120025 only deleted a workaround line inside them,
so on a branch without those files there is nothing to port.

Resolution, by content. Keep the auto-merged source guard, drop the two absent files. Nothing is
hand-authored: every byte comes from git's 3-way merge plus git rm of a file 26.6 does not have.

Scope. Against backport/26.6/120025 the merge changes exactly one path and nothing else (no
contrib/ path, no .gitmodules):

-        nats_settings->loadFromQuery(*args.storage_def);
+        if (args.storage_def->settings)
+            nats_settings->loadFromQuery(*args.storage_def);

Verification. I built the merge with the compiler this branch pins (clang-21, read from
ci/defs/defs.py at the merged tree) and compared it against a binary differing only in that hunk, on
26.6.8.1:

  • without the guard, a collection-only definition (ENGINE = NATS(coll), no SETTINGS clause) stores a
    dangling SETTINGS keyword, and reloading it in a fresh process fails with
    Code: 62 ... Cannot parse definition from metadata file ... (SYNTAX_ERROR);
  • with the guard, no SETTINGS clause is stored and the reload succeeds;
  • a control table carrying a real SETTINGS clause stores byte-identical metadata on both binaries.

Local style checks flag nothing in this path.

To take it. The merge's first parent is this PR's head, so this is a fast-forward and nothing needs
resolving by hand:

git fetch https://github.com/groeneai/ClickHouse.git groeneai/resolve-26.6-cherrypick-120025
git push origin FETCH_HEAD:cherrypick/26.6/120025

Once this PR reports mergeable, cherry_pick.py merges it and opens the 26.6 backport pull request
itself.

… cherrypick/26.6/120025

# Conflicts:
#	tests/queries/0_stateless/04891_nats_credential_file_path_restriction.sql
#	tests/queries/0_stateless/05029_nats_tls_certificate_path_restriction.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants