Skip to content

Add system.s3(azure)_queue_metadata - #108522

Merged
kssenii merged 31 commits into
masterfrom
system-s3-queue-metadata
Aug 13, 2026
Merged

kssenii merged 31 commits into
masterfrom
system-s3-queue-metadata

Conversation

@kssenii

@kssenii kssenii commented Jun 25, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Improvement

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

Add system.s3(azure)_queue_metadata.

Version info

  • Merged into: 26.8.1.1316 (included in 26.8 and later)

kssenii and others added 3 commits June 25, 2026 18:16
Add stateless system tables that show, for each registered
ObjectStorageQueue metadata object, the current number of `processed`,
`processing` and `failed` nodes in Keeper.

The counts are read cheaply from Keeper via `stat.numChildren` (one
`exists` call per folder). The tables also expose the contents of these
folders (node name -> node data) via `Map(String, String)` columns
`processed`, `processing` and `failed`. To avoid listing and fetching
node data unnecessarily, the contents are fetched only when the
corresponding column is explicitly selected: the table enables
`supportsColumnsMask` and consults the column mask in `fillData`, so a
folder is touched in Keeper only when one of its columns is queried.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
In ordered mode there are no per-file `processed` nodes - the metadata
keeps a compact "last processed" pointer instead (a single node, one per
bucket, or one per partition). So make `processed_nodes` a
`Nullable(UInt64)` that is only populated for unordered mode and `NULL`
for ordered mode, and add a `processed_path` `Map(String, String)`
column that exposes the last processed file path for each pointer
(relative pointer path -> last processed file path), covering the
single, per-bucket and per-partition layouts.

`processing_nodes` and `failed_nodes` remain populated for both modes,
since those folders are per-file directories regardless of mode. Like
the contents columns, `processed_path` is read from keeper only when the
column is explicitly selected.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Address review feedback on system.s3_queue_metadata:

- Batch the keeper multiread when fetching node contents (`processed`,
  `processing`, `failed` maps) and the ordered-mode processed pointers,
  chunking by `keeper_multiread_batch_size` like `cleanupTrackedNodes`,
  so a folder with many nodes does not build a single oversized request
  that could exceed keeper limits. Add `getKeeperMultireadBatchSize` to
  `ObjectStorageQueueMetadata` to expose the batch size.

- Add integration tests for the two previously uncovered ordered
  layouts: per-bucket pointers (`buckets/<n>/processed`) and
  per-partition pointers (`processed/<partition>`), and pin
  `use_persistent_processing_nodes` in the ordered tests so the counts
  are deterministic.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Jun 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [da345ca]

Summary: ❌

job_name test_name status info comment
Stateless tests (arm_asan_ubsan, azure, parallel) FAIL
04780_json_subcolumn_index_match_not_quadratic FAIL cidb IGNORED
Integration tests (arm_binary, distributed plan, 2/4) FAIL
test_storage_nats/test_nats_jet_stream.py::test_nats_restore_failed_connection_without_losses_on_write FAIL cidb IGNORED
AST fuzzer (amd_debug) FAIL
Logical error: Invalid number of columns in chunk pushed to OutputPort. Expected A, found B (STID: 2270-3258) FAIL cidb, issue ISSUE CREATED

AI Review

Summary

This PR adds system.s3_queue_metadata and system.azure_queue_metadata for inspecting queue state directly in keeper, including ordered-mode processed pointers, auxiliary keeper paths, column-selective reads, and zookeeper_path filter pushdown. The earlier correctness gaps raised on this PR appear addressed in the current head, and I do not see a remaining code-level blocker in the final diff.

PR Metadata
  • Changelog category: Improvement matches the change.
  • Changelog entry: Add system.s3(azure)_queue_metadata. is understandable, but it is still code-centric and does not explain the user-facing purpose of the new tables. Suggested replacement: Add system.s3_queue_metadata and system.azure_queue_metadata for inspecting S3Queue and AzureQueue state stored in keeper.
Final Verdict
  • Status: ✅ Approve

LLVM Coverage Report

Metric Baseline Current Δ
Lines 86.70% 86.70% +0.00%
Functions 92.00% 92.00% +0.00%
Branches 79.10% 79.00% -0.10%

