Skip to content

Add Vitess query deadline support via QUERY_TIMEOUT_MS comment directive#118

Merged
TheSentinel454 merged 2 commits intomasterfrom
luket/vitess-query-deadline
Mar 6, 2026
Merged

Add Vitess query deadline support via QUERY_TIMEOUT_MS comment directive#118
TheSentinel454 merged 2 commits intomasterfrom
luket/vitess-query-deadline

Conversation

@TheSentinel454
Copy link
Copy Markdown
Collaborator

Summary

Adds a new QueryDeadlineVitess DBOption that enables query timeouts using Vitess's /*vt+ QUERY_TIMEOUT_MS=<ms> */ comment directive syntax.

Changes

  • QueryDeadlineVitess — new DBOption, follows the same pattern as QueryDeadlinePercona56 and QueryDeadlineMySQL57
  • vitessDeadlineQueryRewriter — prepends the Vitess comment directive to SELECT queries (including parenthesized unions). Non-SELECT queries are left unchanged, matching Vitess's limitation.
  • TestsTestWithVitessDeadline and TestWithVitessDefaultDeadline covering Query/QueryRow on DB and Tx, nested queries, whitespace trimming, non-SELECT passthrough, and default deadline behavior.

Usage

db, err := squalor.NewDB(sqlDB, squalor.QueryDeadlineVitess)

Optionally with a default deadline:

db, err := squalor.NewDB(sqlDB, squalor.QueryDeadlineVitess, squalor.QueryDeadlineDefault(30 * time.Second))

References

TheSentinel454 and others added 2 commits March 6, 2026 07:40
Add QueryDeadlineVitess DBOption that enables query timeouts using Vitess's
/*vt+ QUERY_TIMEOUT_MS=<ms> */ comment directive syntax. Only SELECT queries
are rewritten, matching Vitess's limitation.

Follows the same pattern as existing QueryDeadlinePercona56 and
QueryDeadlineMySQL57 options.

Amp-Thread-ID: https://ampcode.com/threads/T-019cc326-2a7a-7269-8d1f-7957213f8916
Co-authored-by: Amp <amp@ampcode.com>
Skip rewriting queries that already contain a QUERY_TIMEOUT_MS directive
to avoid double-adding the timeout comment.

Amp-Thread-ID: https://ampcode.com/threads/T-019cc326-2a7a-7269-8d1f-7957213f8916
Co-authored-by: Amp <amp@ampcode.com>
@TheSentinel454 TheSentinel454 merged commit db0a3e9 into master Mar 6, 2026
6 checks passed
@TheSentinel454 TheSentinel454 deleted the luket/vitess-query-deadline branch March 6, 2026 13:38
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.

2 participants