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

BACKUP SQL Command returns size of 0 #27247

Closed
haiboumich opened this issue Aug 16, 2021 · 6 comments · Fixed by #27508
Closed

BACKUP SQL Command returns size of 0 #27247

haiboumich opened this issue Aug 16, 2021 · 6 comments · Fixed by #27508
Assignees
Labels
component/br This issue is related to BR of TiDB. severity/major sig/migrate type/bug The issue is confirmed as a bug.

Comments

@haiboumich
Copy link

Bug Report

1. Minimal reproduce step (Required)

(1) start a TiDB cluster locally through tiup

  1. env: CentOS
  2. command: tiup playground
  3. version: v5.1.1

(2) generate some data before backup

I used the following script to generate around 5 million records

#!/bin/bash

mysql -h127.0.0.1 -P4000 -uroot -e "CREATE TABLE if not exists test.user(name VARCHAR(200), age int) COMMENT='user info';"

for((i=1;i<=10000;i++));  
do   
        mysql -h127.0.0.1 -P4000 -uroot -e "INSERT INTO test.user VALUES('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30), ('AAA', 10), ('BBB', 20), ('CCC', 30);"
done  

(3) use SQL command to backup

BACKUP DATABASE * TO 'local:///tmp/backup0816/full';

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

After the BACKUP is finished, it should return info about the BACKUP whose size is bigger than 0.

3. What did you see instead (Required)

The backup took 9.04 seconds and the "Size" is 0, while I could see the backup file in folder /tmp/backup0816/full and I could use these files to retore to a new constructed empty TiDB cluster using SQL command RESTORE DATABASE * FROM 'local:///tmp/backup0816/full';

+------------------------------+------+--------------------+---------------------+---------------------+
| Destination                  | Size | BackupTS           | Queue Time          | Execution Time      |
+------------------------------+------+--------------------+---------------------+---------------------+
| local:///tmp/backup0816/full |    0 | 427058788672733186 | 2021-08-16 15:46:33 | 2021-08-16 15:46:33 |
+------------------------------+------+--------------------+---------------------+---------------------+
1 row in set (9.04 sec)

4. What is your TiDB version? (Required)

MySQL [test]> SELECT tidb_version();
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| tidb_version()                                                                                                                                                                                                                                                                                                       |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Release Version: v5.1.1
Edition: Community
Git Commit Hash: 797bddd25310ed42f0791c8eccb78be8cce2f502
Git Branch: heads/refs/tags/v5.1.1
UTC Build Time: 2021-07-28 11:00:26
GoVersion: go1.16.4
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
@haiboumich haiboumich added the type/bug The issue is confirmed as a bug. label Aug 16, 2021
@jebter jebter added component/br This issue is related to BR of TiDB. sig/migrate labels Aug 16, 2021
@3pointer
Copy link
Contributor

/assign @fengou1

@YuJuncen
Copy link
Contributor

The root cause of the problem is that we get the total size via a key named "Size" in the summary collector:

tidb/executor/brie.go

Lines 509 to 510 in f7fdffc

case "Size":
gs.info.archiveSize = value

...but we recorded the size with other keys, we can record the same data with key "Size" to solve the problem, at, for example, here:

g.Record(summary.RestoreDataSize, archiveSize)

@fengou1
Copy link
Contributor

fengou1 commented Aug 19, 2021

Test on v5.0.2, it works as expected
image

@fengou1
Copy link
Contributor

fengou1 commented Aug 19, 2021

BACKUP in v5.1.1:
image

RESTORE in v5.1.1:
image

@fengou1
Copy link
Contributor

fengou1 commented Aug 23, 2021

#27508

@ti-srebot
Copy link
Contributor

Please edit this comment or add a new comment to complete the following information

Not a bug

  1. Remove the 'type/bug' label
  2. Add notes to indicate why it is not a bug

Duplicate bug

  1. Add the 'type/duplicate' label
  2. Add the link to the original bug

Bug

Note: Make Sure that 'component', and 'severity' labels are added
Example for how to fill out the template: #20100

1. Root Cause Analysis (RCA) (optional)

2. Symptom (optional)

3. All Trigger Conditions (optional)

4. Workaround (optional)

5. Affected versions

6. Fixed versions

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 sig/migrate type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants