You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After a leader transfer, split or merge, the new leader rejects async-commit and 1PC prewrites with MaxTimestampNotSynced until it has synced max_ts from PD. This usually takes only a few milliseconds.
client-go treats this error as retryable: onRegionError backs off with BoMaxTsNotSynced (2ms to 500ms) and resends the request. This client returned the error to the caller instead, so a commit with use_async_commit() or try_one_pc() failed whenever its prewrite hit that window.
This PR backs off with the region backoff and resends, like client-go. TiKV checks max_ts before it writes anything, so resending is safe, even at commit points. If the backoff runs out, the region error is returned unchanged.
Summary by CodeRabbit
Bug Fixes
Operations encountering a temporary timestamp synchronization issue now retry instead of failing immediately, improving the chance that they complete successfully.
If retries are exhausted, the original region error is reported.
After a leader transfer, split or merge, the new leader rejects
async-commit and 1PC prewrites with MaxTimestampNotSynced until it has
synced max_ts from PD, which usually takes milliseconds.
handle_region_error returned the error to the caller, so a transaction
committed with use_async_commit or try_one_pc failed whenever its
prewrite hit that window.
TiKV checks the sync status before writing anything, so the rejection is
definitive and the cached leader remains valid. Back off with the region
backoff and resend, as client-go does with BoMaxTsNotSynced. This applies
to commit points too: only an UndeterminedResult is terminal for them.
Signed-off-by: Yijun Zhao <ariesdevil77@gmail.com>
No actionable comments were generated in the recent review.
Recent review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: d2b3a8e8-cdea-4895-bc32-774c563aa3c7
Commits
Reviewing files that changed from the base of the PR and between 1b883bf and 03139c8.
Files selected for processing: 1
src/request/plan.rs
Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.
Walkthrough
The request plan now retries MaxTimestampNotSynced without invalidating the cached leader. Tests cover success after retries and return of the region error when retries are exhausted.
Changes: Retry handling
Layer / File(s)
Summary
Retry classification and validation src/request/plan.rs
MaxTimestampNotSynced follows the retry path, while RaftEntryTooLarge remains terminal. Tests verify success after two retries and error return after three configured retries.
No actionable merge-blocking risk is established; the new retry behavior follows the available protocol contract.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title clearly and concisely describes the main change: retrying requests after MaxTimestampNotSynced errors.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage
Explanation
Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 2 functions across 1 files.
Resolution
Write docstrings for the functions missing them to satisfy the coverage threshold.
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Warning
Some tools did not complete. Review the errors below.
Clippy (1.99.0)
Clippy execution failed
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.
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
approvedcontributionThis PR is from a community contributor.dco-signoff: yesIndicates the PR's author has signed the dco.needs-1-more-lgtmIndicates a PR needs 1 more LGTM.size/LDenotes a PR that changes 100-499 lines, ignoring generated files.
2 participants
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.
After a leader transfer, split or merge, the new leader rejects async-commit and 1PC prewrites with
MaxTimestampNotSynceduntil it has synced max_ts from PD. This usually takes only a few milliseconds.client-go treats this error as retryable:
onRegionErrorbacks off withBoMaxTsNotSynced(2ms to 500ms) and resends the request. This client returned the error to the caller instead, so a commit withuse_async_commit()ortry_one_pc()failed whenever its prewrite hit that window.This PR backs off with the region backoff and resends, like client-go. TiKV checks max_ts before it writes anything, so resending is safe, even at commit points. If the backoff runs out, the region error is returned unchanged.
Summary by CodeRabbit