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

Fix check for inequal boundary #9

Merged
merged 2 commits into from
May 31, 2022
Merged

Fix check for inequal boundary #9

merged 2 commits into from
May 31, 2022

Conversation

JaySon-Huang
Copy link
Owner

@JaySon-Huang JaySon-Huang commented May 31, 2022

Signed-off-by: JaySon-Huang [email protected]

The tiflash#4956(pingcap/tiflash#4956) may result in varying rows between TiFlash and TiKV. And the boundary between TiFlash and TiKV is not the same.

> set tidb_isolation_read_engines = "tiflash";select min(_tidb_rowid), max(_tidb_rowid) from cdm_unit_convert_dh;
+------------------+------------------+
| min(_tidb_rowid) | max(_tidb_rowid) |
+------------------+------------------+
| 11367899         | 19915336         |
+------------------+------------------+

> set tidb_isolation_read_engines = "tikv";select min(_tidb_rowid), max(_tidb_rowid) from cdm_unit_convert_dh;
+------------------+------------------+
| min(_tidb_rowid) | max(_tidb_rowid) |
+------------------+------------------+
| <null>           | <null>           |
+------------------+------------------+

@JaySon-Huang
Copy link
Owner Author

JaySon-Huang commented May 31, 2022

# Run the check and find the region peers we need to remove from the log
> ./bin/tiflash-ctl check consistency --database test --table test_table --tidb_ip ${TIDB_IP} --tidb_port ${TIDB_PORT} > check.log
>  grep 'operator' check.log
operator add remove-peer 581 62
operator add remove-peer 581 95
operator add remove-peer 699 63
operator add remove-peer 699 64
operator add remove-peer 829 63
operator add remove-peer 829 64

# Remove the region peers that contains incorrect data, PD will schedule new peers on TiFlash and overwrite the incorrect data automatically
> tiup ctl:v5.4.0 pd -u ${PD_IP}:${PD_PORT} -i
» operator add remove-peer 581 62
Success!
» operator add remove-peer 581 95
Success!
» operator add remove-peer 699 63
Success!
» operator add remove-peer 699 64
Success!
» operator add remove-peer 829 63
Success!
» operator add remove-peer 829 64
Success!

# repeat to check and run again if need
> ./bin/tiflash-ctl check consistency --database test --table test_table --tidb_ip ${TIDB_IP} --tidb_port ${TIDB_PORT} > check_2.log
# The row id range and number of rows of tikv and tiflash shown in the output file should be the same
> cat check_2.log
set tidb_allow_batch_cop = 0 => 4ms
set tidb_allow_mpp = 0 => 0ms
select min(_tidb_rowid), max(_tidb_rowid) from `test`.`test_table` => 24036ms (tikv)
select min(_tidb_rowid), max(_tidb_rowid) from `test`.`test_table` => 557ms (tiflash)
RowID range: [62530067, 64156203] (tikv)      <-- check the rowid range
RowID range: [62530067, 64156203] (tiflash)   <-- check the rowid range
Init query ranges: [[62530067, 64156204)]
select count(*) from `test`.`test_table` where 62530067 <= _tidb_rowid and _tidb_rowid < 64156204 => 488ms (tikv)
select count(*) from `test`.`test_table` where 62530067 <= _tidb_rowid and _tidb_rowid < 64156204 => 173ms (tiflash)
select count(*) from `test`.`test_table` where 62530067 <= _tidb_rowid and _tidb_rowid < 64156204 => 2ms (tikv)
select count(*) from `test`.`test_table` where 62530067 <= _tidb_rowid and _tidb_rowid < 64156204 => 186ms (tiflash)
Range [62530067, 64156204), num of rows: tikv 1624960, tiflash 1624960. OK   <-- check the number of rows

Here is a example of output
check.log

@JaySon-Huang JaySon-Huang merged commit fdbd866 into main May 31, 2022
@JaySon-Huang JaySon-Huang deleted the fix_check_consistency branch May 31, 2022 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant