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

[to #67] fix rawkv backup failure #77

Merged
merged 12 commits into from
Apr 14, 2022
Merged

[to #67] fix rawkv backup failure #77

merged 12 commits into from
Apr 14, 2022

Conversation

pingyu
Copy link
Collaborator

@pingyu pingyu commented Mar 28, 2022

Signed-off-by: pingyu yuping@pingcap.com

What problem does this PR solve?

Issue Number: to #67

Problem Description: Cherry pick pingcap/tidb#32612 to fix rawkv backup failure

What is changed and how does it work?

Pass isRawKv to necessary functions.
Migrate integration codes to new framework (from run.sh to run.py).

Effectiveness of fail points is verified by log as following:

$ cat /tmp/br.log.2022-04-07T21.51.18+0800
[2022/04/07 21:51:18.809 +08:00] [INFO] [info.go:40] ["Welcome to Backup & Restore (BR)"] [release-version=] [git-hash=] [git-branch=] [go-version=go1.16.10] [utc-build-time=] [race-enabled=false]
[2022/04/07 21:51:18.810 +08:00] [INFO] [common.go:561] [arguments] [__command="br backup raw"] [check-requirements=false] [end=3130303030303030] [format=hex] [log-level=debug] [start=31] [storage=local:///tmp/storage1/fp]
[2022/04/07 21:51:18.810 +08:00] [INFO] [conn.go:240] ["new mgr"] [pdAddrs=127.0.0.1:45588]
[2022/04/07 21:51:18.818 +08:00] [INFO] [client.go:352] ["[pd] create pd client with endpoints"] [pd-address="[127.0.0.1:45588]"]
[2022/04/07 21:51:18.824 +08:00] [INFO] [base_client.go:349] ["[pd] switch leader"] [new-leader=http://127.0.0.1:45588] [old-leader=]
[2022/04/07 21:51:18.824 +08:00] [INFO] [base_client.go:104] ["[pd] init cluster id"] [cluster-id=7083823612246103449]
[2022/04/07 21:51:18.824 +08:00] [INFO] [client.go:648] ["[pd] tso dispatcher created"] [dc-location=global]
[2022/04/07 21:51:18.825 +08:00] [INFO] [conn.go:217] ["checked alive KV stores"] [aliveStores=1] [totalStores=1]
[2022/04/07 21:51:18.825 +08:00] [INFO] [client.go:352] ["[pd] create pd client with endpoints"] [pd-address="[127.0.0.1:45588]"]
[2022/04/07 21:51:18.826 +08:00] [INFO] [base_client.go:349] ["[pd] switch leader"] [new-leader=http://127.0.0.1:45588] [old-leader=]
[2022/04/07 21:51:18.826 +08:00] [INFO] [base_client.go:104] ["[pd] init cluster id"] [cluster-id=7083823612246103449]
[2022/04/07 21:51:18.826 +08:00] [INFO] [client.go:648] ["[pd] tso dispatcher created"] [dc-location=global]
[2022/04/07 21:51:18.831 +08:00] [INFO] [client.go:84] ["new backup client"]
[2022/04/07 21:51:18.833 +08:00] [INFO] [client.go:268] ["backup started"] [startKey=31] [endKey=3130303030303030] [rateLimit=0] [concurrency=0]
[2022/04/07 21:51:18.835 +08:00] [INFO] [client.go:681] ["try backup"] [store-id=1] ["retry time"=0]
[2022/04/07 21:51:19.691 +08:00] [INFO] [client.go:752] ["range backed up"] [store-id=1] [small-range-start-key=31] [small-range-end-key=3130303030303030]
[2022/04/07 21:51:19.691 +08:00] [INFO] [client.go:730] ["backup streaming finish"] [store-id=1] [retry-time=0]
[2022/04/07 21:51:19.691 +08:00] [DEBUG] [push.go:147] ["failpoint tikv-regionh-error injected."] [msg="region error"]
[2022/04/07 21:51:19.691 +08:00] [WARN] [push.go:173] ["backup occur region error"] [error="{"RegionError":{"message":"region error"}}"]
[2022/04/07 21:51:19.692 +08:00] [INFO] [client.go:290] ["finish backup push down"] [small-range-count=0]
[2022/04/07 21:51:19.692 +08:00] [INFO] [client.go:409] ["start fine grained backup"] [incomplete=1]
[2022/04/07 21:51:19.693 +08:00] [INFO] [client.go:355] ["find leader"] [Leader="{"id":5,"store_id":1}"] [key=31]
[2022/04/07 21:51:19.693 +08:00] [INFO] [client.go:681] ["try backup"] ["retry time"=0]
[2022/04/07 21:51:20.527 +08:00] [INFO] [client.go:752] ["range backed up"] [small-range-start-key=31] [small-range-end-key=3130303030303030]
[2022/04/07 21:51:20.527 +08:00] [DEBUG] [client.go:503] [OnBackupResponse] [resp="{"start_key":"MQ==","end_key":"MTAwMDAwMDA=","files":[{"name":"1_4_2_6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b_1649339479693_default.sst","sha256":"RQUromdvrdnWPTeu3G7zpTB597HLHYhwy8DE1oy07u8=","start_key":"MQ==","end_key":"MTAwMDAwMDA=","total_kvs":112343,"total_bytes":28390723,"cf":"default","size":29577131,"cipher_iv":"MIwBb8H8VGrLIaTl7TyBxw=="}]}"]
[2022/04/07 21:51:20.528 +08:00] [INFO] [client.go:730] ["backup streaming finish"] [retry-time=0]
[2022/04/07 21:51:20.528 +08:00] [INFO] [client.go:469] ["put fine grained range"] [fine-grained-range-start=31] [fine-grained-range-end=3130303030303030]
[2022/04/07 21:51:20.528 +08:00] [INFO] [client.go:305] ["raw ranges backed up"] [startKey=31] [endKey=3130303030303030] [cf=default]
[2022/04/07 21:51:20.528 +08:00] [INFO] [client.go:262] ["backup range finished"] [take=1.694703644s]
[2022/04/07 21:51:20.528 +08:00] [INFO] [metafile.go:329] ["write metas finished"] [type=datafile]
[2022/04/07 21:51:20.528 +08:00] [INFO] [metafile.go:369] ["finish the write metas"] [item=1] [type=datafile] [costs=1.69502175s]
[2022/04/07 21:51:20.528 +08:00] [DEBUG] [metafile.go:388] ["backup meta"] [meta="{"cluster_id":7083823612246103449,"cluster_version":"\"6.0.0\"\n","br_version":"BR\nRelease Version: \nGit Commit Hash: \nGit Branch: \nGo Version: go1.16.10\nUTC Build Time: \nRace Enabled: false","files":[{"name":"1_4_2_6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b_1649339479693_default.sst","sha256":"RQUromdvrdnWPTeu3G7zpTB597HLHYhwy8DE1oy07u8=","start_key":"MQ==","end_key":"MTAwMDAwMDA=","total_kvs":112343,"total_bytes":28390723,"cf":"default","size":29577131,"cipher_iv":"MIwBb8H8VGrLIaTl7TyBxw=="}],"is_raw_kv":true,"raw_ranges":[{"start_key":"MQ==","end_key":"MTAwMDAwMDA=","cf":"default"}],"ddls":"W10="}"]
[2022/04/07 21:51:20.529 +08:00] [INFO] [metafile.go:389] ["save backup meta"] [size=351]
[2022/04/07 21:51:20.529 +08:00] [ERROR] [client.go:752] ["[pd] fetch pending tso requests error"] [dc-location=global] [error="[PD:client:ErrClientGetTSO]context canceled: context canceled"] [stack="github.com/tikv/pd/client.(*client).handleDispatcher\n\t/disk1/home/pingyu/go/pkg/mod/github.com/tikv/pd@v1.1.0-beta.0.20211118054146-02848d2660ee/client/client.go:752"]
[2022/04/07 21:51:20.529 +08:00] [INFO] [client.go:666] ["[pd] exit tso dispatcher"] [dc-location=global]
[2022/04/07 21:51:20.529 +08:00] [ERROR] [client.go:752] ["[pd] fetch pending tso requests error"] [dc-location=global] [error="[PD:client:ErrClientGetTSO]context canceled: context canceled"] [stack="github.com/tikv/pd/client.(*client).handleDispatcher\n\t/disk1/home/pingyu/go/pkg/mod/github.com/tikv/pd@v1.1.0-beta.0.20211118054146-02848d2660ee/client/client.go:752"]
[2022/04/07 21:51:20.529 +08:00] [INFO] [client.go:666] ["[pd] exit tso dispatcher"] [dc-location=global]
[2022/04/07 21:51:20.529 +08:00] [INFO] [collector.go:68] ["Raw backup success summary"] [total-ranges=1] [ranges-succeed=1] [ranges-failed=0] [backup-total-regions=2] [total-take=1.72139527s] [total-kv=112343] [total-kv-size=28.39MB] [average-speed=16.49MB/s] [backup-data-size(after-compressed)=29.58MB]

This line is printed when fail point is trigger.

[2022/04/07 21:51:19.691 +08:00] [DEBUG] [push.go:147] ["failpoint tikv-regionh-error injected."] [msg="region error"]

This line is printed because the fail point cause backup of one of the region failed.

[2022/04/07 21:51:19.692 +08:00] [INFO] [client.go:409] ["start fine grained backup"] [incomplete=1]

Code changes

  • Has exported function/method change
    No.
  • Has exported variable/fields change
    No.
  • Has interface methods change
    No.
  • Has persistent data change
    No.
  • No code
    No.

Check List for Tests

This PR has been tested by at least one of the following methods:

  • Unit test
  • Integration test

Side effects

  • No side effects

Related changes

  • No.

Issue Number: tikv#67

Signed-off-by: pingyu <yuping@pingcap.com>
Signed-off-by: pingyu <yuping@pingcap.com>
@pingyu pingyu requested review from zeminzhou and zz-jason and removed request for zeminzhou March 28, 2022 13:15
@pingyu pingyu mentioned this pull request Mar 28, 2022
12 tasks
zeminzhou
zeminzhou previously approved these changes Mar 29, 2022
Signed-off-by: pingyu <yuping@pingcap.com>
br/Makefile Outdated
@@ -118,3 +118,22 @@ clean:
rm -rf *.out
rm -rf bin
rm -rf tools/bin

br_integration_test: br_bins build_br build_for_br_integration_test
@cd br && tests/run.sh
Copy link
Member

Choose a reason for hiding this comment

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

  1. would it raise an error if we build the target br_integration_test?
  2. why name it with br_ prefix?
  3. how about adding this integration test to .github/workflow/ci-br.yml?

Signed-off-by: pingyu <yuping@pingcap.com>
Signed-off-by: pingyu <yuping@pingcap.com>
Signed-off-by: pingyu <yuping@pingcap.com>
Signed-off-by: pingyu <yuping@pingcap.com>
Signed-off-by: pingyu <yuping@pingcap.com>
Signed-off-by: pingyu <yuping@pingcap.com>
zeminzhou
zeminzhou previously approved these changes Apr 8, 2022

def parse_args():
parser = argparse.ArgumentParser(description="The backup/restore integration test runner for RawKV")
parser.add_argument("--br", dest = "br", required = True,
help = "The br binary to be tested.")
help = "The normal br binary to be tested.")
parser.add_argument("--br-test", dest = "br_test", required = True,
Copy link
Member

Choose a reason for hiding this comment

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

can we only test the br with code coverage and failpoint enabled?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

En... I think yes. I worried overmuch.

self.pd = global_args.pd
self.br = global_args.br
self.br = br
self.br_test = global_args.br_test
Copy link
Member

Choose a reason for hiding this comment

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

seems like it hasn't been used?

tester.test_rawkv()

tester_fp = rawkvTester(args.br_test, args, storage_path_suffix="fp", failpoints=FAILPOINT_TIKV_REGION_ERROR)
Copy link
Member

Choose a reason for hiding this comment

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

can we set this failpoint in each test case directly? so we don't need to maintain global failpoint test variables.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will fix it later.

br/Makefile Show resolved Hide resolved
cd br
make test/integration
br-integration-test-5X:
name: br-integration-test-5X-${{ matrix.tikv_version }}
Copy link
Member

Choose a reason for hiding this comment

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

could you add some comments about why separating integrations for v6.0 and nightly apart from it?

Signed-off-by: pingyu <yuping@pingcap.com>
@pingyu
Copy link
Collaborator Author

pingyu commented Apr 11, 2022

@zz-jason All comments are addressed. PTAL~

# construct command and arguments
cmd_list = [cmd]
cmd_list = cmd.split() # `cmd` may contain arguments, so split() to meet requirement of `subprocess.check_output`.
Copy link
Member

Choose a reason for hiding this comment

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

cmd may contain arguments

it breaks the assumption that cmd is used to point to the binary to be executed and args represents all the arguments to the command. Is there other method to maintain this assumption?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I will try to fix it later.

@zz-jason zz-jason changed the title to #67: br: cherry pick tidb#32612 to fix rawkv backup failure [to #67] fix rawkv backup failure Apr 12, 2022
Signed-off-by: pingyu <yuping@pingcap.com>
Signed-off-by: pingyu <yuping@pingcap.com>
Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

@zz-jason
Copy link
Member

we can merge this PR right now and fix the broken test in the future.

@pingyu pingyu merged commit a5cb1a1 into tikv:main Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants