apache/flink · error · IOException
Interrupted when untarring file {inFilePath}
Error message
Interrupted when untarring file {inFilePath} What it means
Thrown by the Unix tar extraction path (extractTarFileUsingTar) when the thread waiting for the `bash -c "... | tar ..."` process is interrupted. The code restores the interrupt flag before throwing, preserving the interruption request.
Source
Thrown at flink-core/src/main/java/org/apache/flink/util/CompressionUtils.java:138
// Copy and simplify from hadoop-common package that is used in YARN
// See
// https://github.com/apache/hadoop/blob/7f93349ee74da5f35276b7535781714501ab2457/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileUtil.java
private static void extractTarFileUsingTar(
String inFilePath, String targetDirPath, boolean gzipped) throws IOException {
inFilePath = makeSecureShellPath(inFilePath);
targetDirPath = makeSecureShellPath(targetDirPath);
String untarCommand =
gzipped
? String.format(
"gzip -dc '%s' | (cd '%s' && tar -xf -)", inFilePath, targetDirPath)
: String.format("cd '%s' && tar -xf '%s'", targetDirPath, inFilePath);
Process process = new ProcessBuilder("bash", "-c", untarCommand).start();
int exitCode = 0;
try {
exitCode = process.waitFor();
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IOException("Interrupted when untarring file " + inFilePath);
}
if (exitCode != 0) {
throw new IOException(
"Error untarring file "
+ inFilePath
+ ". Tar process exited with exit code "
+ exitCode);
}
}
// Follow the pattern suggested in
// https://commons.apache.org/proper/commons-compress/examples.html
private static void extractTarFileUsingJava(
String inFilePath, String targetDirPath, boolean gzipped) throws IOException {
try (InputStream fi = Files.newInputStream(Paths.get(inFilePath));
InputStream bi = new BufferedInputStream(fi);
final TarArchiveInputStream tai =
new TarArchiveInputStream(View on GitHub (pinned to 2f3c205e92)
Solutions
- Let the interruption propagate: do not swallow it — unwind and stop the extraction work
- If interruption is expected during shutdown, catch the IOException, check Thread.currentThread().isInterrupted(), and finish cleanup without starting new extractions
- Avoid sharing the extracting thread with tasks that can be cancelled, or run extraction in a dedicated executor you control
Example fix
// before
executor.submit(() -> CompressionUtils.extractTarFile(src, dst));
// after
Future<?> f = executor.submit(() -> CompressionUtils.extractTarFile(src, dst));
try {
f.get(5, TimeUnit.MINUTES);
} catch (ExecutionException e) {
if (Thread.interrupted()) { /* treat as shutdown, skip retry */ }
throw new RuntimeException(e.getCause());
} Defensive patterns
Strategy: try-catch
Try / catch
catch (IOException e) { if (Thread.currentThread().isInterrupted()) { abort extraction, do not retry } else { rethrow } } Prevention
- Run extraction in a dedicated thread/executor you never cancel mid-extraction
- On shutdown paths, treat interruption as a stop signal — skip starting new extractions
When it happens
Trigger: Running extractTarFile on Unix while the calling thread gets interrupted — typically a shutdown hook, task cancellation, or a test framework timeout aborting the extraction thread.
Common situations: Job/TaskManager shutdown racing archive extraction in a YARN container; CI test timeout interrupting a worker thread mid-extraction; explicit Future.cancel(true) on an extraction task.
Related errors
- Mkdirs failed to create {targetDir}
- Error untarring file {inFilePath}. Tar process exited with e
- expanding {entry.getName()} would create entry outside of {t
- Failed to create directory {outputFile}
- Mkdirs failed to create tar internal dir {targetDir}
AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14).
Data as JSON: /api/errors/d74e9d0ee230750b.
Report an issue: GitHub.