Skip to content

--mpi-command: a background process started by a rank holds back SPAWN_EXITCODE and --on-complete until it exits (mpirun waits on its I/O forwarding; #1459 for MPI) #1479

Closed

Description

@scttfrdmn

Summary

With --mpi-command, a background process started by an MPI rank (e.g. sleep 600 &, or an un-waited aws s3 sync … &) holds back SPAWN_EXITCODE, the completion record and --on-complete until that process exits. Only the TTL bounds it. This is the --mpi-command version of #1459. The #1459 fix (PR #1474, v0.154.0) covers --command only.

The mechanism differs from #1459. In #1459 the straggler held the tee pipe. Here it does not: mpirun itself does not exit. Open MPI keeps a rank "running" until its I/O-forwarding channels close, and the straggler inherits them. So pkg/userdata/mpi.go (mpirun … 2>&1 | tee -a /var/log/spawn-command.log; spawn_mpi_done "${PIPESTATUS[0]}") waits on mpirun, which waits on the straggler.

Reproduction (live, spawn v0.154.0, us-east-1)

spawn launch t2mpi --instance-type c7g.medium --region us-east-1 --ttl 1h --yes --no-dns \
  --on-complete terminate --count 2 --job-array-name t2mpi --mpi --mpi-processes-per-node 1 \
  --auto-placement-group=false \
  --mpi-command 'sleep 600 & echo rank-$OMPI_COMM_WORLD_RANK-exit; date +%s.%N > /tmp/t_exit_rank$OMPI_COMM_WORLD_RANK; exit 0'

Array t2mpi-20261101-18e89f1f: rank 0 i-07a7f761efd85e1e4, rank 1 i-052fdf344406de8ca (AL2023 openmpi package, mpirun -np 2).

Evidence

Timestamps are epoch seconds on rank 0.

event time delta
rank 0 command exits (/tmp/t_exit_rank0) 1793571714.396 (22:21:54 UTC) 0
rank 1 command exits (/tmp/t_exit_rank1, rank 1 clock) 1793571714.402 +0.006 s
/tmp/SPAWN_EXITCODE written 1793572314.408 +600.0 s
/tmp/SPAWN_COMPLETE written: {"status": "completed", "exit_code": 0, "source": "mpi"} 1793572314.697 +600.3 s

The delay is exactly the straggler's lifetime.

Snapshot on rank 0, 45 s after both ranks exited. Both rank-N-exit lines were already in /var/log/spawn-command.log, and there was no SPAWN_EXITCODE yet:

29713 2044 mpirun --mca orte_base_help_aggregate 0 -np 2 -hostfile /tmp/mpi-hostfile bash /etc/spawn/mpi-command
29714 2044 tee -a /var/log/spawn-command.log
29718 29713 /usr/bin/ssh -x 172.31.34.162 orted ...
29722 1 sleep 600
tee stdin pipe:[39539], holders: mpirun 29713, tee 29714, ssh 29718   <- the straggler is NOT a holder
sleep 29722 fds: 0 -> /dev/null; 1 -> /dev/pts/0; 2 -> pipe:[39612]
mpirun 29713 fds include: 22 -> /dev/ptmx; 26 -> pipe:[39612]         <- mpirun's IOF pty/pipe for the rank

Rank 1 shows the same pattern under orted: sleep has fd 1 on /dev/pts/0 and fd 2 on pipe:[39131], and orted holds /dev/ptmx and pipe:[39131]. So the straggler holds the IOF pty and stderr pipe that mpirun/orted read for the rank, and the rank is not complete until those close.

Control, same release: with plain --command, a sleep 600 & straggler is released after the 10 s drain, as designed. Main exit 1793571323.431 → SPAWN_EXITCODE 1793571333.605 (+10.17 s), exit code 7, ⚠️ spawn: not waiting for processes still holding --command's output after 10s; they run on: 27018 sleep 600.

Impact

--mpi-command is completion-driven (#894): the help says "When it exits, pass or fail, every member is signalled, so --on-complete fires across the whole cohort". A rank that leaves any background job un-waited bills the whole cohort until that job ends or the TTL fires. #1459 fixed exactly this for --command, and the --command help now documents the 10 s drain. The --mpi-command help makes no such promise, and does not warn either.

Possible directions (not prescriptive)

Found during the v0.154.0 live validation of #1459 / PR #1474, which asked whether the mpirun … | tee line had the same exposure. It does, through mpirun rather than tee. Both instances were terminated via on-complete, and nothing leaked.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:mpibug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions