Skip to content

Commit

Permalink
Don't retry table metadata read when cause is FileNotFoundException
Browse files Browse the repository at this point in the history
  • Loading branch information
krvikash authored and findepi committed Apr 11, 2023
1 parent f520212 commit 20841a6
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import javax.annotation.Nullable;
import javax.annotation.concurrent.NotThreadSafe;

import java.io.FileNotFoundException;
import java.time.Duration;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -230,8 +231,8 @@ protected void refreshFromMetadataLocation(String newLocation)
.withMaxRetries(20)
.withBackoff(100, 5000, MILLIS, 4.0)
.withMaxDuration(Duration.ofMinutes(10))
.abortOn(org.apache.iceberg.exceptions.NotFoundException.class)
.build()) // qualified name, as this is NOT the io.trino.spi.connector.NotFoundException
.abortOn(AbstractIcebergTableOperations::isNotFoundException)
.build())
.get(() -> TableMetadataParser.read(fileIo, io().newInputFile(newLocation)));

String newUUID = newMetadata.uuid();
Expand All @@ -246,6 +247,14 @@ protected void refreshFromMetadataLocation(String newLocation)
shouldRefresh = false;
}

private static boolean isNotFoundException(Throwable failure)
{
// qualified name, as this is NOT the io.trino.spi.connector.NotFoundException
return failure instanceof org.apache.iceberg.exceptions.NotFoundException ||
// This is used in context where the code cannot throw a checked exception, so FileNotFoundException would need to be wrapped
failure.getCause() instanceof FileNotFoundException;
}

protected static String newTableMetadataFilePath(TableMetadata meta, int newVersion)
{
String codec = meta.property(METADATA_COMPRESSION, METADATA_COMPRESSION_DEFAULT);
Expand Down

0 comments on commit 20841a6

Please sign in to comment.