forked from pingcap/br
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add retry on split client. (pingcap#247)
* restore: add retry on split client. * restore: don't fail when RegionError has no leader * restore: use findLeaderErr instead of splitErrors * *: use go.uber.org/multierr instead of coreos/multierror. * restore: add failpoint tests on retry. * *: make linter happy. * *: remove probabilistic, and disable failpoint anyway. * restore: add test on generic retryable error. * *: fix CI. * restore: use failpoint to inject leader. * *: enable failpoint in testcover. * *: accept some advise from @kenny. * *: add a test point. * Update pkg/restore/split_client.go Co-authored-by: kennytm <[email protected]> * restore: apply suggestions. * Merge branch 'master' of https://github.com/pingcap/br into retry-split-master * go.mod: fix version of failpoint. * restore: remove some retry on batcher. Co-authored-by: kennytm <[email protected]>
- Loading branch information
Showing
10 changed files
with
260 additions
and
47 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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,84 @@ | ||
#!/bin/sh | ||
# | ||
# Copyright 2020 PingCAP, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
set -eu | ||
DB="$TEST_NAME" | ||
TABLE="usertable" | ||
LOG="not-leader.log" | ||
DB_COUNT=3 | ||
|
||
for i in $(seq $DB_COUNT); do | ||
run_sql "CREATE DATABASE $DB${i};" | ||
go-ycsb load mysql -P tests/$TEST_NAME/workload -p mysql.host=$TIDB_IP -p mysql.port=$TIDB_PORT -p mysql.user=root -p mysql.db=$DB${i} | ||
done | ||
|
||
for i in $(seq $DB_COUNT); do | ||
row_count_ori[${i}]=$(run_sql "SELECT COUNT(*) FROM $DB${i}.$TABLE;" | awk '/COUNT/{print $2}') | ||
done | ||
|
||
|
||
# backup full | ||
echo "backup start..." | ||
run_br --pd $PD_ADDR backup full -s "local://$TEST_DIR/$DB" --ratelimit 5 --concurrency 4 | ||
|
||
rm -f $LOG | ||
|
||
for i in $(seq $DB_COUNT); do | ||
run_sql "DROP DATABASE $DB${i};" | ||
done | ||
|
||
|
||
# restore full | ||
echo "restore start..." | ||
|
||
unset BR_LOG_TO_TERM | ||
GO_FAILPOINTS="github.com/pingcap/br/pkg/restore/not-leader-error=1*return(true)->1*return(false);\ | ||
github.com/pingcap/br/pkg/restore/somewhat-retryable-error=3*return(true)" \ | ||
run_br restore full -s "local://$TEST_DIR/$DB" --pd $PD_ADDR --ratelimit 1024 --log-file $LOG || true | ||
BR_LOG_TO_TERM=1 | ||
|
||
grep "a error occurs on split region" $LOG && \ | ||
grep "split region meet not leader error" $LOG && \ | ||
grep "Full restore Success" $LOG && \ | ||
grep "find new leader" $LOG | ||
|
||
if [ $? -ne 0 ]; then | ||
echo "failed to retry on failpoint." | ||
echo "full log:" | ||
cat $LOG | ||
exit 1 | ||
fi | ||
|
||
for i in $(seq $DB_COUNT); do | ||
row_count_new[${i}]=$(run_sql "SELECT COUNT(*) FROM $DB${i}.$TABLE;" | awk '/COUNT/{print $2}') | ||
done | ||
|
||
fail=false | ||
for i in $(seq $DB_COUNT); do | ||
if [ "${row_count_ori[i]}" != "${row_count_new[i]}" ];then | ||
fail=true | ||
echo "TEST: [$TEST_NAME] fail on database $DB${i}" | ||
fi | ||
echo "database $DB${i} [original] row count: ${row_count_ori[i]}, [after br] row count: ${row_count_new[i]}" | ||
done | ||
|
||
if $fail; then | ||
echo "TEST: [$TEST_NAME] failed!" | ||
exit 1 | ||
fi | ||
|
||
echo "TEST $TEST_NAME passed." | ||
|
||
|
This file contains 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,12 @@ | ||
recordcount=1000 | ||
operationcount=0 | ||
workload=core | ||
|
||
readallfields=true | ||
|
||
readproportion=0 | ||
updateproportion=0 | ||
scanproportion=0 | ||
insertproportion=0 | ||
|
||
requestdistribution=uniform |
This file contains 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
This file contains 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
Oops, something went wrong.