Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/soak.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ selectable; RR uses exactly one worker so its diagnostics have a single owner.
The existing RR memory supervisor stays enabled at 256 MiB. A process identity
change invalidates continuity, including recycling within a running container.

The process probe buffers each record before publishing it. A transient healthcheck
that exits during collection is omitted. Missing or replaced service processes
still fail the identity check. Read failures for processes that remain present
abort collection with the PID and failed field in the error message.

This is sustained-load/resource-growth evidence, not a maximum-RPS test. Calibrate
RATE first on the actual host and hold it fixed afterwards. The short unprofiled
baseline is a sanity comparison, not a separate full overhead campaign. Record
Expand Down
64 changes: 64 additions & 0 deletions reports/2026-11-19-soak-observer-failure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# RoadRunner soak interrupted by a process probe race

Methodology follows [METHOD.md](../METHOD.md) and the
[observed-soak runbook](../docs/soak.md).

## Outcome

The attempted 72-hour RR and Go-agent run is **invalid**. It stopped after
27.12 hours of steady observations with an empty-detail
`/proc probe failed` error. Final drain and cooldown did not run.
The raw evidence is retained locally under
`reports/_local/failed-20261119/soak-20261117T182006Z`.

The sampling window ran from 2026-11-17 18:31 UTC until the last successful
observation at 2026-11-18 21:38 UTC. Benchmarks used
`e4835846fd0ba04b895ea81c0bb4a128da82e103`, Tracewick used
`55eb7bdb91cd4269a86bb0dd8ce22a243e5486b4`, and the Go agent used
`a15f0d310ba6d5942e67b37d3c3c55dc1b3b8100`. Excimer 1.2.7 used
`23f541b9d970db0524a1b2506b4df727e5e59998`. The host had 2 vCPU,
3.8 GiB RAM and Ubuntu 26.04.1. The configuration used one RR worker,
depth 48, sample rate 0.1, target 10 RPS and 15-second observations.

## Observations before interruption

There were 6,266 steady snapshots, with a maximum gap of 16.10 seconds.
k6 recorded 976,223 HTTP requests, zero HTTP failures and zero dropped
iterations. The observed rate was 10.00 RPS. Cumulative p95 was 37.40 ms.
The queue peaked at nine files and four seconds of age. The agent delivered
97,851 profiles during the observed steady span, with zero retries or rejects.
The last complete observation contained two pending files.

| Process | First-hour mean RSS MiB | Last-hour mean RSS MiB | First-hour CPU ms/request | Last-hour CPU ms/request |
| --- | ---: | ---: | ---: | ---: |
| PHP worker | 28.398 | 28.406 | 25.754 | 25.704 |
| RoadRunner | 47.986 | 49.910 | 0.785 | 0.787 |
| Go agent | 13.648 | 14.084 | 0.0695 | 0.0697 |

PHP and agent identities remained continuous through the saved observations.
Later inspection found the containers still running, with zero restarts and
no OOM flags. The agent reported an empty queue after the interruption.
This later observation does not replace the missing final drain phase.

## Reproduction and correction

A separate burst of real PHP extension healthchecks reproduced a probe failure
on iteration 17. The shell trace showed a PHP process with an empty cmdline,
followed by failure to read its stat file after process exit.
The old probe had already emitted the record header. It exited with status 1
and suppressed the underlying error text.

This reproduces a failure path consistent with the interruption. The original
run did not save the failing probe's partial stdout or field-level context,
so its exact failing PID and read cannot be recovered.

The corrected probe buffers stat, status and descriptors before emitting the
record. It omits exiting transient processes and retains the existing identity
validator for missing or replaced workers. Read failures for a process that
remains present still fail collection, with PID and field diagnostics.
Deterministic tests cover process exit during reads, a live-process read failure,
and a descriptor-read failure.

