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

*: add tiflash replica sync progress #14713

Merged
merged 14 commits into from
Feb 12, 2020

Conversation

crazycs520
Copy link
Contributor

Signed-off-by: crazycs crazycs520@gmail.com

What problem does this PR solve?

Add tiflash replica sync Progress in tiflash_replica table.

information_schema> select table_name,available,progress from `TIFLASH_REPLICA`;
+------------+-----------+----------+
| table_name | available | progress |
+------------+-----------+----------+
| t          | 0         | 0.67     |
| tt         | 0         | 0.83     |
+------------+-----------+----------+

What is changed and how it works?

Store the sync progress info in PD(etcd) when TiFlash report the progress.
When sync progress finished, delete the progress info in PD.

Check List

Tests

  • Unit test
  • Manual test (add detailed scripts or steps below)

Step 1: mock tiflash report sync info.

▶ curl -X POST -d '{"id":140,"region_count":5,"flash_region_count":6}' http://127.0.0.1:10080/tiflash/replica

▶ curl -X POST -d '{"id":129,"region_count":2,"flash_region_count":3}' http://127.0.0.1:10080/tiflash/replica

Step 2: check the progress info in the PD(etcd)

▶ etcdctl --endpoints=127.0.0.1:2379 get "/tiflash" --prefix
/tiflash/table/sync/129
0.67
/tiflash/table/sync/140
0.83

step 3: query progress info from tiflash_replica

information_schema> select table_name,table_id,available,progress from `TIFLASH_REPLICA`;
+------------+----------+-----------+----------+
| table_name | table_id | available | progress |
+------------+----------+-----------+----------+
| t          | 129      | 0         | 0.67     |
| tt         | 140      | 0         | 0.83     |
+------------+----------+-----------+----------+

Step 4: mock tiflash report sync info. mock for table_id=140 already sync finished.

▶ curl -X POST -d '{"id":140,"region_count":6,"flash_region_count":6}' http://127.0.0.1:10080/tiflash/replica

Step 5: check the progress info in the PD(etcd)

# the progress info of table_id=140 was been deleted. 
▶ etcdctl --endpoints=127.0.0.1:2379 get "/tiflash" --prefix
/tiflash/table/sync/129
0.67

step 6: query progress info from tiflash_replica

information_schema> select table_name,table_id,available,progress from `TIFLASH_REPLICA`;
+------------+----------+-----------+----------+
| table_name | table_id | available | progress |
+------------+----------+-----------+----------+
| t          | 129      | 0         | 0.67     |
| tt         | 140      | 1         | 1.0      |
+------------+----------+-----------+----------+

Code changes

  • Has exported function/method change

Side effects

Related changes

  • Need to cherry-pick to the release branch

Release note

  • Support query TiFlash replica synchronization progress in the TIFLAH_REPLICA table.

Signed-off-by: crazycs <crazycs520@gmail.com>
domain/infosync/info.go Outdated Show resolved Hide resolved
Copy link
Contributor

@zimulala zimulala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest LGTM

Signed-off-by: crazycs <crazycs520@gmail.com>
Copy link
Contributor

@zimulala zimulala left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zimulala zimulala added the status/LGT1 Indicates that a PR has LGTM 1. label Feb 12, 2020
if available {
err = infosync.DeleteTiFlashTableSyncProgress(status.ID)
} else {
err = infosync.UpdateTiFlashTableSyncProgress(context.Background(), status.ID, float64(status.RegionCount)/float64(status.FlashRegionCount))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are RegionCount and FlashRegionCount? These names are confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, already add a comment for those fields.

Copy link
Contributor

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest is quite ok.

domain/infosync/info.go Outdated Show resolved Hide resolved
domain/infosync/info.go Outdated Show resolved Hide resolved
Copy link
Contributor

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rest LGTM

server/http_handler.go Outdated Show resolved Hide resolved
server/http_handler.go Outdated Show resolved Hide resolved
crazycs520 and others added 2 commits February 12, 2020 19:06
Co-Authored-By: Arenatlx <ailinsilence4@gmail.com>
Co-Authored-By: Arenatlx <ailinsilence4@gmail.com>
@crazycs520
Copy link
Contributor Author

/run-all-tests

@crazycs520
Copy link
Contributor Author

/run-unit-test

1 similar comment
@crazycs520
Copy link
Contributor Author

/run-unit-test

Copy link
Contributor

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@AilinKid AilinKid added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Feb 12, 2020
@crazycs520
Copy link
Contributor Author

/rebuild

@crazycs520 crazycs520 merged commit 7cd8ba3 into pingcap:master Feb 12, 2020
crazycs520 added a commit to lzmhhh123/tidb that referenced this pull request Feb 13, 2020
Signed-off-by: crazycs <crazycs520@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/LGT2 Indicates that a PR has LGTM 2. type/usability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants