Repository navigation
Downgrade S3 PreconditionFailed log level from Error to Info - #99371
Conversation
The `PreconditionFailed` (412) HTTP response is an expected outcome of conditional S3 writes using `If-None-Match: *` headers — it means the object already exists, and the caller handles this case. Previously, both the S3 HTTP client and `WriteBufferFromS3` logged it at Error level, which caused it to be forwarded to the client via `--send_logs_level=warning` and appear in stderr. This was observed in the `03800_mv_from_iceberg` test: a `CREATE TABLE IF NOT EXISTS` for an Iceberg table writes `v1.metadata.json` with `If-None-Match: *`. When the first S3 PUT times out but actually succeeds on the server side, the S3 SDK retries and gets 412. The Error-level log leaked to the client's stderr, causing the test to fail. https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=a5483cedba19a14e57f9c27fe76b707f5a1a45bb&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_asan%2C%20distributed%20plan%2C%20parallel%2C%202%2F2%29 Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Workflow [PR], commit [b5143bb] Summary: ✅ AI ReviewSummaryThis PR downgrades S3 Findings
ClickHouse Rules
Final Verdict
|
| outcome.GetError().GetExceptionName(), outcome.GetError().GetMessage(), bucket, key, content_length); | ||
| /// PreconditionFailed is an expected response for conditional writes (e.g. If-None-Match: *), | ||
| /// not a genuine error — the caller handles it. | ||
| if (outcome.GetError().GetExceptionName() == "PreconditionFailed") |
There was a problem hiding this comment.
Using GetExceptionName() == "PreconditionFailed" is brittle and may miss equivalent 412 responses if SDK naming changes; prefer checking GetErrorType() against the enum (e.g. Aws::S3::S3Errors::PRECONDITION_FAILED) for stable behavior.
LLVM Coverage Report
PR changed lines: PR changed-lines coverage: 80.95% (17/21, 0 noise lines excluded) |
Each sink of a parallel INSERT into an Iceberg table commits its own
snapshot, so with max_insert_threads > 1 the sinks race for the same
metadata version. The loser's conditional write fails with
FILE_ALREADY_EXISTS (local, If-None-Match), STALE_VERSION (local,
If-Match) or an S3 412 PreconditionFailed, and the caller retries on
the next version. writeMetadataFile and tryWriteVersionHintFile logged
that expected outcome with tryLogCurrentException, i.e. at Error with a
stack trace, which reaches the client's stderr with
send_logs_level=warning and fails stateless tests such as
05325_iceberg_mixed_format_top_k_dynamic_filtering ("having stderror"),
although the INSERT succeeds and the data is correct.
Classify such a failure with one helper, isConditionalWriteConflict,
and log only that case at Debug, keeping every other failure at Error.
This matches the REST catalog commit path (409 is logged at Debug) and
the S3 layer, which already logs a 412 at Info (ClickHouse#99371). Control flow
is unchanged. IcebergMetadata::createInitial reuses the helper for its
CREATE ... IF NOT EXISTS race; its behaviour is identical because that
write is If-None-Match only.
The new test runs parallel INSERTs (8 sinks, 10 INSERTs, version hint
off and on) and fails on every run without the change.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
PreconditionFailed(HTTP 412) S3 response log level from Error to Info in bothPocoHTTPClientandWriteBufferFromS3If-None-Match: *) used by Iceberg metadata commits — it should not be logged at Error level03800_mv_from_icebergwhich failed because Error-level logs leaked to stderr via--send_logs_level=warningThe root cause: during
CREATE TABLE IF NOT EXISTSfor an Iceberg table, the first S3 PUT forv1.metadata.jsontimed out but actually succeeded on MinIO. The S3 SDK retried and got 412 PreconditionFailed. The Error-level log was forwarded to the client's stderr, causing the test to fail.CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?REF=master&sha=a5483cedba19a14e57f9c27fe76b707f5a1a45bb&name_0=MasterCI&name_1=Stateless%20tests%20%28amd_asan%2C%20distributed%20plan%2C%20parallel%2C%202%2F2%29
Test plan
03800_mv_from_icebergtest should no longer fail due toPreconditionFailedstderr outputChangelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
...
🤖 Generated with Claude Code
Note
Low Risk
Low risk: only adjusts logging severity for expected S3 conditional-write failures (HTTP 412 /
PreconditionFailed) while keeping other error handling unchanged.Overview
Reduces noise from expected S3 conditional-write failures by downgrading
HTTP 412 PreconditionFailedresponses from error to info logs.This is applied in both the low-level
PocoHTTPClientHTTP status logging and theWriteBufferFromS3single-partPutObjectfailure path, while preserving error-level logging for other non-expected failures.Written by Cursor Bugbot for commit b5143bb. This will update automatically on new commits. Configure here.