Repository navigation
[yumin-xia] feat(wicked): pass query timeouts to wpgx as database timeouts - #25
Merged
Merged
Conversation
Generated methods call wpgx.WithDBTimeout instead of starting their own deadline, so the timeout starts once the query has a connection and no longer covers waiting for one or the cache lookup. Each visitors receive the statement context from wpgx rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each reuses qctx for the statement context instead of declaring a new local, and a parameter named wpgx is generated as wpgx_. Document that the cache bound needs dcache without Redis single flight. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A visitor returning the statement deadline and a drain that outlasts the database timeout after an early stop both fail with wpgx.ErrDBTimeout, as the previous Each failed when its query context expired. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The generated code needs wpgx.WithDBTimeout. Pin the wpgx branch commit in the endtoend module and run the bookstore contracts at the commit regenerated with this generator, until wpgx is tagged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
:one,:many,:exec,:execrows,:execresult,:copyfrom, Each) pass their-- -- timeouttowpgx.WithDBTimeoutinstead of startingcontext.WithTimeoutat the top. The timeout therefore bounds database work: it starts once the query has a pooled connection (wpgx waits at mostmax(T, AcquireTimeout), default 2s) and no longer covers the wait for a connection or the cache lookup, which is bounded by the Redis client's own timeouts.WithDBTimeout(compile-time check). Old generated code keeps its behavior with new wpgx.Architecture and Key Decisions
qctxis reassigned, so no new local can collide with a SQL parameter) and report throughwpgx.StatementErr: an expired statement context, a visitor returning that deadline, and a drain that outlasts the timeout after an early stop matchwpgx.ErrDBTimeout; other errors stay primary.wpgxis a reserved identifier (a parameter namedwpgxbecomeswpgx_), because method bodies now call the package.GUIDE.mddocuments the semantics; local recorddocs/changelogs/2026-11-20-db-timeout-after-acquire.md(primary design record in [yumin-xia] feat: start the database timeout after a connection is acquired wpgx#24).Risks and Remaining Work
v0.5.2-0.20261120053742-4b29cac2136d) and the wicked CI job checks out the bookstore PR commit89b3fbc; before merge, bump both to the wpgx tag and the merged bookstore commit.Breaking Changes
Regenerating changes the generated code (the timeout no longer covers waiting for a connection or the cache lookup) and requires the new wpgx. No signature changes.
Database Migrations
None.
Verification
go test -p=1 ./internal/codegen/wicked ./internal/cmd;go test -run 'TestReplay/base/' ./internal/endtoend(with this repo'ssqlc-gen-json): pass.internal/endtoend/testdata:CGO_ENABLED=0 go build ./...;SQLC_EACH_TEST_DSN=… go test -race ./wicked_compat/go: pass, including new PostgreSQL checks (TestGeneratedTimeoutPostgres: a 1.3s wait does not fail a 1s query, visitor deadline, visitor/drain timeouts, a lock-blocked query reportswpgx.ErrDBTimeout). Mutation checks: the v2.5.0 generated Each fixture and the pre-fix Each lines fail them.89b3fbc.--tags=examples ./...suite (needs MySQL/PostgreSQL services); CI runs it.Merge Order
Related PRs
🤖 Generated with Claude Code