{"record":{"id":"93fc37907517ce1b","repo":"apache/flink","slug":"could-not-create-recordwriter","errorCode":null,"errorMessage":"Could not create RecordWriter.","messagePattern":"Could not create RecordWriter\\.","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapreduce/HadoopOutputFormatBase.java","lineNumber":164,"sourceCode":"            this.context.getCredentials().addAll(this.credentials);\n            Credentials currentUserCreds =\n                    getCredentialsFromUGI(UserGroupInformation.getCurrentUser());\n            if (currentUserCreds != null) {\n                this.context.getCredentials().addAll(currentUserCreds);\n            }\n\n            // compatible for hadoop 2.2.0, the temporary output directory is different from hadoop\n            // 1.2.1\n            if (outputCommitter instanceof FileOutputCommitter) {\n                this.configuration.set(\n                        \"mapreduce.task.output.dir\",\n                        ((FileOutputCommitter) this.outputCommitter).getWorkPath().toString());\n            }\n\n            try {\n                this.recordWriter = this.mapreduceOutputFormat.getRecordWriter(this.context);\n            } catch (InterruptedException e) {\n                throw new IOException(\"Could not create RecordWriter.\", e);\n            }\n        }\n    }\n\n    /**\n     * commit the task by moving the output file out from the temporary directory.\n     *\n     * @throws java.io.IOException\n     */\n    @Override\n    public void close() throws IOException {\n\n        // enforce sequential close() calls\n        synchronized (CLOSE_MUTEX) {\n            try {\n                this.recordWriter.close(this.context);\n            } catch (InterruptedException e) {\n                throw new IOException(\"Could not close RecordReader.\", e);","sourceCodeStart":146,"sourceCodeEnd":182,"githubUrl":"https://github.com/apache/flink/blob/2f3c205e9266cb30240eb7f4fdab15cad629a70f/flink-connectors/flink-hadoop-compatibility/src/main/java/org/apache/flink/api/java/hadoop/mapreduce/HadoopOutputFormatBase.java#L146-L182","documentation":"Wraps an InterruptedException raised by mapreduceOutputFormat.getRecordWriter(context) inside open() while the task sets up its writer. Flink re-throws it as an IOException per the OutputFormat contract. It reflects writer creation being interrupted, typically a task-lifecycle event, not a configuration error.","triggerScenarios":"Produced in HadoopOutputFormatBase.open(context) when this.mapreduceOutputFormat.getRecordWriter(this.context) throws InterruptedException — e.g. the task was cancelled/failing during writer setup, the underlying filesystem open was interrupted, or a committer/lock blocked and was interrupted.","commonSituations":"Task cancelled while opening the sink; output filesystem unreachable or slow during writer creation; failover interrupting setup; a custom OutputFormat whose getRecordWriter blocks and mishandles interrupts.","solutions":["Inspect the wrapped InterruptedException in the logs to find the interrupt source (cancellation, failover).","Verify the output directory exists/ is writable and the filesystem (HDFS/S3) is reachable from the TaskManager.","Ensure output-committer configuration (mapreduce.task.output.dir) is correct so getRecordWriter does not block.","Treat as expected if the job was intentionally cancelled."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    hadoopOutputFormat.open(initContext);\n} catch (IOException e) {\n    if (e.getCause() instanceof InterruptedException) {\n        LOG.warn(\"RecordWriter creation interrupted; check task cancellation\", e);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Ensure the output directory exists and is writable before open().","Verify output-committer config (mapreduce.task.output.dir) is correct.","Treat writer-creation interruptions as lifecycle events.","Keep getRecordWriter from blocking indefinitely in custom OutputFormats."],"tags":["hadoop","mapreduce","output-format","interrupted","record-writer"],"backgroundTag":null,"analyzedSha":"2f3c205e9266cb30240eb7f4fdab15cad629a70f","analyzedAt":"2026-08-14T08:48:24.518Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}