{"record":{"id":"0f72391c9dcab131","repo":"apache/iceberg","slug":"database-connection-failed-0f7239","errorCode":null,"errorMessage":"Database Connection failed","messagePattern":"Database Connection failed","errorType":"exception","errorClass":"UncheckedSQLException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/jdbc/JdbcViewOperations.java","lineNumber":117,"sourceCode":"    try {\n      Map<String, String> view =\n          JdbcUtil.loadView(JdbcUtil.SchemaVersion.V1, connections, catalogName, viewIdentifier);\n      if (base != null) {\n        validateMetadataLocation(view, base);\n        String oldMetadataLocation = base.metadataFileLocation();\n        // Start atomic update\n        LOG.debug(\"Committing existing view: {}\", viewName());\n        updateView(newMetadataLocation, oldMetadataLocation);\n      } else {\n        // view does not exist, create it\n        LOG.debug(\"Committing new view: {}\", viewName());\n        createView(newMetadataLocation);\n      }\n\n    } catch (SQLTimeoutException e) {\n      throw new UncheckedSQLException(e, \"Database Connection timeout\");\n    } catch (SQLTransientConnectionException | SQLNonTransientConnectionException e) {\n      throw new UncheckedSQLException(e, \"Database Connection failed\");\n    } catch (DataTruncation e) {\n      throw new UncheckedSQLException(e, \"Database data truncation error\");\n    } catch (SQLWarning e) {\n      throw new UncheckedSQLException(e, \"Database warning\");\n    } catch (SQLException e) {\n      if (JdbcUtil.isConstraintViolation(e)) {\n        if (currentMetadataLocation() == null) {\n          throw new AlreadyExistsException(e, \"View already exists: %s\", viewIdentifier);\n        } else {\n          throw new UncheckedSQLException(e, \"View already exists: %s\", viewIdentifier);\n        }\n      }\n\n      throw new UncheckedSQLException(e, \"Unknown failure\");\n    } catch (InterruptedException e) {\n      Thread.currentThread().interrupt();\n      throw new UncheckedInterruptedException(e, \"Interrupted during commit\");\n    }","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/jdbc/JdbcViewOperations.java#L99-L135","documentation":"Thrown by JdbcViewOperations.doCommit when the driver raises SQLTransientConnectionException or SQLNonTransientConnectionException while committing a view — the connection to the catalog database failed. Transient variants may succeed on retry; non-transient ones usually indicate a permanent config or access problem. The commit was not applied.","triggerScenarios":"Committing a view create/update when the DB connection is dropped mid-operation, the pool can't obtain a connection, credentials are rejected, or the database is restarting.","commonSituations":"Database failover/restart during a commit, connection pool exhaustion under concurrent writers, wrong user/password, or max_connections reached on the DB server.","solutions":["Retry the operation — transient connection exceptions often resolve on their own","Check DB availability, max_connections, and the JDBC connection pool sizing","Validate credentials and network reachability (firewalls, VPC/security groups)","Inspect the wrapped SQLException cause to distinguish transient vs non-transient failure"],"exampleFix":"// before\nview.updateSchema(...); // fails if DB connection drops\n// after\nTasks.foreach(() -> view.updateSchema(...))\n    .retry(3)\n    .exponentialBackoff(100, 1000, 10000)\n    .throwFailureWhenFinished();","handlingStrategy":"retry","validationCode":"try (Connection c = DriverManager.getConnection(uri, user, pass)) {\n  Preconditions.checkArgument(c.isValid(5), \"Cannot connect to catalog DB\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  view.refresh();\n  view.updateSchema(apply);\n} catch (UncheckedSQLException e) {\n  if (e.getCause() instanceof SQLTransientConnectionException) {\n    retryWithBackoff(); // transient: safe to retry\n  } else throw e;\n}","preventionTips":["Retry transient connection exceptions with exponential backoff","Validate credentials and network paths before workloads run","Keep DB max_connections well above expected writer concurrency","Use a stable, HA database endpoint for the catalog"],"tags":["jdbc","connection","network"],"backgroundTag":"connection-refused","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}