The saved window shows stable PHP resources and modest agent memory changes.
It provides partial-duration observations. A fresh continuous 72-hour run is
required to complete the intended experiment.
35 changes: 18 additions & 17 deletions scripts/soak_probe.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@
# Read only this container's process namespace. The probe itself is excluded.
set -eu
self=$$
read_failed() {
# A healthcheck can exit between any two /proc reads. A missing service
# process is still rejected by the process identity continuity validator.
[ ! -e "$path" ] && return
printf 'Cannot read %s for PID %s (%s)\n' "$1" "$pid" "${name:-unknown}" >&2
exit 1
}
for path in /proc/[0-9]*; do
pid=${path##*/}
[ "$pid" = "$self" ] && continue
[ -r "$path/stat" ] && [ -r "$path/status" ] || continue
# Observe service/worker processes, not transient runc/exec/healthcheck helpers.
name=$(cat "$path/comm" 2>/dev/null) || {
[ ! -e "$path" ] && continue
exit 1
}
name=$(cat "$path/comm" 2>/dev/null) || { read_failed comm; continue; }
case "$name" in rr|php|php-fpm*|tracewick-agent) ;; *) continue ;; esac
# Compose's extension healthcheck is a transient diagnostic, not a worker.
args=$(tr '\000' ' ' < "$path/cmdline" 2>/dev/null) || {
[ ! -e "$path" ] && continue
exit 1
}
case "$args" in *'exit(extension_loaded'*) continue ;; esac
printf '@ %s\n' "$pid"
cat "$path/stat" 2>/dev/null || exit 1
cat "$path/status" 2>/dev/null || exit 1
printf 'FDs:\t'
# Failure must not become a convincing zero descriptor count.
fds=$(find "$path/fd" -mindepth 1 -maxdepth 1 2>/dev/null) || exit 1
args=$(tr '\000' ' ' < "$path/cmdline" 2>/dev/null) || { read_failed cmdline; continue; }
# An exiting process may already have an empty cmdline. Healthchecks are
# transient diagnostics, including when caught during process teardown.
case "$args" in ''|*'exit(extension_loaded'*) continue ;; esac
stat=$(cat "$path/stat" 2>/dev/null) || { read_failed stat; continue; }
status=$(cat "$path/status" 2>/dev/null) || { read_failed status; continue; }
fds=$(find "$path/fd" -mindepth 1 -maxdepth 1 2>/dev/null) || { read_failed fd; continue; }
# Publish complete records only. A disappearing process cannot leave a
# partial record that gets mistaken for a malformed worker observation.
printf '@ %s\n%s\n%s\nFDs:\t' "$pid" "$stat" "$status"
if [ -n "$fds" ]; then printf '%s\n' "$fds" | wc -l; else printf '0\n'; fi
printf '@end\n'
done
2 changes: 1 addition & 1 deletion scripts/soaklib.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def sample(self, cid, processes=False, allow_shared=False):
raw = subprocess.run(['docker', 'exec', '-i', '-u', '0', cid, 'sh'],
input=PROBE, text=True, capture_output=True, timeout=15)
if raw.returncode:
raise RuntimeError(f'/proc probe failed: {raw.stderr.strip()}')
raise RuntimeError(f'/proc probe failed for {cid[:12]} (exit {raw.returncode}): {raw.stderr.strip()}')
result['processes'] = parse_processes(raw.stdout)
return result

Expand Down
77 changes: 77 additions & 0 deletions tests/test_soak_probe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
"""Deterministic /proc teardown races in the shell collector."""
import os
import subprocess
import sys
import tempfile
import unittest
from pathlib import Path

sys.path.insert(0, str(Path(__file__).resolve().parents[1] / 'scripts'))
from soaklib import parse_processes

PROBE = (Path(__file__).resolve().parents[1] / 'scripts/soak_probe.sh').read_text()


class ProbeTest(unittest.TestCase):
def run_probe(self, failure, disappear=False):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
proc = root / 'proc'
for pid in (10, 20):
process = proc / str(pid)
process.mkdir(parents=True)
(process / 'comm').write_text('php\n')
(process / 'cmdline').write_bytes(b'php\0worker.php\0')
fields = ['S'] + ['0'] * 19
fields[19] = str(pid * 100)
(process / 'stat').write_text(f'{pid} (php) ' + ' '.join(fields) + '\n')
(process / 'status').write_text('VmRSS:\t8 kB\nRssAnon:\t4 kB\nThreads:\t2\n')
(process / 'fd').mkdir()
(process / 'fd/0').symlink_to('/dev/null')
binaries = root / 'bin'
binaries.mkdir()
# Process 20 exits after its cmdline was read. Process 10 is stable.
cat = binaries / 'cat'
cat.write_text('''#!/bin/sh
if [ "$1" = "$PROBE_FIXTURE/20/stat" ]; then
if [ "$PROBE_DISAPPEAR" = 1 ]; then rm -r "$PROBE_FIXTURE/20"; fi
exit 1
fi
exec /bin/cat "$@"
''')
cat.chmod(0o755)
find = binaries / 'find'
find.write_text('''#!/bin/sh
if [ "$1" = "$PROBE_FIXTURE/10/fd" ]; then exit 1; fi
exec /usr/bin/find "$@"
''')
find.chmod(0o755)
if failure == 'stat':
find.unlink()
else:
cat.unlink()
env = {**os.environ, 'PATH': str(binaries) + ':' + os.environ['PATH'],
'PROBE_FIXTURE': str(proc), 'PROBE_DISAPPEAR': '1' if disappear else '0'}
script = PROBE.replace('/proc/', str(proc) + '/')
return subprocess.run(['sh'], input=script, text=True, capture_output=True, env=env)

def test_exited_process_cannot_leave_a_partial_record(self):
result = self.run_probe('stat', disappear=True)
self.assertEqual(0, result.returncode, result.stderr)
self.assertEqual([10], [p['pid'] for p in parse_processes(result.stdout)])
self.assertNotIn('@ 20', result.stdout)

def test_live_process_read_failure_is_reported(self):
result = self.run_probe('stat')
self.assertNotEqual(0, result.returncode)
self.assertIn('Cannot read stat for PID 20 (php)', result.stderr)

def test_failed_descriptor_read_cannot_become_zero(self):
result = self.run_probe('fd')
self.assertNotEqual(0, result.returncode)
self.assertIn('Cannot read fd for PID 10 (php)', result.stderr)
self.assertEqual('', result.stdout)


if __name__ == '__main__':
unittest.main()