require-timeout-settings: explain lock impact in the warning#1216
Merged
kodiakhq[bot] merged 1 commit intoJun 30, 2026
Merged
Conversation
👷 Deploy request for squawkhq pending review.Visit the deploys page to approve it
|
cc405ee to
dcd2dbc
Compare
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
dcd2dbc to
0acb0d1
Compare
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.
Motivation
require-timeout-settingsfires on any statement that can wait on a lock, but the message never says which lock the statement takes or what it conflicts with. That flattens a real distinction:ALTER TABLE ... ADD COLUMNtakes an ACCESS EXCLUSIVE lock that blocks reads and writes, whileCOMMENT ONtakes a SHARE UPDATE EXCLUSIVE lock that blocks neither — it only contends with VACUUM/ANALYZE/index builds. Same generic message today, so a reader can't tell a potential outage from a catalog write that's effectively free.What this changes
Classifies statements by the Postgres lock mode they take, then names that lock in the warning and uses it to build the
lock_timeouthelp, so both are keyed off the lock level rather than the statement.The model is small: a
LockModeenum withname()(used to buildviolation_message()) andhelp(), plusstatement_lock(&stmt) -> LockModefor the classification. This PR wires upSHARE UPDATE EXCLUSIVE(viaCOMMENT ON); everything else maps toLockMode::Unknown, whosename()isNoneso the message and help fall back to the original generic text — so every other message and snapshot is unchanged. Same statements are flagged.Extending
Adding a lock class is a new
LockModevariant plus itsname()/help()arms, and the statements that map to it instatement_lock. The notable gap is the ACCESS EXCLUSIVEALTER TABLEvariants: their lock depends on the per-action subcommand (ADD COLUMNvsVALIDATE CONSTRAINTvsSET STATISTICS…), so classifying them means descending intoalter_table.actions()rather than matching at theStmtlevel. Left for a follow-up to keep this reviewable.Example
Testing
Existing snapshots unchanged; adds
err_comment_on_explains_lock_impact, which asserts theCOMMENT ONhelp includes the lock mode (contains("EXCLUSIVE")rather than a snapshot, so it's robust to help-text wrapping).