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,