{"record":{"id":"7120878c80dd5caf","repo":"apache/iceberg","slug":"interrupted-in-sql-query","errorCode":null,"errorMessage":"Interrupted in SQL query","messagePattern":"Interrupted in SQL query","errorType":"exception","errorClass":"UncheckedInterruptedException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java","lineNumber":816,"sourceCode":"            try (PreparedStatement preparedStatement = conn.prepareStatement(sql)) {\n              for (int pos = 0; pos < args.length; pos += 1) {\n                preparedStatement.setString(pos + 1, args[pos]);\n              }\n\n              try (ResultSet rs = preparedStatement.executeQuery()) {\n                while (rs.next()) {\n                  result.add(toRow.apply(rs));\n                }\n              }\n            }\n\n            return result;\n          });\n    } catch (SQLException e) {\n      throw new UncheckedSQLException(e, \"Failed to execute query: %s\", sql);\n    } catch (InterruptedException e) {\n      Thread.currentThread().interrupt();\n      throw new UncheckedInterruptedException(e, \"Interrupted in SQL query\");\n    }\n  }\n\n  private Map<String, String> fetchProperties(Namespace namespace) {\n    if (!namespaceExists(namespace)) {\n      throw new NoSuchNamespaceException(\"Namespace does not exist: %s\", namespace);\n    }\n\n    String namespaceName = JdbcUtil.namespaceToString(namespace);\n\n    List<Map.Entry<String, String>> entries =\n        fetch(\n            row ->\n                new AbstractMap.SimpleImmutableEntry<>(\n                    row.getString(JdbcUtil.NAMESPACE_PROPERTY_KEY),\n                    row.getString(JdbcUtil.NAMESPACE_PROPERTY_VALUE)),\n            JdbcUtil.GET_ALL_NAMESPACE_PROPERTIES_SQL,\n            catalogName,","sourceCodeStart":798,"sourceCodeEnd":834,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java#L798-L834","documentation":"fetch() catches InterruptedException while running catalog queries and throws UncheckedInterruptedException with \"Interrupted in SQL query\" after restoring the thread's interrupt flag. The thread was signalled to stop while a catalog read (list/entries) was executing.","triggerScenarios":"Thread interrupt during listTables/listNamespaces/listViews/entries: executor shutdown, task cancellation, or timeout watchdogs interrupting a blocked JDBC read.","commonSituations":"Graceful shutdown racing background catalog scans; Spark task preemption; interruptible connection-statement timeouts firing mid-query.","solutions":["Do not interrupt threads performing catalog reads; cancel at a higher level","Restore and honor the interrupt flag (the catalog already sets it) and stop processing","Increase timeouts so watchdogs do not interrupt slow queries","Retry the read from a fresh, non-interrupted thread if the operation is safe to repeat"],"exampleFix":"// before\nList<Namespace> ns = catalog.listNamespaces();\n// after\ntry {\n  List<Namespace> ns = catalog.listNamespaces();\n} catch (UncheckedInterruptedException e) {\n  Thread.currentThread().interrupt();\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  List<Namespace> namespaces = catalog.listNamespaces();\n} catch (UncheckedInterruptedException e) {\n  Thread.currentThread().interrupt();\n  throw e; // stop processing; thread was asked to cancel\n}","preventionTips":["Honor the interrupt flag — the catalog restores it; do not swallow it","Avoid interrupt-based timeouts around catalog reads","Cancel background scans cooperatively instead of via Thread.interrupt","Keep queries fast with proper indexes on catalog tables"],"tags":["jdbc","interrupt","concurrency","query"],"backgroundTag":"request-timeout","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"}