{"record":{"id":"8612e7b5da6191e3","repo":"apache/iceberg","slug":"interrupted-during-refresh-8612e7","errorCode":null,"errorMessage":"Interrupted during refresh","messagePattern":"Interrupted during refresh","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hive-metastore/src/main/java/org/apache/iceberg/hive/HiveViewOperations.java","lineNumber":112,"sourceCode":"      // Check if we are trying to load an Iceberg Table as a View\n      HiveOperationsBase.validateIcebergTableNotLoadedAsIcebergView(table, fullName);\n      // Check if it is a valid Iceberg View\n      HiveOperationsBase.validateTableIsIcebergView(table, fullName);\n\n      metadataLocation =\n          table.getParameters().get(BaseMetastoreTableOperations.METADATA_LOCATION_PROP);\n\n    } catch (NoSuchObjectException e) {\n      if (currentMetadataLocation() != null) {\n        throw new NoSuchViewException(\"View does not exist: %s.%s\", database, viewName);\n      }\n    } catch (TException e) {\n      String errMsg =\n          String.format(\"Failed to get view info from metastore %s.%s\", database, viewName);\n      throw new RuntimeException(errMsg, e);\n    } catch (InterruptedException e) {\n      Thread.currentThread().interrupt();\n      throw new RuntimeException(\"Interrupted during refresh\", e);\n    }\n\n    refreshFromMetadataLocation(metadataLocation);\n  }\n\n  @SuppressWarnings(\"checkstyle:CyclomaticComplexity\")\n  @Override\n  public void doCommit(ViewMetadata base, ViewMetadata metadata) {\n    boolean newView = base == null;\n    String newMetadataLocation = writeNewMetadataIfRequired(metadata);\n    boolean hiveEngineEnabled = false;\n\n    CommitStatus commitStatus = CommitStatus.FAILURE;\n    boolean updateHiveView = false;\n\n    HiveLock lock = lockObject();\n    try {\n      lock.lock();","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveViewOperations.java#L94-L130","documentation":"HiveViewOperations.doRefresh catches InterruptedException from the metastore RPC, restores the thread's interrupt flag, and throws a RuntimeException. This means the thread waiting on the HMS view fetch was interrupted (e.g., task cancellation or shutdown), and the refresh did not complete.","triggerScenarios":"Refreshing a Hive view while the executing thread is interrupted — e.g., Spark task cancellation, executor shutdown, query kill, or application stop during the HMS getView call.","commonSituations":"Cancelling a long-running Spark/Flink job; cluster node decommissioning; timeout-based cancellation frameworks interrupting blocked thrift calls.","solutions":["Inspect why the thread was interrupted (job cancellation, shutdown hook) and re-run the operation in a live thread if the work should continue.","If intentional shutdown, treat this as expected cleanup; do not suppress the interrupt flag (the code already re-sets it).","Add retry logic around refresh only when the interruption was spurious and cancellation is not in progress.","Increase cancellation grace periods in your engine so refreshes finish or are cancelled cleanly."],"exampleFix":"// before\nview.refresh(); // RuntimeException(\"Interrupted during refresh\") on cancel\n// after\ntry {\n  view.refresh();\n} catch (RuntimeException e) {\n  if (Thread.currentThread().isInterrupted()) { /* honoring cancel; abort */ return; }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"if (Thread.currentThread().isInterrupted()) {\n  throw new IllegalStateException(\"Thread already interrupted; skipping view refresh\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  view.refresh();\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Interrupted during refresh\")) {\n    // cancellation in progress: abort cleanly; interrupt flag is already restored\n    return;\n  }\n  throw e;\n}","preventionTips":["Avoid interrupting worker threads during metastore calls unless cancelling intentionally.","Configure adequate cancellation grace periods in Spark/Flink.","Check Thread.interrupted() before long-running metastore operations.","Treat this exception as cancellation, not a data error."],"tags":["hive-metastore","interrupt","threading","view"],"backgroundTag":"request-timeout","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}