Skip to content

S3Queue: fix "file is already processed" error in ordered bucket mode - #106718

Closed
kssenii wants to merge 18 commits into
masterfrom
s3queue-processing-threads-investigation
Closed

kssenii wants to merge 18 commits into
masterfrom
s3queue-processing-threads-investigation

Conversation

@kssenii

@kssenii kssenii commented Jun 8, 2026 •

Copy link
Copy Markdown
Member

Linked issues

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

S3Queue: fix "file is already processed" error in ordered bucket mode

@clickhouse-gh

clickhouse-gh Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [6538d53]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_asan_ubsan, db disk, old analyzer, 5/6) FAIL
test_check_table/test.py::test_check_all_tables FAIL cidb, issue

AI Review

Summary

This PR strengthens S3Queue ordered-bucket ownership handling, adds the s3queue_allow_unsafe_alter guard for deduplication_v2, and adds regression coverage. The deduplication_v2 ALTER/RESET guard looks fixed, but the ownership-loss fix is still incomplete: several plain-ZooKeeper and stale-node-removal paths can still let one processor delete another processor's freshly recreated znode or let both replicas insert the same file's rows.

Findings

❌ Blockers

  • [src/Storages/ObjectStorageQueue/ObjectStorageQueueOrderedFileMetadata.cpp:843-847; src/Storages/ObjectStorageQueue/StorageObjectStorageQueue.cpp:1139-1239] The no-CHECK_STAT branch still adds no commit-time ownership proof or heartbeat on plain ZooKeeper. If TTL cleanup removes A's lock and processing nodes, B can reprocess the same file, while A's insert side effects have already happened before commit. The processed-pointer race only decides which Keeper commit wins; it does not prevent duplicate rows from the stale owner. Suggested fix: fail closed when CHECK_STAT is unavailable, or reject ordered bucket processing with persistent-node cleanup on external ZooKeeper.
  • [src/Storages/ObjectStorageQueue/ObjectStorageQueueOrderedFileMetadata.cpp:276-286] BucketHolder::release still does a separate ownership read and then an unguarded tryRemove. If the stale lock is deleted and another processor recreates the same bucket_lock_path between those calls, this release path removes the new owner's lock and reopens the duplicate-processing race. Suggested fix: tie the remove to the observed node identity (czxid) or skip removal when exact ownership cannot be proven.
  • [src/Storages/ObjectStorageQueue/ObjectStorageQueueIFileMetadata.cpp:183-198, 399-411] The per-file processing-node cleanup paths still do checkProcessingOwnership and removal as separate Keeper operations. After TTL cleanup deletes a stale node and another processor recreates it for the same file, the current destructor / resetProcessing path can still delete that fresh node and let a third processor start the file concurrently. Suggested fix: pin the remove to the observed node identity/version, or fail closed and leave the node for TTL cleanup.
  • [src/Storages/ObjectStorageQueue/ObjectStorageQueueMetadata.cpp:1610-1637] The plain-ZooKeeper cleanup fallback still removes by version alone when CHECK_STAT is unavailable. Fresh bucket locks and per-file processing nodes start at version 0, so a node that was removed and recreated after the scan is still eligible for deletion by this cleanup thread. Suggested fix: fail closed on the no-CHECK_STAT path, or reject this cleanup mode on external ZooKeeper.
Tests
  • ⚠️ [tests/integration/test_storage_s3_queue/test_2.py:578-599] The new regression helper collapses destination rows to a set, so it passes even when a lock handoff duplicates rows. Add a multiplicity check such as total row count or GROUP BY column1, column2, column3 HAVING count() != 1 before treating recovery as proven.
Final Verdict
  • Status: ❌ Block

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Jun 8, 2026
return false;

auto zk_client = ObjectStorageQueueMetadata::getZooKeeper(log, zookeeper_name);
if (!zk_client->isFeatureEnabled(KeeperFeatureFlag::CHECK_STAT))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Returning here makes the ownership/heartbeat fix a no-op on external ZooKeeper, because CHECK_STAT is a ClickHouse Keeper extension and ZooKeeper-compatible connections do not advertise it. S3Queue still supports external ZooKeeper, and in that mode bucket locks are still persistent nodes cleaned by persistent_processing_node_ttl_seconds with no commit-time ownership check or heartbeat, so the original ownership-loss race remains for any processing that outlives the TTL. Please either add a ZooKeeper-compatible path, disable/reject ordered bucket processing with TTL cleanup when this feature is missing, or clearly scope the fix and add coverage for the unsupported branch.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current code still does not preserve ownership on plain ZooKeeper. At src/Storages/ObjectStorageQueue/ObjectStorageQueueOrderedFileMetadata.cpp:822, the fallback heartbeat is a SET with version -1; if TTL cleanup deleted A's lock and processor B already recreated the same buckets/<n>/lock path, A's commit multi overwrites B's lock data with A's processor_info and then succeeds. That lets the stale owner advance the processed pointer after losing the bucket, and its later release can also remove B's lock. The non-CHECK_STAT path needs to fail closed when exact-node ownership cannot be proven, or the mode/configuration should be rejected for external ZooKeeper.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current no-CHECK_STAT branch still cannot prove ownership before committing. At current src/Storages/ObjectStorageQueue/ObjectStorageQueueOrderedFileMetadata.cpp:813 it deliberately adds no request, so A can lose the bucket, B can acquire it, and if A prepares the commit before B advances the processed pointer, A still writes the Keeper marker after its insert has already written rows. The version-pinned processed pointer only serializes the marker; it does not prove A still owns the bucket or prevent duplicate insert side effects. For plain ZooKeeper this should fail closed or reject the mode/configuration, unless there is a ZooKeeper-compatible ownership proof before commit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current code still leaves the plain-ZooKeeper branch unsafe. At src/Storages/ObjectStorageQueue/ObjectStorageQueueOrderedFileMetadata.cpp:843-848 the no-CHECK_STAT path deliberately adds no heartbeat or ownership assertion, so the bucket lock's mtime is never refreshed there and any holder that lives past persistent_processing_node_ttl_seconds is still reclaimed even while it is actively committing. StorageObjectStorageQueue::commit still sends the Keeper multi only after the insert has already succeeded (src/Storages/ObjectStorageQueue/StorageObjectStorageQueue.cpp:1070-1138), so the version-pinned processed pointer does not prove the stale owner still held the bucket or prevent duplicate insert side effects once another replica re-acquires it.

@watson-ch

watson-ch Bot commented Jun 8, 2026

Copy link
Copy Markdown

Backport labels have been automatically added based on https://github.com/clickhouse/clickhouse-core-incidents/issues/714

Labels added:

  • v26.2-must-backport
  • v26.4-must-backport
  • v26.5-must-backport

These labels ensure backport PRs are properly created for each affected release version. The release automation will create backport PRs as needed based on these labels.

@CheSema CheSema self-assigned this Jun 8, 2026
kssenii and others added 3 commits June 15, 2026 14:26
…threads-investigation

# Conflicts:
#	src/Common/ErrorCodes.cpp
#	src/Storages/ObjectStorageQueue/ObjectStorageQueueSettings.cpp
Fixes from the AI review on PR #106718:

- Bucket ownership without `CHECK_STAT`: `prepareBucketOwnershipCheckRequests`
  now always emits the lock-node mtime heartbeat (a plain `SET`, supported by
  external ZooKeeper) and only adds the atomic `czxid`-match `CHECK` when the
  Keeper advertises `CHECK_STAT`. The heartbeat keeps the TTL cleanup from
  removing a lock that is actively committing, and a missing lock fails the
  commit multi with `ZNONODE` so the file is retried instead of double-committed.
  Together with the non-atomic `stillOwnsBucket` check on the error path, the
  ownership-loss race is covered on plain ZooKeeper too; only the `CHECK_STAT`
  path makes it fully atomic.

- `deduplication_v2` alter guard: `checkAlterIsPossible` treated a setting that
  was missing from the old settings as unchanged, so it skipped the safety guard
  while `alter` still applied the change. It now treats a missing old setting as
  changed, matching `alter`, so `ALTER ... MODIFY SETTING deduplication_v2 = 0`
  on a table that did not set it at creation is rejected without
  `s3queue_allow_unsafe_alter`. Added `test_alter_deduplication_v2_guard`.

