Skip to content

[core] Cache catalog tag lookups across native reads - #1565

Open
XiaoHongbo-Hope wants to merge 1 commit into
apache:mainfrom
XiaoHongbo-Hope:fix/caching-catalog-tags
Open

XiaoHongbo-Hope wants to merge 1 commit into
apache:mainfrom
XiaoHongbo-Hope:fix/caching-catalog-tags

Conversation

@XiaoHongbo-Hope

@XiaoHongbo-Hope XiaoHongbo-Hope commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Closes #1564.

Repeated native reads with scan.tag-name resolve the same REST tag during planning/reading, even when callers reuse a table. Add an opt-in CachingCatalog so those reads can reuse successful GetTag responses. The native bridge regression performs three scans of the same tagged table and asserts a single GetTag HTTP request with identical returned rows.

Brief change log

  • Add CachingCatalog, delegating other operations and sharing its bounded tag cache with REST-backed tables returned by get_table / load_table.
  • Wire REST CatalogFactory, the Python context shortcut, and Table.from_rest_response. The latter retains a table-scoped cache because the Python bridge can bypass CatalogFactory.
  • Coalesce concurrent loads for a key; cache only successful responses; keep failed/cancelled loads retryable. Invalidation detaches in-flight entries so old loads cannot repopulate the cache.
  • Invalidate conservatively around catalog mutations, including cancellation, and expose Catalog::invalidate_table with a default no-op implementation.
  • Enable with catalog options cache.enabled=true, cache.expire-after-write=1 min, and cache.tag.max-num=1024. Caching defaults to disabled; zero TTL or capacity also disables it.

Keys include database, table, branch and tag and are scoped to a catalog instance. External mutations may remain unseen until expiration. This does not pin a read view, extend snapshot retention, or cache GetTable/query authorization. Existing behavior remains unchanged with caching disabled.

Tests

  • cargo test -p paimon --lib catalog::caching_catalog::tests: 5 passed.
  • cargo test -p paimon --test rest_catalog_test tag: 9 passed, including four new cache integration tests and existing lifecycle/authorization tests.
  • cargo clippy -p paimon --lib -- -D warnings: passed.
  • cargo fmt --all -- --check and git diff --check: passed.
  • cargo check -p pypaimon_rust with PYO3_PYTHON pointing to Python 3.11: passed.

The complete workspace test suite has not been run locally.

API and Format

Adds the Rust CachingCatalog wrapper and a default Catalog::invalidate_table hook. No storage format changes or Python pin API.

Documentation

Document configuration, native table reuse, expiration/invalidation, and retention/freshness boundaries in the Python binding guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Cache repeated REST GetTag lookups across native reads

1 participant