-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
MDEV-14992 BACKUP SERVER #4817
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
Open
dr-m
wants to merge
7
commits into
main
Choose a base branch
from
MDEV-14992
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
MDEV-14992 BACKUP SERVER #4817
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
4b4f4ba
MDEV-40756 Incorrect multi-batch recovery of file size
dr-m b387a4a
MDEV-14992/MDEV-38362/MDEV-39092 BACKUP SERVER
dr-m 69dad73
squash! b387a4a6f9f9b3194a29c1a80c39c983d5dc4fd5
dr-m a77b37c
fixup! 69dad73b01a4706718bf7e078f3c861a341110fe
dr-m 035883e
fixup! a77b37c49cf47284580e507303d538a5daa2ea79
dr-m 81b2d10
fixup! 69dad73b01a4706718bf7e078f3c861a341110fe
dr-m 402fa7c
squash! b387a4a6f9f9b3194a29c1a80c39c983d5dc4fd5
dr-m File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| #!/bin/sh | ||
| exec cat > "$MARIADB_DATADIR/$1.tar" | ||
| # This is for use by mysql-test/mtr backup.backup_stream |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ innodb,^ | |
| versioning,^ | ||
| plugins,^ | ||
| mariabackup,^ | ||
| backup,^ | ||
| roles,^ | ||
| auth_gssapi,^ | ||
| mysql_sha2,^ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| BACKUP SERVER TO '$datadir/some_directory'; | ||
| ERROR HY000: Incorrect arguments to BACKUP SERVER TO | ||
| BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory'; | ||
| BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory'; | ||
| ERROR HY000: Can't create directory 'MYSQLTEST_VARDIR/some_directory' (Errcode: 17 "File exists") | ||
| BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| --let $datadir=`select @@datadir` | ||
| --error ER_WRONG_ARGUMENTS | ||
| evalp BACKUP SERVER TO '$datadir/some_directory'; | ||
| --error 0,1 | ||
| --rmdir $MYSQLTEST_VARDIR/some_directory | ||
| evalp BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory'; | ||
| --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR | ||
| --error 21 | ||
| evalp BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory'; | ||
| --rmdir $MYSQLTEST_VARDIR/some_directory | ||
| evalp BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory'; | ||
| --rmdir $MYSQLTEST_VARDIR/some_directory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory'; | ||
| ERROR HY000: Can't create directory 'MYSQLTEST_VARDIR/some_directory' (Errcode: 17 "File exists") | ||
| BACKUP STAGE START; | ||
| connect backup,localhost,root; | ||
| SET STATEMENT max_statement_time=0.1 FOR | ||
| BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory'; | ||
| ERROR 70100: Query was interrupted: execution time limit 0.1 sec exceeded | ||
| connection default; | ||
| BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory'; | ||
| ERROR HY000: Can't execute the command as you have a BACKUP STAGE active | ||
| BACKUP STAGE END; | ||
| connection backup; | ||
| SET STATEMENT max_statement_time=0.1 FOR | ||
| BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory'; | ||
| ERROR HY000: Can't create directory 'MYSQLTEST_VARDIR/some_directory' (Errcode: 17 "File exists") | ||
| disconnect backup; | ||
| connection default; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| --source include/not_embedded.inc | ||
| --source include/count_sessions.inc | ||
|
|
||
| --mkdir $MYSQLTEST_VARDIR/some_directory | ||
| --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR | ||
| --error 21 | ||
| evalp BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory'; | ||
|
|
||
| BACKUP STAGE START; | ||
| --connect (backup,localhost,root) | ||
| --error ER_STATEMENT_TIMEOUT | ||
| evalp SET STATEMENT max_statement_time=0.1 FOR | ||
| BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory'; | ||
|
|
||
| --connection default | ||
|
|
||
| --error ER_BACKUP_LOCK_IS_ACTIVE | ||
| evalp BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory'; | ||
|
|
||
| BACKUP STAGE END; | ||
| --connection backup | ||
| --replace_result $MYSQLTEST_VARDIR MYSQLTEST_VARDIR | ||
| --error 21 | ||
| evalp SET STATEMENT max_statement_time=0.1 FOR | ||
| BACKUP SERVER TO '$MYSQLTEST_VARDIR/some_directory'; | ||
| --disconnect backup | ||
| --connection default | ||
|
|
||
| --rmdir $MYSQLTEST_VARDIR/some_directory | ||
|
|
||
| --source include/wait_until_count_sessions.inc | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| CREATE USER user1@localhost IDENTIFIED BY ''; | ||
| connect con1,localhost,user1; | ||
| BACKUP SERVER TO 'some_directory'; | ||
| ERROR 42000: Access denied; you need (at least one of) the RELOAD privilege(s) for this operation | ||
| disconnect con1; | ||
| connection default; | ||
| GRANT SELECT ON test.* TO user1@localhost; | ||
| connect con1,localhost,user1; | ||
| BACKUP SERVER TO 'some_directory'; | ||
| ERROR 42000: Access denied; you need (at least one of) the RELOAD privilege(s) for this operation | ||
| disconnect con1; | ||
| connection default; | ||
| GRANT RELOAD ON test.* TO user1@localhost; | ||
| ERROR HY000: Incorrect usage of DB GRANT and GLOBAL PRIVILEGES | ||
| GRANT RELOAD ON *.* TO user1@localhost; | ||
| connect con1,localhost,user1; | ||
| BACKUP SERVER TO 'some_directory'; | ||
| ERROR 42000: Access denied; you need (at least one of) the SELECT privilege(s) for this operation | ||
| disconnect con1; | ||
| connection default; | ||
| GRANT SELECT ON *.* TO user1@localhost; | ||
| connect con1,localhost,user1; | ||
| BACKUP SERVER TO '$datadir/some_directory'; | ||
| ERROR HY000: Incorrect arguments to BACKUP SERVER TO | ||
| disconnect con1; | ||
| connection default; | ||
| DROP USER user1@localhost; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| --source include/not_embedded.inc | ||
| CREATE USER user1@localhost IDENTIFIED BY ''; | ||
| --connect con1,localhost,user1 | ||
| --error ER_SPECIFIC_ACCESS_DENIED_ERROR | ||
| BACKUP SERVER TO 'some_directory'; | ||
| --disconnect con1 | ||
| --connection default | ||
| GRANT SELECT ON test.* TO user1@localhost; | ||
| --connect con1,localhost,user1 | ||
| --error ER_SPECIFIC_ACCESS_DENIED_ERROR | ||
| BACKUP SERVER TO 'some_directory'; | ||
| --disconnect con1 | ||
| --connection default | ||
| --error ER_WRONG_USAGE | ||
| GRANT RELOAD ON test.* TO user1@localhost; | ||
| GRANT RELOAD ON *.* TO user1@localhost; | ||
| --connect con1,localhost,user1 | ||
| --error ER_SPECIFIC_ACCESS_DENIED_ERROR | ||
| BACKUP SERVER TO 'some_directory'; | ||
| --disconnect con1 | ||
| --connection default | ||
| GRANT SELECT ON *.* TO user1@localhost; | ||
| --connect con1,localhost,user1 | ||
| --let $datadir=`select @@datadir` | ||
| --error ER_WRONG_ARGUMENTS | ||
| evalp BACKUP SERVER TO '$datadir/some_directory'; | ||
| --disconnect con1 | ||
| --connection default | ||
| DROP USER user1@localhost; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -180,6 +180,7 @@ END | |
| main- | ||
| archive- | ||
| atomic- | ||
| backup- | ||
| binlog- | ||
| binlog_encryption- | ||
| binlog_in_engine- | ||
|
|
||
53 changes: 53 additions & 0 deletions
53
mysql-test/suite/backup/backup_ddl_concurrent_verify.result
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| CREATE TABLE t_myisam (a INT) ENGINE=MyISAM; | ||
| INSERT INTO t_myisam VALUES (1), (2), (3); | ||
| CREATE TABLE t_aria (a INT) ENGINE=Aria TRANSACTIONAL=0; | ||
| INSERT INTO t_aria VALUES (1), (2), (3); | ||
| CREATE TABLE t_arch (a INT) ENGINE=ARCHIVE; | ||
| INSERT INTO t_arch VALUES (1), (2), (3); | ||
| CREATE PROCEDURE reader_churn(IN iterations INT) | ||
| BEGIN | ||
| DECLARE i INT DEFAULT 0; | ||
| WHILE i < iterations DO | ||
| SELECT SLEEP(0.002) INTO @discard | ||
| FROM t_myisam, t_aria, t_arch LIMIT 1; | ||
| SET i = i + 1; | ||
| END WHILE; | ||
| END| | ||
| CREATE PROCEDURE ddl_churn(IN iterations INT) | ||
| BEGIN | ||
| DECLARE i INT DEFAULT 0; | ||
| WHILE i < iterations DO | ||
| ALTER TABLE t_myisam ADD INDEX ix (a); | ||
| ALTER TABLE t_myisam DROP INDEX ix; | ||
| ALTER TABLE t_myisam FORCE, ALGORITHM=COPY; | ||
| SET i = i + 1; | ||
| END WHILE; | ||
| END| | ||
| connect r1,localhost,root,,; | ||
| CALL reader_churn(800); | ||
| connect r2,localhost,root,,; | ||
| CALL reader_churn(800); | ||
| connect d1,localhost,root,,; | ||
| CALL ddl_churn(400); | ||
| connection default; | ||
| connection r1; | ||
| connection r2; | ||
| connection d1; | ||
| connection default; | ||
| disconnect r1; | ||
| disconnect r2; | ||
| disconnect d1; | ||
| # restart: --datadir=MYSQLTEST_VARDIR/backup_ddl_concurrent_verify | ||
| SELECT COUNT(*) FROM t_myisam; | ||
| COUNT(*) | ||
| 3 | ||
| SELECT COUNT(*) FROM t_aria; | ||
| COUNT(*) | ||
| 3 | ||
| SELECT COUNT(*) FROM t_arch; | ||
| COUNT(*) | ||
| 3 | ||
| # restart | ||
| DROP PROCEDURE reader_churn; | ||
| DROP PROCEDURE ddl_churn; | ||
| DROP TABLE t_myisam, t_aria, t_arch; |
137 changes: 137 additions & 0 deletions
137
mysql-test/suite/backup/backup_ddl_concurrent_verify.test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| --source include/have_archive.inc | ||
| --source include/have_aria.inc | ||
|
|
||
| # | ||
| # Verify a backup that nominally succeeded while DDL was running. | ||
| # | ||
| # BACKUP SERVER can fail with ER_LOCK_DEADLOCK next to concurrent DDL, which is | ||
| # what backup_ddl_deadlock reproduces. Because of that, the other DDL tests | ||
| # never get as far as checking the backup they produced. This one tolerates the | ||
| # deadlock and retries until a backup completes, so that a backup taken while | ||
| # DDL was in progress is actually read back. | ||
| # | ||
| # Two things could make such a backup wrong: | ||
| # | ||
| # - flush_tables() skips a table it cannot lock. The deadlock is reported, but | ||
| # a plain lock wait timeout is swallowed by its error handler, and the | ||
| # fallback that opens an instance of its own asks for the metadata lock with | ||
| # a zero timeout. A DDL merely waiting for an exclusive lock is enough to | ||
| # make that fail, and in that state the table has not been closed yet, so it | ||
| # can be copied while still marked open. | ||
| # | ||
| # - MDL_BACKUP_ALTER_COPY is not blocked by any backup phase, so an | ||
| # ALTER TABLE ... ALGORITHM=COPY keeps writing its #sql- intermediate files | ||
| # throughout BACKUP_PHASE_NO_DDL. copy_misc_files() selects files by | ||
| # extension only and does not exclude them. | ||
| # | ||
|
|
||
| CREATE TABLE t_myisam (a INT) ENGINE=MyISAM; | ||
| INSERT INTO t_myisam VALUES (1), (2), (3); | ||
|
|
||
| CREATE TABLE t_aria (a INT) ENGINE=Aria TRANSACTIONAL=0; | ||
| INSERT INTO t_aria VALUES (1), (2), (3); | ||
|
|
||
| CREATE TABLE t_arch (a INT) ENGINE=ARCHIVE; | ||
| INSERT INTO t_arch VALUES (1), (2), (3); | ||
|
|
||
| DELIMITER |; | ||
| # Keeps the tables open, so that flush_tables() has no free TABLE instance and | ||
| # has to take a metadata lock of its own. | ||
| CREATE PROCEDURE reader_churn(IN iterations INT) | ||
| BEGIN | ||
| DECLARE i INT DEFAULT 0; | ||
| WHILE i < iterations DO | ||
| SELECT SLEEP(0.002) INTO @discard | ||
| FROM t_myisam, t_aria, t_arch LIMIT 1; | ||
| SET i = i + 1; | ||
| END WHILE; | ||
| END| | ||
|
|
||
| # ADD/DROP INDEX rewrites the index file in place; FORCE with ALGORITHM=COPY | ||
| # rebuilds through a #sql- intermediate table. Row counts are unaffected. | ||
| CREATE PROCEDURE ddl_churn(IN iterations INT) | ||
| BEGIN | ||
| DECLARE i INT DEFAULT 0; | ||
| WHILE i < iterations DO | ||
| ALTER TABLE t_myisam ADD INDEX ix (a); | ||
| ALTER TABLE t_myisam DROP INDEX ix; | ||
| ALTER TABLE t_myisam FORCE, ALGORITHM=COPY; | ||
| SET i = i + 1; | ||
| END WHILE; | ||
| END| | ||
| DELIMITER ;| | ||
|
|
||
| --let $target_directory=$MYSQLTEST_VARDIR/backup_ddl_concurrent_verify | ||
| --error 0,1 | ||
| --rmdir $target_directory | ||
|
|
||
| --connect (r1,localhost,root,,) | ||
| --send CALL reader_churn(800) | ||
| --connect (r2,localhost,root,,) | ||
| --send CALL reader_churn(800) | ||
| --connect (d1,localhost,root,,) | ||
| --send CALL ddl_churn(400) | ||
|
|
||
| --connection default | ||
|
|
||
| # Do not start before the DDL is actually running, so that the backup that is | ||
| # kept is one that overlapped it. | ||
| --let $wait_condition= SELECT COUNT(*) FROM information_schema.processlist WHERE info LIKE 'ALTER TABLE t_myisam%' | ||
| --source include/wait_condition.inc | ||
|
|
||
| # Retry until one backup gets through, keeping that one. | ||
| --let $attempts= 40 | ||
| --let $have_backup= 0 | ||
| --disable_query_log | ||
| while ($attempts) | ||
| { | ||
| --error 0,1 | ||
| --rmdir $target_directory | ||
| --error 0,ER_LOCK_DEADLOCK | ||
| --eval BACKUP SERVER TO '$target_directory' | ||
| if ($mysql_errno == 0) | ||
| { | ||
| --let $have_backup= 1 | ||
| --let $attempts= 1 | ||
| } | ||
| dec $attempts; | ||
| } | ||
| --enable_query_log | ||
|
|
||
| --connection r1 | ||
| --reap | ||
| --connection r2 | ||
| --reap | ||
| --connection d1 | ||
| --reap | ||
|
|
||
| --connection default | ||
| --disconnect r1 | ||
| --disconnect r2 | ||
| --disconnect d1 | ||
|
|
||
| if (!$have_backup) | ||
| { | ||
| --skip every BACKUP SERVER attempt hit ER_LOCK_DEADLOCK | ||
| } | ||
|
|
||
| # An ALTER TABLE ... ALGORITHM=COPY that was running during the backup must not | ||
| # have left its intermediate table in it. | ||
| --list_files $target_directory/test #sql* | ||
|
|
||
| # The tables have to come back without needing repair, so any message about a | ||
| # table being crashed or not closed properly fails the test here. | ||
| --let $restart_parameters=--datadir=$target_directory | ||
| --source include/restart_mysqld.inc | ||
|
|
||
| SELECT COUNT(*) FROM t_myisam; | ||
| SELECT COUNT(*) FROM t_aria; | ||
| SELECT COUNT(*) FROM t_arch; | ||
|
|
||
| --let $restart_parameters= | ||
| --source include/restart_mysqld.inc | ||
|
|
||
| DROP PROCEDURE reader_churn; | ||
| DROP PROCEDURE ddl_churn; | ||
| DROP TABLE t_myisam, t_aria, t_arch; | ||
| --rmdir $target_directory |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| --- backup_innodb.result | ||
| +++ backup_innodb,debug.result | ||
| @@ -24,13 +24,16 @@ | ||
| BEGIN; | ||
| DELETE FROM t; | ||
| connect backup,localhost,root; | ||
| +SET DEBUG_SYNC='innodb_backup_start SIGNAL start WAIT_FOR resume'; | ||
| BACKUP SERVER TO 'target_directory' 4 CONCURRENT; | ||
| connection default; | ||
| +SET DEBUG_SYNC='now WAIT_FOR start'; | ||
| connect rename,localhost,root; | ||
| RENAME TABLE rt TO rtt; | ||
| disconnect rename; | ||
| connection default; | ||
| INSERT INTO t(a) SELECT * FROM seq_1_to_30000; | ||
| +SET DEBUG_SYNC='now SIGNAL resume'; | ||
| connection backup; | ||
| disconnect backup; | ||
| connection default; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| [archived] | ||
| innodb_log_archive=ON | ||
| [circular] | ||
| innodb_log_archive=OFF |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.