Debian Codegraph @

mysql-test/suite/binlog/t/binlog_crash_safe_ddl.test

raw
1 # ==== Purpose ====
2 # Prove successful server recovery after simulated crash while
3 # there were recoverable DDL queries in processing.
4 # The recoverable DDL:s are those that are binary-logged with xid info
5 # with enables the server to decide on their commit or rollback at server
6 # recovery.
7 #
8 # ==== Implementation ====
9 #
10 # The test consists of two part. In the first major part
11 # it verifies the server recovery for each recoverable DDL query.
12 # A client connection issues a DDL query whose processing either completes
13 # is interrupted by simulated crash either at time the DDL has been
14 # already prepared in the engine and binary-logged, or just prepared
15 # and not yet logged.
16 # Upon the server restart the query execution status is checked, and
17 # the check outcome must correspond to timing of the crash. The logged
18 # query's result must be committed, and not-logged are to be rolled
19 # back by the server recovery.
20 # The 2nd minor part proves correct mysqlbinlog processing.
21 #
22
23 #
24 # ==== References ====
25 # WL#9175 Correct recovery of DDL statements/transactions by binary log
26
27 --source include/big_test.inc
28 --source include/not_crashrep.inc
29 --source include/not_valgrind.inc
30 --source include/have_log_bin.inc
31 --source include/have_debug.inc
32 --source include/have_binlog_format_mixed.inc
33 --source include/have_udf.inc
34
35 # The part II related variable to describe a binlog file
36 # with recorded CREATE USER. The file is created in the Ist part.
37 --let $binlog_file_create_user=
38
39 --source include/gtid_utils.inc
40
41 # The *internal* var is used by gtid_step_assert.inc
42 --let $gtid_mode_on= `SELECT @@GLOBAL.GTID_MODE = 'ON'`
43 --let $gtid_mode= `SELECT @@GLOBAL.GTID_MODE`
44 # Instructing gtid_step_assert called by sourced file
45 # to work in gtid-mode OFF as well.
46 --let $gtid_step_gtid_mode_agnostic=`SELECT '$gtid_mode' != 'ON'`
47
48 # sourcing event generator interrupted by the two crashes according to params:
49 --let $do_pre_binlog=1
50 --let $do_post_binlog=1
51 --let $do_only_regular_logging=0
52 --let $do_show_binlog_events= 0
53 --let $table=t_1
54 --eval CREATE TABLE $table (a int)
55
56 --source extra/binlog_tests/binlog_ddl.inc
57
58 ## --source include/gtid_utils_end.inc
59
60 #
61 # Part II.
62 # mysqlbinlog processing.
63 #
64
65 --let $MYSQLD_DATADIR= `select @@datadir`
66 --exec $MYSQL_BINLOG --short-form --to-last-log $MYSQLD_DATADIR/$binlog_file_create_user > $MYSQLTEST_VARDIR/tmp/wl9175.sql
67
68 RESET MASTER;
69 --let $gtid_step_gtid_mode_agnostic=1
70 --source include/gtid_step_reset.inc
71 --exec $MYSQL < $MYSQLTEST_VARDIR/tmp/wl9175.sql
72 --let $gtid_step_count=1
73 --let $gtid_step_only_count= 1
74 --source include/gtid_step_assert.inc
75 --remove_file $MYSQLTEST_VARDIR/tmp/wl9175.sql
76
77 # Cleanup of the above CREATE USER with manual GTID_NEXT,
78 # interrupted by crashes. This use case verifies the manual gtid headed
79 # DDL transaction.
80 if ($gtid_mode == 'ON')
81 {
82 --let $manual_gtid_next= SET @@SESSION.GTID_NEXT='$uuid0:1'
83 }
84 --let $ddl_query=DROP USER user1
85 --let $pre_binlog_crash_check=SELECT count(*) = 1 FROM mysql.user WHERE user = 'user1'
86 --let $post_binlog_crash_check=SELECT count(*) = 0 FROM mysql.user WHERE user = 'user1'
87 --source extra/binlog_tests/binlog_crash_safe_ddl.inc
88 --let $manual_gtid_next=
89
90 #
91 # Cleanup
92 #
93 --eval DROP TABLE $table
94 --source include/gtid_utils_end.inc