- Bucket-lock regression tests: bucket ownership is enabled only when there is
  more than one bucket, so the tests now use `s3queue_buckets = 2` and discover
  whichever `buckets/<i>/lock` node is acquired via `_wait_for_any_bucket_lock`
  instead of waiting on a hard-coded `buckets/0/lock` that could never appear.

#106718 (comment)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Capture when a bucket lock is acquired and include how long it had been
held in the OBJECT_STORAGE_QUEUE_BUCKET_OWNERSHIP_LOST message, so it is
clear whether the hold exceeded persistent_processing_node_ttl_seconds.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
{
LOG_TEST(log_, "Processor {} acquired bucket {} for processing", processor_info, bucket);

/// Capture the lock node's `czxid` for the commit-time ownership check (see `lock_czxid`).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capturing lock_czxid only protects the commit path; the holder release path can still delete a lock recreated by another processor. If this holder loses the bucket to TTL cleanup, BucketHolder::release reaches the first-attempt tryRemove(bucket_lock_path, -1) with only a chassert ownership check, so release builds remove the new owner's lock. That reintroduces the same ownership-loss loop even when CHECK_STAT made the stale commit fail. Release needs to use the captured czxid as well, e.g. remove only under an atomic stat check when supported, and otherwise fail closed by leaving the old lock for TTL cleanup instead of deleting a lock whose identity is not proven.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The release path still has a check-then-remove race. In the current code, checkBucketOwnership only reads the lock data, then tryRemove removes the path without tying the remove to the node identity. Interleaving: A reads A's data, TTL cleanup deletes A's lock, B creates the same bucket_lock_path, and A's tryRemove removes B's lock. That is the stale-holder deletion this thread was about. Release needs to remove under the same czxid identity check, or fail closed and leave the lock for TTL cleanup when that cannot be expressed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original race is still present in the current code. BucketHolder::release still does a separate ownership read and then an unguarded remove at src/Storages/ObjectStorageQueue/ObjectStorageQueueOrderedFileMetadata.cpp:276-286: if A reads its own processor_info, the TTL cleanup deletes that lock, B creates the same bucket_lock_path, and then A's tryRemove deletes B's fresh lock. The remove still needs to be tied to the node identity (czxid) or skipped entirely when exact ownership cannot be proven.

- Fail closed without Keeper CheckStat: only heartbeat the bucket lock
  inside the atomic ownership check, so a blind Set can no longer steal a
  lock that was cleaned up and re-acquired by another processor.
- Guard BucketHolder::release in all build types so it removes the lock
  only while still owned, instead of deleting the new owner's lock.
- Require s3queue_allow_unsafe_alter for RESET SETTING deduplication_v2,
  which previously bypassed the guard via re-derived defaults.
- Handle in-flight bucket ownership loss gracefully (release and
  re-acquire) instead of asserting, and drop the racy acquire-time
  ownership assertion.
- Add a RESET deduplication_v2 guard regression test.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
):
expected = set(tuple(v) for v in total_values)

def union_distinct():

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This helper collapses the destination rows to a set, so the new regression tests pass even if the ownership race duplicates rows. That is one of the unsafe outcomes of two replicas processing the same file after a bucket lock handoff. Please assert multiplicity as well, for example compare the total row count across both destination tables to len(total_values) and check GROUP BY column1, column2, column3 HAVING count != 1 returns no rows before declaring recovery.

@watson-ch

watson-ch Bot commented Jun 23, 2026

Copy link
Copy Markdown

Backport labels have been automatically added based on https://github.com/clickhouse/clickhouse-core-incidents/issues/714

Labels added:

  • v26.6-must-backport

These labels ensure backport PRs are properly created for each affected release version. The release automation will create backport PRs as needed based on these labels.

kssenii and others added 4 commits June 29, 2026 18:10
The TTL cleanup may remove a persistent processing node (a per-file processing
node or a bucket lock) while it is still held, when a long batch does not commit
(and therefore does not heartbeat) before `persistent_processing_node_ttl_seconds`
elapses, after which another processor may re-acquire it. This is an expected,
recoverable condition handled on the commit path, but several node-removal paths
still asserted that a held node is always owned via `chassert(checkProcessingOwnership)`
/ `chassert(checkBucketOwnership)`, which aborts the server in debug/sanitizer
builds the moment the cleanup reclaims a live node.

