Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add iceberg.jdbc-catalog.retryable-status-codes configuration property #24066

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/src/main/sphinx/object-storage/metastores.md
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,14 @@ directory.
* - `iceberg.jdbc-catalog.schema-version`
- JDBC catalog schema version.
Valid values are `V0` or `V1`. Defaults to `V1`.
* - `iceberg.jdbc-catalog.retryable-status-codes`
ebyhr marked this conversation as resolved.
Show resolved Hide resolved
- On connection error to JDBC metastore, retry if
it is one of these JDBC status codes.
Valid value is a comma-separated list of status codes.
Note: JDBC catalog always retries the following status
codes: `08000,08003,08006,08007,40001`. Specify only
additional codes (such as `57000,57P03,57P04` if using
PostgreSQL driver) here.
:::

:::{warning}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public enum SchemaVersion
private String catalogName;
private String defaultWarehouseDir;
private SchemaVersion schemaVersion = SchemaVersion.V1;
private String retryableStatusCodes;

@NotNull
public String getDriverClass()
Expand Down Expand Up @@ -134,4 +135,18 @@ public IcebergJdbcCatalogConfig setSchemaVersion(SchemaVersion schemaVersion)
this.schemaVersion = schemaVersion;
return this;
}

@NotNull
public Optional<String> getRetryableStatusCodes()
{
return Optional.ofNullable(retryableStatusCodes);
}

@Config("iceberg.jdbc-catalog.retryable-status-codes")
@ConfigDescription("On connection error to JDBC metastore, retry if it is one of these JDBC status codes")
public IcebergJdbcCatalogConfig setRetryableStatusCodes(String retryableStatusCodes)
{
this.retryableStatusCodes = retryableStatusCodes;
return this;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public TrinoJdbcCatalogFactory(
properties.put(PROPERTY_PREFIX + "schema-version", jdbcConfig.getSchemaVersion().toString());
jdbcConfig.getConnectionUser().ifPresent(user -> properties.put(PROPERTY_PREFIX + "user", user));
jdbcConfig.getConnectionPassword().ifPresent(password -> properties.put(PROPERTY_PREFIX + "password", password));
jdbcConfig.getRetryableStatusCodes().ifPresent(codes -> properties.put("retryable_status_codes", codes));
this.catalogProperties = properties.buildOrThrow();

this.clientPool = new JdbcClientPool(jdbcConfig.getConnectionUrl(), catalogProperties);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public void testDefaults()
.setConnectionPassword(null)
.setCatalogName(null)
.setDefaultWarehouseDir(null)
.setRetryableStatusCodes(null)
.setSchemaVersion(SchemaVersion.V1));
}

Expand All @@ -48,6 +49,7 @@ public void testExplicitPropertyMappings()
.put("iceberg.jdbc-catalog.connection-password", "bar")
.put("iceberg.jdbc-catalog.catalog-name", "test")
.put("iceberg.jdbc-catalog.default-warehouse-dir", "s3://bucket")
.put("iceberg.jdbc-catalog.retryable-status-codes", "57P01,57P05")
.put("iceberg.jdbc-catalog.schema-version", "V0")
.buildOrThrow();

Expand All @@ -58,6 +60,7 @@ public void testExplicitPropertyMappings()
.setConnectionPassword("bar")
.setCatalogName("test")
.setDefaultWarehouseDir("s3://bucket")
.setRetryableStatusCodes("57P01,57P05")
.setSchemaVersion(SchemaVersion.V0);

assertFullMapping(properties, expected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ protected QueryRunner createQueryRunner()
.put("iceberg.register-table-procedure.enabled", "true")
.put("iceberg.writer-sort-buffer-size", "1MB")
.put("iceberg.jdbc-catalog.default-warehouse-dir", warehouseLocation.getAbsolutePath())
.put("iceberg.jdbc-catalog.retryable-status-codes", "57P01,57P05")
.buildOrThrow())
.setInitialTables(REQUIRED_TPCH_TABLES)
.build();
Expand Down
Loading