Skip to content
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

Implement the merging operation of Keyspace Group #6589

Closed
JmPotato opened this issue Jun 13, 2023 · 3 comments · Fixed by #6745
Closed

Implement the merging operation of Keyspace Group #6589

JmPotato opened this issue Jun 13, 2023 · 3 comments · Fixed by #6745
Assignees
Labels
component/keyspace Key space. component/tso Timestamp Oracle. type/development The issue belongs to a development tasks

Comments

@JmPotato
Copy link
Member

JmPotato commented Jun 13, 2023

Development Task

As we now support the split operation of Keyspace Group, it is also necessary to provide reverse merge operations, which can help us better manage the number of Keyspace Groups and do some rollback operations.

To implement the merging operation of Keyspace Group, it may contain the following process:

  1. Put all merging groups into the merging state.
    a. Once the groups that need to be merged watch this change, it will stop serving any TSO request to the outside.
    b. Once the merging target groups watch this change, it will start the merging process described as follows.
  2. The merging target server sends the merging gRPC requests to all group primaries which need to be merged.
  3. Once a primary received the merging request, it will:
    a. Stop serving any TSO request to the outside if it has not been performed step 1.a yet.
    b. Return the current TSO as the gRPC response.
  4. The merging target server keeps trying step 3 until all the primaries responded, and then:
    a. Set its current TSO to the biggest one among all the primary responses.
    b. Ask the PD leader to delete these groups from the meta and move the keyspaces.
@JmPotato JmPotato added component/tso Timestamp Oracle. component/keyspace Key space. type/development The issue belongs to a development tasks labels Jun 13, 2023
@JmPotato JmPotato self-assigned this Jun 13, 2023
@binshi-bing
Copy link
Contributor

What if the primary of a keyspace group, which has already stopped the service and responded the PD leader, transferred to another server before 4.a. Without persistent info, will the new primary of the keyspace group still serve the requests before 4.a?

@binshi-bing
Copy link
Contributor

binshi-bing commented Jun 13, 2023

To solve the above problem, can we have the following steps?

  1. Once the default keyspace group watches this change, it deletes all non-default keyspace groups in etcd.
  2. The keyspace group managers on tso servers watch this change and handle the DELETE events to stop serving these keyspace groups.
  3. Once the default keyspace group watches all primaries of non-default keyspace groups are gone, it reads the timestamps saved in etcd of all non-default keyspace groups, reset own timestmp with the max(all non-default persisted timestamps) + a time window.

After synced offline with @JmPotato , we'll go with this improvement.

@binshi-bing
Copy link
Contributor

We already have step 2 implemented. We also have part of 3 implemented and the other part has the similar logic and code.

ti-chi-bot bot added a commit that referenced this issue Jun 14, 2023
ref #6589

Implement the keyspace group merging API.

Signed-off-by: JmPotato <ghzpotato@gmail.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
ti-chi-bot bot pushed a commit that referenced this issue Jun 15, 2023
ref #6589

Prohibit merging the default keyspace group.

Signed-off-by: JmPotato <ghzpotato@gmail.com>
ti-chi-bot bot pushed a commit that referenced this issue Jun 25, 2023
ref #6589

Implement the keyspace group merge checker.

Signed-off-by: JmPotato <ghzpotato@gmail.com>
ti-chi-bot bot added a commit that referenced this issue Jun 26, 2023
ref #6589

Signed-off-by: Ryan Leung <rleungx@gmail.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
@ti-chi-bot ti-chi-bot bot closed this as completed in #6745 Jul 6, 2023
ti-chi-bot bot pushed a commit that referenced this issue Jul 6, 2023
)

close #6589

- Implement `deletedGroupCleaner` to clean up the legacy TSO key.
- Extract the timestamp key path constructor.

Signed-off-by: JmPotato <ghzpotato@gmail.com>
ti-chi-bot bot added a commit that referenced this issue Jul 7, 2023
ref #6589

Since it's possible that a keyspace group is to be deleted and merged before its TSO is initialized,
we should allow `mergedTS` to be zero in `mergingChecker`. This PR allows this case and only
block the merging when loading the TSO meets the error.

Signed-off-by: JmPotato <ghzpotato@gmail.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
rleungx pushed a commit to rleungx/pd that referenced this issue Aug 2, 2023
ref tikv#6589

Implement the keyspace group merging API.

Signed-off-by: JmPotato <ghzpotato@gmail.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
rleungx pushed a commit to rleungx/pd that referenced this issue Aug 2, 2023
ref tikv#6589

Prohibit merging the default keyspace group.

Signed-off-by: JmPotato <ghzpotato@gmail.com>
rleungx pushed a commit to rleungx/pd that referenced this issue Aug 2, 2023
ref tikv#6589

Implement the keyspace group merge checker.

Signed-off-by: JmPotato <ghzpotato@gmail.com>
rleungx added a commit to rleungx/pd that referenced this issue Aug 2, 2023
ref tikv#6589

Signed-off-by: Ryan Leung <rleungx@gmail.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
rleungx pushed a commit to rleungx/pd that referenced this issue Aug 2, 2023
…kv#6745)

close tikv#6589

- Implement `deletedGroupCleaner` to clean up the legacy TSO key.
- Extract the timestamp key path constructor.

Signed-off-by: JmPotato <ghzpotato@gmail.com>
rleungx pushed a commit to rleungx/pd that referenced this issue Aug 2, 2023
ref tikv#6589

Since it's possible that a keyspace group is to be deleted and merged before its TSO is initialized,
we should allow `mergedTS` to be zero in `mergingChecker`. This PR allows this case and only
block the merging when loading the TSO meets the error.

Signed-off-by: JmPotato <ghzpotato@gmail.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
rleungx pushed a commit to rleungx/pd that referenced this issue Aug 2, 2023
ref tikv#6589

Implement the keyspace group merge checker.

Signed-off-by: JmPotato <ghzpotato@gmail.com>
rleungx added a commit to rleungx/pd that referenced this issue Aug 2, 2023
ref tikv#6589

Signed-off-by: Ryan Leung <rleungx@gmail.com>

Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com>
rleungx pushed a commit to rleungx/pd that referenced this issue Aug 2, 2023
…kv#6745)

close tikv#6589

- Implement `deletedGroupCleaner` to clean up the legacy TSO key.
- Extract the timestamp key path constructor.

Signed-off-by: JmPotato <ghzpotato@gmail.com>
ti-chi-bot bot pushed a commit that referenced this issue Aug 22, 2023
ref #6589

Add log to show the progress of group cleaning up.

Signed-off-by: JmPotato <ghzpotato@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/keyspace Key space. component/tso Timestamp Oracle. type/development The issue belongs to a development tasks
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants