Skip to content

fix(hub): generous read-pool FD cap + safe rows.Close defer-conversion (#79)#292

Merged
physercoe merged 1 commit into
mainfrom
agent/deepseek-1/290-fix-hub-generous-read-pool-fd
Jun 14, 2026
Merged

fix(hub): generous read-pool FD cap + safe rows.Close defer-conversion (#79)#292
physercoe merged 1 commit into
mainfrom
agent/deepseek-1/290-fix-hub-generous-read-pool-fd

Conversation

@agentfleets

Copy link
Copy Markdown
Collaborator

Closes #290

Part A — generous read-pool FD safety cap

  • Added maxReadConns() helper (default 64, overridable via HUB_DB_MAX_READ_CONNS)
  • Applied SetMaxOpenConns(maxReadConns()) + SetMaxIdleConns(maxReadConns()) to:
    • s.db — the control reader pool (server.go)
    • Per-team eventsR and digestR reader pools (openStorePool reader branch in store_split.go)
  • Updated all "uncapped" comments to reflect the generous bound (server.go struct field, comment block, db.go, store_split.go)
  • Writer pools untouched (already SetMaxOpenConns(1))

Part B — safe rows.Close defer-conversion

Converted 7 single-query sites to defer rows.Close():

File Function Reason
handlers_admin_teams.go handleAdminRotateTeamToken single query, then writes on writeDB
handlers_insights.go fillInsightsByProject 1st query single query, then bulk queries
handlers_criteria.go cascadeDeliverableRatified single query, then transitionCriterion
phase_completion_gate.go cascadeDeliverableUnratified single query, then transitionCriterion
seed_demo_lifecycle.go ResetLifecycleDemo single query, then BeginTx
loop_hooks.go onPreAgentIdle single query, then emitSystemNotification
loop_sweep.go bumpLoopProgress single query, then writeDB.ExecContexts

Left all loop-body and multi-query manual closes alone (per spec trap).

Verify

PATH=/usr/local/go/bin:$PATH go build ./... && go vet ./... && go test ./internal/server/ -timeout=20m

All pass. gofmt -w clean.

🤖 Generated with Claude Code

#79)

Part A: add SetMaxOpenConns(maxReadConns()) to all reader pools —
s.db and per-team eventsR/digestR via openStorePool. Default 64,
overridable via HUB_DB_MAX_READ_CONNS. Writer pools unchanged.

Part B: convert 7 single-query manual rows.Close() sites to defer.
Leave all loop-body and multi-query closes alone.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@agentfleets agentfleets requested a review from physercoe June 14, 2026 04:53
@physercoe physercoe merged commit 7b03ec3 into main Jun 14, 2026
4 checks passed
@physercoe physercoe deleted the agent/deepseek-1/290-fix-hub-generous-read-pool-fd branch June 14, 2026 04:55
physercoe pushed a commit that referenced this pull request Jun 14, 2026
Hub robustness sweep (#74#79) + Projects-tab segmented sub-tabs.
- ADR-045 D4 storage maintenance (#288)
- raw-SQL-error no-leak sweep (#280/#283), rows.Err audit (#286),
  FTS/routing status codes (#287), owner-or-steward gate (#281),
  read-pool cap + rows.Close defer (#292), additive pagination (#293)
- segmented Projects | Workspaces tabs (#289)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(hub): generous read-pool FD cap + safe rows.Close defer-conversion (#79)

3 participants