File: rpl_crash_safe.inc

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (154 lines) | stat: -rw-r--r-- 4,233 bytes parent folder | download
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
# ==== Purpose ====
#
# This file is an engine to process commands like
# rpl_mixing_engines.inc.  It has the same set of commands, and in
# addition the extra command 'recovery'.  The 'configure' and 'clean'
# commands are also extended version of the same commands in
# rpl_mixing_engines.inc.
#
# ==== Usage ====
#
# --let $commands= command1 command2 ...
# --let $database_name= name
# --let $failure= d,debug_flag
# [--let $verbose= 1]
# --source include/rpl_mixing_engines.inc
#
#   Parameters:
#
#     $commands, $database_name, $verbose
#       See rpl_mixing_engines.inc.
#
#     $failure
#       This debug symbol will be set. See the implementation for
#       details.
#
# ==== Implementation ====
#
# This file has its own code for 'configure' and 'clean'.  For other
# commands, this file first configures the server according to
# $failure, and then delegates the commands to rpl_mixing_engines.inc.

#
# Creates tables used throughout the test and changes the type of the
# mysql.slave_relay_log_info to Innodb.
#
if ($commands == 'configure')
{
  --sync_slave_with_master
  --source include/stop_slave.inc
  SHOW CREATE TABLE mysql.slave_relay_log_info;
  SHOW CREATE TABLE mysql.slave_worker_info;
  ALTER TABLE mysql.slave_relay_log_info ENGINE= Innodb;
  ALTER TABLE mysql.slave_worker_info ENGINE= Innodb;
  SHOW CREATE TABLE mysql.slave_relay_log_info;
  SHOW CREATE TABLE mysql.slave_worker_info;
  --source include/start_slave.inc

  connection master;
  --source extra/rpl_tests/rpl_mixing_engines.inc

  --sync_slave_with_master
  connection master;
  --let $commands=
}

#
# Cleans the test case by deleting all tables, triggers, procedures and
# functions that were created.
#
if ($commands == 'clean')
{
  connection master;
  --source extra/rpl_tests/rpl_mixing_engines.inc
  --let $commands=
}

#
# Executes the set of commands defined in $command by calling
# rpl_mixing_engines.inc
#
if ($commands != '')
{
  # 
  # If an fault injection point was defined, stop the SQL THREAD and
  # prepare the slave to be restarted. Otherwise, do nothing.
  #
  if ($failure != '')
  {
    connection slave;
    STOP REPLICA SQL_THREAD;
    source include/wait_for_slave_sql_to_stop.inc;
    --eval SET GLOBAL debug="$failure";
    --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
  }

  #
  # Prints the expected outcome after the recovery. Check the
  # WL#4801 for further details.
  #
  connection master;
  if ($failure != '')
  {
    --let $outcome= O2
    if ($failure != 'd,crash_after_commit_and_update_pos')
    {
      if ($failure != 'd,crash_after_apply')
      {
        if ($failure != 'd,crash_after_commit_before_update_pos')
        {
          --let $outcome= O1
        }
      }
    }
    --echo FAILURE $failure and OUTCOME $outcome
  }

  #
  # Executes the set of commands defined in $command by calling
  # rpl_mixing_engines.inc
  #
  connection master;
  let $master_before= query_get_value(SHOW MASTER STATUS, Position, 1);
  --source extra/rpl_tests/rpl_mixing_engines.inc
  let $master_after= query_get_value(SHOW MASTER STATUS, Position, 1);

  #
  # Restarts the SQL THREAD and waits for the SLAVE to be crashed and
  # re-started.
  #
  connection master;
  if ($failure != '')
  {
    connection slave;
    --error 0, 2013
    START REPLICA SQL_THREAD;
    --source include/wait_until_disconnected.inc
    --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
    --let $rpl_server_number= 2
    --source include/rpl_reconnect.inc
    connection slave;
    --let $slave_before= `SELECT master_log_pos FROM mysql.slave_relay_log_info`
    START REPLICA;
    source include/wait_for_slave_to_start.inc;
  }

  #
  # Syncs the slave with the master and checks if the slaves applied all
  # changes from the master and is not out of sync.
  #
  connection master;
  sync_slave_with_master;

  --let $slave_after= `SELECT master_log_pos FROM mysql.slave_relay_log_info`
  if ($slave_after != $master_after)
  {
    --echo Slave is out of sync.
    --echo MASTER_BEFORE $master_before MASTER_AFTER $master_after SLAVE_BEFORE $slave_before SLAVE_AFTER $slave_after
    connection slave;
    --source include/show_rpl_debug_info.inc
    --die
  }
}

connection master;