{"record":{"id":"4a2dd4aad1d11b5e","repo":"t8y2/dbx","slug":"rss-probe-exited-early-join-stderr-lines","errorCode":null,"errorMessage":"RSS probe exited early: {'; '.join(stderr_lines)}","messagePattern":"RSS probe exited early: (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"agents/drivers/iotdb/bench/run.py","lineNumber":151,"sourceCode":"        env=environment | {\"IOTDB_BENCH_MODE\": \"hold\"},\n        text=True,\n        stdout=subprocess.PIPE,\n        stderr=subprocess.PIPE,\n    )\n    stderr_lines: list[str] = []\n\n    def drain_stderr() -> None:\n        assert process.stderr is not None\n        stderr_lines.extend(line.rstrip() for line in process.stderr)\n\n    threading.Thread(target=drain_stderr, daemon=True).start()\n    try:\n        assert process.stdout is not None\n        deadline = time.monotonic() + env_float(\"BENCH_READY_TIMEOUT\", 30.0)\n        while time.monotonic() < deadline:\n            line = process.stdout.readline()\n            if line == \"\" and process.poll() is not None:\n                raise RuntimeError(f\"RSS probe exited early: {'; '.join(stderr_lines)}\")\n            try:\n                payload = json.loads(line)\n            except json.JSONDecodeError:\n                continue\n            if payload.get(\"ready\") is True:\n                break\n        else:\n            raise TimeoutError(f\"RSS probe timed out: {'; '.join(stderr_lines)}\")\n        time.sleep(0.2)\n        completed = subprocess.run(\n            [\"ps\", \"-o\", \"rss=\", \"-p\", str(process.pid)],\n            text=True,\n            stdout=subprocess.PIPE,\n            stderr=subprocess.PIPE,\n            check=True,\n        )\n        return float(completed.stdout.strip())\n    finally:","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/iotdb/bench/run.py#L133-L169","documentation":"measure_rss() starts the benchmark in 'hold' mode and reads its stdout, waiting for a JSON line with ready=true. If the process's stdout hits EOF while the process has already exited, it raises RuntimeError listing all stderr lines collected, i.e. the probe crashed before signaling readiness.","triggerScenarios":"The spawned RSS probe subprocess exits early (non-zero or zero) before emitting {\"ready\": true}: readline() returns \"\" and process.poll() is not None. Causes include bad arguments, crash at startup, missing IOTDB_BENCH_MODE support, or instant OOM.","commonSituations":"Probe binary crashes on startup; env var IOTDB_BENCH_MODE not supported by the installed tool version; port conflict killing the server immediately; stderr shows a Python/JVM traceback.","solutions":["Read the stderr lines embedded in the RuntimeError for the crash reason","Confirm the installed benchmark tool supports IOTDB_BENCH_MODE=hold","Run the probe command manually with the same env to see the startup failure","Check for port conflicts or missing dependencies that kill the process instantly","Verify the probe writes readiness JSON to stdout before doing heavy work"],"exampleFix":"// before\n$ IOTDB_BENCH_MODE=hold ./bench  # crashes: unknown mode -> RuntimeError: RSS probe exited early\n// after\n$ upgrade bench tool to a version supporting hold mode, then rerun measure_rss(...)","handlingStrategy":"try-catch","validationCode":"def preflight_hold_mode(env: dict) -> None:\n    probe = subprocess.run(\n        [\"echo\", \"check\"], env=env | {\"IOTDB_BENCH_MODE\": \"hold\"}, capture_output=True, text=True)\n    # on the real tool: run with a tiny workload and assert it starts without stderr\n    if probe.returncode != 0:\n        raise SystemExit(f\"probe fails at startup: {probe.stderr}\")","typeGuard":null,"tryCatchPattern":"try:\n    rss = measure_rss(command, environment)\nexcept RuntimeError as e:\n    print(f\"probe died at startup:\\n{e}\")  # stderr lines are embedded\n    raise SystemExit(1)","preventionTips":["Confirm IOTDB_BENCH_MODE=hold is supported by the installed tool version before measuring","Check for port conflicts and missing dependencies that crash the probe instantly","Capture and read stderr at startup — the error message already joins all stderr lines","Run the probe command manually once when setting up a new environment"],"tags":["subprocess","process-crash","rss-measurement","python"],"backgroundTag":"subprocess-exited-nonzero","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}