{"record":{"id":"c323116642bf67c3","repo":"apache/iceberg","slug":"interrupted-during-refresh-c32311","errorCode":null,"errorMessage":"Interrupted during refresh","messagePattern":"Interrupted during refresh","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"warning","filePath":"hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java","lineNumber":203,"sourceCode":"      (e.g. metadata json file) that can be tampered with. For example, an attacker can remove\n      the table key parameter (along with existing snapshots) in the file, making the writers\n      produce unencrypted files. Table key ID is taken directly from HMS catalog */\n      tableKeyIdFromHMS = table.getParameters().get(TableProperties.ENCRYPTION_TABLE_KEY);\n      dekLengthFromHMS = table.getParameters().get(TableProperties.ENCRYPTION_DEK_LENGTH);\n      metadataHashFromHMS = table.getParameters().get(METADATA_HASH_PROP);\n    } catch (NoSuchObjectException e) {\n      if (currentMetadataLocation() != null) {\n        throw new NoSuchTableException(\"No such table: %s.%s\", database, tableName);\n      }\n\n    } catch (TException e) {\n      String errMsg =\n          String.format(\"Failed to get table info from metastore %s.%s\", database, tableName);\n      throw new RuntimeException(errMsg, e);\n\n    } catch (InterruptedException e) {\n      Thread.currentThread().interrupt();\n      throw new RuntimeException(\"Interrupted during refresh\", e);\n    }\n\n    refreshFromMetadataLocation(metadataLocation, metadataRefreshMaxRetries);\n\n    if (tableKeyIdFromHMS != null) {\n      checkIntegrityForEncryption(tableKeyIdFromHMS, dekLengthFromHMS, metadataHashFromHMS);\n\n      tableKeyId = tableKeyIdFromHMS;\n      encryptionDekLength =\n          (dekLengthFromHMS != null)\n              ? Integer.parseInt(dekLengthFromHMS)\n              : TableProperties.ENCRYPTION_DEK_LENGTH_DEFAULT;\n\n      encryptedKeys =\n          Optional.ofNullable(current().encryptionKeys())\n              .map(Lists::newLinkedList)\n              .orElseGet(Lists::newLinkedList);\n","sourceCodeStart":185,"sourceCodeEnd":221,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveTableOperations.java#L185-L221","documentation":"HiveTableOperations.doRefresh catches InterruptedException, restores the thread's interrupt flag, and rethrows as RuntimeException 'Interrupted during refresh'. The refresh was cancelled while waiting on the metastore call, typically during shutdown or task cancellation.","triggerScenarios":"Thread interrupted while inside the HMS client call in doRefresh — e.g. executor shutdown, Spark task kill, or query cancellation during table refresh.","commonSituations":"Cancelling a Spark/Flink job; application shutdown while a catalog refresh is in flight; timeouts that interrupt worker threads.","solutions":["Treat it as cancellation: let the job terminate; restart if the operation must complete.","Avoid interrupting threads during catalog operations, or retry the full operation after re-establishing context.","The interrupt flag is restored, so keep propagation intact — do not swallow it in surrounding code."],"exampleFix":"// before\ntry { table.refresh(); } catch (RuntimeException e) { /* ignore */ } // swallows interruption\n// after\ntry { table.refresh(); } catch (RuntimeException e) { if (Thread.currentThread().isInterrupted()) throw e; }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { table.refresh(); } catch (RuntimeException e) { if (Thread.currentThread().isInterrupted()) { /* cancellation path: stop work */ return; } throw e; }","preventionTips":["Avoid cancelling jobs mid-refresh; drain gracefully.","Keep interrupt propagation intact in wrapper code.","Shut down executors with adequate grace periods."],"tags":["interruption","hive-metastore","refresh"],"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"}