mariadb/mysql-test/main/xa_prepared_binlog_off.result
Marko Mäkelä 3cef4f8f0f MDEV-515 Reduce InnoDB undo logging for insert into empty table
We implement an idea that was suggested by Michael 'Monty' Widenius
in October 2017: When InnoDB is inserting into an empty table or partition,
we can write a single undo log record TRX_UNDO_EMPTY, which will cause
ROLLBACK to clear the table.

For this to work, the insert into an empty table or partition must be
covered by an exclusive table lock that will be held until the transaction
has been committed or rolled back, or the INSERT operation has been
rolled back (and the table is empty again), in lock_table_x_unlock().

Clustered index records that are covered by the TRX_UNDO_EMPTY record
will carry DB_TRX_ID=0 and DB_ROLL_PTR=1<<55, and thus they cannot
be distinguished from what MDEV-12288 leaves behind after purging the
history of row-logged operations.

Concurrent non-locking reads must be adjusted: If the read view was
created before the INSERT into an empty table, then we must continue
to imagine that the table is empty, and not try to read any records.
If the read view was created after the INSERT was committed, then
all records must be visible normally. To implement this, we introduce
the field dict_table_t::bulk_trx_id.

This special handling only applies to the very first INSERT statement
of a transaction for the empty table or partition. If a subsequent
statement in the transaction is modifying the initially empty table again,
we must enable row-level undo logging, so that we will be able to
roll back to the start of the statement in case of an error (such as
duplicate key).

INSERT IGNORE will continue to use row-level logging and locking, because
implementing it would require the ability to roll back the latest row.
Since the undo log that we write only allows us to roll back the entire
statement, we cannot support INSERT IGNORE. We will introduce a
handler::extra() parameter HA_EXTRA_IGNORE_INSERT to indicate to storage
engines that INSERT IGNORE is being executed.

In many test cases, we add an extra record to the table, so that during
the 'interesting' part of the test, row-level locking and logging will
be used.

Replicas will continue to use row-level logging and locking until
MDEV-24622 has been addressed. Likewise, this optimization will be
disabled in Galera cluster until MDEV-24623 enables it.

dict_table_t::bulk_trx_id: The latest active or committed transaction
that initiated an insert into an empty table or partition.
Protected by exclusive table lock and a clustered index leaf page latch.

ins_node_t::bulk_insert: Whether bulk insert was initiated.

trx_t::mod_tables: Use C++11 style accessors (emplace instead of insert).
Unlike earlier, this collection will cover also temporary tables.

trx_mod_table_time_t: Add start_bulk_insert(), end_bulk_insert(),
is_bulk_insert(), was_bulk_insert().

trx_undo_report_row_operation(): Before accessing any undo log pages,
invoke trx->mod_tables.emplace() in order to determine whether undo
logging was disabled, or whether this is the first INSERT and we are
supposed to write a TRX_UNDO_EMPTY record.

row_ins_clust_index_entry_low(): If we are inserting into an empty
clustered index leaf page, set the ins_node_t::bulk_insert flag for
the subsequent trx_undo_report_row_operation() call.

lock_rec_insert_check_and_lock(), lock_prdt_insert_check_and_lock():
Remove the redundant parameter 'flags' that can be checked in the caller.

btr_cur_ins_lock_and_undo(): Simplify the logic. Correctly write
DB_TRX_ID,DB_ROLL_PTR after invoking trx_undo_report_row_operation().

trx_mark_sql_stat_end(), ha_innobase::extra(HA_EXTRA_IGNORE_INSERT),
ha_innobase::external_lock(): Invoke trx_t::end_bulk_insert() so that
the next statement will not be covered by table-level undo logging.

ReadView::changes_visible(trx_id_t) const: New accessor for the case
where the trx_id_t is not read from a potentially corrupted index page
but directly from the memory. In this case, we can skip a sanity check.

row_sel(), row_sel_try_search_shortcut(), row_search_mvcc():
row_sel_try_search_shortcut_for_mysql(),
row_merge_read_clustered_index(): Check dict_table_t::bulk_trx_id.

row_sel_clust_sees(): Replaces lock_clust_rec_cons_read_sees().

lock_sec_rec_cons_read_sees(): Replaced with lower-level code.

btr_root_page_init(): Refactored from btr_create().

