Add Vitess query deadline support via QUERY_TIMEOUT_MS comment directive#118
Merged
TheSentinel454 merged 2 commits intomasterfrom Mar 6, 2026
Merged
Add Vitess query deadline support via QUERY_TIMEOUT_MS comment directive#118TheSentinel454 merged 2 commits intomasterfrom
TheSentinel454 merged 2 commits intomasterfrom
Conversation
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>
gruane-sq
approved these changes
Mar 6, 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
Adds a new
QueryDeadlineVitessDBOptionthat enables query timeouts using Vitess's/*vt+ QUERY_TIMEOUT_MS=<ms> */comment directive syntax.Changes
QueryDeadlineVitess— newDBOption, follows the same pattern asQueryDeadlinePercona56andQueryDeadlineMySQL57vitessDeadlineQueryRewriter— prepends the Vitess comment directive to SELECT queries (including parenthesized unions). Non-SELECT queries are left unchanged, matching Vitess's limitation.TestWithVitessDeadlineandTestWithVitessDefaultDeadlinecovering Query/QueryRow on DB and Tx, nested queries, whitespace trimming, non-SELECT passthrough, and default deadline behavior.Usage
Optionally with a default deadline:
References