beads/internal/storage/dbproxy/server
Julian Knutsen d803ec9126
fix(dbproxy): retire the proxy when its Dolt backend exits cleanly (#6937)
* fix(dbproxy): retire the proxy when its Dolt backend exits cleanly

DoltServer supervised `dolt sql-server` with cmd.Wait inside an
errgroup, and Running read the errgroup context. errgroup cancels that
context only for a non-nil result, so a backend that shut down
gracefully (dolt exits 0 on SIGTERM) was reported as running forever.
The proxy's backend health watcher never fired: the proxy stayed up and
adoptable in front of a dead store. With --proxied-server-idle-timeout 0
(the setting Gas City uses) it never went away; `bd dolt status` said
"running" and every command, `bd ping` included, failed until
`bd dolt stop`.

The supervising goroutine now reports a clean exit as errBackendExited,
so Running flips on any backend exit and Stop treats it as benign. This
follows the existing proxied lifecycle contract (child death retires
the owned proxy; the next bd invocation starts a fresh proxy/backend
pair) rather than adding in-proxy restarts: spawn, adoption, stop
epochs and identity already live in the on-demand start path, and a
second restart loop inside the proxy would duplicate that and could
mask a crash-looping backend.

`bd dolt status` no longer headlines a proxy whose managed backend is
gone as "running"; it says the proxy is up but not serving and points
at `bd dolt stop` (for proxies from an older bd). The JSON payload is
unchanged. `bd ping` already verifies by running SELECT 1 through the
proxy, so after this fix a successful ping reflects a live pair.

Tests: DoltServer Running goes false after SIGTERM (clean exit) and
SIGKILL, and Stop succeeds; managed-local lane test that SIGTERMs the
backend with idle timeout 0 and requires the proxy to retire and
`bd ping --json` to succeed on a fresh pair; status render case.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(dolt status): report running=false for a proxy over a dead managed backend

Review follow-up: the JSON running field now means "serving" (a live proxy
and, on a managed topology, a live dolt behind it), so scripts that key off
running alone are not fooled by a stranded proxy left by an older bd.
proxy_pid/proxy_port and backend_* are unchanged. Adds the PR link to the
CHANGELOG entry.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs(changelog): resolve merge markers left by the origin/main merge

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Gas City Adopt-PR <adopt-pr@gascity.local>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 01:48:15 -07:00
..
BUILD.bazel fix(dbproxy): retire the proxy when its Dolt backend exits cleanly (#6937) 2026-09-29 01:48:15 -07:00
doltserver.go fix(dbproxy): retire the proxy when its Dolt backend exits cleanly (#6937) 2026-09-29 01:48:15 -07:00
doltserver_exit_unix_test.go fix(dbproxy): retire the proxy when its Dolt backend exits cleanly (#6937) 2026-09-29 01:48:15 -07:00
doltserver_test.go build(bazel): integration-tag lane (--config=integration) matching main.yml (#6916) 2026-09-28 14:11:34 -07:00
external_dolt_server.go /{cmd,internal}: get proxy working with remote and tls 2026-07-16 16:44:13 -07:00
external_dolt_server_test.go test(dbproxy): make external_dolt_server_test paths platform-portable (#5820) 2026-08-19 20:25:19 -07:00
server.go /{internal,cmd,.gitignore}: wip, proxy server fixes and uow impl 2026-05-10 06:57:41 -07:00
testmain_test.go fix(test): reap dolt sql-servers leaked by killed test runs, and fail the suite that leaks (#6441) 2026-09-22 15:08:40 -07:00
testserver.go /{internal,cmd,.gitignore}: wip, proxy server fixes and uow impl 2026-05-10 06:57:41 -07:00
testserver_test.go /{internal,cmd,.gitignore}: wip, proxy server fixes and uow impl 2026-05-10 06:57:41 -07:00