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

Performing full restore and log restore separately will be a disaster #54418

Closed
Leavrth opened this issue Jul 3, 2024 · 2 comments · Fixed by #54421
Closed

Performing full restore and log restore separately will be a disaster #54418

Leavrth opened this issue Jul 3, 2024 · 2 comments · Fixed by #54421
Labels
component/br This issue is related to BR of TiDB. severity/major type/bug The issue is confirmed as a bug.

Comments

@Leavrth
Copy link
Contributor

Leavrth commented Jul 3, 2024

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

  1. Start a Log Restore.
  2. Create a table named as test.t1.
  3. Full Backup with backup ts T1.
  4. Insert one row into the cluster.
  5. Wait for log backup task checkpoint to advance.
  6. Restart a new cluster
  7. restore full
  8. restore log restore with start ts T1.

2. What did you expect to see? (Required)

There is one row in the table test.t1.

3. What did you see instead (Required)

There is no row in the table test.t1.

4. What is your TiDB version? (Required)

v6.5, v7.1, v7.5, v8.1

@Leavrth Leavrth added type/bug The issue is confirmed as a bug. severity/major component/br This issue is related to BR of TiDB. affects-6.5 affects-7.1 affects-7.5 affects-8.1 labels Jul 3, 2024
@ti-chi-bot ti-chi-bot bot added may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.1 labels Jul 3, 2024
@Leavrth
Copy link
Contributor Author

Leavrth commented Jul 3, 2024

                                 time line
                                     |
             start a log task -----> | -----> T0, save table infos at T0, not having table test.t1
                                     |
       create a table test.t1 -----> |
                                     |
                  full backup -----> | -----> T1, save table infos at T1, having table test.t1
                                     |
     insert rows into test.t1 -----> |
                                     |
                                     v
                                 time line
                                     |
                 full restore -----> | -----> downstream having table test.t1
                                     |
                  log restore -----> | -----> use table infos at T0 as based upstream tables' view, however test.t1 is not exist.
                                     |          Therefore, it doesn't know the table id of test.t1, and then doesn't know which data belongs to test.t1
                                     |
                                     v

@Leavrth
Copy link
Contributor Author

Leavrth commented Jul 5, 2024

Minimal reproduce step

Backup

# workload 1
mysql --host 127.0.0.1 --port 4000 -u root -e "CREATE TABLE test.t1(id int primary key, a char(20));"

# start a log backup task
tiup br:v8.1.0 log start --task-name pitr -s "local:///root/backups/test1/log" -u 127.0.0.1:2379

# backup full -- BackupTS 450884656681451549
tiup br:v8.1.0 backup full -s "local:///root/backups/test1/full" -u 127.0.0.1:2379

# workload 2
mysql --host 127.0.0.1 --port 4000 -u root -e "CREATE TABLE test.t2(id int primary key, a char(20));"
mysql --host 127.0.0.1 --port 4000 -u root -e "INSERT INTO test.t1 values (1, '1');"

# incremental backup -- BackupTS 450884684363857924
tiup br:v8.1.0 backup full -s "local:///root/backups/test1/incremental" -u 127.0.0.1:2379 --lastbackupts 450884656681451549

# workload 3
mysql --host 127.0.0.1 --port 4000 -u root -e "REPLACE INTO test.t1 values (1, '2');"
mysql --host 127.0.0.1 --port 4000 -u root -e "REPLACE INTO test.t2 values (1, '2');"

Backup Checksum

$ mysql --host 127.0.0.1 --port 4000 -u root -e "SELECT * FROM test.t1;"                               
+----+------+
| id | a    |
+----+------+
|  1 | 2    |
+----+------+

$ mysql --host 127.0.0.1 --port 4000 -u root -e "SELECT * FROM test.t2;"
+----+------+
| id | a    |
+----+------+
|  1 | 2    |
+----+------+

Restore

# full restore
tiup br:v8.1.0 restore full -s "local:///root/backups/test1/full" -u 127.0.0.1:2379

# incremental restore
tiup br:v8.1.0 restore full -s "local:///root/backups/test1/incremental" -u 127.0.0.1:2379

# log restore
tiup br:v8.1.0 restore point -s "local:///root/backups/test1/log" -u 127.0.0.1:2379 --start-ts 450884684363857924

Restore Checksum

# Case - Rewrite TS overrided
$ mysql --host 127.0.0.1 --port 4000 -u root -e "SELECT * FROM test.t1;"
+----+------+
| id | a    |
+----+------+
|  1 | 1    |
+----+------+

# Case - No Rewrite Rule Find
$ mysql --host 127.0.0.1 --port 4000 -u root -e "SELECT count(*) FROM test.t2;"
+----------+
| count(*) |
+----------+
|        0 |
+----------+

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/br This issue is related to BR of TiDB. severity/major type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant