fix(dolt): retarget base's poolCfg comment, drop the false serve-provider claim, cover the config.yaml rung

Maintainer fixup for the #6145 adoption. Two parts.

Rebase compose (original): base's comment above poolCfg said it was "shared by
the pool knobs below", which the deadline compose falsified -- after this PR
poolCfg has exactly one call site (dolt.max-conns). Retargeted to match.

Review fixes (iteration 1, all three non-gating minors; the nit is declined
below):

- The PR claimed `bd serve`'s store provider as a beneficiary of the relocated
  ladder. It is not one: `grep -c -F 'dolt.New' cmd/bd/uow_factory.go` is 0, and
  the tree says so itself at uow_factory.go:365-367 ("the DoltStore serve never
  touches"). Dropped that clause from all three sites that carried it -- the
  CHANGELOG bullet (both of its clauses), applyPoolTimeouts's doc comment, and
  this test file's header. The surviving beneficiaries are verified rather than
  merely shortened: cmd/bd/store_factory.go:76 does reach dolt.New, as do the
  doctor paths, alongside library callers of New/NewFromConfig*. The separate
  "`bd serve`'s HTTP data path ... is unchanged" sentence is true and is kept.

- Added a fourth subtest covering the config.yaml rung on the constructor path.
  The three existing subtests only reach the env rung, so poolTimeoutFromConfig's
  directory fallback -- the rung a library consumer that never called
  config.Initialize depends on -- was pinned only for applyResolvedConfig
  (TestApplyResolvedConfig in open_test.go). The new subtest mirrors that one
  through applyConfigDefaults, which reads the directory off cfg.BeadsDir rather
  than a parameter, and asserts the no-global-viper premise first so it cannot
  pass vacuously. Proven load-bearing: disabling the GetStringFromDir rung fails
  exactly two subtests, base's and this new one.

- Listed pool_timeouts_test.go in internal/storage/dolt/BUILD.bazel's go_test
  srcs. At origin/main that list is an exact 223/223 match with the package's
  test files, so it is gazelle-maintained and the PR's new file was the only
  drift in the merged tree (223 srcs vs 224 on disk) -- which is what
  .github/workflows/bazel.yml's `make bazel-sync` + git-status check reds on.
  Added the single entry by hand rather than running a full sync, so no
  base-owned rows come along.

Declined, deliberately: the nit proposing a `beadsDir string` parameter for
poolTimeoutFromConfig. The claude lane names that exact shape as the refactor
that silently re-opens #6144 while every existing pin stays green, and the two
items are coupled through their remedies. The coverage subtest above is the
precondition for it, so the ordering is recorded for a future change rather than
taken here; it is optional and out of scope for a non-gating nit.

Validation on this head: go build ./... and go vet ./internal/storage/dolt/
clean, gofmt clean, and -run
'^(TestApplyConfigDefaultsAppliesPoolTimeoutLadder|TestApplyResolvedConfig)$'
gives 2 top-level PASS / 17 subtests / 0 FAIL.
This commit is contained in:
Gas City Adopt-PR 2026-09-29 00:19:14 +00:00
commit d0f0b013fe
4 changed files with 54 additions and 11 deletions

View file

@ -12,13 +12,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- **`BEADS_DOLT_POOL_READ_TIMEOUT` / `dolt.pool-read-timeout` (and the write
twins) now apply to every `bd` command in server mode.** The knobs shipped in
#5089, but their env/config ladder ran only for callers of `NewFromConfig*`;
the CLI's own store open and `bd serve`'s provider hand-build their config
and go straight to `New`, so every `bd` command kept the built-in 10 s pool
the CLI's own store open hand-builds its config and goes straight to `New`,
so every `bd` command kept the built-in 10 s pool
deadline whatever the knob said — on a large shared server that is what made
`bd close` of a bead with dependents die in its recompute with `i/o timeout`
and no relief valve. The ladder now runs from the constructor every DoltStore
open shares — the CLI's store, `bd serve`'s store provider and library
callers of `New`/`NewFromConfig*`; `bd serve`'s HTTP data path builds its own
open shares — the CLI's store and library callers of
`New`/`NewFromConfig*`; `bd serve`'s HTTP data path builds its own
DSN without pool deadlines and is unchanged
([#6144](https://github.com/gastownhall/beads/issues/6144)). Note for
operators of loaded servers: the documented precedence now reaches `bd

View file

@ -268,6 +268,7 @@ go_test(
"mixed_table_lifecycle_test.go",
"multistore_multiprocess_test.go",
"open_test.go",
"pool_timeouts_test.go",
"port_provenance_test.go",
"portsource_propagation_test.go",
"post_migration_pool_heal_integration_test.go",

View file

@ -315,7 +315,7 @@ func applyResolvedConfig(ctx context.Context, beadsDir string, fileCfg *configfi
cfg.ServerTLS = fileCfg.GetDoltServerTLS()
}
// config.yaml rung shared by the pool knobs below. It needs both reads:
// config.yaml rung for the pool-size knob below. It needs both reads:
// config.GetString reads a package-global viper populated only by
// cmd/bd's config.Initialize(), so for a library consumer it always
// returns "" and the project's configured values were silently ignored.
@ -323,7 +323,9 @@ func applyResolvedConfig(ctx context.Context, beadsDir string, fileCfg *configfi
// fallback dolt.auto-start carries above for this exact hole. The
// fallback follows GetStringFromDir's ladder, so when beadsDir is not
// the process CWD a user-level ~/.config/bd/config.yaml value outranks
// that project's file — same behavior as dolt.auto-start.
// that project's file — same behavior as dolt.auto-start. The pool
// deadlines carry the same rung in poolTimeoutFromConfig, which runs
// from applyPoolTimeouts so every DoltStore open gets it.
poolCfg := func(key string) string {
if v := config.GetString(key); v != "" {
return v
@ -359,8 +361,8 @@ func applyResolvedConfig(ctx context.Context, beadsDir string, fileCfg *configfi
// overloaded shared-server deployments raise it so ordinary queries stop dying
// with "i/o timeout" under load (bd-vz0y9). It is idempotent, and it runs from
// New (applyConfigDefaults) so every DoltStore open honors the knob — the CLI's own
// store open and bd serve's provider hand-build their Config and never pass
// through applyResolvedConfig, which is how the knob shipped in #5089 stayed
// store open hand-builds its Config and never passes through
// applyResolvedConfig, which is how the knob shipped in #5089 stayed
// inert for every bd command in server mode (gastownhall/beads#6144).
func applyPoolTimeouts(cfg *Config) {
if cfg.PoolReadTimeout == 0 {

View file

@ -1,17 +1,20 @@
package dolt
import (
"github.com/steveyegge/beads/internal/config"
"os"
"path/filepath"
"strings"
"testing"
"time"
"github.com/steveyegge/beads/internal/config"
)
// TestApplyConfigDefaultsAppliesPoolTimeoutLadder pins the pool-deadline knobs
// at the seam every DoltStore open shares. applyResolvedConfig applied the
// BEADS_DOLT_POOL_READ_TIMEOUT / dolt.pool-read-timeout ladder (#5089), but
// only callers of NewFromConfig* pass through it: the CLI's own store open and
// bd serve's provider hand-build their Config and go straight to New →
// only callers of NewFromConfig* pass through it: the CLI's own store open
// hand-builds its Config and goes straight to New →
// applyConfigDefaults, so every `bd` command in server mode kept the built-in
// 10s deadline whatever the knob said (gastownhall/beads#6144). New is the one
// constructor all of them call, so the ladder has to hold there.
@ -61,4 +64,41 @@ func TestApplyConfigDefaultsAppliesPoolTimeoutLadder(t *testing.T) {
t.Fatalf("buildServerDSN default deadline missing: %s", dsn)
}
})
// The config.yaml rung, on the constructor path. The subtests above only
// reach the env rung, so poolTimeoutFromConfig's dir fallback -- the rung a
// library consumer that never called config.Initialize depends on -- was
// pinned only for applyResolvedConfig (TestApplyResolvedConfig in
// open_test.go). This mirrors that subtest through applyConfigDefaults,
// which reads the directory off cfg.BeadsDir rather than a parameter.
t.Run("config.yaml populates the pool deadlines on the constructor path", func(t *testing.T) {
// Premise, as in the base subtest: with a populated global viper the
// dir-fallback rung under test is not the one answering and this would
// pass vacuously.
config.ResetForTesting()
t.Cleanup(config.ResetForTesting)
if config.GetString("dolt.pool-read-timeout") != "" || config.GetString("dolt.pool-write-timeout") != "" {
t.Fatal("global viper unexpectedly configured; this subtest's premise is broken")
}
t.Setenv("BEADS_DOLT_POOL_READ_TIMEOUT", "")
t.Setenv("BEADS_DOLT_POOL_WRITE_TIMEOUT", "")
beadsDir := t.TempDir()
body := "dolt:\n pool-read-timeout: 120s\n pool-write-timeout: 45\n"
if err := os.WriteFile(filepath.Join(beadsDir, "config.yaml"), []byte(body), 0o644); err != nil {
t.Fatalf("writing config.yaml: %v", err)
}
cfg := &Config{ServerMode: true, Database: "ladder", Path: t.TempDir(), BeadsDir: beadsDir}
applyConfigDefaults(cfg)
if cfg.PoolReadTimeout != 120*time.Second {
t.Fatalf("PoolReadTimeout = %v, want 120s from config.yaml", cfg.PoolReadTimeout)
}
if cfg.PoolWriteTimeout != 45*time.Second {
t.Fatalf("PoolWriteTimeout = %v, want 45s from config.yaml (bare number = seconds)", cfg.PoolWriteTimeout)
}
if dsn := buildServerDSN(cfg, cfg.Database); !strings.Contains(dsn, "readTimeout=2m0s") {
t.Fatalf("buildServerDSN did not carry the config.yaml deadline: %s", dsn)
}
})
}