Skip to content

Flink: Reuse loaded Catalog in TableSerializerCache instead of reloading per cache miss (cherry-pick apache/iceberg#17437) - #14

Merged
nickwu241 merged 2 commits into
1.11.0-affirm-patchfrom
nick/cherry-pick-17437-tableserializercache-leak
Sep 25, 2026
Merged

nickwu241 merged 2 commits into
1.11.0-affirm-patchfrom
nick/cherry-pick-17437-tableserializercache-leak

Conversation

@nickwu241

Copy link
Copy Markdown
Member

What

TableSerializerCache.SerializerInfo.update() calls catalogLoader.loadCatalog().loadTable(...) on every cache miss. CatalogLoader.loadCatalog() reflectively instantiates a new Catalog and calls initialize() — for REST catalogs, RESTSessionCatalog.initialize() builds and stores a real HTTPClient (connection pool) that this path never closes.

Why this matters for us

replication-kt's DynamicIcebergSink.forInput(...).catalogLoader(CatalogBuilders.polarisCatalogLoader()) (all 3 apps) hits this cache-miss path on every schema-evolution event — a real, recurring trigger, not theoretical. Each miss leaks one REST HTTP client/connection pool, accumulating over a long-running job's life. Pre-existing on master/1.10.2 today — flagged by dcagney reviewing all-the-things#222721.

Fix

Cache the loaded Catalog and reuse it instead of reloading on every miss.

…ing per cache miss

catalogLoader.loadCatalog().loadTable(...) reflectively instantiates a new Catalog
and calls initialize() on every cache miss. For REST catalogs this builds and stores
a real HTTPClient (connection pool) that's never closed, leaking one HTTP client per
schema-evolution event on a long-running job. Cache and reuse the loaded Catalog for
the serializer's lifetime instead.

Cherry-picked from apache#17437.
Cherry-picked from apache#17590, a real, already-merged upstream v2.0/v1.20
backport of apache#17437 — not a from-scratch port.
@dcagney

dcagney commented Sep 25, 2026

Copy link
Copy Markdown

it looks like this may have merged or rebased rather than cherry-picking, its showing a 3000+ file diff

@nickwu241
nickwu241 changed the base branch from main to 1.11.0-affirm-patch September 25, 2026 15:32
@nickwu241

nickwu241 commented Sep 25, 2026 •

Copy link
Copy Markdown
Member Author

it looks like this may have merged or rebased rather than cherry-picking, its showing a 3000+ file diff

Fixed now. Was pointing at main instead of 1.11.0-affirm-patch
nickwu241 changed the base branch from main to 1.11.0-affirm-patch (#14 (comment))

@dcagney dcagney left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approving — diff matches upstream apache#17437 + backport apache#17590 byte-for-byte across flink/v1.20, v2.0, v2.1 (v2.0 compared against upstream's historical pre-fix state, since that module has since been dropped upstream — expected, not drift).

Checked specifically for hidden dependency on unbackported upstream work: CatalogLoader, RESTSessionCatalog, and the serializer duplicate()/snapshot-restore contracts this fix touches are all unmodified between the relevant upstream commits and current HEAD — no missing prerequisite.

LGTM.

@nickwu241
nickwu241 merged commit e49f8c0 into 1.11.0-affirm-patch Sep 25, 2026
43 of 55 checks passed
nickwu241 added a commit that referenced this pull request Sep 25, 2026
Bumps version.txt and adds the AFFIRM_VERSIONS.md changelog entry for the next
patch release, covering the 3 review-triggered fixes from all-the-things#222721
(#12/#13/#14). Those PRs are open, not yet merged — rebase this branch onto
1.11.0-affirm-patch once they land, then tag 1.11.0-affirm-patch.2 at the
resulting commit and publish per RUNBOOK_ICEBERG_PATCH_PUBLISH.md.
nickwu241 added a commit that referenced this pull request Sep 25, 2026
* Document and stage 1.11.0-affirm-patch.2

Bumps version.txt and adds the AFFIRM_VERSIONS.md changelog entry for the next
patch release, covering the 3 review-triggered fixes from all-the-things#222721
(#12/#13/#14). Those PRs are open, not yet merged — rebase this branch onto
1.11.0-affirm-patch once they land, then tag 1.11.0-affirm-patch.2 at the
resulting commit and publish per RUNBOOK_ICEBERG_PATCH_PUBLISH.md.

* Update AFFIRM_VERSIONS.md: base off 1.11.0-affirm-patch.1, drop reviewer names

* Drop #10/#11 from .2 table (already covered by .1 base)

* Note #12/#13/#14 merged and branch rebased; ready to tag

* Drop 'not yet published' framing now that .2 contents are final

* Drop trailing note from .2 section to match .1 format
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants