-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for BACKUP LOCK / BACKUP UNLOCK
- Loading branch information
Showing
11 changed files
with
186 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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,46 @@ | ||
# | ||
# Test lock taken | ||
# | ||
BACKUP LOCK test.t1; | ||
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info; | ||
LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME | ||
MDL_SHARED_HIGH_PRIO Table metadata lock test t1 | ||
BACKUP UNLOCK; | ||
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info; | ||
LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME | ||
BACKUP LOCK t1; | ||
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info; | ||
LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME | ||
MDL_SHARED_HIGH_PRIO Table metadata lock test t1 | ||
BACKUP UNLOCK; | ||
BACKUP LOCK non_existing.t1; | ||
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info; | ||
LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME | ||
MDL_SHARED_HIGH_PRIO Table metadata lock non_existing t1 | ||
BACKUP UNLOCK; | ||
# | ||
# Test that backup lock protects against ddl | ||
# | ||
connect con1,localhost,root,,; | ||
connection default; | ||
create table t1 (a int) engine=innodb; | ||
insert into t1 values (1); | ||
backup lock t1; | ||
select * from t1; | ||
a | ||
1 | ||
connection con1; | ||
drop table t1; | ||
connection default; | ||
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info; | ||
LOCK_MODE LOCK_TYPE TABLE_SCHEMA TABLE_NAME | ||
MDL_SHARED_HIGH_PRIO Table metadata lock test t1 | ||
MDL_INTENTION_EXCLUSIVE Schema metadata lock test | ||
select * from t1; | ||
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction | ||
backup unlock; | ||
connection con1; | ||
connection default; | ||
disconnect con1; | ||
show tables; | ||
Tables_in_test |
This file contains 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,50 @@ | ||
######################################################################## | ||
# Tests BACKUP STAGE locking | ||
######################################################################## | ||
|
||
--source include/have_innodb.inc | ||
--source include/have_metadata_lock_info.inc | ||
--source include/not_embedded.inc | ||
|
||
--echo # | ||
--echo # Test lock taken | ||
--echo # | ||
|
||
BACKUP LOCK test.t1; | ||
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info; | ||
BACKUP UNLOCK; | ||
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info; | ||
BACKUP LOCK t1; | ||
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info; | ||
BACKUP UNLOCK; | ||
BACKUP LOCK non_existing.t1; | ||
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info; | ||
BACKUP UNLOCK; | ||
|
||
--echo # | ||
--echo # Test that backup lock protects against ddl | ||
--echo # | ||
|
||
connect (con1,localhost,root,,); | ||
|
||
connection default; | ||
create table t1 (a int) engine=innodb; | ||
insert into t1 values (1); | ||
backup lock t1; | ||
select * from t1; | ||
connection con1; | ||
--send drop table t1 | ||
connection default; | ||
let $wait_condition= | ||
select count(*) = 1 from information_schema.processlist | ||
where state = "Waiting for table metadata lock"; | ||
--source include/wait_condition.inc | ||
SELECT LOCK_MODE, LOCK_TYPE, TABLE_SCHEMA, TABLE_NAME FROM information_schema.metadata_lock_info; | ||
--error ER_LOCK_DEADLOCK | ||
select * from t1; | ||
backup unlock; | ||
connection con1; | ||
--reap | ||
connection default; | ||
disconnect con1; | ||
show tables; |
This file contains 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 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 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 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 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 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 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 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 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