Skip to content

Cherry pick #129383 to 26.3: Require the same source and WRITE for queue after_processing - #133532

Merged
robot-clickhouse merged 31 commits into
backport/26.3/129383from
cherrypick/26.3/129383
Nov 23, 2026
Merged

robot-clickhouse merged 31 commits into
backport/26.3/129383from
cherrypick/26.3/129383

Conversation

@robot-ch-test-poll

Copy link
Copy Markdown
Contributor

Original pull-request #129383

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

NIKTONIKTO717 and others added 30 commits November 4, 2026 21:37
# Conflicts:
#	tests/queries/0_stateless/05441_s3queue_move_destination_access.sh
# Conflicts:
#	src/Storages/StorageFactory.h
Tables with the same `keeper_path` share the settings stored in Keeper,
such as `after_processing`, and all such tables on one server share one
copy of them in memory. So these settings can differ from the definition
of a table.

`ALTER` reloaded these settings from Keeper into that shared copy without
the lock of `alterSettings`, so an `ALTER` of another setting, which needs
no `WRITE` grant, could put an older `delete` back into use:
#129383 (comment)

Remove the reload. Instead, an `ALTER` changes exactly the shared settings
that the query names:
- in `StorageObjectStorageQueue::alter`, a named setting is applied even
  if the definition already has the value, so an explicit `keep` always
  takes effect;
- `alterSettings` writes to Keeper what Keeper has, with only the named
  settings on top, so this server's outdated copy is not written back;
- `alterSettings` updates only the named settings in this server's copy,
  so an outdated value in Keeper is not put into use.

The settings are listed once, in `forEachChangeableSetting`. A query that
sets `after_processing` to anything but `keep` is the one checked for
`WRITE`, and no other query can change the action anywhere.

A table whose definition differs from Keeper in `after_processing` fails
to attach with `METADATA_MISMATCH` again, as on master, instead of taking
the value from Keeper. To attach it, `ALTER` an attached table with the
same `keeper_path` to the value of the definition.

Related: #129383

Co-Authored-By: Claude Fable 5.2 <[email protected]>
`alterSettings` copies this server's settings, applies the query to the
copy and saves the copy. But it skipped a value when the live settings
already had it. An `ALTER` replayed from a `Replicated` database or run
`ON CLUSTER` takes no settings lock, so the live settings can change after
the copy is made: with `delete` in the copy and `keep` set meanwhile by
another table, a request for `keep` was skipped and the old `delete` was
saved, although both queries asked for `keep`:
<LINK TO THE REVIEW COMMENT>

Compare with the copy instead, so the saved value is always the one the
query asked for.

Related: #129383

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Review: #129383 (review)

- Keeper stores a `SipHash` of the source (`Source::getHash`) instead of
  the storage type, endpoint, bucket and path. The mismatch error no
  longer shows the source of another queue. With only a hash in Keeper,
  `Source::clearIfMasked` is not needed: paths that differ in a part like
  `&sig=` have different hashes.
- `syncWithKeeper` has one flag, `strict`, instead of `is_attach` and
  `strict`. It also takes the source from Keeper for an existing table,
  so `adjustFromKeeper` is as on master.
- `ObjectStorageQueueMetadataFactory::getOrCreate` no longer copies the
  source: a table that reaches it has already been checked against Keeper.
- `StorageFactory::getExportAccess` has an overload for the settings of
  a table with a known engine: move destinations of every engine, as on
  master, and `after_processing` of that engine only. Before, the move
  destinations of other engines needed no grant, which
  `05441_s3queue_move_destination_access` caught.
- `changesSourceObjects` takes the value with `safeGet<String>`. The
  value comes from the query before it is validated, so it cannot be an
  assertion.
- The configuration records that it was initialized from a named
  collection, instead of looking at the type of the first engine argument.
- In `StorageObjectStorageQueue::alter`, a setting stored in Keeper that
  the query names is applied if it differs from Keeper or from this
  server's copy. The values come from `getSettings`, so no new list of
  settings is needed.
- `alterSettings` starts from the metadata in Keeper, so Keeper gets only
  the settings of the query, and copies only these settings to this
  server's copy. A requested `buckets` is kept when another query has
  already migrated this server's copy:
  #129383 (comment)
- `parallel_inserts` is back in `isStoredInKeeper`, as on master: no
  code path of this change reads it there.

Related: #129383

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The `arm_tidy` build failed on `modernize-use-nodiscard` in
`ObjectStorageQueueTableMetadata.h`.