Changed lines: Changed C/C++ lines covered: 60/225 (26.67%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-improvement Pull request with some product improvements label Jun 25, 2026
… partitions

Address review feedback and the integration test failures in
test_storage_s3_queue/test_3.py for the new system.s3_queue_metadata /
system.azure_queue_metadata tables.

* Set the Keeper component for the scope of `fillData`. Without it,
  `Coordination::ZooKeeper::pushRequest` raises a logical error
  ("Current component is empty"), which aborted the server on the first
  query and cascaded into "Connection refused" failures in the
  following tests.

* Use `metadata->getPath` (the raw Keeper path) for Keeper reads instead
  of the factory key. For auxiliary Keepers the factory key is built as
  "<keeper>:<path>", so deriving read paths from it sent paths like
  `aux:/clickhouse/.../processing` to Keeper and made the metadata empty
  or failing. The factory key is now used only for the displayed
  `zookeeper_path` column.

* In ordered mode, read partition pointers as raw last-processed file
  paths. Partition child nodes under `processed/<partition>` are written
  directly as the file path, not as `NodeMetadata` JSON, so parsing them
  with `NodeMetadata::fromString` threw for partitioned ordered queues.
  Only the root/bucket pointers are parsed as `NodeMetadata`.

Add `test_system_queue_metadata_auxiliary_keeper` covering the auxiliary
Keeper path.

CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=108522&sha=latest&name_0=PR
PR: #108522

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Address review feedback: in `batched_get` only `ZOK` responses were
stored and every other per-node error was treated like a missing node,
so a real Keeper failure (authorization, session, runtime error) would
make `system.s3_queue_metadata` / `system.azure_queue_metadata` silently
report incomplete or empty metadata.

Only `ZNONODE` is benign here - a node can disappear between listing it
with `tryGetChildren` and reading it. For any other non-`ZOK` error,
throw `zkutil::KeeperException::fromPath` so the failure propagates
instead of being hidden. Also assert the multiread response size matches
the request.

Verified by running the five `test_system_queue_metadata*` integration
tests in `test_storage_s3_queue/test_3.py` (all pass).

Review comment: #108522 (comment)

Co-Authored-By: Claude Opus 4.8 <[email protected]>
In ordered partitioned queues the root `processed` (or
`buckets/<n>/processed`) node itself holds a `NodeMetadata` pointer,
while only its children store raw per-partition file paths. The
`processed_path` column of `system.s3_queue_metadata` walked only the
children, dropping the root pointer - e.g. a table created with
`partitioning_mode != none` and `last_processed_path` showed an empty
`processed_path` before any partition child existed.

#108522 (comment)

Co-Authored-By: Claude Fable 5 <[email protected]>
Cover the regression from the previous fix directly: an ordered
partitioned queue created with `s3queue_last_processed_path` persists a
`NodeMetadata` pointer on the root `processed` node before any
`processed/<partition>` child exists, and `system.s3_queue_metadata`
must return it.

#108522 (comment)

Co-Authored-By: Claude Fable 5 <[email protected]>
kssenii and others added 2 commits July 21, 2026 14:22
Run `test_system_queue_metadata` for both `S3Queue` and `AzureQueue` so
the separately registered `system.azure_queue_metadata` table is
exercised too.

#108522 (comment)

Co-Authored-By: Claude Fable 5 <[email protected]>
kssenii and others added 2 commits July 22, 2026 17:42
Take the factory mutex in `ObjectStorageQueueMetadataFactory::getAll` so a
concurrent `SELECT` from `system.s3_queue_metadata` /
`system.s3queue_metadata_cache` no longer races with `getOrCreate`/`remove`
mutating `metadata_by_path`.

Add the missing English docs for the new keeper-backed introspection tables
`system.s3_queue_metadata` and `system.azure_queue_metadata`, and update the
`S3Queue` / `AzureQueue` introspection sections to explain when to use them.

Addresses:
#108522 (comment)
#108522 (comment)

Co-Authored-By: Claude Fable 5 <[email protected]>
@mintlify

mintlify Bot commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
ClickHouse-docs 🟢 Ready View Preview Jul 22, 2026, 4:05 PM

@kssenii kssenii added pr-autogenerated-docs PR that regenerates docs artifacts from source; exempt from the autogenerated-region edit guard and removed pr-autogenerated-docs PR that regenerates docs artifacts from source; exempt from the autogenerated-region edit guard labels Jul 22, 2026
The `check_autogenerated_regions` docs guard rejects any PR that introduces
content inside `<!--AUTOGENERATED_START-->`/`<!--AUTOGENERATED_END-->` markers
unless the PR carries the `pr-autogenerated-docs` label (used only by the
nightly docs-generation bot). The bot's generator does not cover system-table
pages, so `system.s3_queue_metadata` / `system.azure_queue_metadata` must be
hand-written. Drop the markers so the pages are plain docs and the guard has
no region to police.

Co-Authored-By: Claude Fable 5 <[email protected]>
kssenii and others added 3 commits July 23, 2026 14:21
Add `test_system_queue_metadata_ordered_partitioned_buckets`, which exercises
the `useBucketsForProcessing() && partitioned` branch of
`read_processed_pointers` that the existing cases missed:
`test_system_queue_metadata_ordered_buckets` covers per-bucket roots without
partition children, and `test_system_queue_metadata_ordered_partitioned`
covers partition children without buckets, but nothing queried
`system.s3_queue_metadata` for the real `buckets/<n>/processed/<partition>`
layout. The new test asserts `processed_path` returns both the bucket root
pointers and the per-partition children, covering every processed partition.

Also drop the `use_persistent_processing_nodes = false` table setting (and the
comments claiming it makes the counts deterministic) from the metadata tests:
the value is ignored - `StorageObjectStorageQueue` hardcodes persistent
processing nodes - so it is a no-op. The counts are already made deterministic
by polling for the terminal state.

Verified locally: all 7 `test_system_queue_metadata*` cases pass.

Co-Authored-By: Claude Fable 5 <[email protected]>
The test asserted that every `buckets/<n>/processed` root pointer is returned
(`root_keys == {buckets/0..N/processed}`), but files are linked to buckets by
the hash of their path, and the path carries a random per-test prefix, so the
spread of partitions across buckets varies between runs. When only a subset of
buckets processed a file, the assertion failed - it passed locally but failed
in CI (asan_ubsan flaky / msan / llvm_coverage) with, e.g.,
`root_keys == {buckets/2/processed, buckets/3/processed}`.

Assert only distribution-independent invariants instead: every bucket that has
per-partition children also exposes its root pointer (`child_buckets <=
root_buckets`), the root buckets are a subset of the configured buckets, and
every processed partition is exposed as a child. This still proves the reader
returns both the bucket root pointers and the `buckets/<n>/processed/<partition>`
children.

Verified locally: 5 consecutive runs pass across different random distributions.

CI report: #108522 (comment)

Co-Authored-By: Claude Fable 5 <[email protected]>
@bharatnc bharatnc self-assigned this Jul 24, 2026
@kssenii
kssenii requested a review from a team as a code owner August 3, 2026 08:05
…metadata

`processing`, `failed`, and the unordered-mode `processed` folders are created
up front by `ObjectStorageQueueUnorderedFileMetadata::getMetadataPaths` and
`ObjectStorageQueueOrderedFileMetadata::getMetadataPaths`. If one of them is
missing, the queue metadata layout in Keeper is broken and the queue will start
failing its own updates.

`readFolder` treated `ZNONODE` as an empty folder, so
`SELECT failed_nodes_count, failed_nodes FROM system.s3_queue_metadata` reported
`0` / `{}` after `<zk>/failed` was deleted, making a broken queue look healthy.
Report the error instead, on both the count-only (stat) and the contents (list)
path.

`ZNONODE` stays benign where it is expected: the ordered-mode `processed`
pointers, which `ObjectStorageQueueOrderedFileMetadata::getMetadataPaths`
deliberately does not create in advance, and per-file nodes that disappear
between the child listing and the read.

Co-Authored-By: Claude Opus 5 <[email protected]>
kssenii and others added 2 commits August 8, 2026 11:30
…adata

# Conflicts:
#	docs/en/engines/table-engines/integrations/azure-queue.md
#	docs/en/engines/table-engines/integrations/s3queue.md
The legacy Docusaurus tree docs/en/ was removed on master; system-table
reference pages under docs/reference/system-tables/ are now generated by
the nightly docs-autogen job from the table comments and the column
comments embedded in the source. Drop the hand-written pages added by
this pull request and fold their extra prose into the `system.s3_queue_metadata`
and `system.azure_queue_metadata` table descriptions in `attachSystemTables.cpp`.

Co-Authored-By: Claude Fable 5 <[email protected]>
kssenii and others added 2 commits August 12, 2026 15:50
The keeper commit (writing the processed pointer and removing the processing
node) runs after the inserted rows become visible in the destination table
(`executor.execute()` completes before `commit(...)` in
`StorageObjectStorageQueue`), so asserting the persisted keeper state right
after the destination row count settles is racy - the ordered-mode tests could
observe missing pointers or non-zero processing counts, especially under the
test cluster's keeper fault injection.

Add `wait_for_keeper_commit`, which polls until the `processing` folder is
drained (the commit is atomic, so an empty `processing` folder implies every
finished file has had its processed pointer written), and call it after the
row-count wait in the six ordered/auxiliary-keeper metadata tests. The
unordered `test_system_queue_metadata` already polled its keeper assertions.

Also fix a stale reference to the old `read_processed_pointers` lambda name in a
comment (now `readProcessedPointers`).

Co-Authored-By: Claude Fable 5 <[email protected]>
`zookeeper_path` is the factory key, which for a queue on an auxiliary
zookeeper is `<zookeeper_name>:<path>` rather than the raw keeper path - a
`WHERE zookeeper_path = '/path'` on such a queue would otherwise silently
return nothing. Document this in the column description and both reference
pages.

Also refresh the stale class comment in the header: the table exposes the
folder contents and (in ordered mode) the last-processed pointers, not just the
node counts.

Co-Authored-By: Claude Fable 5 <[email protected]>
kssenii and others added 2 commits August 12, 2026 16:06
…ystem-s3-queue-metadata

# Conflicts:
#	docs/en/operations/system-tables/azure_queue_metadata.md
#	docs/en/operations/system-tables/s3_queue_metadata.md
…ptions

Address review nit: use `directory` for the keeper node groups in the column
descriptions and the surrounding comments, matching the terminology preferred
in review.

Related: #108522 (comment)

Co-Authored-By: Claude Fable 5 <[email protected]>
}

template <ObjectStorageType type>
void StorageSystemObjectStorageQueueMetadata<type>::fillData(

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.

One small observation here.

A query against this system table can fail if an S3Queue/AzureQueue table is dropped at the same time. fillData copies the list of queues, but a queue can be dropped before its Keeper data is read. In that case, readFolder treats the missing Keeper folder as broken metadata and throws an exception, even though the queue was removed normally.

Could we check whether the queue is still registered when a required folder is missing? If it has been removed, skip the row. If it is still registered, continue reporting the exception because the missing folder indicates broken metadata.

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.

But in the greater spirit of this, this might probably be just fine as such an occurrence might be quite rare.

@bharatnc bharatnc left a comment

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.

Looks good to me, just one point (might consider if it's possible at all).

Skip the row when the queue is no longer registered; keep throwing for a still-registered (broken) one. Related: #108522 (comment)

Co-Authored-By: Claude Fable 5 <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing da345caa0 with master 809fc9a43 (stripped binary size, per-symbol sizes and ThinLTO time; object sizes against the warmup build of a63b5b574; compile times per translation unit against the most recent warmup build that recompiled it).

⚠️ Significant changes: object file sizes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 692.03 MiB 689.09 MiB -2.95 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Object file sizes ⚠️

5 object files changed (+516.36 KiB total), 1 added.

Object file Master PR Δ
src/Storages/System/CMakeFiles/clickhouse_storages_system.dir/StorageSystemObjectStorageQueueMetada… new 491.95 KiB +491.95 KiB
src/Storages/System/CMakeFiles/clickhouse_storages_system.dir/attachSystemTables.cpp.o 1.66 MiB 1.68 MiB +20.48 KiB (+1.21%)

737 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

24 translation units recompiled, 265 s compile time in total, 23 of them have a recent master baseline.

Translation units without a recent master baseline:

  • src/Storages/System/StorageSystemObjectStorageQueueMetadata.cpp: 11.6 s

Job report

@kssenii
kssenii added this pull request to the merge queue Aug 13, 2026
Merged via the queue into master with commit dc031f8 Aug 13, 2026
177 of 181 checks passed
@kssenii
kssenii deleted the system-s3-queue-metadata branch August 13, 2026 09:39
@robot-ch-test-poll robot-ch-test-poll added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants