pingcap / br

A command-line tool for distributed backup and restoration of the TiDB cluster data
https://pingcap.com/docs/dev/how-to/maintain/backup-and-restore/br/
Apache License 2.0
124 stars 102 forks source link

Check whether table has data before the restoration. #801

Open 3pointer opened 3 years ago

3pointer commented 3 years ago

Feature Request

Describe your feature request related problem:

problem is like #797 When the table already has some data before we do a full restore job and the job will be failed. The response error is checksum mismatched.

Describe the feature you'd like:

We'd better add a pre-check before this restoration. because the whole restoration may take a long time to finish. if the checksum result is not reliable. we should let the user know it at the beginning.

Describe alternatives you've considered:

This check should only use in the full restoration.

Teachability, Documentation, Adoption, Migration Strategy:

feniljain commented 3 years ago

Hey @3pointer @kennytm, I am a first time contributor to br, I am interested to take up this issue, understanding from the issue one wants a pre-check for confirming if there's already some data before restore starts, looking into some code, I think this could be approached by changing filterRestoreFunction(), where we are looping over various tables, we could add a check by TotalBytes for each table and stop the process if anyone of the tables would be non-empty we would return an error back. Please correct me if I am wrong.