Commit 4e4ad171 authored by sjaakola's avatar sjaakola Committed by Nirbhay Choubey

Refs MW-255

- popping PS reprepare observer before BF aborted PS replaying begins
  dangling observer will cause failure in open_table() ater on
- test case for this anomaly
parent d246630d
......@@ -30,3 +30,30 @@ SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c';
COUNT(*) = 1
1
DROP TABLE t1;
CREATE TABLE t1 (i int primary key, j int) ENGINE=INNODB;
INSERT INTO t1 VALUES (1, 0), (3, 0);
SELECT * FROM t1;
i j
1 0
3 0
PREPARE stmt1 FROM "UPDATE t1 SET j = 1 where i > 0";
SET GLOBAL wsrep_provider_options = 'dbug=d,commit_monitor_enter_sync';
EXECUTE stmt1;;
SET SESSION wsrep_sync_wait = 0;
SET SESSION wsrep_on = 0;
SET SESSION wsrep_on = 1;
INSERT INTO t1 VALUES(2,2);
SET GLOBAL wsrep_provider_options = 'dbug=';
SET GLOBAL wsrep_provider_options = 'signal=commit_monitor_enter_sync';
SELECT * FROM t1;
i j
1 1
2 2
3 1
SELECT * FROM t1;
i j
1 1
2 2
3 1
DEALLOCATE PREPARE stmt1;
DROP TABLE t1;
......@@ -69,3 +69,56 @@ SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'b';
SELECT COUNT(*) = 1 FROM t1 WHERE f2 = 'c';
DROP TABLE t1;
#echo "# test for PS replaying"
#
# test replaying of prepared statements
#
--connection node_1
CREATE TABLE t1 (i int primary key, j int) ENGINE=INNODB;
INSERT INTO t1 VALUES (1, 0), (3, 0);
SELECT * FROM t1;
PREPARE stmt1 FROM "UPDATE t1 SET j = 1 where i > 0";
# block the commit of PS
--connection node_1a
--let $galera_sync_point = commit_monitor_enter_sync
--source include/galera_set_sync_point.inc
--connection node_1
--send EXECUTE stmt1;
# Wait until commit is blocked
--connection node_1a
SET SESSION wsrep_sync_wait = 0;
--source include/galera_wait_sync_point.inc
# Issue a conflicting update on node_2
--connection node_2
#UPDATE t1 SET j=2;
INSERT INTO t1 VALUES(2,2);
# Wait until applying begins in node_1
--connection node_1a
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE STATE LIKE 'Write_rows_log_event::write_row%';
--source include/wait_condition.inc
# Unblock the PS commit
--connection node_1a
--source include/galera_clear_sync_point.inc
--source include/galera_signal_sync_point.inc
# Commit succeeds
--connection node_1
--reap
SELECT * FROM t1;
--connection node_2
SELECT * FROM t1;
--connection node_1
DEALLOCATE PREPARE stmt1;
DROP TABLE t1;
......@@ -185,6 +185,7 @@ static void wsrep_return_from_bf_mode(THD *thd, struct wsrep_thd_shadow* shadow)
void wsrep_replay_transaction(THD *thd)
{
DBUG_ENTER("wsrep_replay_transaction");
/* checking if BF trx must be replayed */
if (thd->wsrep_conflict_state== MUST_REPLAY) {
DBUG_ASSERT(wsrep_thd_trx_seqno(thd));
......@@ -193,6 +194,13 @@ void wsrep_replay_transaction(THD *thd)
{
WSREP_ERROR("replay issue, thd has reported status already");
}
/*
PS reprepare observer should have been removed already.
open_table() will fail if we have dangling observer here.
*/
DBUG_ASSERT(thd->m_reprepare_observer == NULL);
thd->get_stmt_da()->reset_diagnostics_area();
thd->wsrep_conflict_state= REPLAYING;
......@@ -299,6 +307,7 @@ void wsrep_replay_transaction(THD *thd)
mysql_mutex_unlock(&LOCK_wsrep_replaying);
}
}
DBUG_VOID_RETURN;
}
static void wsrep_replication_process(THD *thd)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment