{"record":{"id":"26a3d520a878da43","repo":"pentaho/pentaho-kettle","slug":"csvinput-exception-errorpreparingparallelrun","errorCode":null,"errorMessage":"CsvInput.Exception.ErrorPreparingParallelRun","messagePattern":"CsvInput\\.Exception\\.ErrorPreparingParallelRun","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/csvinput/CsvInput.java","lineNumber":256,"sourceCode":"          if ( data.startPosition == 0 ) {\n            data.bytesToSkipInFirstFile = 0L;\n          } else {\n            data.bytesToSkipInFirstFile = data.startPosition - totalFileSize;\n          }\n\n          break;\n        }\n        totalFileSize += size;\n      }\n\n      if ( data.filenames.length > 0 ) {\n        logBasic( BaseMessages.getString(\n          PKG, \"CsvInput.Log.ParallelFileNrAndPositionFeedback\", data.filenames[ data.filenr ], Long\n            .toString( data.fileSizes.get( data.filenr ) ), Long.toString( data.bytesToSkipInFirstFile ), Long\n            .toString( data.blockToRead ) ) );\n      }\n    } catch ( Exception e ) {\n      throw new KettleException( BaseMessages.getString( PKG, \"CsvInput.Exception.ErrorPreparingParallelRun\" ), e );\n    }\n  }\n\n  private void getFilenamesFromPreviousSteps() throws KettleException {\n    List<String> filenames = new ArrayList<>();\n    boolean firstRow = true;\n    int index = -1;\n    Object[] row = getRow();\n    while ( row != null ) {\n\n      if ( firstRow ) {\n        firstRow = false;\n\n        // Get the filename field index...\n        //\n        String filenameField = environmentSubstitute( meta.getFilenameField() );\n        index = getInputRowMeta().indexOfValue( filenameField );\n        if ( index < 0 ) {","sourceCodeStart":238,"sourceCodeEnd":274,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/csvinput/CsvInput.java#L238-L274","documentation":"prepareToRunInParallel computes file split blocks for parallel CSV reading; any exception in that preparation is wrapped in KettleException with the localized message 'CsvInput.Exception.ErrorPreparingParallelRun' and the cause chained.","triggerScenarios":"Invoked from processRow when the CSV step is configured for parallel running (running in multiple copies) and computing file sizes/byte offsets (getFileSize, split calculations) fails.","commonSituations":"Input file missing or unreadable when sizes are probed, non-local/unsupported file systems that can't report size, character-set issues computing split positions.","solutions":["Read the chained cause for the real failure (usually file access or size lookup)","Verify the CSV file exists and is readable at the time the transformation starts","Disable parallel running (multiple copies) or switch to sequential reading for non-split-safe files","Ensure the file system supports size queries (local/NFS rather than some VFS endpoints)"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// verify file exists and size is queryable before parallel run\nFile f = new File(filename);\nif (!f.isFile() || f.length() <= 0) throw new KettleException(\"Cannot read CSV for parallel run: \" + filename);","typeGuard":"boolean isSplitSafe(File f) { return f != null && f.isFile() && f.length() > 0; }","tryCatchPattern":"try { prepareToRunInParallel(); }\ncatch (KettleException e) { logError(\"Parallel prep failed: \" + e.getCause(), e); fallBackToSequential(); }","preventionTips":["Ensure the file is present and readable at start time","Use local/NFS files for parallel CSV reads","Fall back to single-copy execution for non-size-reporting file systems"],"tags":["pdi","csv","parallelism"],"backgroundTag":"file-read-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"}