Repository navigation
Add paimon metadata cache - #104657
Add paimon metadata cache#104657
Conversation
|
Workflow [PR], commit [82792c9] Summary: ✅
AI ReviewSummaryThis PR adds an in-memory cache for deserialized Paimon manifest metadata, wires it into server/query settings, and adds a Findings❌ Blockers
Final VerdictChanges required: the external-table recreation guard still does not fail closed for incremental and targeted-snapshot reads. |
03d9be0 to
5e210e0
Compare
a64935f to
07c0e1f
Compare
…ceberg and add DROP TABLE invalidation
…copy on cache hit, and fix type mismatches
| /// analysis->execution window where an external DROP + re-CREATE would otherwise be reused stale. | ||
| /// iterate() runs once per query read (the iterator is shared across streams), so this single | ||
| /// remote schema-0 check is negligible relative to the data scan it guards (fail-close). | ||
| validateTableIdentity(); |
There was a problem hiding this comment.
The single validateTableIdentity() here still does not protect the later loadStateForSnapshot() calls.
Concrete incremental trace:
iterate()pinsstateat snapshot10and this check passes.- The upstream Paimon table is then
DROP+CREATEd. collectIncrementalDataFiles()callsgetSnapshotsBetween(9, 10), andloadStateForSnapshot(10)now reads from the recreated table path. Ifsnapshot-10is missing there, the catch block ingetSnapshotsBetween()treats that as a compaction gap.snapshots.empty()then advanceslast_consumed_snapshot_idto10, anditerate()commits that watermark to Keeper.
So the new fail-close contract is still broken: after a recreate, incremental reads can silently skip unread snapshots instead of raising the documented schema-0 mismatch exception. The same gap exists for the paimon_target_snapshot_id branch if the recreated table reuses the requested snapshot id.
Please revalidate table identity around every later loadStateForSnapshot() / getSnapshotsBetween() call (including the exception path that currently assumes compaction), not only before consuming the already-pinned state.
There was a problem hiding this comment.
This is fundamentally a race with the external Paimon table being dropped/recreated during query execution. Without an external lock or transaction, no single schema-0 check can make the whole read consistent: the table can always be recreated immediately after the check.
So adding checks around every loadStateForSnapshot only moves the TOCTOU window; it does not close it. At most, we can do best-effort validation at key boundaries.
There was a problem hiding this comment.
The current guard is a best-effort fail-close check intended to prevent stale schema reuse across refresh/analysis boundaries. It does not promise strong consistency if the external table is dropped and recreated during query execution.
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 424/451 (94.01%) · Uncovered code |
…a_cache Add paimon metadata cache
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Add an in-memory SLRU cache for deserialized Paimon metadata files (manifest lists and manifests). When enabled via the
use_paimon_metadata_files_cachesetting, repeated queries against the same Paimon table skip re-downloading and re-parsing metadata from object storage.Documentation entry for user-facing changes
Motivation
Every Paimon query must read and deserialize manifest-list and manifest files from object storage (S3/Azure/HDFS/Local) to locate data files. For tables with many snapshots or partitions these metadata files can be large, and re-parsing them on every query adds noticeable overhead. The metadata cache keeps the deserialized results in memory so that subsequent queries can reuse them without any I/O.
Settings
Query-level setting:
use_paimon_metadata_files_cacheBoolfalseServer-level settings (config.xml):
paimon_metadata_files_cache_policyStringSLRUpaimon_metadata_files_cache_sizeUInt641073741824(1 GiB)paimon_metadata_files_cache_max_entriesUInt641000paimon_metadata_files_cache_size_ratioDouble0.5Observability:
PaimonMetadataFilesCacheHitsPaimonMetadataFilesCacheMissesPaimonMetadataFilesCacheWeightLostPaimonMetadataFilesCacheBytesPaimonMetadataFilesCacheFilesExample use
Version info
26.7.1.1014(included in26.7and later)