{"record":{"id":"cd994454289c7b8b","repo":"pentaho/pentaho-kettle","slug":"error-writing-marker-flag","errorCode":null,"errorMessage":"Error writing marker flag","messagePattern":"Error writing marker flag","errorType":"exception","errorClass":"org.pentaho.di.core.exception.KettleFileException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/row/RowMeta.java","lineNumber":684,"sourceCode":"   * @throws KettleFileException in case things go awry\n   */\n  @Override\n  public void writeData( DataOutputStream outputStream, Object[] data ) throws KettleFileException {\n    lock.readLock().lock();\n    try {\n      // Write all values in the row\n      for ( int i = 0; i < size(); i++ ) {\n        getValueMeta( i ).writeData( outputStream, data[ i ] );\n      }\n\n      // If there are 0 values in the row, we write a marker flag to be able to detect an EOF on the other end (sockets\n      // etc)\n      //\n      if ( size() == 0 ) {\n        try {\n          outputStream.writeBoolean( true );\n        } catch ( IOException e ) {\n          throw new KettleFileException( \"Error writing marker flag\", e );\n        }\n      }\n    } finally {\n      lock.readLock().unlock();\n    }\n  }\n\n  /**\n   * Write ONLY the specified metadata to the outputStream\n   *\n   * @throws KettleFileException in case things go awry\n   */\n  @Override\n  public void writeMeta( DataOutputStream outputStream ) throws KettleFileException {\n    lock.readLock().lock();\n    try {\n      // First handle the number of fields in a row\n      try {","sourceCodeStart":666,"sourceCodeEnd":702,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/row/RowMeta.java#L666-L702","documentation":"writeData serializes row data to an OutputStream and first writes a boolean marker flag when the row metadata has zero fields. If outputStream.writeBoolean throws IOException, it is wrapped in a KettleFileException with the message \"Error writing marker flag\". This signals the underlying stream failed mid-write.","triggerScenarios":"Calling RowMeta.writeData(outputStream, data) with size()==0 metadata and the underlying OutputStream throws IOException (socket closed, pipe broken, disk full, stream already closed).","commonSituations":"Writing row data across a socket where the peer disconnected; writing to a closed ByteArrayOutputStream/FileOutputStream; network interruption in clustered/transformation slave-server streaming.","solutions":["Check the cause IOException on the KettleFileException (broken pipe vs closed stream) to diagnose the transport.","Ensure the OutputStream is open and connected before serialization; re-establish the socket/connection and retry the transfer.","For sockets, increase timeouts and validate the peer is still alive before writing large row streams.","Wrap stream lifecycle in try-with-resources so streams are never written after close."],"exampleFix":"// before\nrowMeta.writeData(outputStream, rowData); // NPE/ke: Error writing marker flag if stream dead\n// after\nif (!isStreamOpen(outputStream)) { reconnect(); }\ntry {\n  rowMeta.writeData(outputStream, rowData);\n} catch (KettleFileException e) {\n  log.error(\"Failed writing marker flag: \" + e.getCause(), e);\n  reconnectAndResend(rowData);\n}","handlingStrategy":"retry","validationCode":"if (outputStream == null || !isStreamWritable(outputStream)) { throw new IllegalStateException(\"Output stream not writable\"); }","typeGuard":null,"tryCatchPattern":"try {\n  rowMeta.writeData(outputStream, rowData);\n  outputStream.flush();\n} catch (KettleFileException e) {\n  if (e.getCause() instanceof IOException) { reconnectAndRetry(rowData); }\n  else throw e;\n}","preventionTips":["Flush and verify connectivity before streaming rows.","Set socket timeouts and keep-alive on clustered transfers.","Never reuse a closed stream; manage lifecycle with try-with-resources."],"tags":["io","serialization","row-metadata","stream"],"backgroundTag":"broken-pipe","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"}