-
Notifications
You must be signed in to change notification settings - Fork 12
add async commit downgrading design doc #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sticnarf
wants to merge
1
commit into
tikv:master
Choose a base branch
from
sticnarf:async-commit-downgrade
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| # Downgrade to 4.0 | ||
|
|
||
| Async commit has made some changes to the format of the persistent data. The new format cannot be recognized by TiKV 4.0. And async commit locks cannot be processed by TiKV 4.0 correctly. Therefore, TiKV 5.0 users cannot downgrade seamlessly to 4.0 if async commit is used. Some extra procedures are needed before the downgrading. | ||
|
|
||
| ## Resolve locks | ||
|
|
||
| Async commit locks must be handled by TiKV 5.0 clients. It is because in async commit, a transaction can be considered committed even if none of the locks are committed. However, TiKV 4.0 will always treat such a transaction uncommitted. | ||
|
|
||
| ## Format changes | ||
|
|
||
| Async commit locks must be all resolved before downgrading, so we can ignore the format changes on the locks. | ||
|
|
||
| However, the records in the write CF also have format changes after async commit. | ||
|
|
||
| * Rollbacks may overlap with normal commits. `FLAG_OVERLAPPED_ROLLBACK` marks that a write record has an overlapped rollback. | ||
| * To deal with the compatibility between async commit and bypass-raft GC (compaction filter and green GC), `gc_fence` field is added to write records. | ||
|
|
||
| Before downgrading to 4.0, we must clear these newly added fields. | ||
|
|
||
| ## Solution | ||
|
|
||
| The downgrading preparation should be done in an external tool. | ||
|
|
||
| 1. Use the internal API to disable async commit. | ||
|
|
||
| 2. Trigger a full lock resolving using the latest timestamp. | ||
|
|
||
| After resolving locks, there should be no locks using the async commit protocol. And because async commit has already been disabled, no more async commit locks will appear. | ||
|
|
||
| 3. Wait until all peers apply to the current index to guarantee that no async commit locks or no write records with `FLAG_OVERLAPPED_ROLLBACK` or `gc_fence` will be written to any of the TiKV stores. | ||
|
|
||
| 4. Add a new debug service in TiKV for cleaning the fields in write records introduced by async commit. Run it on each TiKV store. | ||
|
|
||
| It scans the whole write CF in the local TiKV. If it reads any write record with these new fields, it removes these fields and rewrite. The amount of data that needs rewriting should be very small. | ||
|
|
||
| 5. After all write records are processed, downgrading to 4.0 shouldn't be blocked by async commit. | ||
|
|
||
| This solution does not need the cluster to be offline. | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How to do it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Iterate all peers and do a follower read (execute a read index) for each, then I think we can make sure it's up to date.