From 2db1ea3061e04320804f04f32fed38af0d45605f Mon Sep 17 00:00:00 2001 From: Auto Researcher - Kent Huang Date: Tue, 16 Jun 2026 16:50:01 +0000 Subject: [PATCH] fix(dab): restart dab-postgres on-failure so a mid-run crash doesn't lose the DB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The dab-postgres service had a pg_isready healthcheck and a service_healthy startup gate but no restart policy (unlike dab-mongo). When postgres:17 dies mid-run (crash/OOM) it is never restarted, the container leaves dab-net, and `dab-postgres` stops resolving for the rest of the trial ('could not translate host name dab-postgres'). For hybrid pg+duckdb datasets like PANCANCER_ATLAS the clinical data then becomes unreachable and the agent can only abstain — observed on PANCANCER_ATLAS q2/q3 (both 'UNABLE TO DETERMINE', reward 0), which alone account for ~0.056 of stratified pass@1. Add 'restart: on-failure' to dab-postgres, mirroring the dab-mongo fix, so the populated data dir comes straight back up and main's healthcheck recovers. Co-Authored-By: Claude Opus 4.8 (1M context) --- .../src/razorback_plugin_dab/generate/compose.py | 6 ++++++ .../tests/unit/test_compose_postgres.py | 14 ++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/packages/razorback-plugin-dab/src/razorback_plugin_dab/generate/compose.py b/packages/razorback-plugin-dab/src/razorback_plugin_dab/generate/compose.py index 99441a9..50e1fc4 100644 --- a/packages/razorback-plugin-dab/src/razorback_plugin_dab/generate/compose.py +++ b/packages/razorback-plugin-dab/src/razorback_plugin_dab/generate/compose.py @@ -116,6 +116,12 @@ def generate_compose( "POSTGRES_PASSWORD": POSTGRES_PASSWORD, "POSTGRES_DB": pg_dbs[0], }, + # postgres:17 can die mid-run (crash/OOM). Without a restart policy the + # container leaves dab-net and `dab-postgres` stops resolving for the rest + # of the trial — clinical data (e.g. PANCANCER_ATLAS) becomes unreachable + # and the agent can only abstain. Restart on failure so the populated data + # dir comes straight back up and the healthcheck recovers (mirrors dab-mongo). + "restart": "on-failure", "healthcheck": { "test": ["CMD-SHELL", f"pg_isready -U {POSTGRES_USER} -d {pg_dbs[0]}"], "interval": "5s", diff --git a/packages/razorback-plugin-dab/tests/unit/test_compose_postgres.py b/packages/razorback-plugin-dab/tests/unit/test_compose_postgres.py index b7d9975..d902b90 100644 --- a/packages/razorback-plugin-dab/tests/unit/test_compose_postgres.py +++ b/packages/razorback-plugin-dab/tests/unit/test_compose_postgres.py @@ -40,6 +40,20 @@ def test_postgres_service_emitted(tmp_path: Path): assert "dab-net" in pg["networks"] +def test_postgres_has_restart_policy(tmp_path: Path): + # postgres:17 can die mid-run (crash/OOM). Without restart-on-failure the + # container leaves dab-net and `dab-postgres` stops resolving for the rest of + # the trial, so clinical data becomes unreachable and the agent can only + # abstain (observed on PANCANCER_ATLAS q2/q3). Mirror the dab-mongo fix. + compose_text = generate_compose( + db_config=_BOOKREVIEW_LIKE, + dataset_name="bookreview", + data_root=tmp_path, + ) + pg = yaml.safe_load(compose_text)["services"]["dab-postgres"] + assert pg["restart"] == "on-failure" + + def test_main_service_depends_on_postgres(tmp_path: Path): compose_text = generate_compose( db_config=_BOOKREVIEW_LIKE,