IBM Support

DataStage dsjob command to run or reset job fails with DSJE_BADSTATE.

Troubleshooting


Problem

When scripting a job run or job reset, the dsjob command can fail with return code -2 (DSJE_BADSTATE) under certain conditions.

Diagnosing The Problem

Multiple conditions cause result code DSJE_BADSTATE (rc = -2) to be validly issued for the dsjob command:

  • The dsjob command is issued to run a job normally (either -mode NORMAL, or -mode not defined) when the job is in un-runnable state (aborted, not compiled, etc).
  • The dsjob command is issue with RESET mode in an attempt to reset an a job that does not need to be reset (job is not in an aborted or uncompiled state).
  • A script issues dsjob reset request followed immediately by a job run request, without waiting for reset to complete, i.e.:
    dsjob -run -mode RESET projectname jobname
    dsjob -run -wait -jobstatus projectname jobname
    This can fail because the second command may try to run the job before the reset completes and thus job is not yet in valid state , resulting in DJSE_BADSTATE
  • The dsjob run was requested at a time when the job was currently already running (for non-multiinstance job)

Resolving The Problem

When the dsjob command (or job run through other method) fails with return code -2, or status DSJE_BADSTATE, it means that the job is not in the correct state for the dsjob mode that was requested.

Specifically, if you try to run a job that is not in a runnable state (i.e. job is aborted, not compiled, or other state not runnable) then the job start request will fail. Similarly, if you try to reset a job that is already in a runnable state (finished, compiled, reset) rather than a state needing reset, the error will occur.

When creating custom scripts to issue the dsjob command, logic can be added to check the job status before running it using the following command:
dsjob -jobinfo projectname jobname

This will give multiple lines of output including lines such as the following 2 lines:
Job Status : RESET (21)
Interim Status : NOT RUNNING (99)

Check if the job status is in one of several states that allows running jobs, for example:
RESET, RUNOK, RUNWARN
or is in a state that requires a reset before running, such as:
RUNFAILED, CRASHED.

You can also check for status of RUNNING to prevent trying to run a non-multi-instance job that is already running. More information on the dsjob state

The set of status codes which can be returned by dsjob -jobinfo request are listed in the following section of the online Information Server manuals:
The DSJOBINFO structure

Search on DSJS_RUNFAILED to find the list of status codes. Note that if you are accessing this information using the dsjob -jobstatus command rather than a programming API, then "DSJS_" prefix will not be included as part of the job state.

Additionally , if you setup script to perform a reset of job (when needed) prior to running the job, then be sure to include the -wait option on the reset command so that the script will wait for reset to complete before attempting the subsequent job run command. For example:
dsjob -run -mode RESET -wait -jobstatus projectname jobname
dsjob -run -wait -jobstatus projectname jobname

[{"Product":{"code":"SSVSEF","label":"IBM InfoSphere DataStage"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"--","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"8.7;8.5;8.1;8.0;7.5","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
16 June 2018

UID

swg21595194