File: kill_bomb.test

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 (88 lines) | stat: -rw-r--r-- 2,962 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
# This test tries to shutdown the server in different ways and remove the
# datadir right away to check if the process is fully closed.
 
--let ORIG=$MYSQL_TMP_DIR/datadir_orig
--let WORK_COPY=$MYSQL_TMP_DIR/datadir_work
--let MYSQLD_DATADIR=`select @@datadir`

CREATE TABLE t3 (a INT PRIMARY KEY);

SET GLOBAL innodb_fast_shutdown = 0;
--source include/shutdown_mysqld.inc
--source include/wait_until_disconnected.inc

--let $restart_parameters = "restart: --datadir=$WORK_COPY"
--force-cpdir $MYSQLD_DATADIR $ORIG
--force-cpdir $ORIG $WORK_COPY

--replace_result $WORK_COPY WORK_COPY
--source include/start_mysqld.inc

# We test three .inc scripts that are used to kill the server.
# They are `stop_mysqld.inc`, `kill_mysqld.inc` and
# `kill_and_restart_mysqld.inc`.
--let $script = 1
while($script <= 3){
  # We test two scenarios of deleting the files. One is trying to first delete
  # some files that we know were opened and modified. Second just tries to
  # delete the whole dir in one operation as soon as possible.
  --let $scenario = 1
  while($scenario <= 2){
    --echo ### Executing scenario $scenario, script $script
    
    # We drop and recreate the table to force the `mysql.ibd` file to be opened
    # and modified. This should additionally trigger dblwr files to be used.
    DROP TABLE t3;
    CREATE TABLE t3 (a INT PRIMARY KEY);
    # Insert some data so the undo log is being written to also.
    INSERT INTO t3 VALUES (1), (4) ,(5);

    # The reason for adding these SELECTs is forgotten. But they increase the
    # failure rate twice.
    --disable_result_log
    SELECT * FROM INFORMATION_SCHEMA.FILES;
    SELECT * FROM INFORMATION_SCHEMA.INNODB_TABLESPACES;
    --enable_result_log
    if ($script == 1) {
      --source include/stop_mysqld.inc
    }
    if ($script == 2) {
      --source include/kill_mysqld.inc
    }
    if ($script == 3) {
      --replace_result $WORK_COPY WORK_COPY
      --source include/kill_and_restart_mysqld.inc
    }
    # The third script is starting the server immediatelly for us. We don't have
    # to do anything, we don't test the files removal. In case the previous
    # process did not fully die, the new one started right away could get some
    # sharing violation errors.
    if ($script != 3) {
      if ($scenario == 1) {
        --remove_file $WORK_COPY/mysql.ibd
        --remove_file $WORK_COPY/#ib_16384_0.dblwr
        --remove_file $WORK_COPY/undo_001
      }
      # Remove the workdir as soon as possible, and recreate it from backup.
      # If the server is not fully dead by now, this will report an error.
      --force-rmdir $WORK_COPY
      --force-cpdir $ORIG $WORK_COPY

      --replace_result $WORK_COPY WORK_COPY
      --source include/start_mysqld.inc
   }

    --inc $scenario
  }
  --inc $script
}

# Cleanup

--let $restart_parameters = "restart:"
--source include/kill_and_restart_mysqld.inc

# Cleanup
--force-rmdir $WORK_COPY
--force-rmdir $ORIG
DROP TABLE t3;