Skip to content

Commit

Permalink
cherry pick pingcap#35641 to release-5.4
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
  • Loading branch information
3pointer authored and ti-srebot committed Jun 23, 2022
1 parent 1f8716d commit 704fada
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
3 changes: 1 addition & 2 deletions br/pkg/task/restore_raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ func RunRestoreRaw(c context.Context, g glue.Glue, cmdName string, cfg *RestoreR
!cfg.LogProgress)

// RawKV restore does not need to rewrite keys.
rewrite := &restore.RewriteRules{}
err = restore.SplitRanges(ctx, client, ranges, rewrite, updateCh, true)
err = restore.SplitRanges(ctx, client, ranges, nil, updateCh, true)
if err != nil {
return errors.Trace(err)
}
Expand Down
28 changes: 27 additions & 1 deletion br/tests/br_rawkv/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,23 @@ run_test() {
--key "$TEST_DIR/certs/br.key" \
--mode put --put-data "311121:31, 31112100:32, 311122:33, 31112200:34, 3111220000:35, 311123:36"


# put some keys starts with t. https://github.com/pingcap/tidb/issues/35279
# t_128_r_12 --<hex encode>--> 745f3132385f725f3132
# t_128_r_13 --<hex encode>--> 745f3132385f725f3133
bin/rawkv --pd $PD_ADDR \
--ca "$TEST_DIR/certs/ca.pem" \
--cert "$TEST_DIR/certs/br.pem" \
--key "$TEST_DIR/certs/br.key" \
--mode put --put-data "745f3132385f725f3132:31, 745f3132385f725f3133:32"

checksum_ori=$(checksum 31 3130303030303030)
checksum_partial=$(checksum 311111 311122)
checksum_t_prefix=$(checksum 745f3132385f725f3131 745f3132385f725f3134)

# backup rawkv
echo "backup start..."
run_br --pd $PD_ADDR backup raw -s "local://$BACKUP_DIR" --start 31 --end 3130303030303030 --format hex --concurrency 4 --crypter.method "aes128-ctr" --crypter.key "0123456789abcdef0123456789abcdef"
run_br --pd $PD_ADDR backup raw -s "local://$BACKUP_DIR" --start 31 --end 745f3132385f725f3134 --format hex --concurrency 4 --crypter.method "aes128-ctr" --crypter.key "0123456789abcdef0123456789abcdef"

# delete data in range[start-key, end-key)
clean 31 3130303030303030
Expand Down Expand Up @@ -153,6 +164,21 @@ run_test() {
fail_and_exit
fi

echo "t prefix restore start..."
run_br --pd $PD_ADDR restore raw -s "local://$BACKUP_DIR" --start "745f3132385f725f3131" --end "745f3132385f725f3134" --format hex --concurrency 4 --crypter.method "aes128-ctr" --crypter.key "0123456789abcdef0123456789abcdef"
bin/rawkv --pd $PD_ADDR \
--ca "$TEST_DIR/certs/ca.pem" \
--cert "$TEST_DIR/certs/br.pem" \
--key "$TEST_DIR/certs/br.key" \
--mode scan --start-key 745f3132385f725f3131 --end-key 745f3132385f725f3134

checksum_new=$(checksum 745f3132385f725f3131 745f3132385f725f3134)

if [ "$checksum_new" != "$checksum_t_prefix" ];then
echo "checksum failed after restore"
fail_and_exit
fi

export GO_FAILPOINTS=""
}

Expand Down

0 comments on commit 704fada

Please sign in to comment.