summaryrefslogtreecommitdiff
path: root/storage/rocksdb/mysql-test/rocksdb_rpl/t/multiclient_2pc.test
blob: 0f68de0471208e27184cfd063a41b84e101ea7f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
--source include/have_rocksdb.inc
--source include/have_binlog_format_row.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
--source include/big_test.inc

--exec echo > $MYSQLTEST_VARDIR/log/mysqld.1.err

--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings

SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
create table t1 (a int primary key, b int, c varchar(255)) engine=rocksdb;

connect (con1, localhost, root,,);
connect (con2, localhost, root,,);

# On connection one we insert a row and pause after commit marker is written to WAL.
# Connection two then inserts many rows. After connection two
# completes connection one continues only to crash before commit but after
# binlog write. On crash recovery we see that connection one's value
# has been recovered and commited
connection con1;
--echo 'con1'
--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
SET SESSION debug="d,crash_commit_after_log";
SET DEBUG_SYNC='rocksdb.prepared SIGNAL parked WAIT_FOR go';
--error 0,2013
--send insert into t1 values (1, 1, "iamtheogthealphaandomega");

connection con2;
--echo 'con2'
insert into t1 values (2, 1, "i_am_just_here_to_trigger_a_flush");

# Disable 2PC and syncing for faster inserting of dummy rows
# These rows only purpose is to rotate the binlog
SET GLOBAL ROCKSDB_ENABLE_2PC = OFF;
SET GLOBAL ROCKSDB_WRITE_SYNC = OFF;
SET GLOBAL SYNC_BINLOG = 0;

SET DEBUG_SYNC='now WAIT_FOR parked';
--disable_query_log
--let $pk= 3
while ($pk < 1000000) {
  eval insert into t1 values ($pk, 1, "foobardatagoesheresothatmorelogsrollwhichiswhatwewant");
  --inc $pk
}
--enable_query_log

# re-enable 2PC an syncing then write to trigger a flush
# before we trigger the crash to simulate full-durability
SET GLOBAL ROCKSDB_ENABLE_2PC = ON;
SET GLOBAL ROCKSDB_WRITE_SYNC = ON;
SET GLOBAL SYNC_BINLOG = 1;

insert into t1 values (1000000, 1, "i_am_just_here_to_trigger_a_flush");

SET DEBUG_SYNC='now SIGNAL go';

--enable_reconnect
--source include/wait_until_connected_again.inc

--exec sleep 60

--exec python suite/rocksdb/t/check_log_for_xa.py $MYSQLTEST_VARDIR/log/mysqld.1.err commit,prepare,rollback

select * from t1 where a=1;
select count(*) from t1;

drop table t1;