[#11133] feat(iceberg): Enable table metadata cache by default and increase default capacity#11156
[#11133] feat(iceberg): Enable table metadata cache by default and increase default capacity#11156lasdf1234 wants to merge 20 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR makes Iceberg table metadata caching enabled-by-default with a larger default capacity, updates docs/catalog metadata to reflect the new defaults, and makes cache initialization tolerant of catalogs that don’t support metadata locations.
Changes:
- Set defaults for
table-metadata-cache-impl(LocalTableMetadataCache) and increase default capacity to 1000. - Change cache initialization to warn + skip (use DUMMY) when the catalog doesn’t support
SupportsMetadataLocationinstead of throwing. - Update docs and catalog property metadata; add a unit test validating the new defaults.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| iceberg/iceberg-common/src/test/java/org/apache/gravitino/iceberg/common/TestIcebergConfig.java | Adds assertions for new cache default impl/capacity. |
| iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/ops/IcebergCatalogWrapper.java | Avoids failing fast; skips metadata cache for unsupported catalogs with a warning. |
| iceberg/iceberg-common/src/main/java/org/apache/gravitino/iceberg/common/IcebergConfig.java | Defines default cache implementation + increases default capacity. |
| docs/lakehouse-iceberg-catalog.md | Documents new defaults for cache implementation and capacity. |
| docs/iceberg-rest-service.md | Documents new defaults for REST cache implementation and capacity. |
| catalogs/catalog-lakehouse-iceberg/src/main/java/org/apache/gravitino/catalog/lakehouse/iceberg/IcebergCatalogPropertiesMetadata.java | Updates catalog property defaults to match new cache defaults. |
Default table-metadata-cache-impl to LocalTableMetadataCache and raise table-metadata-cache-capacity to 1000 in IcebergConfig and docs. Co-authored-by: Cursor <cursoragent@cursor.com>
172134f to
89d3223
Compare
Keep only the table-metadata-cache-capacity default change (1000). Co-authored-by: Cursor <cursoragent@cursor.com>
Default table-metadata-cache-impl to LocalTableMetadataCache and raise table-metadata-cache-capacity to 1000 per issue apache#11133. Co-authored-by: Cursor <cursoragent@cursor.com>
…adata Assert table metadata cache defaults in TestIcebergConfig and update IcebergCatalogPropertiesMetadata to match IcebergConfig. Co-authored-by: Cursor <cursoragent@cursor.com>
…aults Assert catalog property metadata defaults align with IcebergConfig. Co-authored-by: Cursor <cursoragent@cursor.com>
|
@yuqi1129 If you have time, please take a moment to review it for me. Thank you. |
| "Table metadata cache implementation", | ||
| false /* immutable */, | ||
| null /* defaultValue */, | ||
| LocalTableMetadataCache.class.getName() /* defaultValue */, |
There was a problem hiding this comment.
I did not see this class in the PR, so has it already existed in the code? Why did we set it as default value before.
There was a problem hiding this comment.
Why didn't we set it as the default value before? Do you have some informations on this part?
There was a problem hiding this comment.
TABLE_METADATA_CACHE_IMPL has no default value, causing every default deployment to fall back to TableMetadataCache.DUMMY. Every loadTable call reads metadata.json from object storage on every request, with no caching. Latency degrades silently as commit history grows.
| |--------------------------------------------------------------|---------------------------------------------|---------------|----------|---------------| | ||
| | `gravitino.iceberg-rest.table-metadata-cache-impl` | The implement of the cache. | (none) | No | 1.1.0 | | ||
| | `gravitino.iceberg-rest.table-metadata-cache-capacity` | The capacity of table metadata cache. | 200 | No | 1.1.0 | | ||
| | `gravitino.iceberg-rest.table-metadata-cache-impl` | The implement of the cache. | `org.apache.gravitino.iceberg.common.cache.LocalTableMetadataCache` | No | 1.1.0 | |
There was a problem hiding this comment.
The formatting has been revised.
| |---------------------------------------|---------------------------------------------|---------------|----------|---------------| | ||
| | `table-metadata-cache-impl` | The implement of the cache. | (none) | No | 1.1.0 | | ||
| | `table-metadata-cache-capacity` | The capacity of table metadata cache. | 200 | No | 1.1.0 | | ||
| | `table-metadata-cache-impl` | The implement of the cache. | `org.apache.gravitino.iceberg.common.cache.LocalTableMetadataCache` | No | 1.1.0 | |
There was a problem hiding this comment.
The formatting has been revised.
| .version(ConfigConstants.VERSION_1_1_0) | ||
| .stringConf() | ||
| .create(); | ||
| .createWithDefault("org.apache.gravitino.iceberg.common.cache.LocalTableMetadataCache"); |
There was a problem hiding this comment.
Can we use LocalTableMetadataCache.class.getName() here to avoid possible class rename in the future?
…-defaults' into issue-11133-table-metadata-cache-defaults
Code Coverage Report
Files
|
RESTCatalog does not support SupportsMetadataLocation; set an empty table-metadata-cache-impl in integration tests that use REST backend. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
maintenance/jobs has no dependency on catalog-common; use the property key string instead of IcebergConstants in env IT setup. Co-authored-by: Cursor <cursoragent@cursor.com>
Use IcebergConstants in TestIcebergUpdateStatsJobWithSpark instead of a hard-coded property key so the jobs module compiles like optimizer. Co-authored-by: Cursor <cursoragent@cursor.com>
|
How to handle the consistency issue? For example, |
|
Could u check the logic? Some catalog will throws exception if you changed the default value. |
Yes,
When implementing this requirement, I have already checked this part of the logic, and only rest(hive),rest(jdbc),rest(memory) support cache.Should I explain this issue in the irc doc? |
|
Could u elaborate more about influence? Does it only influence the custom catalog? Custom catalog can't be used. This would be a breaking change. Could u avoid a breaking change? |
IRC has five backends: memory/jdbc/hive/rest/custom. Memory, jdbc and hive support table cache, while rest does not explicitly support it. Custom depends on the specific implementation. I have come up two solutions as follows: 1.Enable table cache by default. 2.Disabled table cache by default. Which is better? |
REST catalog is disable cached. Maybe we can disable the cache for the custom catalog, too. cc @jerryshao WDYT? |
|
Can you update the PR as we discussed in the morning? @lasdf1234 |
Clarify that table-metadata-cache-impl should be set to "" for REST or custom catalogs without SupportsMetadataLocation, and improve the runtime error message to point users at the config key and restart. Co-authored-by: Cursor <cursoragent@cursor.com>
Got.The instructions in the configuration have been fully updated, and the log that prompts users to modify the configuration has also been added. |
|
@roryqi The logs and doc have been added. If you have time, please review code for me.THX. |
Could u address the conflicts first? |
Resolve FlinkIcebergRestCatalogIT import conflict by keeping both IcebergConstants for REST metadata cache config and main's Flink SQL test imports. Co-authored-by: Cursor <cursoragent@cursor.com>
Got resolved |
Add IcebergCacheIT to verify REST and custom catalogs disable or enable the default metadata cache based on SupportsMetadataLocation, and fall back to DUMMY with a warning when the catalog does not support it. Co-authored-by: Cursor <cursoragent@cursor.com>
Explain that the cache is disabled because the catalog implementation does not support get metadata location. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
|
@roryqi The code has been fixed. If you have time, please take a look at it for review. |
Move custom catalog test doubles into IcebergCacheIT as inner classes. Drop maintenance/jobs test dependency on catalog-common by using the table-metadata-cache-impl property key directly in tests. Co-authored-by: Cursor <cursoragent@cursor.com>
IcebergCatalogWrapper already falls back to DUMMY when the catalog does not support metadata location. Cache behavior is covered by IcebergCacheIT. Co-authored-by: Cursor <cursoragent@cursor.com>



What changes were proposed in this pull request?
table-metadata-cache-impltoorg.apache.gravitino.iceberg.common.cache.LocalTableMetadataCacheinIcebergConfig.table-metadata-cache-capacityfrom 200 to 1000 inIcebergConfig.IcebergCatalogPropertiesMetadatadefaults withIcebergConfig.TestIcebergConfig.testTableMetadataCacheDefaultsto assert the new defaults.IcebergCatalogWrapperalready loads the configured cache implementation whentable-metadata-cache-implis set; with the new config default, deployments no longer silently fall back toTableMetadataCache.DUMMYunless the property is explicitly cleared.Why are the changes needed?
Fixes #11133
TABLE_METADATA_CACHE_IMPLhas no default today, so every deployment that does not set the property usesTableMetadataCache.DUMMYinIcebergCatalogWrapper.loadTableMetadataCacheand readsmetadata.jsonfrom object storage on everyloadTable. The default capacity of 200 is also too small for typical enterprise working sets.Does this PR introduce any user-facing change?
Yes.
table-metadata-cache-impldefaults toLocalTableMetadataCachewhen not configured.table-metadata-cache-capacitydefaults to 1000 when not configured.How was this patch tested?
./gradlew :iceberg:iceberg-common:spotlessApply :catalogs:catalog-lakehouse-iceberg:spotlessApply./gradlew :iceberg:iceberg-common:test -PskipITs -PskipDockerTests=true --tests "org.apache.gravitino.iceberg.common.TestIcebergConfig"