| 1 |
-- source include/have_ndb.inc |
| 2 |
-- source include/count_sessions.inc |
| 3 |
-- source suite/ndb/include/backup_restore_setup.inc |
| 4 |
|
| 5 |
# Turn off metadata check so it doesn't interfere with table discovery |
| 6 |
--disable_query_log |
| 7 |
SET @save_ndb_metadata_check = @@global.ndb_metadata_check; |
| 8 |
SET GLOBAL ndb_metadata_check = false; |
| 9 |
--enable_query_log |
| 10 |
|
| 11 |
--echo # |
| 12 |
--echo # 18075170 - sql node restart required to avoid deadlock after |
| 13 |
--echo # restore |
| 14 |
--echo # |
| 15 |
# Test Auto Discover option within a transaction and make sure the transaction |
| 16 |
# is not broken. |
| 17 |
CREATE TABLE t1 (id INT) ENGINE=NDBCluster; |
| 18 |
CREATE TABLE t2 (id INT) ENGINE=NDBCluster; |
| 19 |
|
| 20 |
INSERT INTO t1 VALUES (1); |
| 21 |
INSERT INTO t2 VALUES (1); |
| 22 |
|
| 23 |
-- source include/ndb_backup.inc |
| 24 |
|
| 25 |
DROP TABLE t1; |
| 26 |
DROP TABLE t2; |
| 27 |
|
| 28 |
-- source include/ndb_restore_master.inc |
| 29 |
|
| 30 |
SET autocommit = 0; |
| 31 |
SELECT * FROM t1; |
| 32 |
|
| 33 |
# Without fix below select was resulting in DEADLOCK error. With fix select |
| 34 |
# should succeed and return erorr indicating that table definition is outdated |
| 35 |
# and can't be discovered. |
| 36 |
--error ER_TABLE_DEF_CHANGED |
| 37 |
SELECT * FROM t2; |
| 38 |
ROLLBACK; |
| 39 |
SET autocommit = 1; |
| 40 |
|
| 41 |
drop table t1; |
| 42 |
drop table t2; |
| 43 |
|
| 44 |
# |
| 45 |
# Checking lock preservation in transaction |
| 46 |
# |
| 47 |
# Using existing backup to create the scenario. Tables are deleted as part of |
| 48 |
# above test cleanup. Thus restoring the backup will bring the system to |
| 49 |
# required state. |
| 50 |
-- source include/ndb_restore_master.inc |
| 51 |
|
| 52 |
SET autocommit = 0; |
| 53 |
SELECT * FROM t1; |
| 54 |
--error ER_TABLE_DEF_CHANGED |
| 55 |
SELECT * FROM t2; |
| 56 |
|
| 57 |
connect(con2, localhost, root); |
| 58 |
--SEND ALTER TABLE t1 ADD val INT |
| 59 |
|
| 60 |
connection default; |
| 61 |
# Alter from con2 will be in waiting state as there is a lock on t1 from |
| 62 |
# default connection due to active transaction. We check for this condition |
| 63 |
# then releasing the lock by rollbacking active transaction. |
| 64 |
let $wait_condition= |
| 65 |
SELECT count(*) = 1 FROM information_schema.processlist WHERE state |
| 66 |
LIKE "Waiting%" AND info = "ALTER TABLE t1 ADD val INT"; |
| 67 |
--source include/wait_condition.inc |
| 68 |
ROLLBACK; |
| 69 |
SET autocommit = 1; |
| 70 |
|
| 71 |
connection con2; |
| 72 |
--REAP |
| 73 |
|
| 74 |
disconnect con2; |
| 75 |
connection default; |
| 76 |
drop table t1; |
| 77 |
drop table t2; |
| 78 |
|
| 79 |
--disable_query_log ONCE |
| 80 |
SET GLOBAL ndb_metadata_check = @save_ndb_metadata_check; |
| 81 |
|
| 82 |
# Wait till all disconnects are completed |
| 83 |
-- source include/wait_until_count_sessions.inc |
| 84 |
--source suite/ndb/include/backup_restore_cleanup.inc |
| 85 |
--remove_file $NDB_TOOLS_OUTPUT |