Section 17.21

Zero return and complete execution are different claims

Question

Why is a launcher returning zero insufficient evidence that its hardware job succeeded?

Short answer

A launcher’s exit status §13.24 of 0 shows only that the launcher reached the point where its author chose to report success, which usually comes before the hardware job ends. Many launchers only hand the job to a worker process or a device, then exit. Afterwards the worker can fail, the device can still be working and output records can be missing. Success must be shown by the job’s own evidence, checked item by item: the worker’s result, the device’s report of completion and a complete, valid set of outputs.

Terms in the question

Full answer

The operating system only carries the number. The kernel passes the status from child to parent and attaches no meaning to it. The meaning of 0 is chosen by whoever wrote the launcher, through the place in the code where the launcher ends with 0. The first question about any launcher is therefore which event its 0 stands for. In time order, the candidates are:

  1. the request was submitted;

  2. the worker started;

  3. the worker ended and reported success;

  4. the device reported that its operation completed;

  5. the outputs were checked and found complete and valid.

These are five different claims. A 0 tied to an early event says nothing about the later ones.

Most launchers report an early event. A job that takes minutes is started asynchronously: the launcher starts a worker in the background, or submits the job to a scheduler, and exits so that its caller can continue. For example, sbatch, the command that submits batch jobs to the Slurm workload manager, exits with 0 as soon as the scheduler has accepted the job, before the job has run. That 0 is a true report of a successful submission. Read as a report that the job succeeded, it is false.

A launcher that waits can still lose a failure.

The host is not the device. When a worker on the host ends with 0, the host’s part is done: for example, the command bytes have left the host. The device may still be carrying out the operation, may have rejected it, or may have restarted part way through. Only evidence that the device itself produces shows that the device operation completed: a completion message, a status read back from the device, or an output that only the device can produce. Whether every process of the job has ended, called process closure §13.23, is yet another fact. A launcher can exit while the worker it started is still running.

The outputs decide the result. A job defined as three measurement runs, each producing one record, succeeded only if three valid records exist and each comes from this job. A record counts when it is complete, parses correctly and carries this job’s identifier, so that a record left over from an earlier job is not counted. A missing record proves less than it seems. The recording can fail while the device completes the operation, and the device’s state is then unknown, not unchanged. This matters before a retry: an operation that is not idempotent §8.31, meaning that doing it twice has a different effect from doing it once, must not be repeated without first reading the state of the device.

What to record instead. Record each layer separately: the submission status; the exit status or ending signal of every worker; whether every process of the job has ended; the device’s evidence of completion; the number and validity of the outputs; and whether the attempt is eligible to count as evidence. Declare the job successful only when every required item passes. A wrapper, meaning a program that runs another program, must report a failure of any child instead of replacing it with its own success.

Worked example

A job requires three records, one per measurement run. These are the events, with times counted from the start.

The evaluation, item by item:

Verdict: the job failed, and run 3 does not count. Before operation 3 is repeated, the state of the device must be read, because operation 3 may have taken effect; in this case it did.

Truncation sets a second trap. A checking program that exits with its number of failed checks calls exit(256) after 256 failures. The parent receives the remainder of 256 after division by 256, which is 256−1×256=0256 - 1 \times 256 = 0: success. After 300 failures it receives 300−1×256=44300 - 1 \times 256 = 44.

Follow-up questions and limits

Is a nonzero status then proof of failure? No. Each program defines its own values. The search tool grep exits with 1 when no line matched, which is a normal result, and with 2 when an error occurred.

Is it enough for the launcher to wait for the device? Only if the wait ends on evidence from the device and has a timeout §9.34. A wait that runs out of time must be reported as unknown, not as success.

Could the records come from another job? Yes, if another job used the same device in the meantime. A lease, a grant of exclusive use that expires, keeps other jobs off the device, and a job identifier in every record ties each record to its job.

This answer does not cover how to recover a device that was left in the middle of an operation.

Fullest treatment: Exit status (§13.24).

Related entries: Process closure (§13.23), Lease and exclusive ownership (§13.26), Evidence eligibility (§13.14), Asynchronous completion (§9.28), Idempotency (§8.31), Deadline versus timeout (§9.34).