Related: #129383

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`StorageObjectStorageQueue::alter` compares a setting of the query with
Keeper when `isStoredInKeeper` lists it. `parallel_inserts` is listed,
but `ObjectStorageQueueTableMetadata` neither reads nor writes it, so its
value there is always `false`. With `parallel_inserts = 1` in the table
definition, `ALTER TABLE q MODIFY SETTING parallel_inserts = 1,
polling_max_timeout_ms = 2000` then failed with `SUPPORT_IS_DISABLED`
instead of changing only `polling_max_timeout_ms`:
#129383 (comment)

Remove it from the list, as 44a7143 already did before 825cb8a
put it back.

Related: #129383

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review: #129383 (review)

- A table with user info in the URL got an empty source, so attaching it
  after an upgrade saved no hash, and every later `CREATE` on its
  `keeper_path` was told to attach a table that was already attached.
  Now `S3Queue` parses the URL again without the user info, with the same
  `s3_uri_style`, and such a table has a source. `AzureQueue` keeps the
  user info in the endpoint, which is only hashed.
- `syncWithKeeper` keeps the result of saving the source hash in `code`,
  like the result of creating the metadata. `ZBADVERSION` and `ZNONODE`
  mean that Keeper was changed after the metadata was read, so the loop
  starts again.
- The error for metadata without a source hash says to attach the main
  table of the queue.
- `test_source_hash_after_upgrade` in `test_storage_s3_queue/test_0.py`
  checks that the source hash is added to Keeper when a server is
  upgraded from 26.7.

Related: #129383

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	src/Storages/ObjectStorageQueue/registerQueueStorage.cpp
Require the same source and `WRITE` for queue `after_processing`
@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-critical-bugfix labels Nov 22, 2026
…ypick/26.3/129383

Conflicts:
- `registerQueueStorage.cpp`: keep only the `<Poco/URI.h>` include that the PR adds.
  26.3 does not have the `s3_uri_style` setting, so `getQueueSource` parses the URL
  without user info with the default style, as 26.3 parses the URL of the table.
  `StorageAzureConfiguration` in 26.3 has `getNamespace` instead of `getContainer`.
  26.3 does not have the `exclusive` mode, so the PR line that clears the path of an
  `exclusive` queue is not backported. 26.3 does not have `isReplayedTableDefinition`
  and `isSecondaryDDLReplay`, so `strict_metadata_check` uses the same conditions
  directly.
- `Azure/Configuration.h`: 26.3 does not have `getSasKey`, so the new
  `getConnectionURLWithoutQuery` reads `connection_params.endpoint.sas_auth`.
- `StorageObjectStorageConfiguration.cpp` and `StorageObjectStorageConfiguration.h`:
  add only `initialized_from_named_collection`.
- `StorageFactory.h`: add the new `getExportAccess` overload without `[[nodiscard]]`,
  like the other declarations in 26.3.
- `StorageObjectStorageQueue.cpp`: `alter` in 26.3 takes the mode from
  `getTableMetadata`, so the settings of the queue on this server come from it too.
- `InterpreterAlterQuery.cpp` and `InterpreterAlterQuery.h`: `getRequiredAccess` in
  26.3 does not take the table, so it takes the name of the engine, and
  `executeToTable` passes the engine of the table that is not a stand-in of a table
  that is not loaded yet. 26.3 does not have `run_as_submitting_user` for
  `Replicated` databases, so that part of the PR is not backported, and the comment of
  the `Replicated` case in `05441_s3queue_move_destination_access.sh` says that the
  initiator checks the grants. 26.3 does not look up the table by name again after
  the access check, and the `ALTER` runs on the table that was checked, so the second
  check of the PR is not needed.
- `05441_s3queue_move_destination_access.sh`: keep the `RESTORE TEMPORARY TABLE` case
  of 26.3 and add the `RESTORE` case of the PR.
- `05366_s3queue_metadata_mismatch_immutable_fields`: 26.3 does not have this test,
  which was added in #125286. Add it with
  the cases of the PR, without the cases of the `exclusive` mode and of `s3_uri_style`.
- `test_storage_s3_queue/test_0.py`: the old version of the upgrade test is 25.10,
  because 26.7 is newer than 26.3.

Related: #129383

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@robot-clickhouse
robot-clickhouse merged commit ff4aae5 into backport/26.3/129383 Nov 23, 2026
1 check passed
@robot-clickhouse
robot-clickhouse deleted the cherrypick/26.3/129383 branch November 23, 2026 14:51
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-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! pr-critical-bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants