Skip to content

fix(wpgx): separate cache and SQL execution budgets - #20

Open
obrr-hhx wants to merge 1 commit into
Stumble:mainfrom
obrr-hhx:handson/cache-sql-timeout-budget
Open

obrr-hhx wants to merge 1 commit into
Stumble:mainfrom
obrr-hhx:handson/cache-sql-timeout-budget

Conversation

@obrr-hhx

Copy link
Copy Markdown

Summary

Cached reads can exhaust their SQL deadline while waiting for a cache miss. Add opt-in sql_timeout for cached :one and :many queries, starting the SQL context inside the database callback. Existing timeout remains the overall budget; existing queries retain their behavior.

For example, timeout: 1s plus sql_timeout: 250ms allows a slow cache miss without giving SQL a full second. Earlier caller deadlines still win. Cache keys, TTLs, invalidation and public method signatures are unchanged.

Generation and baseline checks

Fix 115 existing full-vet warnings in the SQLite ANTLR generation pipeline. Move the generated unused-label workaround before its label rather than after return. Keep ANTLR 4.13.1, grammar and parser tables unchanged; the generated diff is exactly 115 goto moves. A helper regression checks both exit paths, idempotence, compilation and vet.

Verification

Go 1.26.8:

  • make build CGO_ENABLED=0 COMMIT_HASH=v2.4.0-dev
  • CGO_ENABLED=0 go vet ./...
  • go run ./scripts/test-local -- go test -count=1 -tags=examples -timeout=20m ./...
  • CGO_ENABLED=0 go build ./... in the root and generated fixture module
  • make fmt; unrelated existing formatter churn restored
  • Pinned bookstore consumer: make sqlc, make sqlc-verify, unchanged generated output and go test -race -count=1 -p 1 -timeout=10m ./pkg/usecases

No database migration or runtime dependency change. Consumer adoption is opt-in. Redis transport deadlines remain the consumer's responsibility.

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.

1 participant