Skip to content

Re-add paimon storage engine - #102343

Merged
hanfei1991 merged 40 commits into
ClickHouse:masterfrom
Binnn-MX:add_paimon_storage_engine
May 8, 2026
Merged

hanfei1991 merged 40 commits into
ClickHouse:masterfrom
Binnn-MX:add_paimon_storage_engine

Conversation

@Binnn-MX

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • New Feature

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

Add Paimon, PaimonS3, PaimonAzure, PaimonHDFS, and PaimonLocal table engines with incremental read support backed by Keeper snapshot progress tracking. Incremental mode returns only new rows since the last committed snapshot. Targeted snapshot delta reads are available via paimon_target_snapshot_id, and per-query snapshot caps via max_consume_snapshots. Background metadata refresh is configurable with paimon_metadata_refresh_interval_sec. Gated by allow_experimental_paimon_storage_engine.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Motivation:
Paimon tables can now be consumed incrementally in ClickHouse with persisted snapshot progress in Keeper, enabling streaming-like snapshot delta consumption semantics. Previously Paimon was only accessible via table functions; now dedicated table engines allow persistent table definitions with Paimon-specific settings.

Parameters:

Table-level settings (specified in SETTINGS clause of CREATE TABLE):

  • paimon_incremental_read (Bool, default false): Enable incremental read mode. When enabled, the table tracks the last committed snapshot in Keeper and each read returns only rows added since then.
  • paimon_keeper_path (String): Keeper path for incremental read state. Must be unique per table. Supports macros {database}, {table}, {uuid}.
  • paimon_replica_name (String): Replica identity for incremental read state. Must be unique per replica. Supports macros {replica}.
  • paimon_metadata_refresh_interval_sec (Int64, default 30): Background metadata refresh interval in seconds. When greater than 0, a background task periodically pulls the latest snapshot from object storage.

Query-level settings:

  • paimon_target_snapshot_id (Int64, default -1): Read a specific snapshot delta without advancing committed incremental state. When > 0, overrides the normal incremental read flow.
  • max_consume_snapshots (UInt64, default 0): Maximum number of snapshots to consume per incremental read. 0 means no limit.
  • use_paimon_partition_pruning (Bool, default false): Enable Paimon partition pruning.
  • allow_experimental_paimon_storage_engine (Bool, default false): Gate for creating Paimon* table engines.

Example use:

SET allow_experimental_paimon_storage_engine = 1;

CREATE TABLE t_paimon_inc
ENGINE = PaimonS3(s3_conn, filename = 'paimon_all_types')
SETTINGS
    paimon_incremental_read = 1,
    paimon_keeper_path = '/clickhouse/tables/{uuid}',
    paimon_replica_name = '{replica}';

-- Incremental delta consumption (returns only new rows since last committed snapshot)
SELECT count() FROM t_paimon_inc;

-- Targeted snapshot delta read (does not advance committed state)
SELECT count() FROM t_paimon_inc SETTINGS paimon_target_snapshot_id = 1;

-- Consume with per-query snapshot cap
SELECT count() FROM t_paimon_inc SETTINGS max_consume_snapshots = 2;

@clickhouse-gh

clickhouse-gh Bot commented Apr 10, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [840828f]

Summary: ✅


AI Review

Summary

This PR re-introduces Paimon* table engines with incremental read state persisted in Keeper and adds corresponding settings/tests/docs. I did not find any additional high-confidence blocker/major issues beyond the already posted inline comments from clickhouse-gh[bot]; those existing issues still need to be addressed before merge.

ClickHouse Rules
Item Status Notes
Deletion logging ⚠️ Existing inline bot feedback reports missing deletion log for a Keeper node removal path.
Serialization versioning ➖
Core-area scrutiny ⚠️ Core storage/coordination paths have existing inline bot-reported correctness/concurrency concerns.
No test removal ✅
Experimental gate ✅
No magic constants ✅
Backward compatibility ⚠️ Existing inline bot feedback reports macro expansion compatibility regression ({uuid} handling) in Keeper path logic.
SettingsChangesHistory.cpp ✅
PR metadata quality ✅
Safe rollout ⚠️ Existing inline bot feedback indicates unresolved correctness risks in incremental watermark/coordination flows.
Compilation time ✅
No large/binary files ✅
Final Verdict
  • Status: ⚠️ Request changes
  • Minimum required actions: resolve the already posted inline blocker/major comments from clickhouse-gh[bot]; no additional inline findings were identified in this pass.

@clickhouse-gh clickhouse-gh Bot added the pr-feature Pull request with new product feature label Apr 10, 2026
@JiaQiTang98 JiaQiTang98 added the can be tested Allows running workflows for external contributors label Apr 10, 2026
@Binnn-MX

Copy link
Copy Markdown
Contributor Author

@hanfei1991 @JiaQiTang98 Please have a look.

@JiaQiTang98
JiaQiTang98 requested a review from hanfei1991 April 15, 2026 08:52
Comment thread src/Storages/ObjectStorage/Utils.cpp Resolved
@JiaQiTang98 JiaQiTang98 added the pr-experimental Experimental Feature label Apr 20, 2026
@clickhouse-gh clickhouse-gh Bot removed the pr-experimental Experimental Feature label Apr 21, 2026
@Binnn-MX

Binnn-MX commented May 6, 2026

Copy link
Copy Markdown
Contributor Author

@hanfei1991 When can this PR be merged, please have a look.

@clickhouse-gh

