{"record":{"id":"be67f088969efe90","repo":"apache/hadoop","slug":"thread-interrupted-during-retry","errorCode":null,"errorMessage":"Thread interrupted during retry","messagePattern":"Thread interrupted during retry","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"warning","filePath":"hadoop-cloud-storage-project/hadoop-bos/src/main/java/org/apache/hadoop/fs/bos/BosInputStream.java","lineNumber":222,"sourceCode":"        } catch (Exception ex) {\n          if (retry <= 0) {\n            String errorMsg =\n                ex.getMessage() != null\n                    ? ex.getMessage()\n                    : ex.getClass().getSimpleName();\n            throw new IOException(\n                \"Retry \" + retry\n                    + \" times to read still\"\n                    + \" exception: \" + errorMsg,\n                ex);\n          }\n\n          try {\n            TimeUnit.SECONDS.sleep(\n                intervalSeconds);\n          } catch (InterruptedException ite) {\n            Thread.currentThread().interrupt();\n            throw new IOException(\n                \"Thread interrupted during retry\", ite);\n          }\n          intervalSeconds *= 2;\n          retry--;\n          // Update e to ex for the next iteration\n          e = ex;\n        }\n      }\n    }\n\n    if (bytesRead > 0) {\n      pos += bytesRead;\n      nextReadPos += bytesRead;\n    }\n\n    if (statistics != null && bytesRead >= 0) {\n      statistics.incrementBytesRead(bytesRead);\n    }","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-cloud-storage-project/hadoop-bos/src/main/java/org/apache/hadoop/fs/bos/BosInputStream.java#L204-L240","documentation":"While sleeping between read retries, BosInputStream is interrupted; it re-asserts the interrupt flag (Thread.currentThread().interrupt()) and throws IOException('Thread interrupted during retry') wrapping the InterruptedException. This converts task cancellation into an I/O failure so upper layers unwind cleanly.","triggerScenarios":"The reading thread is interrupted during the backoff window: Hadoop kills a speculative duplicate task, the job is cancelled, a Spark task is retracted, or an executor/thread-pool shuts down mid-retry.","commonSituations":"Speculative execution killing slow-but-healthy mappers that happen to be backing off; user job cancellation during a BOS outage; application shutdown racing an in-flight retry loop.","solutions":["Treat it as cancellation, not corruption: let it propagate and make sure the task exits promptly; do not 'fix' by clearing the interrupt","If spurious speculative kills are common, disable mapreduce.map.speculative for these jobs or fix the slow-task cause","Shorten backoff windows so tasks respond to cancellation faster"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"static boolean isCancellation(IOException e) {\n  return \"Thread interrupted during retry\".equals(e.getMessage())\n      && e.getCause() instanceof InterruptedException;\n}","tryCatchPattern":"catch (IOException e) {\n  if (isCancellation(e)) {\n    // cooperative shutdown: stop the reader promptly, keep the interrupt status\n    throw new RuntimeException(\"cancelled\", e);\n  }\n  throw e;\n}","preventionTips":["Never swallow the interrupt — honor cancellation semantics","Keep backoff windows bounded so tasks die quickly when killed","Disable speculative execution if duplicate tasks churn on slow inputs"],"tags":["bos","thread-interruption","task-cancellation","hadoop"],"backgroundTag":"thread-interrupted","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}