{"record":{"id":"135654b774a7adda","repo":"apache/iceberg","slug":"interrupted-in-call-to-listviews","errorCode":null,"errorMessage":"Interrupted in call to listViews","messagePattern":"Interrupted in call to listViews","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java","lineNumber":233,"sourceCode":"      // Retrieving the Table objects from HMS in batches to avoid OOM\n      List<TableIdentifier> filteredTableIdentifiers = Lists.newArrayList();\n      Iterable<List<String>> viewNameSets = Iterables.partition(viewNames, 100);\n\n      for (List<String> viewNameSet : viewNameSets) {\n        filteredTableIdentifiers.addAll(\n            listIcebergTables(viewNameSet, namespace, HiveOperationsBase.ICEBERG_VIEW_TYPE_VALUE));\n      }\n\n      return filteredTableIdentifiers;\n    } catch (UnknownDBException e) {\n      throw new NoSuchNamespaceException(\"Namespace does not exist: %s\", namespace);\n\n    } catch (TException e) {\n      throw new RuntimeException(\"Failed to list all views under namespace \" + namespace, e);\n\n    } catch (InterruptedException e) {\n      Thread.currentThread().interrupt();\n      throw new RuntimeException(\"Interrupted in call to listViews\", e);\n    }\n  }\n\n  @Override\n  public String name() {\n    return name;\n  }\n\n  @Override\n  public boolean dropTable(TableIdentifier identifier, boolean purge) {\n    if (!isValidIdentifier(identifier)) {\n      return false;\n    }\n\n    String database = identifier.namespace().level(0);\n\n    TableOperations ops = newTableOps(identifier);\n    TableMetadata lastMetadata = null;","sourceCodeStart":215,"sourceCodeEnd":251,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java#L215-L251","documentation":"listViews() catches InterruptedException, restores the thread's interrupt flag via Thread.currentThread().interrupt(), and rethrows as a RuntimeException with this message. It means the thread was interrupted while waiting on the Hive Metastore call.","triggerScenarios":"Calling catalog.listViews(namespace) from a thread that is interrupted (executor shutdownNow, task cancellation, Spark/Flink task kill) while the metastore RPC is in flight.","commonSituations":"Cancelling a Spark job or Flink tasklet that was enumerating views; shutting down a thread pool; query timeouts implemented via thread interruption.","solutions":["Treat the interruption as a cancellation signal: stop processing and propagate/cleanup.","Inspect the calling executor's lifecycle — why was shutdown/cancel issued.","Adjust timeout/cancellation settings if interruption is unintentional.","Never swallow InterruptedException; this code already re-interrupts, so rethrow appropriately."],"exampleFix":"// before\ntry { views = catalog.listViews(ns); } catch (RuntimeException e) { e.printStackTrace(); }\n// after\ntry {\n  views = catalog.listViews(ns);\n} catch (RuntimeException e) {\n  if (Thread.currentThread().isInterrupted() || e.getCause() instanceof InterruptedException) {\n    Thread.currentThread().interrupt();\n    throw e; // propagate cancellation\n  }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"if (Thread.currentThread().isInterrupted()) {\n  throw new InterruptedException(\"Interrupted before listing views\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  views = catalog.listViews(ns);\n} catch (RuntimeException e) {\n  if (e.getCause() instanceof InterruptedException) {\n    Thread.currentThread().interrupt();\n    throw e; // treat as cancellation\n  }\n  throw e;\n}","preventionTips":["Avoid interrupting threads during catalog cleanup; use cooperative cancellation.","Order executor shutdown so metadata operations complete before shutdownNow().","Never swallow InterruptedException without restoring the interrupt flag."],"tags":["hive-metastore","interruption","threading","views"],"backgroundTag":"thread-interrupted","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"}