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

raw_restore: fix the issue that raw restore rewrite the t prefix keys (#35641) #35694

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
30 changes: 30 additions & 0 deletions br/tests/br_rawkv/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,27 @@ 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..."
<<<<<<< HEAD
run_br --pd $PD_ADDR backup raw -s "local://$BACKUP_DIR" --start 31 --end 3130303030303030 --format hex --concurrency 4
=======
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"
>>>>>>> fde7c36e1... raw_restore: fix the issue that raw restore rewrite the t prefix keys (#35641)

# delete data in range[start-key, end-key)
clean 31 3130303030303030
Expand Down Expand Up @@ -153,6 +168,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