Repository navigation
Use the backup S3 retry settings for the destination of a restore fallback - #127638
Conversation
A ranged copy needs `UploadPartCopy`, so `CopyFileHelper::performCopy` declines the native path when multipart copy is unavailable or the source is not above the size S3 requires of a ranged copy source, and reads and reuploads the range instead. It did so silently, while the other three ways into `fallback_method` each say something - at `LOG_INFO`, in an exception, or at `LOG_TRACE`. This one is the most common of the four, because every ranged copy of an object of at most `MIN_SOURCE_SIZE_FOR_RANGE_COPY` takes it, so the path that moves the most objects was the one that could not be measured. Co-Authored-By: Claude Opus 5 <[email protected]>
`copyS3File` issues every request of a native copy with the client it is given as the source, and uses the destination client only in `fallback_method`, which reads the source and reuploads it. On the backup side both are already covered: the source is the disk client cloned with the backup retry settings, and the destination is the backup client. On the restore side only the source is - it is the backup client - while the destination was the client of the disk as the disk configures it, so the upload of a fallback retried on `s3_retry_attempts` instead of `backup_restore_s3_retry_attempts`, and the same object written by a native copy and by a fallback got two different retry budgets. The destination is now cloned through the same `S3BackupDiskClientFactory` the backup side uses, which keeps the configuration of the disk, including its encryption settings, and overrides only the retry strategy and `backup_slow_all_threads_after_retryable_s3_error`. A restore taking the fallback is also traced now, as the backup side already traces it. The fallback of `RestorerFromBackup` that writes through `IDisk::writeFile` is not covered: it is the write path of the disk itself, with no client to override. Co-Authored-By: Claude Opus 5 <[email protected]>
…own settings `test_backup_restore_s3` already runs the `broken_s3` mock on port 8084 and drives it through the `init_broken_s3` and `broken_s3` fixtures, so the tests go there. All the module was missing is a disk whose endpoint goes through that mock: the existing tests use it as a backup destination, never as the storage a table lives on. So `disk_s3.xml` gains `disk_s3_broken` and `policy_s3_broken`, with `s3_retry_attempts` set to 0. With the mock answering `SlowDown` to the uploads of the destination, and the disk allowing no retries of its own, the restore gets its data in only if its upload is retried with the `backup_restore_s3_retry_attempts` of the restore instead. The mirror case sets those retries to none and asserts that a single injected answer fails the restore, so the first test cannot pass on a client that merely retries a lot. `allow_s3_native_copy=0` is what reaches the path at all: it is the one way into the fallback of `copyS3File` that needs no error. The metadata of an `s3` disk is local and merges are stopped, so the data blobs of the restore are the only uploads into the destination and nothing else can consume the injected answers. Co-Authored-By: Claude Opus 5 <[email protected]>
|
Workflow [PR], commit [8ce468b] Summary: ✅
AI ReviewSummaryThe change applies backup retry settings to buffered restore uploads by cloning the destination disk client and rebuilding its SDK retry strategy. The five prior findings are addressed in the current code. One new test-isolation issue remains: the added tests leave shared tables behind and break existing tests when execution order changes. Missing context / blind spots
Findings
Final VerdictStatus: |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units11 translation units recompiled, 38 s compile time in total, 11 of them have a recent master baseline. |
…ans to `cloneWithConfigurationOverride` passed the configuration of the client being cloned straight on, keeping its `retryStrategy`, the object the SDK retries with: `ClientFactory::create` is the only place that builds one, from `retry_strategy`, so overriding that field alone changed nothing. The clone now builds it, with the same cap on `backup_slow_all_threads_after_retryable_s3_error` as the factory. This is what makes the retries of a backup or a restore reach the client of a disk at all, so it also completes the override of #87660. `DataSourceDescription::sameKind` compares the endpoint, so a backup on another one sent the restore through the buffers of `BackupReaderDefault` instead of the native branch the fallback lives in. The tests put the backup on the endpoint of the disk, where the client of the destination is the one that uploads. The injected answer carries `SlowDown` as its code and `Slow Down.` as its message, and the message is what surfaces, as `test_checking_s3_blobs_paranoid` already records. The assertion matches that. The new disk is added to the expectation of `check_system_tables`, which asserts the exact number of disks. Co-Authored-By: Claude Opus 5 <[email protected]>
The positive test failed on the injected `SlowDown`: the first object the restore uploaded into the destination
was not a data blob but `format_version.txt`, the one-byte file `MergeTree` writes when a table is created,
which goes through the client of the disk and so allows no retries. The restore failed while creating the table,
before reaching the upload the retries of the restore are supposed to cover.
Code: 499. Message: Slow Down., bucket root, key data/disks/disk_s3_broken/..., object size 1:
While creating table default.data_restored
DB::WriteBufferFromS3::makeSinglepartUpload
The table is created before the mock is armed, so the only uploads left in the window are the data blobs.
`allow_different_table_def` accepts it: its definition differs from the one in the backup only by its name.
Co-Authored-By: Claude Opus 5 <[email protected]>
The `cache read` and `cache entries with ties kept` checks rerun queries whose entries earlier queries of the test wrote to the server-wide query condition cache. Dropping or renaming a MergeTree table without a UUID (in an Ordinary or Memory database) calls `Context::clearCaches()`, which also empties that cache. In both CI failures a parallel test did that between the fill and the rerun (04498_database_max_tables on master, 01069_database_memory on ClickHouse#127638), so the rerun missed all 3 parts and printed `cache read 0`. Run the test only in the sequential job flavors, as done for 05258 in ClickHouse#125702. Queries and the reference are unchanged; the Random settings limits line is kept byte-identical. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…allback-backup-retries
|
|
||
| node.query(restore_from_broken_disk_backup(backup_destination, retry_attempts=100)) | ||
|
|
||
| assert node.query("SELECT count() FROM data_restored") == "100\n" |
There was a problem hiding this comment.
[P2] Clean up both tables after the new restore tests
Both new tests leave data and data_restored in the module-scoped cluster. Running either before test_incremental_backup_append_table_def makes that existing test fail at CREATE TABLE data with TABLE_ALREADY_EXISTS. Running either before a check_backup_and_restore caller also makes its restore encounter the leftover single-column data_restored, whose definition differs from the three-column backup, and fail with CANNOT_RESTORE_TABLE. This can happen with explicitly ordered test selections or the integration runner's --count mode, which enables --random-order.
Please add cleanup in finally or a shared fixture for both new tests: reset broken_s3, then drop data and data_restored with SYNC, including when an assertion or restore fails.
`BACKUP` to and `RESTORE` from `S3(...)` for a table on an S3 disk with the same endpoint copy natively through `S3BackupClientCreator`, which takes the disk client's configuration and assigns the backup's raw retry settings to it. Since ClickHouse#127638, `Client::cloneWithConfigurationOverride` builds the SDK retry object from that override, but the only validation of `retry_strategy` was in the `PocoHTTPClientConfiguration` constructor, which a copied configuration never runs. So `backup_restore_s3_retry_jitter_factor = 2` (or `-1`) reached the `chassert`s in `Client::RetryStrategy::RetryStrategy` and aborted debug and sanitizer servers; release builds kept the unclamped value. Move the constructor's checks (throw if the initial delay exceeds the maximum, clamp the jitter factor into [0, 1] with the same `LOG_INFO`) into `PocoHTTPClientConfiguration::validateRetryStrategy` and call it on the override's configuration in `cloneWithConfigurationOverride` before the retry object is built. The validated struct is the one stored in the clone, so the `ExpiredToken` retry, which rebuilds a `RetryStrategy` from the stored field, gets the clamped value too. For a valid configuration the call is a no-op. The new test runs `BACKUP` with jitter 2 and `RESTORE` with jitter -1 on `s3_disk`, and asserts `S3CopyObject > 0` for both so that it fails if they stop taking the native copy path. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Related: #87660
copyS3Fileissues every request of a native copy with the client it is given as the source, and uses thedestination client only in
fallback_method, which reads the source and reuploads it. On the backup side both arecovered since #87660; on the restore side only the source is, so the upload of a fallback retried on the
s3_retry_attemptsof the disk instead ofbackup_restore_s3_retry_attempts.The destination is now cloned through the same
S3BackupDiskClientFactorythe backup side uses, which keeps theconfiguration of the disk - cloning it rather than reusing the backup client is what preserves
SSE-KMS- andoverrides only the retry strategy.
A fallback is also traced now, on the restore side and for a ranged copy declining the native path, neither of
which said anything before.
Not covered:
BackupReaderDefault::copyFileToDiskwrites throughIDisk::writeFile, the write path of the diskitself, with no client to override.
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix
RESTOREfromS3ignoring thebackup_restore_s3_retry_*settings for the upload into the destination disk when a server-side copy is not used, which made it retry on thes3_retry_attemptsof that disk instead and give up earlier than the restore was configured to. Also log when a copy of a byte range does not use the server-side copy and reads and reuploads the range instead.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/127638]
Version info
26.11.1.1590-master(included in26.11and later)