Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.NotThreadSafe;

import java.io.FileNotFoundException;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -400,6 +401,7 @@ private void refreshFromMetadataLocation(String newLocation)
try {
Tasks.foreach(newLocation)
.retry(config.getTableRefreshRetries())
.shouldRetryTest(this::shouldRetry)
.exponentialBackoff(
config.getTableRefreshBackoffMinSleepTime().toMillis(),
config.getTableRefreshBackoffMaxSleepTime().toMillis(),
Expand Down Expand Up @@ -428,6 +430,11 @@ private void refreshFromMetadataLocation(String newLocation)
shouldRefresh = false;
}

private boolean shouldRetry(Exception exception)
{
return !(exception.getCause() instanceof FileNotFoundException);
}

private static String newTableMetadataFilePath(TableMetadata meta, int newVersion)
{
String codec = meta.property(METADATA_COMPRESSION, METADATA_COMPRESSION_DEFAULT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
public class TestIcebergMetadataListing
extends AbstractTestQueryFramework
{
private static final int TEST_TIMEOUT = 10_000;
@Override
protected QueryRunner createQueryRunner()
throws Exception
Expand All @@ -61,7 +62,7 @@ protected QueryRunner createQueryRunner()
Map<String, String> icebergProperties = ImmutableMap.<String, String>builder()
.put("hive.metastore", "file")
.put("hive.metastore.catalog.dir", catalogDirectory.toFile().toURI().toString())
.put("iceberg.hive.table-refresh.max-retry-time", "500ms") // improves test time for testTableDropWithMissingMetadata
.put("iceberg.hive.table-refresh.max-retry-time", "20s") // improves test time for testTableDropWithMissingMetadata
.build();

queryRunner.createCatalog(ICEBERG_CATALOG, "iceberg", icebergProperties);
Expand Down Expand Up @@ -120,7 +121,12 @@ public void testTableDescribing()
assertQuery("DESCRIBE iceberg.test_schema.iceberg_table1", "VALUES ('_string', 'varchar', '', ''), ('_integer', 'integer', '', '')");
}

@Test
/*
* The property iceberg.hive.table-refresh.max-retry-time is important for controlling the maximum retry duration
* when refreshing Iceberg table metadata. If this test fails, check the refreshFromMetadataLocation method
* in HiveTableOperations.
*/
@Test (timeOut = TEST_TIMEOUT)
Comment thread
dmariamgeorge marked this conversation as resolved.
public void testTableDropWithMissingMetadata()
{
assertQuerySucceeds("CREATE SCHEMA hive.test_metadata_schema");
Expand Down