mariadb/mysql-test/suite/galera/t/mdev_18730.test
Teemu Ollakka 1ef50a34ec 10.4 wsrep group commit fixes (#1224)
* MDEV-16509 Improve wsrep commit performance with binlog disabled

Release commit order critical section early after trx_commit_low() if
binlog is not transaction coordinator. In order to avoid two phase commit,
binlog_hton is not registered for THD during IO_CACHE population.

Implemented a test which verifies that the transactions release
commit order early.

This optimization will change behavior during recovery as the commit
is not two phase when binlog is off. Fixed and recorded wsrep-recover-v25
and wsrep-recover to match the behavior.

* MDEV-18730 Ordering for wsrep binlog group commit

Previously out of order execution was allowed for wsrep commits.
Established proper ordering by populating wait_for_commit
for every wsrep THD and making group commit leader to wait for
prior commits before proceeding to trx_group_commit_leader().

* MDEV-18730 Added a test case to verify correct commit ordering

* MDEV-16509, MDEV-18730 Review fixes

Use WSREP_EMULATE_BINLOG() macro to decide if the binlog_hton
should be registered. Whitespace/syntax fixes and cleanups.

* MDEV-16509 Require binlog for galera_var_innodb_disallow_writes test

If the commit to InnoDB is done in one phase, the native InnoDB behavior
is that the transaction is committed in memory before it is persisted to
disk. This means that the innodb_disallow_writes=ON may not prevent
transaction to become visible to other readers before commit is completely
over. On the other hand, if the commit is two phase (as it is with binlog),
the transaction will be blocked in prepare phase.

Fixed the test to use binlog, which enforces two phase commit, which
in turn makes commit to block before the changes become visible to
other connections. This guarantees that the test produces expected
result.
2019-03-15 07:09:13 +02:00

71 lines
2.1 KiB
Text

#
# Test scenario:
#
# Run an autocommit INSERT and stop the execution after the INSERT
# has released commit order critical section. On another connection,
# run SR transaction which will store one fragment into streaming log.
# If the bug is present, the fragment streaming log commit may
# out of order, and completing INSERT may cause assertion in debug build.
#
# Note that due to nature of this bug, it is may not be possible
# to construct fully deterministic test case which will crash the
# server each time if the bug is present, but will work with fix.
#
--source include/galera_cluster.inc
--source include/have_log_bin.inc
--source include/have_debug_sync.inc
CREATE TABLE t1 (f1 INT PRIMARY KEY);
# Control connection for controlling node_1 debug sync points
--let $galera_connection_name = ctrl
--let $galera_server_number = 1
--source include/galera_connect.inc
# Another connection for SR transaction
--let $galera_connection_name = node_1_sr
--let $galera_server_number = 1
--source include/galera_connect.inc
# Set up sync point and send INSERT
--connection node_1
SET DEBUG_SYNC = "wsrep_after_commit_order_leave SIGNAL acol_reached WAIT_FOR acol_continue";
--send INSERT INTO t1 VALUES (1)
# Wait until INSERT releases commit order
--connection ctrl
SET DEBUG_SYNC = "now WAIT_FOR acol_reached";
# Streaming transaction, will replicate fragment for each row separately.
--connection node_1_sr
SET SESSION wsrep_sync_wait = 0;
SET SESSION wsrep_trx_fragment_unit = 'rows';
SET SESSION wsrep_trx_fragment_size = 1;
START TRANSACTION;
--send INSERT INTO t1 VALUES (2)
--connection ctrl
# Now let the thread node_1 continue after a one second sleep.
# The sleep while not completely deterministic, will allow the SR
# insert to complete the commit out of order in most of the cases if
# the bug is present, leading to assertion in debug build.
--sleep 1
SET DEBUG_SYNC = "now SIGNAL acol_continue";
--connection node_1
--reap
--connection node_1_sr
--reap
ROLLBACK;
--connection ctrl
SET DEBUG_SYNC = "RESET";
--disconnect ctrl
--disconnect node_1_sr
--connection node_1
DROP TABLE t1;
--source include/galera_end.inc