You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

652 lines
20 KiB

  1. #
  2. # This include file is used by more than one test suite
  3. # (currently rpl and binlog_encryption).
  4. # Please check all dependent tests after modifying it
  5. #
  6. --source include/have_innodb.inc
  7. --let $rpl_topology=1->2->3->4
  8. --source include/rpl_init.inc
  9. # Set up a 4-deep replication topology, then test various fail-overs
  10. # using GTID.
  11. #
  12. # A -> B -> C -> D
  13. connection server_1;
  14. --source include/wait_for_binlog_checkpoint.inc
  15. --let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1)
  16. --let $binlog_pos = query_get_value(SHOW MASTER STATUS,Position,1)
  17. --echo *** GTID position should be empty here ***
  18. --replace_result $binlog_file <BINLOG_FILE> $binlog_pos <BINLOG_POS>
  19. eval SELECT BINLOG_GTID_POS('$binlog_file',$binlog_pos);
  20. CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(10)) ENGINE=MyISAM;
  21. CREATE TABLE t2 (a INT PRIMARY KEY, b VARCHAR(10)) ENGINE=InnoDB;
  22. INSERT INTO t1 VALUES (1, "m1");
  23. INSERT INTO t1 VALUES (2, "m2"), (3, "m3"), (4, "m4");
  24. INSERT INTO t2 VALUES (1, "i1");
  25. BEGIN;
  26. INSERT INTO t2 VALUES (2, "i2"), (3, "i3");
  27. INSERT INTO t2 VALUES (4, "i4");
  28. COMMIT;
  29. save_master_pos;
  30. source include/wait_for_binlog_checkpoint.inc;
  31. --let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1)
  32. --let $binlog_pos = query_get_value(SHOW MASTER STATUS,Position,1)
  33. --let $gtid_pos_server_1 = `SELECT @@gtid_binlog_pos`
  34. --echo *** GTID position should be non-empty here ***
  35. --replace_result $binlog_file <BINLOG_FILE> $binlog_pos <BINLOG_POS> $gtid_pos_server_1 <GTID_POS_SERVER_1>
  36. eval SELECT BINLOG_GTID_POS('$binlog_file',$binlog_pos);
  37. connection server_2;
  38. sync_with_master;
  39. source include/wait_for_binlog_checkpoint.inc;
  40. --let $binlog_file = query_get_value(SHOW MASTER STATUS,File,1)
  41. --let $binlog_pos = query_get_value(SHOW MASTER STATUS,Position,1)
  42. --echo *** GTID position should be the same as on server_1 ***
  43. --replace_result $binlog_file <BINLOG_FILE> $binlog_pos <BINLOG_POS> $gtid_pos_server_1 <GTID_POS_SERVER_1>
  44. eval SELECT BINLOG_GTID_POS('$binlog_file',$binlog_pos);
  45. SELECT * FROM t1 ORDER BY a;
  46. SELECT * FROM t2 ORDER BY a;
  47. save_master_pos;
  48. connection server_3;
  49. sync_with_master;
  50. SELECT * FROM t1 ORDER BY a;
  51. SELECT * FROM t2 ORDER BY a;
  52. save_master_pos;
  53. connection server_4;
  54. sync_with_master;
  55. SELECT * FROM t1 ORDER BY a;
  56. SELECT * FROM t2 ORDER BY a;
  57. --echo *** Now take out D, let it fall behind a bit, and then test re-attaching it to A ***
  58. connection server_4;
  59. --source include/stop_slave.inc
  60. connection server_1;
  61. INSERT INTO t1 VALUES (5, "m1a");
  62. INSERT INTO t2 VALUES (5, "i1a");
  63. save_master_pos;
  64. connection server_4;
  65. --replace_result $MASTER_MYPORT MASTER_PORT
  66. eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT,
  67. MASTER_USE_GTID=CURRENT_POS;
  68. --source include/start_slave.inc
  69. sync_with_master;
  70. SELECT * FROM t1 ORDER BY a;
  71. SELECT * FROM t2 ORDER BY a;
  72. --echo *** Now move B to D (C is still replicating from B) ***
  73. connection server_2;
  74. --source include/stop_slave.inc
  75. --replace_result $SERVER_MYPORT_4 SERVER_MYPORT_4
  76. eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_4,
  77. MASTER_USE_GTID=CURRENT_POS;
  78. --source include/start_slave.inc
  79. connection server_4;
  80. UPDATE t2 SET b="j1a" WHERE a=5;
  81. save_master_pos;
  82. connection server_2;
  83. sync_with_master;
  84. SELECT * FROM t1 ORDER BY a;
  85. SELECT * FROM t2 ORDER BY a;
  86. --echo *** Now move C to D, after letting it fall a little behind ***
  87. connection server_3;
  88. --source include/stop_slave.inc
  89. connection server_1;
  90. INSERT INTO t2 VALUES (6, "i6b");
  91. INSERT INTO t2 VALUES (7, "i7b");
  92. --source include/save_master_gtid.inc
  93. connection server_3;
  94. --replace_result $SERVER_MYPORT_4 SERVER_MYPORT_4
  95. eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_4,
  96. MASTER_USE_GTID=CURRENT_POS;
  97. --source include/start_slave.inc
  98. --source include/sync_with_master_gtid.inc
  99. SELECT * FROM t2 ORDER BY a;
  100. --echo *** Now change everything back to what it was, to make rpl_end.inc happy
  101. # Also check that MASTER_USE_GTID=CURRENT_POS is still enabled.
  102. connection server_2;
  103. # We need to sync up server_2 before switching. If it happened to have reached
  104. # the point 'UPDATE t2 SET b="j1a" WHERE a=5' it will fail to connect to
  105. # server_1, which is (deliberately) missing that transaction.
  106. --source include/sync_with_master_gtid.inc
  107. --source include/stop_slave.inc
  108. --replace_result $MASTER_MYPORT MASTER_MYPORT
  109. eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $MASTER_MYPORT;
  110. --source include/start_slave.inc
  111. --source include/wait_for_slave_to_start.inc
  112. connection server_3;
  113. --source include/stop_slave.inc
  114. --replace_result $SLAVE_MYPORT SLAVE_MYPORT
  115. eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SLAVE_MYPORT;
  116. --source include/start_slave.inc
  117. --source include/sync_with_master_gtid.inc
  118. connection server_4;
  119. --source include/stop_slave.inc
  120. --replace_result $SERVER_MYPORT_3 SERVER_MYPORT_3
  121. eval CHANGE MASTER TO master_host = '127.0.0.1', master_port = $SERVER_MYPORT_3;
  122. --source include/start_slave.inc
  123. connection server_1;
  124. DROP TABLE t1,t2;
  125. --source include/save_master_gtid.inc
  126. --echo *** A few more checks for BINLOG_GTID_POS function ***
  127. --let $valid_binlog_name = query_get_value(SHOW BINARY LOGS,Log_name,1)
  128. --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
  129. SELECT BINLOG_GTID_POS();
  130. --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
  131. SELECT BINLOG_GTID_POS('a');
  132. --error ER_WRONG_PARAMCOUNT_TO_NATIVE_FCT
  133. SELECT BINLOG_GTID_POS('a',1,NULL);
  134. SELECT BINLOG_GTID_POS(1,'a');
  135. SELECT BINLOG_GTID_POS(NULL,NULL);
  136. SELECT BINLOG_GTID_POS('',1);
  137. SELECT BINLOG_GTID_POS('a',1);
  138. eval SELECT BINLOG_GTID_POS('$valid_binlog_name',-1);
  139. eval SELECT BINLOG_GTID_POS('$valid_binlog_name',0);
  140. eval SELECT BINLOG_GTID_POS('$valid_binlog_name',18446744073709551615);
  141. eval SELECT BINLOG_GTID_POS('$valid_binlog_name',18446744073709551616);
  142. --echo *** Some tests of @@GLOBAL.gtid_binlog_state ***
  143. --connection server_2
  144. --source include/sync_with_master_gtid.inc
  145. --source include/stop_slave.inc
  146. --connection server_1
  147. SET @old_state= @@GLOBAL.gtid_binlog_state;
  148. --error ER_BINLOG_MUST_BE_EMPTY
  149. SET GLOBAL gtid_binlog_state = '';
  150. RESET MASTER;
  151. SET GLOBAL gtid_binlog_state = '';
  152. FLUSH LOGS;
  153. --source include/show_binary_logs.inc
  154. SET GLOBAL gtid_binlog_state = '0-1-10,1-2-20,0-3-30';
  155. --source include/show_binary_logs.inc
  156. --let $binlog_file= master-bin.000001
  157. --let $binlog_start= 4
  158. --source include/show_binlog_events.inc
  159. #SELECT @@GLOBAL.gtid_binlog_pos;
  160. #SELECT @@GLOBAL.gtid_binlog_state;
  161. --error ER_BINLOG_MUST_BE_EMPTY
  162. SET GLOBAL gtid_binlog_state = @old_state;
  163. RESET MASTER;
  164. SET GLOBAL gtid_binlog_state = @old_state;
  165. # Check that slave can reconnect again, despite the RESET MASTER, as we
  166. # restored the state.
  167. CREATE TABLE t1 (a INT PRIMARY KEY);
  168. SET gtid_seq_no=100;
  169. INSERT INTO t1 VALUES (1);
  170. --source include/save_master_gtid.inc
  171. --connection server_2
  172. --source include/start_slave.inc
  173. # We cannot just use sync_with_master as we've done RESET MASTER, so
  174. # slave old-style position is wrong.
  175. # So sync on gtid position instead.
  176. --source include/sync_with_master_gtid.inc
  177. SELECT * FROM t1;
  178. # Check that the IO gtid position in SHOW SLAVE STATUS is also correct.
  179. --let $status_items= Gtid_IO_Pos
  180. --source include/show_slave_status.inc
  181. --echo *** Test @@LAST_GTID and MASTER_GTID_WAIT() ***
  182. --disable_ps2_protocol
  183. --connection server_1
  184. DROP TABLE t1;
  185. CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
  186. --save_master_pos
  187. --connection server_2
  188. --sync_with_master
  189. --source include/stop_slave.inc
  190. --connect (m1,127.0.0.1,root,,test,$SERVER_MYPORT_1,)
  191. SELECT @@last_gtid;
  192. SET gtid_seq_no=110;
  193. SELECT @@last_gtid;
  194. BEGIN;
  195. SELECT @@last_gtid;
  196. INSERT INTO t1 VALUES (2);
  197. SELECT @@last_gtid;
  198. COMMIT;
  199. SELECT @@last_gtid;
  200. --let $pos= `SELECT @@gtid_binlog_pos`
  201. --connect (s1,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
  202. eval SET @pos= '$pos';
  203. # Check NULL argument.
  204. SELECT master_gtid_wait(NULL);
  205. # Check empty argument returns immediately.
  206. SELECT master_gtid_wait('', NULL);
  207. # Check this gets counted
  208. SHOW STATUS LIKE 'Master_gtid_wait_count';
  209. SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
  210. SHOW STATUS LIKE 'Master_gtid_wait_time';
  211. # Let's check that we get a timeout
  212. SELECT master_gtid_wait(@pos, 0.5);
  213. SELECT * FROM t1 ORDER BY a;
  214. # Now actually wait until the slave reaches the position
  215. send SELECT master_gtid_wait(@pos);
  216. --connection server_2
  217. --source include/start_slave.inc
  218. --connection s1
  219. reap;
  220. SELECT * FROM t1 ORDER BY a;
  221. # Test waiting on a domain that does not exist yet.
  222. --source include/stop_slave.inc
  223. --connection server_1
  224. SET gtid_domain_id= 1;
  225. INSERT INTO t1 VALUES (3);
  226. --let $pos= `SELECT @@gtid_binlog_pos`
  227. --connection s1
  228. --replace_result $pos POS
  229. eval SET @pos= '$pos';
  230. SELECT master_gtid_wait(@pos, 0);
  231. SELECT * FROM t1 WHERE a >= 3;
  232. send SELECT master_gtid_wait(@pos, -1);
  233. --connection server_2
  234. --source include/start_slave.inc
  235. --connection s1
  236. reap;
  237. SELECT * FROM t1 WHERE a >= 3;
  238. # Waiting for only part of the position.
  239. SELECT master_gtid_wait('1-1-1', 0);
  240. # Now test a lot of parallel master_gtid_wait() calls, completing in different
  241. # order, and some of which time out or get killed on the way.
  242. --connection s1
  243. send SELECT master_gtid_wait('2-1-1,1-1-4,0-1-110');
  244. --connect (s2,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
  245. # This will time out. No event 0-1-1000 exists
  246. send SELECT master_gtid_wait('0-1-1000', 0.5);
  247. --connect (s3,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
  248. # This one we will kill
  249. --let $kill1_id= `SELECT connection_id()`
  250. send SELECT master_gtid_wait('0-1-2000');
  251. --connect (s4,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
  252. send SELECT master_gtid_wait('2-1-10');
  253. --connect (s5,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
  254. send SELECT master_gtid_wait('2-1-6', 1);
  255. # This one we will kill also.
  256. --connect (s6,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
  257. --let $kill2_id= `SELECT connection_id()`
  258. send SELECT master_gtid_wait('2-1-5');
  259. --connect (s7,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
  260. send SELECT master_gtid_wait('2-1-10');
  261. --connect (s8,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
  262. send SELECT master_gtid_wait('2-1-5,1-1-4,0-1-110');
  263. --connect (s9,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
  264. send SELECT master_gtid_wait('2-1-2');
  265. --connection server_2
  266. # This one completes immediately.
  267. SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
  268. SHOW STATUS LIKE 'Master_gtid_wait_count';
  269. SELECT master_gtid_wait('1-1-1');
  270. SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
  271. SHOW STATUS LIKE 'Master_gtid_wait_count';
  272. let $wait_time = query_get_value(SHOW STATUS LIKE 'Master_gtid_wait_time', Value, 1);
  273. --replace_result $wait_time MASTER_GTID_WAIT_TIME
  274. eval SET @a= $wait_time;
  275. SELECT IF(@a <= 100*1000*1000, "OK", CONCAT("Error: wait time ", @a, " is larger than expected"))
  276. AS Master_gtid_wait_time_as_expected;
  277. --connect (s10,127.0.0.1,root,,test,$SERVER_MYPORT_2,)
  278. send SELECT master_gtid_wait('0-1-109');
  279. --connection server_2
  280. # This one should time out.
  281. SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
  282. SHOW STATUS LIKE 'Master_gtid_wait_count';
  283. SELECT master_gtid_wait('2-1-2', 0.5);
  284. SHOW STATUS LIKE 'Master_gtid_wait_timeouts';
  285. SHOW STATUS LIKE 'Master_gtid_wait_count';
  286. let $wait_time = query_get_value(SHOW STATUS LIKE 'Master_gtid_wait_time', Value, 1);
  287. --replace_result $wait_time MASTER_GTID_WAIT_TIME
  288. eval SET @a= $wait_time;
  289. # We expect a wait time of just a bit over 0.5 seconds. But thread scheduling
  290. # and timer inaccuracies could introduce significant jitter. So allow a
  291. # generous interval.
  292. SELECT IF(@a BETWEEN 0.4*1000*1000 AND 100*1000*1000, "OK", CONCAT("Error: wait time ", @a, " not as expected")) AS Master_gtid_wait_time_as_expected;
  293. --replace_result $kill1_id KILL_ID
  294. eval KILL QUERY $kill1_id;
  295. --connection s3
  296. --error ER_QUERY_INTERRUPTED
  297. reap;
  298. --connection server_1
  299. SET gtid_domain_id=2;
  300. SET gtid_seq_no=2;
  301. INSERT INTO t1 VALUES (4);
  302. --connection s9
  303. reap;
  304. --connection server_2
  305. --replace_result $kill2_id KILL_ID
  306. eval KILL CONNECTION $kill2_id;
  307. --connection s6
  308. --error 2013,ER_CONNECTION_KILLED
  309. reap;
  310. --connection server_1
  311. SET gtid_domain_id=1;
  312. SET gtid_seq_no=4;
  313. INSERT INTO t1 VALUES (5);
  314. SET gtid_domain_id=2;
  315. SET gtid_seq_no=5;
  316. INSERT INTO t1 VALUES (6);
  317. --connection s8
  318. reap;
  319. --connection s1
  320. reap;
  321. --connection s2
  322. reap;
  323. --connection s5
  324. reap;
  325. --connection s10
  326. reap;
  327. --connection server_1
  328. SET gtid_domain_id=2;
  329. SET gtid_seq_no=10;
  330. INSERT INTO t1 VALUES (7);
  331. --connection s4
  332. reap;
  333. --connection s7
  334. reap;
  335. --enable_ps2_protocol
  336. --echo *** Test gtid_slave_pos when used with GTID ***
  337. --connection server_2
  338. --source include/stop_slave.inc
  339. --connection server_1
  340. SET gtid_domain_id=2;
  341. SET gtid_seq_no=1000;
  342. INSERT INTO t1 VALUES (10);
  343. INSERT INTO t1 VALUES (11);
  344. --save_master_pos
  345. --connection server_2
  346. SET sql_slave_skip_counter= 1;
  347. --source include/start_slave.inc
  348. --sync_with_master
  349. SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
  350. SELECT IF(LOCATE("2-1-1001", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1001 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
  351. --source include/stop_slave.inc
  352. --connection server_1
  353. SET gtid_domain_id=2;
  354. SET gtid_seq_no=1010;
  355. INSERT INTO t1 VALUES (12);
  356. INSERT INTO t1 VALUES (13);
  357. --save_master_pos
  358. --connection server_2
  359. SET sql_slave_skip_counter= 2;
  360. --source include/start_slave.inc
  361. --sync_with_master
  362. SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
  363. SELECT IF(LOCATE("2-1-1011", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1011 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
  364. --source include/stop_slave.inc
  365. --connection server_1
  366. SET gtid_domain_id=2;
  367. SET gtid_seq_no=1020;
  368. INSERT INTO t1 VALUES (14);
  369. INSERT INTO t1 VALUES (15);
  370. INSERT INTO t1 VALUES (16);
  371. --save_master_pos
  372. --connection server_2
  373. SET sql_slave_skip_counter= 3;
  374. --source include/start_slave.inc
  375. --sync_with_master
  376. SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
  377. SELECT IF(LOCATE("2-1-1022", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1022 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
  378. --source include/stop_slave.inc
  379. --connection server_1
  380. SET gtid_domain_id=2;
  381. SET gtid_seq_no=1030;
  382. # Disable logging Annotate_rows events to preserve events count.
  383. let $binlog_annotate_row_events_saved= `SELECT @@binlog_annotate_row_events`;
  384. SET @@binlog_annotate_row_events= 0;
  385. INSERT INTO t1 VALUES (17);
  386. INSERT INTO t1 VALUES (18);
  387. INSERT INTO t1 VALUES (19);
  388. eval SET @@binlog_annotate_row_events= $binlog_annotate_row_events_saved;
  389. --save_master_pos
  390. --connection server_2
  391. SET sql_slave_skip_counter= 5;
  392. --source include/start_slave.inc
  393. --sync_with_master
  394. SELECT * FROM t1 WHERE a >= 10 ORDER BY a;
  395. SELECT IF(LOCATE("2-1-1032", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1032 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
  396. --source include/stop_slave.inc
  397. --connection server_1
  398. SET gtid_domain_id=3;
  399. SET gtid_seq_no=100;
  400. CREATE TABLE t2 (a INT PRIMARY KEY);
  401. DROP TABLE t2;
  402. SET gtid_domain_id=2;
  403. SET gtid_seq_no=1040;
  404. INSERT INTO t1 VALUES (20);
  405. --save_master_pos
  406. --connection server_2
  407. SET @saved_mode= @@GLOBAL.slave_ddl_exec_mode;
  408. SET GLOBAL slave_ddl_exec_mode=STRICT;
  409. SET sql_slave_skip_counter=1;
  410. START SLAVE UNTIL master_gtid_pos="3-1-100";
  411. --let $master_pos=3-1-100
  412. --source include/sync_with_master_gtid.inc
  413. --source include/wait_for_slave_to_stop.inc
  414. --error ER_NO_SUCH_TABLE
  415. SELECT * FROM t2;
  416. SELECT IF(LOCATE("3-1-100", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 3-1-100 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
  417. # Start the slave again, it should fail on the DROP TABLE as the table is not there.
  418. SET sql_log_bin=0;
  419. CALL mtr.add_suppression("Slave: Unknown table 'test\\.t2' Error_code: 1051");
  420. SET sql_log_bin=1;
  421. START SLAVE;
  422. --let $slave_sql_errno=1051
  423. --source include/wait_for_slave_sql_error.inc
  424. SELECT IF(LOCATE("3-1-100", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 3-1-100 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
  425. STOP SLAVE IO_THREAD;
  426. SET sql_slave_skip_counter=2;
  427. --source include/start_slave.inc
  428. --sync_with_master
  429. SELECT * FROM t1 WHERE a >= 20 ORDER BY a;
  430. SELECT IF(LOCATE("3-1-101", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 3-1-101 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
  431. SELECT IF(LOCATE("2-1-1040", @@GLOBAL.gtid_slave_pos)>0, "Ok", CONCAT("ERROR! expected GTID 2-1-1040 not found in gtid_slave_pos: ", @@GLOBAL.gtid_slave_pos)) AS status;
  432. SET GLOBAL slave_ddl_exec_mode= @saved_mode;
  433. --echo *** Test GTID-connecting to a master with out-of-order sequence numbers in the binlog. ***
  434. # Create an out-of-order binlog on server 2.
  435. # Let server 3 replicate to an out-of-order point, stop it, restart it,
  436. # and check that it replicates correctly despite the out-of-order.
  437. --connection server_1
  438. SET gtid_domain_id= @@GLOBAL.gtid_domain_id;
  439. INSERT INTO t1 VALUES (31);
  440. --save_master_pos
  441. --connection server_2
  442. --sync_with_master
  443. SET gtid_domain_id= @@GLOBAL.gtid_domain_id;
  444. INSERT INTO t1 VALUES (32);
  445. --connection server_1
  446. INSERT INTO t1 VALUES (33);
  447. --save_master_pos
  448. --connection server_2
  449. --sync_with_master
  450. --save_master_pos
  451. --connection server_3
  452. --sync_with_master
  453. --source include/stop_slave.inc
  454. --connection server_1
  455. INSERT INTO t1 VALUES (34);
  456. --save_master_pos
  457. --connection server_2
  458. --sync_with_master
  459. --save_master_pos
  460. --connection server_3
  461. --source include/start_slave.inc
  462. --sync_with_master
  463. SELECT * FROM t1 WHERE a >= 30 ORDER BY a;
  464. --save_master_pos
  465. --connection server_4
  466. --sync_with_master
  467. SELECT * FROM t1 WHERE a >= 30 ORDER BY a;
  468. --echo *** MDEV-31723: Crash on SET SESSION gtid_seq_no= DEFAULT
  469. --connection server_1
  470. # Setting gtid_seq_no forces the GTID logged, but only once.
  471. SET SESSION gtid_seq_no= 2000;
  472. SELECT @@SESSION.gtid_seq_no;
  473. INSERT INTO t1 VALUES (40);
  474. SELECT @@SESSION.gtid_seq_no;
  475. SELECT REGEXP_REPLACE(@@gtid_binlog_pos, ".*\\b(0-1-[0-9]+)\\b.*", "\\1") AS dom0_pos;
  476. INSERT INTO t1 VALUES (41);
  477. SELECT REGEXP_REPLACE(@@gtid_binlog_pos, ".*\\b(0-1-[0-9]+)\\b.*", "\\1") AS dom0_pos;
  478. # Setting to 0 has no effect.
  479. SET SESSION gtid_seq_no= 2010;
  480. INSERT INTO t1 VALUES (42);
  481. SELECT REGEXP_REPLACE(@@gtid_binlog_pos, ".*\\b(0-1-[0-9]+)\\b.*", "\\1") AS dom0_pos;
  482. SET @old_strict= @@GLOBAL.gtid_strict_mode;
  483. SET GLOBAL gtid_strict_mode= 1;
  484. SET SESSION gtid_seq_no= 0;
  485. INSERT INTO t1 VALUES (43);
  486. SELECT REGEXP_REPLACE(@@gtid_binlog_pos, ".*\\b(0-1-[0-9]+)\\b.*", "\\1") AS dom0_pos;
  487. SET GLOBAL gtid_strict_mode= @old_strict;
  488. INSERT INTO t1 VALUES (44);
  489. SELECT REGEXP_REPLACE(@@gtid_binlog_pos, ".*\\b(0-1-[0-9]+)\\b.*", "\\1") AS dom0_pos;
  490. # Setting gtid_seq_no multiple times.
  491. SET SESSION gtid_seq_no= 2020;
  492. SET SESSION gtid_seq_no= 2030;
  493. INSERT INTO t1 VALUES (45);
  494. SELECT REGEXP_REPLACE(@@gtid_binlog_pos, ".*\\b(0-1-[0-9]+)\\b.*", "\\1") AS dom0_pos;
  495. # Setting to DEFAULT or 0 disables prior setting.
  496. SET SESSION gtid_seq_no= 2040;
  497. SET SESSION gtid_seq_no= DEFAULT;
  498. INSERT INTO t1 VALUES (46);
  499. SELECT REGEXP_REPLACE(@@gtid_binlog_pos, ".*\\b(0-1-[0-9]+)\\b.*", "\\1") AS dom0_pos;
  500. INSERT INTO t1 VALUES (47);
  501. SELECT REGEXP_REPLACE(@@gtid_binlog_pos, ".*\\b(0-1-[0-9]+)\\b.*", "\\1") AS dom0_pos;
  502. SET SESSION gtid_seq_no= 2050;
  503. SET SESSION gtid_seq_no= 0;
  504. INSERT INTO t1 VALUES (48);
  505. SELECT REGEXP_REPLACE(@@gtid_binlog_pos, ".*\\b(0-1-[0-9]+)\\b.*", "\\1") AS dom0_pos;
  506. # Clean up.
  507. --connection server_1
  508. DROP TABLE t1;
  509. --source include/rpl_end.inc
  510. --echo #
  511. --echo # Start of 10.2 tests
  512. --echo #
  513. --echo #
  514. --echo # MDEV-10134 Add full support for DEFAULT
  515. --echo #
  516. --error ER_GENERATED_COLUMN_FUNCTION_IS_NOT_ALLOWED
  517. CREATE TABLE t1 (a VARCHAR(100) DEFAULT BINLOG_GTID_POS("master-bin.000001", 600));
  518. --echo #
  519. --echo # End of 10.2 tests
  520. --echo #
  521. --echo #
  522. --echo # Start of 10.3 tests
  523. --echo #
  524. --echo #
  525. --echo # MDEV-13967 Parameter data type control for Item_long_func
  526. --echo #
  527. --error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
  528. SELECT MASTER_GTID_WAIT(ROW(1,1),'str');
  529. --error ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
  530. SELECT MASTER_GTID_WAIT('str',ROW(1,1));
  531. --echo #
  532. --echo # End of 10.3 tests
  533. --echo #