dict_index_t::clear(), dict_table_t::clear(): Empty an index or table,
for the ROLLBACK of an INSERT operation.

ROW_T_EMPTY, ROW_OP_EMPTY: Note a concurrent ROLLBACK of an INSERT
into an empty table.

This is joint work with Thirunarayanan Balathandayuthapani,
who created a working prototype.
Thanks to Matthias Leich for extensive testing.
2021-01-25 18:41:27 +02:00

1053 lines
25 KiB
Text

call mtr.add_suppression("You need to use --log-bin to make --log-slave-updates work.");
connection default;
CREATE VIEW v_processlist as SELECT * FROM performance_schema.threads where type = 'FOREGROUND';
call mtr.add_suppression("Found 10 prepared XA transactions");
CREATE TABLE t (a INT) ENGINE=innodb;
INSERT INTO t VALUES(100);
connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@sql_log_bin = OFF;
CREATE TEMPORARY TABLE tmp1 (a int) ENGINE=innodb;
XA START 'trx1tmp';
INSERT INTO tmp1 SET a=1;
XA END 'trx1tmp';
XA PREPARE 'trx1tmp';
connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@sql_log_bin = OFF;
CREATE TEMPORARY TABLE tmp1 (a int) ENGINE=innodb;
XA START 'trx2tmp';
INSERT INTO tmp1 SET a=1;
XA END 'trx2tmp';
XA PREPARE 'trx2tmp';
connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@sql_log_bin = OFF;
CREATE TEMPORARY TABLE tmp1 (a int) ENGINE=innodb;
XA START 'trx3tmp';
INSERT INTO tmp1 SET a=1;
XA END 'trx3tmp';
XA PREPARE 'trx3tmp';
connection default;
XA COMMIT 'trx1tmp';
ERROR XAE04: XAER_NOTA: Unknown XID
XA ROLLBACK 'trx1tmp';
ERROR XAE04: XAER_NOTA: Unknown XID
XA START 'trx1tmp';
ERROR XAE08: XAER_DUPID: The XID already exists
connection default;
*** 3 prepared transactions must be in the list ***
XA RECOVER;
formatID gtrid_length bqual_length data
1 LEN1 LEN2 TRX_N
1 LEN1 LEN2 TRX_N
1 LEN1 LEN2 TRX_N
connection conn1tmp;
disconnect conn1tmp;
connection default;
XA COMMIT 'trx1tmp';
KILL connection CONN_ID;
XA COMMIT 'trx3tmp';
connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'trx1ro';
SELECT * from t ORDER BY a;
a
100
XA END 'trx1ro';
XA PREPARE 'trx1ro';
connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'trx2ro';
SELECT * from t ORDER BY a;
a
100
XA END 'trx2ro';
XA PREPARE 'trx2ro';
connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'trx3ro';
SELECT * from t ORDER BY a;
a
100
XA END 'trx3ro';
XA PREPARE 'trx3ro';
connection default;
*** 4 prepared transactions must be in the list ***
XA RECOVER;
formatID gtrid_length bqual_length data
1 LEN1 LEN2 TRX_N
1 LEN1 LEN2 TRX_N
1 LEN1 LEN2 TRX_N
1 LEN1 LEN2 TRX_N
connection conn1ro;
disconnect conn1ro;
connection default;
XA ROLLBACK 'trx1ro';
KILL connection CONN_ID;
XA ROLLBACK 'trx3ro';
connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'trx1empty';
XA END 'trx1empty';
XA PREPARE 'trx1empty';
connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'trx2empty';
XA END 'trx2empty';
XA PREPARE 'trx2empty';
connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'trx3empty';
XA END 'trx3empty';
XA PREPARE 'trx3empty';
connection default;
*** 5 prepared transactions must be in the list ***
XA RECOVER;
formatID gtrid_length bqual_length data
1 LEN1 LEN2 TRX_N
1 LEN1 LEN2 TRX_N
1 LEN1 LEN2 TRX_N
1 LEN1 LEN2 TRX_N
1 LEN1 LEN2 TRX_N
connection conn1empty;
disconnect conn1empty;
connection default;
XA COMMIT 'trx1empty';
KILL connection CONN_ID;
XA COMMIT 'trx3empty';
connect conn1$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'trx1unprepared';
INSERT INTO t set a=0;
XA END 'trx1unprepared';
INSERT INTO t set a=0;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
XA START 'trx1unprepared';
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
XA START 'trx1unprepared';
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
disconnect conn1unprepared;
connection default;
XA COMMIT 'trx1unprepared';
ERROR XAE04: XAER_NOTA: Unknown XID
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_0';
INSERT INTO t SET a=0;
XA END 'trx_0';
XA PREPARE 'trx_0';
disconnect conn0;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_1';
INSERT INTO t SET a=1;
XA END 'trx_1';
XA PREPARE 'trx_1';
disconnect conn1;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_2';
INSERT INTO t SET a=2;
XA END 'trx_2';
XA PREPARE 'trx_2';
disconnect conn2;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_3';
INSERT INTO t SET a=3;
XA END 'trx_3';
XA PREPARE 'trx_3';
disconnect conn3;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_4';
INSERT INTO t SET a=4;
XA END 'trx_4';
XA PREPARE 'trx_4';
disconnect conn4;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_5';
INSERT INTO t SET a=5;
XA END 'trx_5';
XA PREPARE 'trx_5';
disconnect conn5;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_6';
INSERT INTO t SET a=6;
XA END 'trx_6';
XA PREPARE 'trx_6';
disconnect conn6;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_7';
INSERT INTO t SET a=7;
XA END 'trx_7';
XA PREPARE 'trx_7';
disconnect conn7;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_8';
INSERT INTO t SET a=8;
XA END 'trx_8';
XA PREPARE 'trx_8';
disconnect conn8;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_9';
INSERT INTO t SET a=9;
XA END 'trx_9';
XA PREPARE 'trx_9';
disconnect conn9;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_10';
INSERT INTO t SET a=10;
XA END 'trx_10';
XA PREPARE 'trx_10';
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_11';
INSERT INTO t SET a=11;
XA END 'trx_11';
XA PREPARE 'trx_11';
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_12';
INSERT INTO t SET a=12;
XA END 'trx_12';
XA PREPARE 'trx_12';
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_13';
INSERT INTO t SET a=13;
XA END 'trx_13';
XA PREPARE 'trx_13';
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_14';
INSERT INTO t SET a=14;
XA END 'trx_14';
XA PREPARE 'trx_14';
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_15';
INSERT INTO t SET a=15;
XA END 'trx_15';
XA PREPARE 'trx_15';
connection default;
KILL CONNECTION CONN_ID;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_16';
INSERT INTO t SET a=16;
XA END 'trx_16';
XA PREPARE 'trx_16';
connection default;
KILL CONNECTION CONN_ID;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_17';
INSERT INTO t SET a=17;
XA END 'trx_17';
XA PREPARE 'trx_17';
connection default;
KILL CONNECTION CONN_ID;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_18';
INSERT INTO t SET a=18;
XA END 'trx_18';
XA PREPARE 'trx_18';
connection default;
KILL CONNECTION CONN_ID;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_19';
INSERT INTO t SET a=19;
XA END 'trx_19';
XA PREPARE 'trx_19';
connection default;
KILL CONNECTION CONN_ID;
connection default;
XA ROLLBACK 'trx_0';
XA ROLLBACK 'trx_1';
XA ROLLBACK 'trx_2';
XA ROLLBACK 'trx_3';
XA ROLLBACK 'trx_4';
XA COMMIT 'trx_5';
XA COMMIT 'trx_6';
XA COMMIT 'trx_7';
XA COMMIT 'trx_8';
XA COMMIT 'trx_9';
# restart
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_0';
INSERT INTO t SET a=0;
XA END 'new_trx_0';
XA PREPARE 'new_trx_0';
disconnect conn_restart_0;
connection default;
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_1';
INSERT INTO t SET a=1;
XA END 'new_trx_1';
XA PREPARE 'new_trx_1';
disconnect conn_restart_1;
connection default;
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_2';
INSERT INTO t SET a=2;
XA END 'new_trx_2';
XA PREPARE 'new_trx_2';
disconnect conn_restart_2;
connection default;
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_3';
INSERT INTO t SET a=3;
XA END 'new_trx_3';
XA PREPARE 'new_trx_3';
disconnect conn_restart_3;
connection default;
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_4';
INSERT INTO t SET a=4;
XA END 'new_trx_4';
XA PREPARE 'new_trx_4';
disconnect conn_restart_4;
connection default;
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_5';
INSERT INTO t SET a=5;
XA END 'new_trx_5';
XA PREPARE 'new_trx_5';
disconnect conn_restart_5;
connection default;
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_6';
INSERT INTO t SET a=6;
XA END 'new_trx_6';
XA PREPARE 'new_trx_6';
disconnect conn_restart_6;
connection default;
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_7';
INSERT INTO t SET a=7;
XA END 'new_trx_7';
XA PREPARE 'new_trx_7';
disconnect conn_restart_7;
connection default;
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_8';
INSERT INTO t SET a=8;
XA END 'new_trx_8';
XA PREPARE 'new_trx_8';
disconnect conn_restart_8;
connection default;
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_9';
INSERT INTO t SET a=9;
XA END 'new_trx_9';
XA PREPARE 'new_trx_9';
disconnect conn_restart_9;
connection default;
connection default;
XA COMMIT 'new_trx_0';
XA COMMIT 'new_trx_1';
XA COMMIT 'new_trx_2';
XA COMMIT 'new_trx_3';
XA COMMIT 'new_trx_4';
XA COMMIT 'new_trx_5';
XA COMMIT 'new_trx_6';
XA COMMIT 'new_trx_7';
XA COMMIT 'new_trx_8';
XA COMMIT 'new_trx_9';
XA START 'trx_10';
ERROR XAE08: XAER_DUPID: The XID already exists
XA COMMIT 'trx_10';
XA START 'trx_11';
ERROR XAE08: XAER_DUPID: The XID already exists
XA COMMIT 'trx_11';
XA START 'trx_12';
ERROR XAE08: XAER_DUPID: The XID already exists
XA COMMIT 'trx_12';
XA START 'trx_13';
ERROR XAE08: XAER_DUPID: The XID already exists
XA COMMIT 'trx_13';
XA START 'trx_14';
ERROR XAE08: XAER_DUPID: The XID already exists
XA COMMIT 'trx_14';
XA START 'trx_15';
ERROR XAE08: XAER_DUPID: The XID already exists
XA ROLLBACK 'trx_15';
XA START 'trx_16';
ERROR XAE08: XAER_DUPID: The XID already exists
XA ROLLBACK 'trx_16';
XA START 'trx_17';
ERROR XAE08: XAER_DUPID: The XID already exists
XA ROLLBACK 'trx_17';
XA START 'trx_18';
ERROR XAE08: XAER_DUPID: The XID already exists
XA ROLLBACK 'trx_18';
XA START 'trx_19';
ERROR XAE08: XAER_DUPID: The XID already exists
XA ROLLBACK 'trx_19';
SELECT * FROM t;
a
100
5
6
7
8
9
10
11
12
13
14
0
1
2
3
4
5
6
7
8
9
disconnect conn2tmp;
disconnect conn3tmp;
disconnect conn2ro;
disconnect conn3ro;
disconnect conn2empty;
disconnect conn3empty;
connection default;
XA ROLLBACK 'trx_20';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn19;
connection default;
XA ROLLBACK 'trx_19';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn18;
connection default;
XA ROLLBACK 'trx_18';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn17;
connection default;
XA ROLLBACK 'trx_17';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn16;
connection default;
XA ROLLBACK 'trx_16';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn15;
connection default;
XA ROLLBACK 'trx_15';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn14;
connection default;
XA ROLLBACK 'trx_14';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn13;
connection default;
XA ROLLBACK 'trx_13';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn12;
connection default;
XA ROLLBACK 'trx_12';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn11;
connection default;
XA ROLLBACK 'trx_11';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn10;
connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@sql_log_bin = OFF;
CREATE TEMPORARY TABLE tmp1 (a int) ENGINE=innodb;
XA START 'trx1tmp';
INSERT INTO tmp1 SET a=1;
XA END 'trx1tmp';
XA PREPARE 'trx1tmp';
connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@sql_log_bin = OFF;
CREATE TEMPORARY TABLE tmp1 (a int) ENGINE=innodb;
XA START 'trx2tmp';
INSERT INTO tmp1 SET a=1;
XA END 'trx2tmp';
XA PREPARE 'trx2tmp';
connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@sql_log_bin = OFF;
CREATE TEMPORARY TABLE tmp1 (a int) ENGINE=innodb;
XA START 'trx3tmp';
INSERT INTO tmp1 SET a=1;
XA END 'trx3tmp';
XA PREPARE 'trx3tmp';
connection default;
XA COMMIT 'trx1tmp';
ERROR XAE04: XAER_NOTA: Unknown XID
XA ROLLBACK 'trx1tmp';
ERROR XAE04: XAER_NOTA: Unknown XID
XA START 'trx1tmp';
ERROR XAE08: XAER_DUPID: The XID already exists
connection default;
*** 3 prepared transactions must be in the list ***
XA RECOVER;
formatID gtrid_length bqual_length data
1 LEN1 LEN2 TRX_N
1 LEN1 LEN2 TRX_N
1 LEN1 LEN2 TRX_N
connection conn1tmp;
disconnect conn1tmp;
connection default;
XA COMMIT 'trx1tmp';
KILL connection CONN_ID;
XA COMMIT 'trx3tmp';
connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'trx1ro';
SELECT * from t ORDER BY a;
a
0
1
2
3
4
5
5
6
6
7
7
8
8
9
9
10
11
12
13
14
100
XA END 'trx1ro';
XA PREPARE 'trx1ro';
connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'trx2ro';
SELECT * from t ORDER BY a;
a
0
1
2
3
4
5
5
6
6
7
7
8
8
9
9
10
11
12
13
14
100
XA END 'trx2ro';
XA PREPARE 'trx2ro';
connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'trx3ro';
SELECT * from t ORDER BY a;
a
0
1
2
3
4
5
5
6
6
7
7
8
8
9
9
10
11
12
13
14
100
XA END 'trx3ro';
XA PREPARE 'trx3ro';
connection default;
*** 4 prepared transactions must be in the list ***
XA RECOVER;
formatID gtrid_length bqual_length data
1 LEN1 LEN2 TRX_N
1 LEN1 LEN2 TRX_N
1 LEN1 LEN2 TRX_N
1 LEN1 LEN2 TRX_N
connection conn1ro;
disconnect conn1ro;
connection default;
XA ROLLBACK 'trx1ro';
KILL connection CONN_ID;
XA ROLLBACK 'trx3ro';
connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'trx1empty';
XA END 'trx1empty';
XA PREPARE 'trx1empty';
connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'trx2empty';
XA END 'trx2empty';
XA PREPARE 'trx2empty';
connect conn$index$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'trx3empty';
XA END 'trx3empty';
XA PREPARE 'trx3empty';
connection default;
*** 5 prepared transactions must be in the list ***
XA RECOVER;
formatID gtrid_length bqual_length data
1 LEN1 LEN2 TRX_N
1 LEN1 LEN2 TRX_N
1 LEN1 LEN2 TRX_N
1 LEN1 LEN2 TRX_N
1 LEN1 LEN2 TRX_N
connection conn1empty;
disconnect conn1empty;
connection default;
XA COMMIT 'trx1empty';
KILL connection CONN_ID;
XA COMMIT 'trx3empty';
connect conn1$type, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'trx1unprepared';
INSERT INTO t set a=0;
XA END 'trx1unprepared';
INSERT INTO t set a=0;
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
XA START 'trx1unprepared';
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
XA START 'trx1unprepared';
ERROR XAE07: XAER_RMFAIL: The command cannot be executed when global transaction is in the IDLE state
disconnect conn1unprepared;
connection default;
XA COMMIT 'trx1unprepared';
ERROR XAE04: XAER_NOTA: Unknown XID
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_0';
INSERT INTO t SET a=0;
XA END 'trx_0';
XA PREPARE 'trx_0';
disconnect conn0;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_1';
INSERT INTO t SET a=1;
XA END 'trx_1';
XA PREPARE 'trx_1';
disconnect conn1;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_2';
INSERT INTO t SET a=2;
XA END 'trx_2';
XA PREPARE 'trx_2';
disconnect conn2;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_3';
INSERT INTO t SET a=3;
XA END 'trx_3';
XA PREPARE 'trx_3';
disconnect conn3;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_4';
INSERT INTO t SET a=4;
XA END 'trx_4';
XA PREPARE 'trx_4';
disconnect conn4;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_5';
INSERT INTO t SET a=5;
XA END 'trx_5';
XA PREPARE 'trx_5';
disconnect conn5;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_6';
INSERT INTO t SET a=6;
XA END 'trx_6';
XA PREPARE 'trx_6';
disconnect conn6;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_7';
INSERT INTO t SET a=7;
XA END 'trx_7';
XA PREPARE 'trx_7';
disconnect conn7;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_8';
INSERT INTO t SET a=8;
XA END 'trx_8';
XA PREPARE 'trx_8';
disconnect conn8;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_9';
INSERT INTO t SET a=9;
XA END 'trx_9';
XA PREPARE 'trx_9';
disconnect conn9;
connection default;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_10';
INSERT INTO t SET a=10;
XA END 'trx_10';
XA PREPARE 'trx_10';
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_11';
INSERT INTO t SET a=11;
XA END 'trx_11';
XA PREPARE 'trx_11';
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_12';
INSERT INTO t SET a=12;
XA END 'trx_12';
XA PREPARE 'trx_12';
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_13';
INSERT INTO t SET a=13;
XA END 'trx_13';
XA PREPARE 'trx_13';
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_14';
INSERT INTO t SET a=14;
XA END 'trx_14';
XA PREPARE 'trx_14';
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_15';
INSERT INTO t SET a=15;
XA END 'trx_15';
XA PREPARE 'trx_15';
connection default;
KILL CONNECTION CONN_ID;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_16';
INSERT INTO t SET a=16;
XA END 'trx_16';
XA PREPARE 'trx_16';
connection default;
KILL CONNECTION CONN_ID;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_17';
INSERT INTO t SET a=17;
XA END 'trx_17';
XA PREPARE 'trx_17';
connection default;
KILL CONNECTION CONN_ID;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
XA START 'trx_18';
INSERT INTO t SET a=18;
XA END 'trx_18';
XA PREPARE 'trx_18';
connection default;
KILL CONNECTION CONN_ID;
connect conn$i, 127.0.0.1,root,,test,$MASTER_MYPORT,;
SET @@binlog_format = STATEMENT;
SET @@binlog_format = ROW;
XA START 'trx_19';
INSERT INTO t SET a=19;
XA END 'trx_19';
XA PREPARE 'trx_19';
connection default;
KILL CONNECTION CONN_ID;
connection default;
XA ROLLBACK 'trx_0';
XA ROLLBACK 'trx_1';
XA ROLLBACK 'trx_2';
XA ROLLBACK 'trx_3';
XA ROLLBACK 'trx_4';
XA COMMIT 'trx_5';
XA COMMIT 'trx_6';
XA COMMIT 'trx_7';
XA COMMIT 'trx_8';
XA COMMIT 'trx_9';
# Kill and restart
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_0';
INSERT INTO t SET a=0;
XA END 'new_trx_0';
XA PREPARE 'new_trx_0';
disconnect conn_restart_0;
connection default;
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_1';
INSERT INTO t SET a=1;
XA END 'new_trx_1';
XA PREPARE 'new_trx_1';
disconnect conn_restart_1;
connection default;
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_2';
INSERT INTO t SET a=2;
XA END 'new_trx_2';
XA PREPARE 'new_trx_2';
disconnect conn_restart_2;
connection default;
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_3';
INSERT INTO t SET a=3;
XA END 'new_trx_3';
XA PREPARE 'new_trx_3';
disconnect conn_restart_3;
connection default;
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_4';
INSERT INTO t SET a=4;
XA END 'new_trx_4';
XA PREPARE 'new_trx_4';
disconnect conn_restart_4;
connection default;
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_5';
INSERT INTO t SET a=5;
XA END 'new_trx_5';
XA PREPARE 'new_trx_5';
disconnect conn_restart_5;
connection default;
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_6';
INSERT INTO t SET a=6;
XA END 'new_trx_6';
XA PREPARE 'new_trx_6';
disconnect conn_restart_6;
connection default;
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_7';
INSERT INTO t SET a=7;
XA END 'new_trx_7';
XA PREPARE 'new_trx_7';
disconnect conn_restart_7;
connection default;
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_8';
INSERT INTO t SET a=8;
XA END 'new_trx_8';
XA PREPARE 'new_trx_8';
disconnect conn_restart_8;
connection default;
connect conn_restart_$k, 127.0.0.1,root,,test,$MASTER_MYPORT,;
XA START 'new_trx_9';
INSERT INTO t SET a=9;
XA END 'new_trx_9';
XA PREPARE 'new_trx_9';
disconnect conn_restart_9;
connection default;
connection default;
XA COMMIT 'new_trx_0';
XA COMMIT 'new_trx_1';
XA COMMIT 'new_trx_2';
XA COMMIT 'new_trx_3';
XA COMMIT 'new_trx_4';
XA COMMIT 'new_trx_5';
XA COMMIT 'new_trx_6';
XA COMMIT 'new_trx_7';
XA COMMIT 'new_trx_8';
XA COMMIT 'new_trx_9';
XA START 'trx_10';
ERROR XAE08: XAER_DUPID: The XID already exists
XA COMMIT 'trx_10';
XA START 'trx_11';
ERROR XAE08: XAER_DUPID: The XID already exists
XA COMMIT 'trx_11';
XA START 'trx_12';
ERROR XAE08: XAER_DUPID: The XID already exists
XA COMMIT 'trx_12';
XA START 'trx_13';
ERROR XAE08: XAER_DUPID: The XID already exists
XA COMMIT 'trx_13';
XA START 'trx_14';
ERROR XAE08: XAER_DUPID: The XID already exists
XA COMMIT 'trx_14';
XA START 'trx_15';
ERROR XAE08: XAER_DUPID: The XID already exists
XA ROLLBACK 'trx_15';
XA START 'trx_16';
ERROR XAE08: XAER_DUPID: The XID already exists
XA ROLLBACK 'trx_16';
XA START 'trx_17';
ERROR XAE08: XAER_DUPID: The XID already exists
XA ROLLBACK 'trx_17';
XA START 'trx_18';
ERROR XAE08: XAER_DUPID: The XID already exists
XA ROLLBACK 'trx_18';
XA START 'trx_19';
ERROR XAE08: XAER_DUPID: The XID already exists
XA ROLLBACK 'trx_19';
SELECT * FROM t;
a
100
5
6
7
8
9
10
11
12
13
14
0
1
2
3
4
5
6
7
8
9
5
6
7
8
9
10
11
12
13
14
0
1
2
3
4
5
6
7
8
9
disconnect conn2tmp;
disconnect conn3tmp;
disconnect conn2ro;
disconnect conn3ro;
disconnect conn2empty;
disconnect conn3empty;
connection default;
XA ROLLBACK 'trx_20';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn19;
connection default;
XA ROLLBACK 'trx_19';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn18;
connection default;
XA ROLLBACK 'trx_18';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn17;
connection default;
XA ROLLBACK 'trx_17';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn16;
connection default;
XA ROLLBACK 'trx_16';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn15;
connection default;
XA ROLLBACK 'trx_15';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn14;
connection default;
XA ROLLBACK 'trx_14';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn13;
connection default;
XA ROLLBACK 'trx_13';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn12;
connection default;
XA ROLLBACK 'trx_12';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn11;
connection default;
XA ROLLBACK 'trx_11';
ERROR XAE04: XAER_NOTA: Unknown XID
disconnect conn10;
connection default;
XA START 'one_phase_trx_0';
INSERT INTO t SET a=0;
XA END 'one_phase_trx_0';
XA COMMIT 'one_phase_trx_0' ONE PHASE;
XA START 'one_phase_trx_1';
INSERT INTO t SET a=1;
XA END 'one_phase_trx_1';
XA COMMIT 'one_phase_trx_1' ONE PHASE;
XA START 'one_phase_trx_2';
INSERT INTO t SET a=2;
XA END 'one_phase_trx_2';
XA COMMIT 'one_phase_trx_2' ONE PHASE;
XA START 'one_phase_trx_3';
INSERT INTO t SET a=3;
XA END 'one_phase_trx_3';
XA COMMIT 'one_phase_trx_3' ONE PHASE;
XA START 'one_phase_trx_4';
INSERT INTO t SET a=4;
XA END 'one_phase_trx_4';
XA COMMIT 'one_phase_trx_4' ONE PHASE;
SELECT SUM(a) FROM t;
SUM(a)
390
DROP TABLE t;
DROP VIEW v_processlist;
All transactions must be completed, to empty-list the following:
XA RECOVER;
formatID gtrid_length bqual_length data