From b575786237f3cfda0921a3ac45ff5701b9d4a046 Mon Sep 17 00:00:00 2001 From: kanthi subramanian Date: Tue, 12 May 2026 12:14:16 -0500 Subject: [PATCH 1/2] Added logs to display catalog backend(etcd/sqlite) and timeout for etcd. --- .../com/altinity/ice/rest/catalog/Main.java | 8 +++ .../catalog/internal/etcd/EtcdCatalog.java | 50 ++++++++++++++++--- 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/ice-rest-catalog/src/main/java/com/altinity/ice/rest/catalog/Main.java b/ice-rest-catalog/src/main/java/com/altinity/ice/rest/catalog/Main.java index 4d94eff7..0a1e63b2 100644 --- a/ice-rest-catalog/src/main/java/com/altinity/ice/rest/catalog/Main.java +++ b/ice-rest-catalog/src/main/java/com/altinity/ice/rest/catalog/Main.java @@ -534,8 +534,16 @@ private Catalog loadCatalog(Config config, Map icebergConfig) th Catalog catalog; if (EtcdCatalog.class.getName().equals(catalogImpl)) { catalog = newEctdCatalog(catalogName, icebergConfig); + logger.info("Catalog backend: etcd"); } else { catalog = CatalogUtil.buildIcebergCatalog(catalogName, icebergConfig, null); + String uri = icebergConfig.getOrDefault(CatalogProperties.URI, ""); + if (uri.toLowerCase().startsWith("jdbc:sqlite:")) { + logger.warn( + "Catalog backend: SQLite ({}); not recommended for production use", uri); + } else { + logger.info("Catalog backend: {} ({})", catalogImpl, uri); + } } return catalog; } diff --git a/ice-rest-catalog/src/main/java/com/altinity/ice/rest/catalog/internal/etcd/EtcdCatalog.java b/ice-rest-catalog/src/main/java/com/altinity/ice/rest/catalog/internal/etcd/EtcdCatalog.java index 11c49473..7a50e704 100644 --- a/ice-rest-catalog/src/main/java/com/altinity/ice/rest/catalog/internal/etcd/EtcdCatalog.java +++ b/ice-rest-catalog/src/main/java/com/altinity/ice/rest/catalog/internal/etcd/EtcdCatalog.java @@ -34,6 +34,8 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ExecutionException; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; import org.apache.iceberg.BaseMetastoreCatalog; import org.apache.iceberg.BaseMetastoreTableOperations; import org.apache.iceberg.CatalogUtil; @@ -61,6 +63,8 @@ public class EtcdCatalog extends BaseMetastoreCatalog implements SupportsNamespa private static final Logger logger = LoggerFactory.getLogger(EtcdCatalog.class); + private static final long DEFAULT_TIMEOUT_SECONDS = 30; + private static final String NAMESPACE_PREFIX = "n/"; private static final String TABLE_PREFIX = "t/"; @@ -79,6 +83,29 @@ public EtcdCatalog(String name, String uri, String warehouseLocation, FileIO io) Client.builder().endpoints(uri.split(",")).keepaliveWithoutCalls(false).build(); this.client = etcdClient; this.kv = etcdClient.getKVClient(); + try { + kv.get(ByteSequence.from("/", StandardCharsets.UTF_8)) + .get(DEFAULT_TIMEOUT_SECONDS, TimeUnit.SECONDS); + logger.info("Connected to etcd at {}", uri); + } catch (TimeoutException e) { + throw new RuntimeIOException( + new IOException( + "Failed to connect to etcd at " + + uri + + ": timed out after " + + DEFAULT_TIMEOUT_SECONDS + + "s", + e)); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new RuntimeIOException( + new IOException("Interrupted connecting to etcd at " + uri, e)); + } catch (ExecutionException e) { + Throwable cause = e.getCause() != null ? e.getCause() : e; + throw new RuntimeIOException( + new IOException( + "Failed to connect to etcd at " + uri + ": " + cause.getMessage(), cause)); + } this.io = io; } @@ -145,19 +172,30 @@ private String namespacePrefix() { private static T unwrapCommit(java.util.concurrent.CompletableFuture x) { try { - return x.get(); - } catch (InterruptedException | ExecutionException e) { - // TODO: Thread.currentThread().interrupt();? + return x.get(DEFAULT_TIMEOUT_SECONDS, TimeUnit.SECONDS); + } catch (TimeoutException e) { + throw new CommitStateUnknownException( + new IOException("etcd commit timed out after " + DEFAULT_TIMEOUT_SECONDS + "s", e)); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new CommitStateUnknownException(e); + } catch (ExecutionException e) { throw new CommitStateUnknownException(e); } } private static T unwrap(java.util.concurrent.CompletableFuture x) { try { - return x.get(); - } catch (InterruptedException | ExecutionException e) { - // TODO: Thread.currentThread().interrupt();? + return x.get(DEFAULT_TIMEOUT_SECONDS, TimeUnit.SECONDS); + } catch (TimeoutException e) { + throw new RuntimeIOException( + new IOException("etcd request timed out after " + DEFAULT_TIMEOUT_SECONDS + "s", e)); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); throw new RuntimeIOException(new IOException(e)); + } catch (ExecutionException e) { + Throwable cause = e.getCause() != null ? e.getCause() : e; + throw new RuntimeIOException(new IOException(cause.getMessage(), cause)); } } From 904e6ec8f999e100078c4ad2abedca9eec28d95e Mon Sep 17 00:00:00 2001 From: kanthi subramanian Date: Tue, 12 May 2026 14:34:47 -0500 Subject: [PATCH 2/2] Fixed lint errors --- .../src/main/java/com/altinity/ice/rest/catalog/Main.java | 3 +-- .../altinity/ice/rest/catalog/internal/etcd/EtcdCatalog.java | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ice-rest-catalog/src/main/java/com/altinity/ice/rest/catalog/Main.java b/ice-rest-catalog/src/main/java/com/altinity/ice/rest/catalog/Main.java index 0a1e63b2..bec382ff 100644 --- a/ice-rest-catalog/src/main/java/com/altinity/ice/rest/catalog/Main.java +++ b/ice-rest-catalog/src/main/java/com/altinity/ice/rest/catalog/Main.java @@ -539,8 +539,7 @@ private Catalog loadCatalog(Config config, Map icebergConfig) th catalog = CatalogUtil.buildIcebergCatalog(catalogName, icebergConfig, null); String uri = icebergConfig.getOrDefault(CatalogProperties.URI, ""); if (uri.toLowerCase().startsWith("jdbc:sqlite:")) { - logger.warn( - "Catalog backend: SQLite ({}); not recommended for production use", uri); + logger.warn("Catalog backend: SQLite ({}); not recommended for production use", uri); } else { logger.info("Catalog backend: {} ({})", catalogImpl, uri); } diff --git a/ice-rest-catalog/src/main/java/com/altinity/ice/rest/catalog/internal/etcd/EtcdCatalog.java b/ice-rest-catalog/src/main/java/com/altinity/ice/rest/catalog/internal/etcd/EtcdCatalog.java index 7a50e704..5d3a5450 100644 --- a/ice-rest-catalog/src/main/java/com/altinity/ice/rest/catalog/internal/etcd/EtcdCatalog.java +++ b/ice-rest-catalog/src/main/java/com/altinity/ice/rest/catalog/internal/etcd/EtcdCatalog.java @@ -98,8 +98,7 @@ public EtcdCatalog(String name, String uri, String warehouseLocation, FileIO io) e)); } catch (InterruptedException e) { Thread.currentThread().interrupt(); - throw new RuntimeIOException( - new IOException("Interrupted connecting to etcd at " + uri, e)); + throw new RuntimeIOException(new IOException("Interrupted connecting to etcd at " + uri, e)); } catch (ExecutionException e) { Throwable cause = e.getCause() != null ? e.getCause() : e; throw new RuntimeIOException(