Skip to content

[BugFix] Bound and expose the Iceberg partition cache memory (backport #76165)#76181

Merged
wanpengfei-git merged 1 commit into
branch-4.0from
mergify/bp/branch-4.0/pr-76165
Jul 10, 2026
Merged

[BugFix] Bound and expose the Iceberg partition cache memory (backport #76165)#76181
wanpengfei-git merged 1 commit into
branch-4.0from
mergify/bp/branch-4.0/pr-76165

Conversation

@mergify

@mergify mergify Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Why I'm doing:

CachingIcebergCatalog's partition cache stores one whole-table partition map (Map<String, Partition>) per entry, but was bounded only by entry count (maximumSize), not bytes. A handful of tables with many partitions (a table can have millions) can therefore grow it without limit. It is also the only metadata cache left out of estimateSize(), so its footprint is invisible in /api/memory_usage and the minute-level memory logs.

This is a real growth path, not a corner case: materialized views over Iceberg tables track base-table partitions, so MV rewrite/refresh populates the partition cache across many base tables.

Alongside it, the auxiliary maps tableLatestAccessTime / tableLatestRefreshTime / tableRefreshLockMap were likewise absent from estimateSize().

What I'm doing:

  • Add a weigher + maximumWeight bound to the partition cache, sized by a new catalog property iceberg_partition_cache_memory_usage_ratio (default 0.1), mirroring the data/delete/table file caches. The weigher samples the partition values (sample size 3) so weighing stays cheap on large maps.
  • Include the partition cache and the three auxiliary maps in estimateSize(), so their bytes are reported. This benefits from the recently merged Estimator container-overhead fix ([BugFix] Count container node/table overhead in memory Estimator #75971), which makes the estimate accurate.

Fixes #issue: N/A — FE memory-safety/observability fix for the Iceberg partition cache (no separate tracking issue).

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

New catalog property iceberg_partition_cache_memory_usage_ratio (default 0.1). The partition cache is now bounded by memory weight instead of a fixed 100k entry count, so under memory pressure it may hold fewer entries than before; the ratio is tunable and can be raised to restore the previous footprint.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
    • This pr needs auto generate documentation
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 4.1
    • 4.0
    • 3.5

This is an automatic backport of pull request #76165 done by [Mergify](https://mergify.com).

@mergify mergify Bot added the conflicts label Jul 10, 2026
@mergify

mergify Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Cherry-pick of 893d888 has failed:

On branch mergify/bp/branch-4.0/pr-76165
Your branch is up to date with 'origin/branch-4.0'.

You are currently cherry-picking commit 893d888783.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --skip" to skip this patch)
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Changes to be committed:
	modified:   fe/fe-core/src/main/java/com/starrocks/connector/iceberg/IcebergCatalogProperties.java
	modified:   fe/fe-core/src/test/java/com/starrocks/connector/iceberg/CachingIcebergCatalogTest.java

Unmerged paths:
  (use "git add <file>..." to mark resolution)
	both modified:   fe/fe-core/src/main/java/com/starrocks/connector/iceberg/CachingIcebergCatalog.java

To fix up this pull request, you can check it out locally. See documentation: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/reviewing-changes-in-pull-requests/checking-out-pull-requests-locally

@wanpengfei-git wanpengfei-git enabled auto-merge (squash) July 10, 2026 06:16
@mergify mergify Bot closed this Jul 10, 2026
auto-merge was automatically disabled July 10, 2026 06:17

Pull request was closed

@mergify

mergify Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

@mergify[bot]: Backport conflict, please reslove the conflict and resubmit the pr

@Youngwb Youngwb reopened this Jul 10, 2026
@wanpengfei-git wanpengfei-git enabled auto-merge (squash) July 10, 2026 06:23
Signed-off-by: Youngwb <yangwenbo_mailbox@163.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
(cherry picked from commit 893d888)

# Conflicts:
#	fe/fe-core/src/main/java/com/starrocks/connector/iceberg/CachingIcebergCatalog.java
@Youngwb Youngwb force-pushed the mergify/bp/branch-4.0/pr-76165 branch from b9e34a8 to 2b8666c Compare July 10, 2026 06:44
@wanpengfei-git wanpengfei-git merged commit b263bc5 into branch-4.0 Jul 10, 2026
31 checks passed
@wanpengfei-git wanpengfei-git deleted the mergify/bp/branch-4.0/pr-76165 branch July 10, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants