{"record":{"id":"02f5ff1a61d85be3","repo":"pentaho/pentaho-kettle","slug":"unable-to-flush-open-files","errorCode":null,"errorMessage":"Unable to flush open files","messagePattern":"Unable to flush open files","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/textfileoutput/TextFileOutput.java","lineNumber":395,"sourceCode":"      }\n\n      writeRow( data.outputRowMeta, row );\n      putRow( data.outputRowMeta, row ); // in case we want it to go further...\n\n      if ( checkFeedback( getLinesOutput() ) ) {\n        logBasic( \"linenr \" + getLinesOutput() );\n      }\n\n      int flushInterval = getFlushInterval();\n      if ( flushInterval > 0 ) {\n        long currentTime = new Date().getTime();\n        if ( data.lastFileFlushTime == 0 ) {\n          data.lastFileFlushTime = currentTime;\n        } else if ( currentTime - data.lastFileFlushTime > flushInterval ) {\n          try {\n            data.getFileStreamsCollection().flushOpenFiles( false );\n          } catch ( IOException e ) {\n            throw new KettleException( \"Unable to flush open files\", e );\n          }\n          data.lastFileFlushTime = new Date().getTime();\n        }\n      }\n      return true;\n    } else {\n      if ( data.writer != null ) {\n        if ( data.outputRowMeta != null && meta.isFooterEnabled() ) {\n          writeHeader();\n        }\n      } else if ( !Utils.isEmpty( environmentSubstitute( meta.getEndedLine() ) ) && !meta.isFileNameInField() ) {\n        String filename = getOutputFileName( null );\n        initFileStreamWriter( filename );\n        initBinaryDataFields();\n      }\n      if ( data.writer != null ) {\n        writeEndedLine();\n      }","sourceCodeStart":377,"sourceCodeEnd":413,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/textfileoutput/TextFileOutput.java#L377-L413","documentation":"During row processing TextFileOutput periodically flushes all open file streams (every flushInterval). If flushing the FileStreamsCollection raises IOException, it is wrapped in a KettleException 'Unable to flush open files'.","triggerScenarios":"Periodic flush timer elapsed during writeRowToFile and flushOpenFiles(false) hit an IO error on one of the open files (disk full, I/O error, stream closed).","commonSituations":"Disk full on the target volume; NFS mount dropped; many files open (split-every rows) and an fd was closed externally.","solutions":["Check disk space and filesystem health of the output directory","Retry the transformation after clearing the IO condition","Verify flush interval is reasonable and target storage is writable; check OS-level file handle limits"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// before run\nlong usable = new File( outputDir ).getUsableSpace();\nif ( usable < minRequiredBytes ) throw new IllegalStateException( \"Not enough disk space: \" + usable );","typeGuard":null,"tryCatchPattern":"try { writeRowToFile( row ); } catch ( KettleException e ) { if ( e.getCause() instanceof IOException && hasFreeSpace() ) { retryFlush(); } else { throw e; } }","preventionTips":["Monitor disk space on output volumes","Avoid network mounts that drop connections for large runs","Set a sane flush interval; watch open file handle limits"],"tags":["kettle","pentaho","io","flush"],"backgroundTag":"file-write-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}