LESSON 8 · Advanced

Production engineering: debug, secure, integrate and tune

Plain-English notes, safe code skeletons, IBM i commands, and a checkpoint you can use before opening the deeper question bank.

After this lesson

Learning notes

Debug from evidence, not guesses

Start with the exact job, timestamp, message ID, input, and last successful step. Read the job log, inspect the call stack, and reproduce with the smallest safe input. For RPG, inspect variables at a breakpoint; for CL, trace the command and monitored message. Preserve the evidence before restarting a job.

A production fix should include a way to prove the symptom is gone: a repeatable test, a metric, a log message, or a reconciliation count.

Useful investigation commands

DSPJOB JOB(123456/USER/BATCH) OPTION(*JOBLOG)
DSPJOBLOG JOB(123456/USER/BATCH)
STRDBG PGM(APPDATA/ORDENTRY)
DSPPFM FILE(APPDATA/QRPGLESRC) MBR(ORDENTRY)
  1. Capture symptom, job, timestamp, and message ID
  2. Check job log and call stack
  3. Form one hypothesis and inspect its evidence
  4. Reproduce safely or add a targeted diagnostic
  5. Fix, verify, and document the recovery

Security is part of the design

Check the object owner, public authority, private authorities, adopted authority, and the profile under which a job runs. A program that works for its owner may fail for a real user. Avoid broad *PUBLIC authority as a convenience; grant the smallest access required and document why an exception exists.

For an API, validate input, protect credentials, use TLS, log a correlation ID without secrets, and define how a timeout or duplicate request is handled. IBM i authority does not replace transport and application controls.

Inspect authority before changing it

DSPOBJAUT OBJ(APPDATA/ORDENTRY) OBJTYPE(*PGM)
DSPLIB LIB(APPDATA)
DSPUSRPRF USRPRF(APPUSER) TYPE(*BASIC)

Tune the bottleneck you can measure

Separate CPU, I/O, lock wait, network, and queue delay. For SQL, inspect the access plan and predicates; for native I/O, inspect the key and access path; for jobs, inspect active-job wait reasons and memory-pool pressure. A new index is useful only when it improves the measured plan without creating unacceptable write cost.

Record before and after timings with the same input and concurrency. Keep the change small enough to roll back and watch the job after deployment.

SQL tuning conversation starter

-- inspect the plan in the target release
explain plan for
  select order_id, amount
    from appdata.orders
   where customer_id = :customerId
     and status = 'OPEN';

Open the detailed question chapters

Practice checkpoint

Answer all five, then review the explanations. The interactive site stores your completed learning checkpoints in this browser.

  1. 1. A breakpoint is missed. Verify first:
    1. Only the monitor size
    2. Only the source comment
    3. Target job, object library/version, and execution path
    4. Only the user’s keyboard
  2. 2. Which command is commonly used to select a service job for debugging?
    1. CRTPF
    2. DSPDTAARA
    3. SETGT
    4. STRSRVJOB
  3. 3. Why can debugging affect other users?
    1. Paused work may retain locks and resources
    2. It always changes every record
    3. It deletes all indexes
    4. It automatically ends the subsystem
  4. 4. What should be captured after a failing embedded SQL statement?
    1. Only %EOF
    2. SQLSTATE, SQLCODE, and diagnostics
    3. Only the last screen text
    4. Only the compile timestamp
  5. 5. A decimal-data error follows a program call. Investigate:
    1. Only job priority
    2. Only the output queue
    3. Parameter storage compatibility
    4. Only database indexes
Show answer key and explanations

1. C — Target job, object library/version, and execution path Debugging the wrong object or job is a common cause.

2. D — STRSRVJOB STRSRVJOB is part of the command-based workflow for servicing another job.

3. A — Paused work may retain locks and resources A breakpoint can prolong resource ownership.

4. B — SQLSTATE, SQLCODE, and diagnostics SQL status identifies the database failure category and context.

5. C — Parameter storage compatibility A type or size mismatch can make valid bytes invalid under the callee’s interpretation.

IBM documentation for this path