mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-24576 Atomic CREATE TABLE
There are a few different cases to consider Logging of CREATE TABLE and CREATE TABLE ... LIKE - If REPLACE is used and there was an existing table, DDL log the drop of the table. - If discovery of table is to be done - DDL LOG create table else - DDL log create table (with engine type) - create the table - If table was created - Log entry to binary log with xid - Mark DDL log completed Crash recovery: - If query was in binary log do nothing and exit - If discoverted table - Delete the .frm file -else - Drop created table and frm file - If table was dropped, write a DROP TABLE statement in binary log CREATE TABLE ... SELECT required a little more work as when one is using statement logging the query is written to the binary log before commit is done. This was fixed by adding a DROP TABLE to the binary log during crash recovery if the ddl log entry was not closed. In this case the binary log will contain: CREATE TABLE xxx ... SELECT .... DROP TABLE xxx; Other things: - Added debug_crash_here() functionality to Aria to be able to test crash in create table between the creation of the .MAI and the .MAD files.
This commit is contained in:
@@ -19,7 +19,7 @@ CREATE TABLE t1 (a INT, b VARCHAR(100), PRIMARY KEY (a,b)) ENGINE=innodb;
|
||||
# MDEV-515 takes X-lock on the table for the first insert.
|
||||
# So concurrent insert won't happen on the table
|
||||
INSERT INTO t1 VALUES(9, "");
|
||||
let pos=`select $binlog_start_pos + 422`;
|
||||
let pos=`select $binlog_start_pos + 431`;
|
||||
--replace_result $pos <pos>
|
||||
SHOW MASTER STATUS;
|
||||
--replace_result $pos <pos>
|
||||
@@ -56,10 +56,10 @@ COMMIT;
|
||||
|
||||
connection default;
|
||||
SELECT * FROM t1 ORDER BY a,b;
|
||||
let pos=`select $binlog_start_pos + 956`;
|
||||
let pos=`select $binlog_start_pos + 974`;
|
||||
--replace_result $pos <pos>
|
||||
SHOW STATUS LIKE 'binlog_snapshot_%';
|
||||
let pos=`select $binlog_start_pos + 1332`;
|
||||
let pos=`select $binlog_start_pos + 1350`;
|
||||
--replace_result $pos <pos>
|
||||
SHOW MASTER STATUS;
|
||||
SELECT * FROM t2 ORDER BY a;
|
||||
@@ -77,7 +77,7 @@ FLUSH LOGS;
|
||||
|
||||
connection default;
|
||||
SELECT * FROM t1 ORDER BY a,b;
|
||||
let pos=`select $binlog_start_pos + 956`;
|
||||
let pos=`select $binlog_start_pos + 974`;
|
||||
--replace_result $pos <pos>
|
||||
SHOW STATUS LIKE 'binlog_snapshot_%';
|
||||
let pos=`select $binlog_start_pos + 131`;
|
||||
|
Reference in New Issue
Block a user