Make the ownership check unconditional on these paths: skip removal if the node
is no longer ours instead of asserting. Covered paths:
- `ObjectStorageQueueIFileMetadata::~ObjectStorageQueueIFileMetadata` and
  `resetProcessing` (per-file processing node);
- `ObjectStorageQueueOrderedFileMetadata::BucketHolder::release` (bucket lock);
- the debug ownership re-check in
  `ObjectStorageQueueSource::FileIterator::getNextKeyFromAcquiredBucket` is
  downgraded from an assertion to a log line.

Tests: `test_ordered_bucket_lock_deleted_during_commit` and
`test_ordered_bucket_lock_cleaned_by_ttl` now use a slower materialized view so a
single bucket's batch stays uncommitted past the TTL even when files are split
across more than one bucket; `test_alter_deduplication_v2_guard` expects the Bool
`deduplication_v2` to render as `true`/`false`.

#106718 (comment)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…tigation' into s3queue-processing-threads-investigation

# Conflicts:
#	src/Storages/ObjectStorageQueue/ObjectStorageQueueOrderedFileMetadata.cpp
#	src/Storages/ObjectStorageQueue/ObjectStorageQueueSource.cpp
- Assert the absence of permanently-failed files via the authoritative Keeper
  state (`<keeper_path>/failed`, excluding transient `.retriable` markers)
  instead of the per-replica in-memory `system.s3queue_metadata_cache`. Under
  the deliberate lock takeover (and the cluster's Keeper fault injection) a
  replica's racing local processing attempt could leave a transient `Failed` in
  its own in-memory cache even though the file was ultimately processed, which
  made `test_ordered_bucket_lock_deleted_during_commit` flaky. Keeper is the
  shared source of truth, so it is checked once.
- Fix stale literals in `test_reset_deduplication_v2_guard`: the Bool
  `deduplication_v2` renders as `true`/`false` in `system.s3_queue_settings`,
  not `1`/`0`.

#106718 (comment)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
code = Coordination::Error::ZOK;
return;
}
code = zk_client->tryRemove(processing_node_path);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ownership check is still a separate read from the remove, so this can delete a processing node recreated by another processor. A concrete interleaving is: this holder reads its own processor_info, the TTL cleanup removes processing_node_path, another processor creates the same path for the same file, then this tryRemove removes the new owner's node. That lets a third processor acquire the file while the second one is still inserting, which is the duplicate-processing class this PR is trying to close. The remove needs to be tied to the node identity/version observed during the ownership check, or fail closed and leave the node for TTL cleanup when exact ownership cannot be proven.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same check-then-remove race is still present for per-file processing nodes. Both the destructor path at src/Storages/ObjectStorageQueue/ObjectStorageQueueIFileMetadata.cpp:183-199 and resetProcessing at src/Storages/ObjectStorageQueue/ObjectStorageQueueIFileMetadata.cpp:399-411 first read ownership and then remove in a separate request. If the stale node is cleaned up and recreated between those two steps, the current code still deletes another processor's fresh processing node.

After `tryCreate` of a bucket lock succeeds in `tryAcquireBucket`, read
the node back with `tryGet` and verify it still holds our `processor_info`
instead of only checking existence. Capture `czxid` when ownership is
confirmed, otherwise flag ownership as lost and return `nullptr` so the
caller skips the bucket.

Move `OBJECT_STORAGE_QUEUE_BUCKET_OWNERSHIP_LOST` to `M(779)` after
`MEMORY_RESERVATION_FAILED` and revert `END` to `1008`.

CI report: #106718 (comment)
Related: #106718

Co-Authored-By: Claude Opus 4.8 <[email protected]>
kssenii and others added 3 commits July 13, 2026 17:24
… removals

Track the believed heartbeat time of the bucket lock in `BucketInfo`:
initialized to the acquisition time and promoted (CAS-max) via the new
`finalizeProcessedImpl` hook once a commit containing the czxid-guarded
heartbeat `Set` succeeds. The timestamp is recorded before the commit is
sent, so it is a conservative lower bound on the lock node's `mtime`.

