mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 18:41:56 +01:00
6aa9a552c2
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.
126 lines
3.5 KiB
Text
126 lines
3.5 KiB
Text
--source include/have_innodb.inc
|
|
--source include/have_log_bin.inc
|
|
--source include/have_binlog_format_mixed_or_statement.inc
|
|
--source include/binlog_start_pos.inc
|
|
|
|
RESET MASTER;
|
|
|
|
# Test that we get the correct binlog position from START TRANSACTION WITH
|
|
# CONSISTENT SNAPSHOT even when other transactions are active.
|
|
|
|
connect(con1,localhost,root,,);
|
|
connect(con2,localhost,root,,);
|
|
connect(con3,localhost,root,,);
|
|
connect(con4,localhost,root,,);
|
|
|
|
connection default;
|
|
|
|
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 + 431`;
|
|
--replace_result $pos <pos>
|
|
SHOW MASTER STATUS;
|
|
--replace_result $pos <pos>
|
|
SHOW STATUS LIKE 'binlog_snapshot_%';
|
|
BEGIN;
|
|
INSERT INTO t1 VALUES (0, "");
|
|
|
|
connection con1;
|
|
BEGIN;
|
|
INSERT INTO t1 VALUES (1, "");
|
|
|
|
connection con2;
|
|
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=myisam;
|
|
BEGIN;
|
|
INSERT INTO t1 VALUES (2, "first");
|
|
INSERT INTO t2 VALUES (2);
|
|
INSERT INTO t1 VALUES (2, "second");
|
|
|
|
connection default;
|
|
COMMIT;
|
|
|
|
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;
|
|
START TRANSACTION WITH CONSISTENT SNAPSHOT;
|
|
|
|
connection con3;
|
|
BEGIN;
|
|
INSERT INTO t1 VALUES (3, "");
|
|
INSERT INTO t2 VALUES (3);
|
|
|
|
connection con4;
|
|
BEGIN;
|
|
INSERT INTO t1 VALUES (4, "");
|
|
COMMIT;
|
|
|
|
connection default;
|
|
SELECT * FROM t1 ORDER BY a,b;
|
|
let pos=`select $binlog_start_pos + 974`;
|
|
--replace_result $pos <pos>
|
|
SHOW STATUS LIKE 'binlog_snapshot_%';
|
|
let pos=`select $binlog_start_pos + 1350`;
|
|
--replace_result $pos <pos>
|
|
SHOW MASTER STATUS;
|
|
SELECT * FROM t2 ORDER BY a;
|
|
|
|
connection con1;
|
|
COMMIT;
|
|
|
|
connection con2;
|
|
COMMIT;
|
|
|
|
connection con3;
|
|
COMMIT;
|
|
FLUSH LOGS;
|
|
--source include/wait_for_binlog_checkpoint.inc
|
|
|
|
connection default;
|
|
SELECT * FROM t1 ORDER BY a,b;
|
|
let pos=`select $binlog_start_pos + 974`;
|
|
--replace_result $pos <pos>
|
|
SHOW STATUS LIKE 'binlog_snapshot_%';
|
|
let pos=`select $binlog_start_pos + 131`;
|
|
--replace_result $pos <pos>
|
|
SHOW MASTER STATUS;
|
|
COMMIT;
|
|
--replace_result $pos <pos>
|
|
SHOW STATUS LIKE 'binlog_snapshot_%';
|
|
--replace_result $pos <pos>
|
|
SHOW MASTER STATUS;
|
|
|
|
source include/show_binlog_events.inc;
|
|
|
|
|
|
--echo *** MDEV-7310: last_commit_pos_offset set to wrong value after binlog rotate in group commit ***
|
|
|
|
SET @old_size= @@GLOBAL.max_binlog_size;
|
|
SET GLOBAL max_binlog_size=4096;
|
|
|
|
CREATE TABLE t3 (a INT PRIMARY KEY, b VARBINARY(8192)) ENGINE=MyISAM;
|
|
INSERT INTO t3 VALUES (10, '');
|
|
--let $bigdata= `SELECT REPEAT('a', 5000)`
|
|
eval INSERT INTO t3 VALUES (11, '$bigdata');
|
|
|
|
# The bug was that binlog_snapshot_file pointed to the new file after binlog
|
|
# rotation, but binlog_snapshot_position was the offset in the old file before
|
|
# binlog rotation. So the position was invalid.
|
|
# So here, we check that the values are consistent with SHOW MASTER STATUS,
|
|
# which uses a different code path and did not have the bug.
|
|
|
|
--source include/wait_for_binlog_checkpoint.inc
|
|
--let $snap_file= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_file', Value, 1)
|
|
--let $snap_pos= query_get_value(SHOW STATUS LIKE 'binlog_snapshot_position', Value, 1)
|
|
|
|
--let $master_file= query_get_value(SHOW MASTER STATUS, File, 1)
|
|
--let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1)
|
|
|
|
--disable_query_log
|
|
eval SET @errmsg= 'ERROR: ($snap_file, $snap_pos) != ($master_file, $master_pos)';
|
|
eval SELECT IF('$snap_file' = '$master_file' AND $snap_pos = $master_pos, 'OK', @errmsg) AS test_result;
|
|
--enable_query_log
|
|
|
|
SET GLOBAL max_binlog_size=@old_size;
|
|
|
|
|
|
DROP TABLE t1,t2, t3;
|