-
Notifications
You must be signed in to change notification settings - Fork 69
[DNM] RFC: keyspace level GC #113
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
ystaticy
wants to merge
54
commits into
tikv:master
Choose a base branch
from
ystaticy:ks_level_gc
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 9 commits
Commits
Show all changes
54 commits
Select commit
Hold shift + click to select a range
57aef25
ks_level_gc init commit
ystaticy b2e017a
in check consistency and trigger compaction
ystaticy 3e5f711
fix words
ystaticy 9196bce
fix words
ystaticy 9e72539
fix words
ystaticy e90dd88
fix words
ystaticy 0900f46
fix words
ystaticy 2dce1cc
add link
ystaticy 09181ad
format
ystaticy b97f612
add details for optimize trigger timing and assert judgment
ystaticy 3689a4d
add details
ystaticy a964053
fix comments
ystaticy 342a08d
fix comments
ystaticy 9c5d786
fix comments
ystaticy 24b2ff8
fix comments
ystaticy 73afd99
fix comments
ystaticy 1b4af39
add Usage and Compatibility
ystaticy 3f2582a
fix comments
ystaticy 0a63d88
fix
ystaticy fb72c0c
fix pick
ystaticy e09dd1e
add upgrade,remove Other non-GC logic desc
ystaticy d68bf14
update img
ystaticy 9607e07
update img
ystaticy 57ad936
fix lint
baiyuqing bd4f336
add Data import and export
ystaticy f40a3c9
add desc about global br
ystaticy 98812bc
add desc about global br
ystaticy 44a3b5e
update
baiyuqing af1fb55
update
baiyuqing 66fbb9b
update formula
baiyuqing c142552
update formula
baiyuqing a5dffa3
update
baiyuqing b1bf526
update
baiyuqing bf00fec
fix
baiyuqing 575fbbe
update Motivation
ystaticy 7cafe00
add
ystaticy 02c37c8
add link for keyspace meta
ystaticy d53aa00
Modify the flow chart
ystaticy d10dbec
Modify the flow chart
ystaticy 8ac31a2
fix comments
ystaticy db0b6b2
fix comments
ystaticy db34775
fix comments
ystaticy 0a9b122
fix comments
ystaticy 1d329a9
fix comments
ystaticy 1eb7445
fix comments
ystaticy 38df077
fix comments
ystaticy 1478202
fix comments
ystaticy 6f70d7d
fix comments
ystaticy 3da02a3
fix code format
ystaticy a83f127
remove upgrade part
ystaticy 1b86eae
correct grammatical and spelling errors
ystaticy a0818df
small fix: Grammar and Expression
ystaticy 5eb460b
small fix: Grammar and Expression
ystaticy 47f606a
update words
ystaticy 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,78 @@ | ||
| # Keyspace level GC | ||
|
|
||
| ## Summary | ||
|
|
||
| - RFC PR: https://github.com/tikv/rfcs/pull/113 | ||
| - Tracking Issue: https://github.com/tikv/tikv/issues/16896 | ||
|
|
||
| TiKV support keyspace level gc. | ||
|
|
||
| ## Motivation | ||
|
|
||
| Previously, TiDB has supported the deployment of multiple TiDB clusters with different keyspaces | ||
| on a single PD TiKV cluster. | ||
|
|
||
| We've implemented multiple TiDB clusters, with one global TiDB GC worker (A TiDB server without Keyspace configuration) | ||
| to calculate the global GC safe point and resolve locks, While each keyspace's TiDB has their own GC Worker, | ||
ystaticy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| keyspace GC Worker use the global GC safe point to do deleteRange in the sepical keyspace ranges. | ||
|
|
||
| But old implementation causes the calculation of the global gc to depend on the oldest safe point and min start ts | ||
| of all keyspaces and TiDB cluster without keyspace configured. | ||
ystaticy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| So we propose the implementation of keyspace level gc: | ||
|
|
||
| TiDB PR https://github.com/pingcap/tidb/pull/51300 implements: | ||
ystaticy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| Isolation of GC safe point calculations between keyspaces (the concept is 'keyspace level GC'). | ||
ystaticy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| When the Keyspace GC safe point calculation of Keyspace with keyspace level gc is slow, | ||
| it will not affect other keyspaces GC safe point calculation. | ||
| Keyspaces can be created by setting gc_management_type = keyspace_level_gc to enable keyspace level GC, | ||
ystaticy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| then this keyspace can calculate GC safe point by itself. | ||
|
|
||
| TiKV PR https://github.com/tikv/tikv/pull/16808 implemented on TiKV side: | ||
ystaticy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| In GC process, it parses the keyspace id from the data key, | ||
ystaticy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| combines the keyspace meta config and the keyspace level GC safe point corresponding to the keyspace id to determine | ||
| the GC safe point value of the data key and execute the GC logic. | ||
|
|
||
|
|
||
| ## Concepts of GC management type: | ||
ystaticy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 1. Global GC: | ||
| - Represents the previous default GC logic; there is a TiDB calculate the global GC safe point for the whole cluster. | ||
| - The default GC management type for keyspace is Global GC, | ||
ystaticy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 2. Keyspace level GC: | ||
| - Indicates that the keyspace will advance its own gc safe point. | ||
| - It is possible and only possible to set gc_management_type = keyspace_level_gc when PD creates keyspaces. | ||
ystaticy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| - The keyspace which already set gc_management_type = keyspace_level_gc, 'gc_management_type' it can not be updated | ||
ystaticy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| to "global_gc". | ||
| - Keyspace GC-related data: min start ts, GC safe point,service safe point of keyspace have their own etcd path | ||
ystaticy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| with keyspace prefix in PD. | ||
| - Therefore, the keysapce can calculate the GC by itself. | ||
ystaticy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| ## Implementation in TiKV | ||
ystaticy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 1. Get keyspace meta and keyspace level GC safe point: | ||
| - New KeyspaceMetaWatchService : Watch keyspace meta etcd path to get the keyspace meta and put it | ||
| in cache keyspace_id_meta_map<u32, keyspacepb::KeyspaceMeta>. | ||
| - New KeyspaceLevelGCWatchService : Watch the etcd path of the keyspace GC safe point to get the GC safe point | ||
| with keyspace level GC enabled, put it in cache keyspace_level_gc_map<u32, u64>. | ||
|
|
||
| 2. How to get GC safe point by mvcc key in Compaction Filter: | ||
|  | ||
|
|
||
| 3. How to determine if a keyspace uses a global gc safe point: | ||
|  | ||
|
|
||
| 4. Use GC safe point to optimize trigger timing and assert judgment | ||
| 1. Skip GC when GC safe point is 0 in create_compaction_filter. | ||
ystaticy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| 2. check_need_gc function return false in create_compaction_filter. | ||
| 3. assert( safe_point > 0 ) when new compaction filter. | ||
|
|
||
| 5. Other non-GC logic that uses GC safe point does not currently have to support keyspace level GC. | ||
| 1. check region consistency command: | ||
| 1. It needs check GC safe point on followers to ensure that the data to be checked on the follower is not GC. | ||
| 2. It doesn't support which keyspace with keyspace level gc enabled yet, if user request check consistency | ||
| for the keyspace range, the user will get a "not supported" message. | ||
| 2. GC safe point used in raftstore to trigger compaction when no valid split key can be found. | ||
ystaticy marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| It was introduced in PR https://github.com/tikv/tikv/pull/15284 | ||
| 1. It just uses GC safe point to determine when to trigger compaction. | ||
| The main PR of the Keyspace level gc will not fit this logic. | ||
| It will be considered for submitting another PR for support after the keyspace level gc core PR is merged. | ||
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.
Uh oh!
There was an error while loading. Please reload this page.