Repository navigation
Conversation
…ngs are applied S3 request settings are built from layers: the global <s3> section, a matching <s3> endpoint section, a disk's own section and the user/profile/query s3_* settings. S3RequestSettings validated each layer when it was built, before the later layers were applied, so a layer that is invalid on its own was rejected even when the effective settings were valid. For example an endpoint section with min_upload_part_size = 5 MiB plus a query with s3_max_upload_part_size = 8 MiB failed with INVALID_SETTING_VALUE against the default 16 MiB minimum, for s3() queries, S3 tables, named collections, BACKUP and RESTORE. An endpoint section that is invalid alone also threw in the middle of S3SettingsByEndpoint::loadFromConfig, which leaves the lazily built endpoint map half filled, so later queries lost their endpoint settings. Intermediate layers are now built without validation. Every existing final check stays as it was: the merged checks in fromAST, readObject and writeObject per query, updateFromSettings in BackupReaderS3 and BackupWriterS3, and the disk-section check at disk reload. S3 disks merge the matching endpoint section at config reload and never validated the merged result, and background merges use those settings with no per-query check. A disk section and an endpoint section that are each valid but contradict each other once merged were accepted by SYSTEM RELOAD CONFIG; afterwards every write failed, and a merge could abort a debug server in ExpBufferAllocationPolicy (std::clamp with min > max). The config reload of a server disk now validates the merged settings before installing them (ApplyNewSettingsOptions:: validate_merged_settings) and refuses the reload instead. Context::updateStorageConfiguration now rebuilds the S3 endpoint map before reloading the disks, so that check sees the endpoint section of the same config rather than the one of the previous reload. Data-lake tables on a disk keep applying query settings on top, so they are not validated at that point. Follow-up to ClickHouse#129578, requested there by the assignee. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Shorten the two-line comments on validate_merged_settings and on the table-path validate flag in S3ObjectStorage::applyNewSettings to one line each. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Internal second-model review (2 rounds)
|
Pre-PR validation gate (click to expand)
Session id: cron:clickhouse-impl-slot-4:20261106-024900 |
|
cc @alesapin @CheSema, could you review this and add the |
|
Workflow [PR], commit [a1bc1f9] Summary: ❌
AI ReviewSummaryThe PR defers S3 request-settings validation until configuration layers are merged and preserves credential updates when a disk's request settings are rejected. Credential removal is still incomplete for existing data-lake tables using private copies of the disk's object storage. Findings❌ Blockers
Tests
Final VerdictStatus: ❌ Block. Apply credential removal to existing disk-derived clients and add the focused regression above. |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units389 translation units recompiled, 3601 s compile time in total, 389 of them have a recent master baseline. |
The query settings of the test (s3_max_upload_part_size = 8 MiB) are valid only at the test endpoint, whose min_upload_part_size is 5 MiB. Every S3 object storage applies and validates the query's S3 settings on each read and write (S3ObjectStorage::readObject/writeObject), so a query that also reads another S3 storage fails there: with the remote database disk (`db disk` CI lanes) the BACKUP reads the table metadata from it, the read fails with "max_upload_part_size (8.00 MiB) can't be less than setting min_upload_part_size (16.00 MiB)", and the swallowed error surfaces as "Table ... was not found" (UNKNOWN_TABLE). With MergeTree on S3 (`s3 storage` lanes) the s3() INSERT and the RESTORE fail the same way. This is master behaviour, unrelated to the fix. A Memory table in a Memory database keeps the metadata and the data off any disk. Also check that invalid effective settings are still rejected by RESTORE (BackupReaderS3) and by a named-collection INSERT and SELECT (per-operation checks in S3ObjectStorage). Each new case turns red when its check is disabled; the INSERT one then aborts a debug server in ExpBufferAllocationPolicy. Measured with a local MinIO: the test passes on the PR binary with the plain, remote database disk and S3 MergeTree configurations (50/50 with both), and fails on master 770b0c15 with the per-layer rejection. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`Context::getStorageS3Settings` built the server-wide endpoint map lazily with the settings of its first caller, so the `s3_*` settings of the first S3 query after start were copied into every endpoint entry and applied to later queries of all users. A config reload already rebuilds the map from the global context's settings. Every per-request path re-applies the query's own `s3_*` settings on top (the end of `fromAST`, `BackupReaderS3`/ `BackupWriterS3`, `S3ObjectStorage::readObject`/`writeObject`), so nothing needs them in the shared map. The previous commits made this easier to reach: a first query that is only valid with its endpoint's override (endpoint A `min_upload_part_size` 5 MiB plus `s3_max_upload_part_size = 8388608`) used to be rejected before the map was built; it now succeeds and left an 8 MiB maximum for endpoint B, so default queries to B failed with INVALID_SETTING_VALUE until the next reload. The same leak was reachable on master with a first query valid everywhere (`<s3>` min 5 MiB / max 20 MiB, endpoint A max 1 GiB, first query `s3_min_upload_part_size = 25165824`: later default queries to B failed). `S3ObjectStorage::writeObject` validates the stored request settings when no query settings are applied on top. A table merges its endpoint section into them without validation, and an unpartitioned S3 sink opens its write buffer before the insert gets a query thread group, so a Buffer flush into such a table after a reload added an endpoint section with `upload_part_size_multiply_parts_count_threshold = 0` reached `ExpBufferAllocationPolicy` unvalidated (debug abort on `multiply_threshold > 0`, modulo by zero otherwise). Master refuses that reload because it validated the endpoint entry while building the map. The server's `s3_validate_request_settings` applies there, as for the reload. Adds a fresh-server case to test_s3_request_settings_merged_layers, plus two cases for the deferred checks: a Buffer flush into an unpartitioned S3 table whose endpoint section sets a value invalid in any combination is rejected (without the new check the debug server aborts), and the data-lake case now uses an endpoint section invalid alone (max 8 MiB) and asserts that without the query override the merged disk + endpoint settings are rejected with their effective values (fails on master and when either layer is skipped). Co-Authored-By: Claude Opus 5.5 <[email protected]>
CI finish ledger - 155c67dEvery failure below has an owner: a fixing PR (mine or external), or a full-effort fix task
The Session id: cron:our-pr-ci-monitor:20261106-130003 |
|
🕵️ @groeneai Validating once after all layers looks right for One concern with the new disk-reload check: a failed check now aborts much more than that disk's reload.
Before this PR, such a reload succeeded and only that disk's writes failed later. A failure of the disk's own section could already abort the reload the same way, but that section is also checked at start, so a server could not run into it with an unchanged config. Could a failed merged check keep the disk's current settings and log an error instead of throwing out of the reload? The rest of the reload would then still apply, and the integration test could check that the disk keeps its settings while another setting in the same reload is applied. |
…n reload At config reload an S3 disk merges the endpoint section into its settings and validates the result. A failed check threw out of `DiskSelector::updateFromConfig` and `Context::updateStorageConfiguration`, so the rest of the reload was skipped: later disks, new disks and storage policies, interserver credentials, cache sizes, named collections. A server started with such a pair (at start a disk is built from its own section only) refused every later reload, including unrelated changes. Now the disk keeps its current settings, the error is logged, and the rest of the reload is applied. The check of the disk's own section is unchanged. Requested in ClickHouse#129670 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
The per-query update of an S3 table merges the query's `s3_*` settings into the settings stored in the table, and a later query with default settings cannot revert them. Since the merged settings are validated only in `readObject` and `writeObject`, a rejected override stayed stored: after `INSERT ... SETTINGS s3_max_upload_part_size = 4194304` failed against an endpoint with `min_upload_part_size = 5242880`, every later default INSERT into the table failed with the same error. On master the per-layer check rejected the query before the settings were stored. The table path now runs the same check, with the query settings on top, before storing the settings. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Done in 65f23d1 (commit). When the merged check fails, the disk logs The integration case now starts the server with disk Also fixed in 4cabbf4 (commit), a regression from this PR found in re-review: the table path stores the query's |
The server's ConfigReloader polls the config files every 2 seconds, so it could reload a replaced file on its own before the test's SYSTEM RELOAD CONFIG. Both reloads log "were not applied", and the absolute counts (1, then 2) failed in the flaky check with 3. A background reload also hid a revert of the endpoint-map-before-disks ordering, since the explicit reload then saw the already rebuilt endpoint settings. Pin config_reload_interval_ms to an hour in the test's config, as other reload tests do, and match the log line of each explicit reload by its query_id with wait_for_log_line, which also waits for the asynchronous logger. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Algunenano
left a comment
There was a problem hiding this comment.
🤖 Please add a focused regression test for this failure path first: start an S3 disk with credential A, reload credential B (or remove credentials) together with contradictory request settings, and verify that credential A can no longer be used.
In S3ObjectStorage::applyNewSettings, both authentication and request settings are merged into modified_settings, but a request-settings validation failure returns before the client is rebuilt or the new settings are installed. As a result, an invalid upload setting can leave the old authenticated client active indefinitely, even when the same configuration reload was intended to rotate or revoke its credentials.
This path must always fail closed. On validation failure, the disk must not continue serving requests through the old authenticated client. It can preserve the previous validated non-authentication request settings only if the new authentication state is safely applied and the client is rebuilt; otherwise, disable the disk/client until a valid configuration is loaded.
…request-settings-master
… invalid A config reload that left the request settings of an S3 disk invalid returned from `S3ObjectStorage::applyNewSettings` before the client was rebuilt, so a reload that also rotated or revoked the disk's credentials kept the old authenticated client. An invalid disk section alone threw out of the reload with the same result. Now both checks of a disk reload (the disk section alone and the settings merged with the endpoint section) only keep the current request settings and log an error: the new authentication settings are still applied and the client is rebuilt. Also test the check of `writeObject` for writes without a query context directly: the table check in `applyNewSettings` now rejects the Buffer flush of `test_background_write_checks_endpoint_settings` before the write. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks, fixed in 8114eaa.
I also merged master to resolve the conflict in |
…request-settings-master # Conflicts: # tests/config/config.d/s3_settings_override.xml
`S3ObjectStorage::applyNewSettings` merged the authentication settings of the endpoint section and of the disk section into the previous ones with `S3AuthSettings::updateIfChanged`, which only copies the fields a layer sets. So a reload that removed `access_key_id`/`secret_access_key` (or a header) from a disk kept signing with the removed credentials. Since the previous commit, a reload with invalid request settings also succeeds and rebuilds the client, so removing the credentials together with an invalid request setting kept them as well (clickhouse-gh review on ClickHouse#129670). The config reload of a server disk now builds the authentication settings from the current config only (endpoint section, then disk section). The option is renamed to `server_disk_reload`, since it now controls both the authentication rebuild and the merged request-settings check. Measured on a private bucket with `use_environment_credentials = false`: before, the INSERT after a reload removing the keys still succeeded (also on master for a reload with valid request settings); now it fails with `Access Denied`, and reloading the keys again restores writes. The integration test covers the plain removal and the removal together with both kinds of invalid request settings.
|
|
||
| auto modified_settings = std::make_unique<S3Settings>(*s3_settings.get()); | ||
| /// Merging below only adds the fields a layer sets, so credentials removed from the config would be kept. | ||
| if (options.server_disk_reload) |
There was a problem hiding this comment.
[Blocker] Apply credential removal to existing data-lake copies of the disk
DataLakeConfiguration::fromDisk retains a private clone of the disk's object storage. Its refresh in StorageObjectStorageConfiguration::update calls applyNewSettings with server_disk_reload = false, so this reset never runs for that clone. Both authentication merges still use updateIfChanged, which preserves omitted keys and empty header lists. Reloading the original disk does not replace the clone's client.
For example, create an Iceberg table with SETTINGS disk = 'merged_s3', using key pair A and use_environment_credentials = false. Remove both key fields and run SYSTEM RELOAD CONFIG with otherwise valid request settings. The original disk loses A, but an INSERT into the existing Iceberg table still uses A: its refresh merges the now-absent fields into its old settings and retains the authenticated client. Credential revocation therefore remains bypassable through a supported consumer of this disk.
Reconstruct configuration-derived authentication for these copies too, and ensure removals trigger client replacement (hasUpdates also uses updateIfChanged). Keep this independent of the request-validation mode, since data-lake copies still need query overrides. Extend the removal regression with an existing disk-backed Iceberg table and verify that a new write is denied after reload.
There was a problem hiding this comment.
This PR does not change that path: the copy a disk-backed data-lake table keeps is refreshed by StorageObjectStorageConfiguration::update without server_disk_reload and merges into its old credentials exactly as on master, so it keeps removed keys there as well. Making that refresh rebuild its credentials from the config is a separate change to the data-lake path, not part of validating the merged request settings, so I am leaving it out of this PR.
… the first query `Context::getStorageS3Settings` builds the `S3SettingsByEndpoint` map shared by all queries on first use, and passed the settings of the calling query. `S3RequestSettings(config, settings, prefix)` copies every changed `s3_*` setting into the object as changed, `loadFromConfig` puts it into every endpoint entry, and consumers merge the entry with `updateIfChanged`. So the first S3 query after a start set the endpoint values for every later query and user: a default backup to a configured endpoint ran with that query's `s3_max_inflight_parts_for_one_file` / `s3_min_upload_part_size`, and a valid `s3_min_upload_part_size` above that query's `s3_max_upload_part_size` was rejected with INVALID_SETTING_VALUE, until `SYSTEM RELOAD CONFIG`, which rebuilds the map from the server settings. The first build now uses the global context's settings, the same input as the reload. Every consumer still applies the current query's own changed settings on its copy. `getGlobalContext()` and `getSettingsRef()` take no lock, so nothing new is locked under `shared->mutex`; the global settings are written only at startup, before any query. The line is the same as in ClickHouse#129670. The new integration test restarts the server before each case so that the map is built by its first S3 query, which no stateless test can do. Closes ClickHouse#131964 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #129578
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fixed rejection of valid S3 request settings:
s3queries, S3 tables,BACKUPandRESTOREvalidated the global<s3>section, an endpoint section and the query settings one at a time, so for examples3_max_upload_part_sizebelow the defaultmin_upload_part_sizefailed withINVALID_SETTING_VALUEeven when an endpoint section loweredmin_upload_part_size. The settings are now validated once, after all overrides. On config reload an S3 disk now validates its settings after merging the endpoint section: if they are invalid, the disk keeps its current request settings and logs an error, instead of later writes and merges failing, and its new credentials are still applied, while removed ones are dropped. The endpoint settings shared by all queries no longer take thes3_*settings of the first S3 query after server start.Description
Follow-up to #129578, requested there by @ PedroTadim.
On 26.10.2.103, an
s3query,BACKUPorRESTOREwhose effective request settings are valid is rejected withINVALID_SETTING_VALUEwhen one layer (the global<s3>section with the query settings, or an endpoint section) is invalid on its own. Example: an endpoint section withmin_upload_part_size = 5242880plusSETTINGS s3_max_upload_part_size = 8388608fails against the default 16 MiB minimum.Each intermediate
S3RequestSettingslayer was validated before the later layers were applied. These layers are now built without validation; the final checks are unchanged. An S3 table checks query overrides before storing them; a write without query settings checks the stored ones. At config reload S3 disks merged the endpoint section without validating the result, so a contradictory disk + endpoint pair was accepted and later writes failed. Now such a disk (or one with an invalid section of its own, which aborted the reload) keeps its request settings and logs an error, while its new credentials and the rest of the reload are applied; the endpoint map is rebuilt before the disks. A disk reload builds the credentials from the current config only, so removed keys or headers are no longer kept.The endpoint map shared by all queries was built with the
s3_*settings of the first S3 query after start; it is now built from the server settings.Tests: stateless
05546_s3_request_settings_validated_after_endpoint_override, integrationtest_s3_request_settings_merged_layersand unitS3ObjectStorage.WriteWithoutQueryContextValidatesStoredSettings. Each fails on master and passes with the fix.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/129670]