Skip to content

Core: Make metadata refresh retries configurable in JDBC catalog - #18539

Merged
pvary merged 2 commits into
apache:mainfrom
aiborodin:jdbc-metadata-refresh-max-retries
Oct 20, 2026
Merged

pvary merged 2 commits into
apache:mainfrom
aiborodin:jdbc-metadata-refresh-max-retries

Conversation

@aiborodin

@aiborodin aiborodin commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

During a storage outage, JdbcTableOperations and JdbcViewOperations retry reading the metadata file 20 times, for up to 10 minutes, before a table or view load fails. Clients stall waiting for these retries, and in a REST catalog server backed by JdbcCatalog each stalled load also holds a request thread. This adds a jdbc.metadata-refresh-max-retries catalog property, similar to iceberg.hive.metadata-refresh-max-retries added for Hive in #3379. The default stays at 20. Each retry is a full metadata read, so the total time also depends on the FileIO's own timeouts and retries, such as http-client.apache.socket-timeout-ms and s3.retry.num-retries for S3FileIO.

Test plan: refreshing a table or a view makes max-retries + 1 metadata reads; a negative value fails catalog initialization.

@aiborodin

Copy link
Copy Markdown
Contributor Author

@pvary could you please have a look?

@pvary

pvary commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Do we want to keep this as a JDBC only config, or do we want to have the same config for every other catalog as well?

Based on this decision we either need to change the config name, or the we need to add implementation to the other catalogs.

this.fileIO = fileIO;
this.connections = dbConnPool;
this.catalogProperties = catalogProperties;
this.metadataRefreshMaxRetries = JdbcUtil.metadataRefreshMaxRetries(catalogProperties);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Shall we calculate this once for the catalog?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done. It's now parsed and validated once in JdbcCatalog.initialize() and passed to the operations classes, so a bad value fails at catalog startup. I kept the existing protected JdbcViewOperations constructor for compatibility.

*/
public static final String METADATA_REFRESH_MAX_RETRIES = "metadata-refresh.max-retries";

public static final int METADATA_REFRESH_MAX_RETRIES_DEFAULT = 20;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we want to use this default in the other places?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

With the property now JDBC-specific, the default lives in JdbcUtil. I left the 20 in the base operations classes alone so core doesn't reference a JDBC setting.


@Test
public void testMetadataRefreshMaxRetries() {
JdbcCatalog jdbcCatalog =

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we want to close these extra catalogs?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch, wrapped them in try-with-resources like the other tests here.

During a storage outage, loading a table or view retries the metadata
read 20 times for up to 10 minutes, stalling clients. Add the
jdbc.metadata-refresh-max-retries catalog property (default 20) to
bound it.
@aiborodin
aiborodin force-pushed the jdbc-metadata-refresh-max-retries branch from cb204ea to bd7c8c9 Compare October 19, 2026 06:00
@aiborodin

Copy link
Copy Markdown
Contributor Author

Do we want to keep this as a JDBC only config, or do we want to have the same config for every other catalog as well?

I'd keep it JDBC-only, following #3379, which added a Hive-specific key. Renamed it to jdbc.metadata-refresh-max-retries to match the other JDBC catalog properties (jdbc.strict-mode, jdbc.schema-version) and moved it out of CatalogProperties. A shared property for the other catalogs can be a follow-up if there's interest.

}

@Test
void metadataRefreshMaxRetries() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For now, use the same pattern as the other test in the file.

We do:

  • new test class - package private and package private test methods, and no test prefix
  • old test class - stick to the pattern used there, and only change if there only a few existing tests

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, switched back to the public void testXxx pattern used in both files.

}

@Test
void metadataRefreshMaxRetries() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Same as above.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@pvary pvary left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1 with small nits

@aiborodin

Copy link
Copy Markdown
Contributor Author

@pvary thank you for the review! All comments are addressed now ✅

@pvary
pvary merged commit e2b6212 into apache:main Oct 20, 2026
42 checks passed
@pvary

pvary commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Merged to main.
Thanks @aiborodin for the PR!

@aiborodin

Copy link
Copy Markdown
Contributor Author

Thanks @pvary for the quick review and merge!

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