clickhouse-gh Bot commented May 7, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 84.10% 84.00% -0.10%
Functions 91.10% 91.10% +0.00%
Branches 76.60% 76.50% -0.10%

Changed lines: 59.22% (565/954) | lost baseline coverage: 6 line(s) · Uncovered code

Full report · Diff report

@hanfei1991 hanfei1991 self-assigned this May 8, 2026
@hanfei1991
hanfei1991 added this pull request to the merge queue May 8, 2026
Merged via the queue into ClickHouse:master with commit 7ba9983 May 8, 2026
165 checks passed
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label May 8, 2026
pull Bot pushed a commit to AnotherGenZ/ClickHouse that referenced this pull request Jun 6, 2026
…-4165)

A `BackgroundJobsAssignee` task on a pool thread can race with
`~StorageMergeTree` / `~StorageReplicatedMergeTree` and dispatch
`data.scheduleDataProcessingJob(*this)` through a vtable that has already
demoted to `MergeTreeData`. `scheduleDataProcessingJob` is pure virtual
at the `MergeTreeData` level (only the leaf storages override it), so
the dispatch lands on `__cxa_pure_virtual` and aborts the server.

This is reachable in practice when `shutdown` throws partway through
the cleanup. `StorageReplicatedMergeTree::~StorageReplicatedMergeTree`
wraps the `shutdown` call in a try/catch and swallows the exception, so
member destruction proceeds with the background scheduler still alive.
`~BackgroundJobsAssignee::finish()` then calls `deactivate()`, which
blocks on `exec_mutex` waiting for the in-flight `threadFunc` to finish
— but `threadFunc`'s next call is the pure-virtual dispatch above.

The fix is a defensive `false`-returning override of
`scheduleDataProcessingJob` on `MergeTreeData`. In normal operation,
the derived overrides win the virtual dispatch and this default is
dead code. During the destruction race, the default takes the dispatch:
`threadFunc` reads `false` as "no work scheduled" and falls through to
`postpone()`, which is a no-op once `finish()` has moved the holder
out. The pool thread completes `execute()` normally, the destructor's
`deactivate()` returns, and destruction proceeds safely.

Affected runs (all identical stack traces, all unrelated PRs):
- PR ClickHouse#102343 (Paimon) — Stress test (arm_asan_ubsan)
- PR ClickHouse#101027 (obfuscateQuery revert) — Stress test (arm_asan_ubsan, s3)
- PR ClickHouse#100272 (h3 → h3o) — Stress test (arm_asan_ubsan, s3)
- PR ClickHouse#104472 (count_distinct_optimization) — Stress test (arm_debug)

CI report (latest):
https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=104472&sha=ad31d65c8cb512098dc41a848bfa9e42650e123e&name_0=PR&name_1=Stress%20test%20%28arm_debug%29

Co-Authored-By: Claude Opus 4.7 <[email protected]>
pull Bot pushed a commit to Mu-L/ClickHouse that referenced this pull request Aug 16, 2026
The Keeper watermark advances at file-collection time, before the
collected batch is delivered (documented at-most-once semantics of
Paimon incremental reads). The pauseable failpoint
paimon_incremental_read_pause_after_watermark_commit sits exactly
between the watermark commit and delivery, so integration tests can pin
that a crash inside the window loses the batch - and will flip if
delivery ever becomes at-least-once. Inert unless enabled via SYSTEM
ENABLE FAILPOINT.

Related: ClickHouse#102343

Co-Authored-By: Claude Fable 5 <[email protected]>
w62 pushed a commit to w62/ClickHouse that referenced this pull request Nov 1, 2026
…snapshot's schema

A Paimon schema change (`ALTER TABLE ... ADD COLUMNS`, `RENAME COLUMN`,
`DROP COLUMN`) writes a new `schema/schema-N` file but no snapshot.
`PaimonMetadata::loadLatestState` built the latest table state with
`snapshot.schema_id`, i.e. the schema the last commit was written with, so
until the next commit `DESCRIBE` showed the old columns, `SELECT` of an added
column failed with `UNKNOWN_IDENTIFIER`, and a renamed or dropped column kept
its old name. `PaimonTableState::operator==` compares `schema_id`, but the id
never changed, so `update()` did not republish the state either.

In Paimon a read of the latest state uses the latest schema file:
`FileStoreTableFactory.create` takes `SchemaManager.latest()`, which lists
`schema/` and picks the highest `schema-N`; a snapshot's `schemaId` is only
the schema its files were written with. Spark, Flink and pypaimon return the
added column as NULL for existing rows.

`loadLatestState` now lists the schema directory after reading the snapshot
(`PaimonTableClient::getLatestTableSchemaInfo`, already used by `create`) and
builds the state with that id. Every consumer of the latest state keys off
`state->schema_id` (table structure, per-query columns, cluster workers,
partition pruner, options, manifest parsing), so they all follow. Manifest
parsing uses the schema only for partition types, and Paimon refuses to
rename, retype or drop partition keys, so parsing with the latest schema is
safe; the manifest cache key includes the schema id. States loaded for a
specific snapshot id (incremental read, `paimon_target_snapshot_id`) keep the
snapshot's own schema.

This is a regression: v26.3 re-read the latest schema file on every update;
ClickHouse#102343 ("Re-add paimon storage engine") switched to the snapshot's schema id
(first stable release v26.5).

Mapping data files written before a RENAME/DROP by field id is out of scope
(ClickHouse#127816).

Closes ClickHouse#128308

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

Labels

can be tested Allows running workflows for external contributors pr-feature Pull request with new product feature 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.

4 participants