{"record":{"id":"dd301cb6075d547a","repo":"pentaho/pentaho-kettle","slug":"error-while-executing-psql","errorCode":null,"errorMessage":"Error while executing psql \\'","messagePattern":"Error while executing psql \\\\'","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"plugins/gp-bulk-loader/core/src/main/java/org/pentaho/di/trans/steps/gpbulkloader/GPBulkLoader.java","lineNumber":424,"sourceCode":"\n      // any output?\n      StreamLogger outputLogger = new StreamLogger( psqlProcess.getInputStream(), \"OUTPUT\" );\n\n      // kick them off\n      errorLogger.start();\n      outputLogger.start();\n\n      if ( wait ) {\n        // any error???\n        int exitVal = psqlProcess.waitFor();\n        logBasic( BaseMessages.getString( PKG, \"GPBulkLoader.Log.ExitValuePsqlPath\", \"\" + exitVal ) );\n      }\n    } catch ( KettleException ke ) {\n      // Re-throw the exception to the caller.\n      throw ke;\n    } catch ( Exception ex ) {\n      // The message below doesn't include the password since passwords aren't supported.\n      throw new KettleException( \"Error while executing psql \\'\" + createCommandLine( meta, false ) + \"\\'\", ex );\n    }\n\n    return true;\n  }\n\n  public boolean processRow( StepMetaInterface smi, StepDataInterface sdi ) throws KettleException {\n    meta = (GPBulkLoaderMeta) smi;\n    data = (GPBulkLoaderData) sdi;\n\n    try {\n      Object[] r = getRow(); // Get row from input rowset & set row busy!\n      if ( r == null ) {\n        // no more input to be expected...\n\n        setOutputDone();\n\n        if ( !preview ) {\n          if ( output != null ) {","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/gp-bulk-loader/core/src/main/java/org/pentaho/di/trans/steps/gpbulkloader/GPBulkLoader.java#L406-L442","documentation":"execute() runs the fully assembled psql command via Runtime exec / process handling. If that execution throws any exception other than a KettleException (e.g. IOException because the executable cannot be spawned, or a process-interrupt failure), it is wrapped in a KettleException whose message embeds the command line built with password=false. The wrapped cause contains the real OS-level error.","triggerScenarios":"execute(meta, wait) catches a non-KettleException from running the psql process: the executable path is wrong/non-executable so ProcessBuilder/Runtime.exec throws IOException; insufficient permissions; the OS cannot fork; or the command file resolution succeeded earlier but spawning fails at runtime.","commonSituations":"psql path points to a file that does not exist on the machine running the transformation (especially when Spoon runs locally but psql lives on a server); the psql binary lacks the execute bit; disk/memory exhaustion prevents process creation; Windows environment where a UNIX-style path was configured.","solutions":["Copy the command line from the exception message and run it manually in a shell to see the OS error.","Verify the psql path exists and is executable for the Kettle process user (chmod +x, correct path, correct OS).","Check that the transformation runs on the machine where psql is installed, or install psql client locally.","Inspect ex.getCause() (usually IOException: Cannot run program ...) for the exact OS-level reason."],"exampleFix":"// before (wrong platform path in step)\npsql path = /usr/local/greenplum-db/bin/psql   (running on Windows)\n\n// after\npsql path = C:\\Program Files\\PostgreSQL\\14\\bin\\psql.exe","handlingStrategy":"try-catch","validationCode":"String psql = transformation.environmentSubstitute(meta.getPsqlpath());\njava.io.File f = new java.io.File(psql);\nif (!f.isFile() || !f.canExecute())\n  throw new IllegalArgumentException(\"psql missing or not executable: \" + psql);","typeGuard":null,"tryCatchPattern":"try {\n  execute(meta, wait);\n} catch (KettleException e) {\n  if (e.getMessage().startsWith(\"Error while executing psql\")) {\n    logError(\"psql spawn failed\", e.getCause());\n    String cmd = e.getMessage(); // embedded command line, safe to run manually for diagnosis\n    logError(\"Reproduce manually: \" + cmd);\n  } else throw e;\n}","preventionTips":["Smoke-test the exact psql path on the executing node before go-live","Ensure the Kettle service user has execute permission on the psql binary","Match paths to the OS actually running the transformation (no UNIX paths on Windows)"],"tags":["process-execution","psql","io","command-line","kettle"],"backgroundTag":"command-not-found","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"}