In `getNextKeyFromAcquiredBucket`, when the debug-only ownership check
finds the lock lost, `chassert` that the believed heartbeat age reached
the TTL: the cleanup may only reclaim a lock whose `mtime` aged past the
TTL, so losing a younger lock indicates a bug (cleanup removing fresh
nodes, a broken heartbeat refresh, or an external deletion). Legitimate
reclaims still drop the holder and re-acquire gracefully.

The TTL cleanup now logs the removed node's `mtime` age and the TTL for
attribution of lock removals.

Run `test_ordered_bucket_lock_deleted_during_commit` and
`test_ordered_bucket_lock_cleaned_by_ttl` in release builds only: they
force removal of a live bucket lock, which intentionally trips the
`chassert` ownership validations in debug/sanitizer builds. Match the
cleanup log line by the table-specific Keeper path.

Related: #106718

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Fixes from an in-depth review of the believed-heartbeat mechanism:

- Construct `BucketInfo` in place: the atomic `last_heartbeat_time`
  member makes it non-copyable, so `make_shared` with a temporary did
  not compile.
- Record `lock_acquired_time` before the create is sent: the node's
  `mtime` is set when `tryCreate` lands, which can be an earlier retry
  than the one that reports success, so the previous post-read-back
  timestamp was not a lower bound on the `mtime`.
- Add clock-skew slack to the ownership-loss `chassert`: the asserted
  chain crosses the committing replica's clock, Keeper's `mtime` and
  the cleaning replica's clock.
- Pin the TTL cleanup removal to the scanned node's `czxid` (via
  `CheckStat` + `Remove` multi) when Keeper supports it: the data
  `version` alone cannot detect a node removed and recreated after the
  scan, so the cleanup could delete another processor's fresh lock.
- Reset the cached bucket processor when dropping a stale holder, so
  the bucket's cached keys are not skipped until the next commit.
- Reset `pending_bucket_heartbeat_time` at prepare time to be robust
  against reuse after a failed commit attempt.
- Report `lock_acquired_time` and `last_heartbeat_time` in
  `BucketInfo::toString`.
- Reword the `persistent_processing_node_ttl_seconds` description: live
  processors that do not commit for longer than the TTL can still have
  their nodes reclaimed; per-file processing nodes are never refreshed.
- Fix a stale comment: a failed commit-time `CheckStat` surfaces as a
  generic Keeper multi error, not `OBJECT_STORAGE_QUEUE_BUCKET_OWNERSHIP_LOST`.

Related: #106718

