fix: Add a configurable lock_timeout (default 5s) to add_partitions - #31
Merged
Merged
Conversation
Bounds how long the CREATE ... PARTITION OF statements wait on the partitioned parent's lock, so a scheduled maintain run backs off instead of blocking writers queued behind it. On timeout the statement errors, the transaction rolls back, and the table is reported as a failed extension to be retried on the next run. Defaults to 5s (matching the swapper) and is tunable via --lock-timeout on the add_partitions and maintain commands (lockTimeout in the library options / MaintainOptions). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Greptile SummaryThis PR adds a configurable lock timeout for partition creation. The main changes are:
Confidence Score: 5/5The change is focused and covered by targeted tests for default behavior, custom overrides, and option forwarding. The implementation follows the existing timeout configuration pattern and the added tests exercise the new transaction-local lock timeout behavior.
What T-Rex did
Reviews (1): Last reviewed commit: "fix: Add a configurable lock_timeout (de..." | Re-trigger Greptile |
ryanmcilmoyl
approved these changes
Jul 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
add_partitionsruns itsCREATE ... PARTITION OFstatements inside one transaction, each of which briefly needs a lock on the partitioned parent. With nolock_timeoutset, a contended run waits indefinitely on that lock and can queue writers behind it.This sets
SET LOCAL lock_timeout(default5s) on theadd_partitionstransaction so those statements back off instead of blocking. On timeout the statement errors, the transaction rolls back, and the caller sees a failed extension it can retry — rather than a run that hangs on a lock.The timeout is configurable, matching the existing
swap/unswapconvention:--lock-timeout(default5s) on theadd_partitionsandmaintaincommands.lockTimeoutonAddPartitionsOptionsandMaintainOptions;maintain()forwards it toaddPartitions.Test plan
add_partitionsdefaults to a5slock_timeoutand honors a custom override (asserted viaSHOW lock_timeout).maintainforwards a customlockTimeoutthrough to theadd_partitionstransaction.tscand Prettier clean.🤖 Generated with Claude Code