retry: delegate killed checks to signal handler - #2042
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthrough
ChangesKill signal handling
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant TransactionAction
participant Backoffer
participant Variables
participant KillSignalHandler
TransactionAction->>Backoffer: CheckKilled()
Backoffer->>Variables: LoadKillSignalHandler()
Variables-->>Backoffer: configured handler or nil
Backoffer->>KillSignalHandler: HandleSignal()
KillSignalHandler-->>Backoffer: error or nil
Backoffer-->>TransactionAction: interruption result
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@kv/variables.go`:
- Around line 39-40: Document the exported HandleSignal method in the
KillSignalHandler interface with a clear Go doc comment describing when it
returns an error, following standard Go documentation conventions.
In `@txnkv/transaction/2pc.go`:
- Around line 1103-1105: Extend transaction-level tests in 2pc_test.go beyond
TestMinCommitTsManager to cover doActionOnBatches with an interruptible batch
and a backoffer configured with a KillSignalHandler that returns
ErrQueryInterrupted. Assert that doActionOnBatches returns that interruption
error before invoking batch handling.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 285cb786-9601-4402-bc04-5b5820e4703a
📒 Files selected for processing (4)
config/retry/backoff.goconfig/retry/backoff_test.gokv/variables.gotxnkv/transaction/2pc.go
da5feb9 to
416c4d8
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@kv/variables.go`:
- Around line 58-66: Synchronize access to Variables.KillSignalHandler between
SetKillSignalHandler and Backoffer.CheckKilled to eliminate races when shared
Variables are reused. Treat handler configuration as lifecycle state and either
protect both reads and writes with the existing synchronization mechanism or
store and retrieve the handler through a concurrency-safe copy/source, while
preserving the current handler precedence behavior.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 52f9cd7b-82ca-4a37-afcd-fb1192fa5e49
📒 Files selected for processing (4)
config/retry/backoff.goconfig/retry/backoff_test.gokv/variables.gotxnkv/transaction/2pc.go
🚧 Files skipped from review as they are similar to previous changes (3)
- config/retry/backoff.go
- txnkv/transaction/2pc.go
- config/retry/backoff_test.go
|
/test pull-integration-test-nextgen |
0c306f8 to
bd0b65f
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
Signed-off-by: Yang Keao <yangkeao@chunibyo.icu>
bd0b65f to
1a233db
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
| @@ -49,6 +58,30 @@ type Variables struct { | |||
| // When its value is 0, it's not killed | |||
| // When its value is not 0, it's killed, the value indicates concrete reason. | |||
| Killed *uint32 | |||
There was a problem hiding this comment.
If we don't need to keep compatibility, we can remove this field. I'm not sure about the interface strategy for client-go so I still kept this.
|
/test pull-integration-test-nextgen |
Problem
TiDB needs to run richer kill-signal handling at interruptible TiKV retry checkpoints so it can cooperatively detect a disconnected client while a statement is blocked in TiKV. The existing client-go code only reads the legacy
Killedflag, and the 2PC path duplicates that check.This is needed by pingcap/tidb#68682.
Downstream integration: pingcap/tidb#70343.
What changed
kv.KillSignalHandlerinterface tokv.Variables.Backoffer.CheckKilleddelegate to the handler when configured, while preserving the existingKilledfallback for compatibility.Backoffer.CheckKilledfor interruptible 2PC actions instead of duplicating the atomic kill-flag check.Compatibility
This is an additive API change. Existing callers that only populate
Variables.Killedkeep the previous behavior. TiDB can opt in by installing its SQL kill-signal handler.Tests
go test ./config/retry ./txnkv/transactionSummary by CodeRabbit
New Features
Bug Fixes