Co-Authored-By: Claude Opus 4.8 <[email protected]>
}
else
{
code = zk_client->tryRemove(node, version);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On plain ZooKeeper this cleanup path can still delete a fresh processing node or bucket lock that was recreated after the scan. The fallback branch only does tryRemove(node, version), but a recreated znode starts back at version 0, so version alone does not distinguish "the stale node we scanned" from "a new owner that recreated the same path before removal". That means the cleanup thread can still remove another processor's active node whenever CHECK_STAT is unavailable. This needs to fail closed on the no-CHECK_STAT path, or ordered / persistent-processing cleanup needs to be rejected on external ZooKeeper.

@clickhouse-gh

clickhouse-gh Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

📊 Cloud Performance Report

✅ AI verdict: no_change — no significant changes across 28 queries analysed

This PR is scoped entirely to ObjectStorageQueue/S3Queue bucket-lock ownership, TTL-cleanup safety, and new ALTER guards (the s3queue_allow_unsafe_alter opt-in); it does not touch the query-execution path any ClickBench or TPC-H query exercises. Every flagged clickbench delta was measured against a single-run baseline that reads high, and none can be attributed to the diff, so all five improvements are downgraded to not_sure as baseline variance. Q32's -5.4% is borderline with mixed test signals and is likewise unrelated. No genuine regression or improvement is supported by this change.

clickbench

⚠️ 6 inconclusive

Flagged queries (6 of 43)
Query Verdict Baseline median (ms) PR median (ms) Change q-value Hint
⚠️ 3 not_sure 73 50 -31.5% <0.0001 Q3 is a plain SELECT that cannot execute the S3Queue lock/ALTER code this PR changes. With a single-run baseline reading high, -31.5% is baseline variance, not a PR effect.
⚠️ 11 not_sure 201 172 -14.4% <0.0001 -14.4% is off-path: the PR only changes S3Queue bucket-lock ownership and ALTER guards, which Q11 never executes. This is thin single-run baseline noise.
⚠️ 23 not_sure 169 79 ×2.1 faster <0.0001 ×2.1 faster is off-path; Q23 does not touch the S3Queue lock/ALTER code. The single-run baseline reads at the top of master's normal band, so this is a baseline artifact.
⚠️ 28 not_sure 6646 1050 ×6.3 faster <0.0001 The base run reads far above master's normal range while source sits at the band floor; an S3Queue-only diff cannot affect Q28, so ×6.3 faster is a thin-baseline artifact.
⚠️ 30 not_sure 318 268 -15.7% <0.0001 -15.7% is off-path: the PR changes only S3Queue lock ownership and ALTER guards. Both medians sit inside master's normal band, so this is run-to-run variance.
⚠️ 32 not_sure 1368 1294 -5.4% 0.0003 Mixed signals from the two tests on a -5.4% delta, and unrelated to the S3Queue-only diff regardless. Treat as noise.

Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on.

Debug info
  • StressHouse run: 99b8c1ea-a5df-49c5-9441-81753f81ecf5
  • MIRAI run: 1aed9763-6b57-43c8-81d6-f36b1cfb1579
  • PR check IDs:
    • clickbench_19941_1784810958
    • clickbench_19953_1784810958
    • clickbench_19966_1784810958
    • tpch_adapted_1_official_19972_1784810958
    • tpch_adapted_1_official_19994_1784810958
    • tpch_adapted_1_official_20008_1784810958

@watson-ch

watson-ch Bot commented Jul 22, 2026

Copy link
Copy Markdown

Backport labels have been automatically added based on https://github.com/clickhouse/clickhouse-core-incidents/issues/714

Labels added:

  • v26.7-must-backport

These labels ensure backport PRs are properly created for each affected release version. The release automation will create backport PRs as needed based on these labels.

@clickhouse-gh

clickhouse-gh Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.20% 86.20% +0.00%
Functions 92.00% 92.00% +0.00%
Branches 78.30% 78.30% +0.00%

Changed lines: Changed C/C++ lines covered: 211/270 (78.15%) · Uncovered code

Full report · Diff report

@kssenii

kssenii commented Aug 7, 2026

Copy link
Copy Markdown
Member Author

A more simpler fix was merged #110292

@kssenii kssenii closed this Aug 7, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
Fixes from the AI review on PR ClickHouse#106718:

- Bucket ownership without `CHECK_STAT`: `prepareBucketOwnershipCheckRequests`
  now always emits the lock-node mtime heartbeat (a plain `SET`, supported by
  external ZooKeeper) and only adds the atomic `czxid`-match `CHECK` when the
  Keeper advertises `CHECK_STAT`. The heartbeat keeps the TTL cleanup from
  removing a lock that is actively committing, and a missing lock fails the
  commit multi with `ZNONODE` so the file is retried instead of double-committed.
  Together with the non-atomic `stillOwnsBucket` check on the error path, the
  ownership-loss race is covered on plain ZooKeeper too; only the `CHECK_STAT`
  path makes it fully atomic.

- `deduplication_v2` alter guard: `checkAlterIsPossible` treated a setting that
  was missing from the old settings as unchanged, so it skipped the safety guard
  while `alter` still applied the change. It now treats a missing old setting as
  changed, matching `alter`, so `ALTER ... MODIFY SETTING deduplication_v2 = 0`
  on a table that did not set it at creation is rejected without
  `s3queue_allow_unsafe_alter`. Added `test_alter_deduplication_v2_guard`.

- Bucket-lock regression tests: bucket ownership is enabled only when there is
  more than one bucket, so the tests now use `s3queue_buckets = 2` and discover
  whichever `buckets/<i>/lock` node is acquired via `_wait_for_any_bucket_lock`
  instead of waiting on a hard-coded `buckets/0/lock` that could never appear.

ClickHouse#106718 (comment)

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants