File: galera_sr_nonPK_and_PA.test

package info (click to toggle)
mariadb 1%3A11.8.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 765,428 kB
  • sloc: ansic: 2,382,827; cpp: 1,803,532; asm: 378,315; perl: 63,176; sh: 46,496; pascal: 40,776; java: 39,363; yacc: 20,428; python: 19,506; sql: 17,864; xml: 12,463; ruby: 8,544; makefile: 6,059; cs: 5,855; ada: 1,700; lex: 1,193; javascript: 1,039; objc: 80; tcl: 73; awk: 46; php: 22
file content (109 lines) | stat: -rw-r--r-- 3,810 bytes parent folder | download | duplicates (5)
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#
# This test is a modified version of Gabor Orosz (GOro) test in jira tracker:
# https://jira.mariadb.org/browse/MDEV-25551
#
# The underlying problem with MDEV-25551 turned out to be that
# transactions having changes for tables with no primary key, 
# were not safe to apply in parallel. This is due to excessive locking
# in innodb side, and even non related row modifications could end up
# in lock conflict during applying.
#
# The test verifies that a transaction executing a streaming replication
# will disable parallel applying if it modifies a table with no primary key.
# And, if PA was disabled temporarily, it will be relaxed if next fragment
# contains changes for table with primary key.
#

--source include/galera_cluster.inc
--source include/have_debug_sync.inc
--source include/galera_have_debug_sync.inc


# Setup
--connection node_2
SET SESSION wsrep_sync_wait = 0;

# Ensure that we have enough applier threads to process transactions in parallel
SET GLOBAL wsrep_slave_threads = 2;

flush status;

--connection node_1
CREATE TABLE t1 (f1 int, f2 int) ENGINE=InnoDB;
CREATE TABLE t2 (f1 int primary key, f2 int) ENGINE=InnoDB;
INSERT INTO t1  VALUES (1,0);
INSERT INTO t1  VALUES (2,0);

INSERT INTO t2  VALUES (1,0);
INSERT INTO t2  VALUES (2,0);

--connection node_2
--let $wait_condition = SELECT COUNT(*)=2 FROM t2;
--source include/wait_condition.inc

# remember status for received replication counter and certification dependency distance
--let $cert_deps_distance = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cert_deps_distance'`

--connection node_1
# Invoke the first transaction
set session wsrep_trx_fragment_size=1;
START TRANSACTION;
UPDATE t1 SET f2=1 where f1=1;

--connection node_2
# verify that certification dependency distance has dropped
--disable_query_log
--eval  SELECT  VARIABLE_VALUE < $cert_deps_distance as 'distance' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cert_deps_distance'
--enable_query_log

# if deps distance dropped, it is indirect evidence that parallel applying was not approved

# Try next that PA retricting is relaxed, if next fragment updates table t1 with primary key
# wsrep_cert_deps_distance cannot be trsuted in this test phase, we verify parallel applying
# by setting sync point for applier thread

# Set up a synchronization point to catch update on t2
--let $galera_sync_point = commit_monitor_slave_enter_sync
--source include/galera_set_sync_point.inc

--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
--connection node_1a
update t2 set f2=1 where f1=1;

--connection node_2
# Wait for the update t2 to apply until commit phase
--let $galera_sync_point = commit_monitor_slave_enter_sync
--source include/galera_wait_sync_point.inc

# Set up a synchronization point to catch the SR trx applying
--let $galera_sync_point = apply_monitor_slave_enter_sync
--source include/galera_set_sync_point.inc

--connection node_1
# continue SR transaction, and now update t2, which has PK
UPDATE t2 set f2=2 where f1=2;

--connection node_2
# Wait for the update t2 to apply until commit phase
--let $galera_sync_point = apply_monitor_slave_enter_sync commit_monitor_slave_enter_sync
--source include/galera_wait_sync_point.inc

# Let the first transaction to proceed
--let $galera_sync_point = commit_monitor_slave_enter_sync
--source include/galera_signal_sync_point.inc
--source include/galera_clear_sync_point.inc
--let $galera_sync_point = apply_monitor_slave_enter_sync
--source include/galera_signal_sync_point.inc
--source include/galera_clear_sync_point.inc

--connection node_1
COMMIT;

# Teardown
--connection node_1
SET GLOBAL wsrep_slave_threads = DEFAULT;

DROP TABLE t1;
DROP TABLE t2;
--connection node_2
SET GLOBAL wsrep_slave_threads = DEFAULT;