{"record":{"id":"f8f52b92066e7e77","repo":"apache/seatunnel","slug":"flush-data-failed-f8f52b","errorCode":"FLUSH_DATA_FAILED","errorMessage":"Flush data to this file [%s] failed","messagePattern":"Flush data to this file \\[(.+?)\\] failed","errorType":"error_code","errorClass":"FileConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/sink/writer/JsonWriteStrategy.java","lineNumber":99,"sourceCode":"            if (isFirstWrite.get(filePath)) {\n                isFirstWrite.put(filePath, false);\n            } else {\n                fsDataOutputStream.write(rowDelimiter);\n            }\n            fsDataOutputStream.write(rowBytes);\n        } catch (IOException e) {\n            throw CommonError.fileOperationFailed(\"JsonFile\", \"write\", filePath, e);\n        }\n    }\n\n    @Override\n    public void finishAndCloseFile() {\n        beingWrittenOutputStream.forEach(\n                (key, value) -> {\n                    try {\n                        value.flush();\n                    } catch (IOException e) {\n                        throw new FileConnectorException(\n                                CommonErrorCodeDeprecated.FLUSH_DATA_FAILED,\n                                String.format(\"Flush data to this file [%s] failed\", key),\n                                e);\n                    } finally {\n                        try {\n                            value.close();\n                        } catch (IOException e) {\n                            log.warn(\"Close file output stream {} failed\", key, e);\n                        }\n                    }\n                    needMoveFiles.put(key, getTargetLocation(key));\n                });\n        beingWrittenOutputStream.clear();\n        isFirstWrite.clear();\n    }\n\n    @Override\n    public FSDataOutputStream getOrCreateOutputStream(@NonNull String filePath) {","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-file/connector-file-base/src/main/java/org/apache/seatunnel/connectors/seatunnel/file/sink/writer/JsonWriteStrategy.java#L81-L117","documentation":"Thrown by JsonWriteStrategy.finishAndCloseFile when flushing buffered JSON output to the underlying file stream fails with an IOException. Raised at finalization (close/checkpoint), meaning the JSON output file may be incomplete. The original IOException is attached as the cause.","triggerScenarios":"value.flush() throws IOException while closing JSON sink files — full disk, HDFS/S3 write error, stream closed early, or file deleted externally.","commonSituations":"Cluster storage quota exhaustion; transient network outage to object store; multiple jobs writing the same output file; filesystem unmounted mid-job.","solutions":["Read e.getCause() to find the root storage problem (ENOSPC, permission, timeout) and remediate it","Check target path availability and quota; clean up stale output directories","Ensure exclusive access to the output path (one writer per file); use job-specific temp dirs","Resubmit the job after fixing storage; most flush failures are transient"],"exampleFix":"// before\ntry { Files.write(path, bytes); } catch (IOException ignored) { }\n// after\ntry { out.flush(); } catch (IOException e) {\n    throw new FileConnectorException(CommonErrorCodeDeprecated.FLUSH_DATA_FAILED,\n        String.format(\"Flush data to this file [%s] failed\", key), e);\n}","handlingStrategy":"try-catch","validationCode":"// verify output dir exists and is writable\nFileSystem fs = path.getFileSystem(conf);\nif (!fs.exists(outDir) || !fs.getFileStatus(outDir).getPermission().getAction().contains(\"w\")) { throw new IllegalStateException(\"output dir not writable\"); }","typeGuard":null,"tryCatchPattern":"try {\n    job.execute();\n} catch (FileConnectorException e) {\n    if (CommonErrorCodeDeprecated.FLUSH_DATA_FAILED.equals(e.getErrorCode())) {\n        // check e.getCause(): ENOSPC / AccessControl / timeout\n        // clean stale outputs, fix storage, retry\n    }\n}","preventionTips":["Pre-create and permission-check the output directory","Keep sufficient free space/quota on the target storage","Never share an output file across parallel jobs","Retry on transient storage errors at the pipeline level"],"tags":["io","file-sink","flush-failure"],"backgroundTag":"file-write-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}