|
| 1 | +# suite/ddl/include/load_tsof_data.inc |
| 2 | +# |
| 3 | + |
| 4 | +# $when_taken must sit right |
| 5 | + |
| 6 | +--enable_abort_on_error |
| 7 | + |
| 8 | +--disable_query_log |
| 9 | +if($script_debug) |
| 10 | +{ |
| 11 | + --enable_query_log |
| 12 | +} |
| 13 | + |
| 14 | +# Add the new state to the bookkeeping files |
| 15 | + |
| 16 | +# Result of SELECT MD5(...) |
| 17 | +# ------------------------- |
| 18 | +# SELECT MD5(NULL) : NULL |
| 19 | +# SELECT MD5('') : d41d8cd98f00b204e9800998ecf8427e |
| 20 | +# SELECT MD5(LOAD_FILE(<file>)) variations |
| 21 | +# secure_file_priv sits right |
| 22 | +# - file is readable by all and zero bytes |
| 23 | +# long : d41d8cd98f00b204e9800998ecf8427e |
| 24 | +# - file is not readable by all : NULL |
| 25 | +# Observed under Linux where some additional tablespaces.open.4 was created |
| 26 | +# by InnoDB with "-rw-rw----" whereas the already existing were with |
| 27 | +# "-rw-r--r--" from whatever reason (MTR during server setup?). |
| 28 | +# - file does not exist : NULL |
| 29 | +# secure_file_priv sits wrong : NULL (no warning!) |
| 30 | +# So in case we take care that |
| 31 | +# - secure_file_priv sits right |
| 32 | +# - any tablespaces.open.* gets treated with chmod 644 |
| 33 | +# than any NULL implies some not existing tablespaces.open.<number>. |
| 34 | +# |
| 35 | +let $TSOF_DIR= $MYSQLD_DATADIR; |
| 36 | +# if($when_taken == $point_postcrash) |
| 37 | +# { |
| 38 | + # let $TSOF_DIR= $MYSQLTEST_VARDIR/tsof_copies/; |
| 39 | +# } |
| 40 | +let $max_num= 5; |
| 41 | +let $num= 1; |
| 42 | +let $null_reached= 0; |
| 43 | +while ($num <= $max_num) |
| 44 | +{ |
| 45 | + let $tsof_name= tablespaces.open.$num; |
| 46 | + let $tsof_path= $TSOF_DIR$tsof_name; |
| 47 | + |
| 48 | + # Fore debugging the script. |
| 49 | + if ($script_debug) |
| 50 | + { |
| 51 | + --echo $tsof_path |
| 52 | + # 1. The --error 0,1,2 is because the file $tsof_name might not exist. |
| 53 | + # This is to be expected for the higher numbers. |
| 54 | + # 2. The "cd $MYSQLD_DATADIR;" allows to use $tsof_name and that causes |
| 55 | + # that the output is shorter and free of the local box specific |
| 56 | + # setting of $MYSQLD_DATADIR. Just imagine the "ls -ld " output for |
| 57 | + # tablespaces.open.4 |
| 58 | + # versus |
| 59 | + # /work/mysql-trunk/mysql-test/var/mysqld.1/data/tablespaces.open.4 |
| 60 | + # 3. "--exec ....<no ';' at end>" and not "exec ...;" is required because |
| 61 | + # - we have two commands, "cd $TSOF_DIR" and "ls -ld $tsof_name" which |
| 62 | + # need to be separated by a ';' in order to work proper in the OS. |
| 63 | + # - In case of "exec" without a preceding "--" mysqltest assumes that |
| 64 | + # only the line end marks the end of the OS command sequence. |
| 65 | + # Some additional ';' at end would be interpreted as "empty" OS cmd. |
| 66 | + --error 0,1,2 |
| 67 | + --exec cd $TSOF_DIR; ls -ld $tsof_name |
| 68 | + --error 0,1,2,3 |
| 69 | + --exec cd $TSOF_DIR; md5sum $tsof_name |
| 70 | + } |
| 71 | + --error 0,1,2 |
| 72 | + chmod 0644 $tsof_path; |
| 73 | + eval SET @md5_value = MD5(LOAD_FILE('$tsof_path')); |
| 74 | + let $md5_is_null= `SELECT @md5_value IS NULL`; |
| 75 | + if(!$md5_is_null) |
| 76 | + { |
| 77 | + # For testing the current script |
| 78 | + # let $null_reached= 1; |
| 79 | + if ($null_reached) |
| 80 | + { |
| 81 | + # There was a tablespaces_open file with lower number which did not |
| 82 | + # exist. Finding now some existing tablespaces_open file with higher |
| 83 | + # number means that we have a hole in numbering which should not exist |
| 84 | + # at all. |
| 85 | + --echo # ERROR: Hole in the numbering of tablespaces_open files. |
| 86 | + --list_files $TSOF_DIR tablespaces.open.* |
| 87 | + --echo # Abort |
| 88 | + exit; |
| 89 | + } |
| 90 | + # Always store $tsof_name and never $tsof_path. |
| 91 | + # The first is "free" of $MYSQLD_DATADIR which |
| 92 | + # - is testing box specific |
| 93 | + # - increases the length of the string without giving something valuable. |
| 94 | + eval |
| 95 | + INSERT INTO tablespaces_open_content (object, when_taken, md5_value) |
| 96 | + SELECT CONCAT('./', '$tsof_name'), $when_taken, @md5_value; |
| 97 | + } |
| 98 | + if ($md5_is_null) |
| 99 | + { |
| 100 | + # No INSERT because the file $tsof_path did not exist. |
| 101 | + let $null_reached= 1; |
| 102 | + } |
| 103 | + inc $num; |
| 104 | +} |
| 105 | +if (!$md5_is_null) |
| 106 | +{ |
| 107 | + # Being here implies that |
| 108 | + # - there was no abort of the test because of error |
| 109 | + # - $max_num files were looked at |
| 110 | + # - @md5_value belongs to tablespaces.open.<$max_num> |
| 111 | + # In case @md5_value IS NOT NULL than the file tablespaces.open.10 existed, |
| 112 | + # $max_num needs to be increased. |
| 113 | + --echo # ERROR: $the_file with highest number tried exists. |
| 114 | + --echo # collect_tsof_data.inc must be adjusted (increase max_num). |
| 115 | + --echo # Abort |
| 116 | + exit; |
| 117 | +} |
| 118 | + |
| 119 | + |
| 120 | +# For testing the scripts especially the next check. |
| 121 | +if(0) |
| 122 | +{ |
| 123 | + --enable_query_log |
| 124 | + --echo # ! error injection for script debugging ! |
| 125 | + --echo # So some abort of test because of error might show up. |
| 126 | + DELETE FROM tablespaces_open_content; |
| 127 | +} |
| 128 | +if (`SELECT COUNT(*) <> 0 FROM tsof_dropped`) |
| 129 | +{ |
| 130 | + --echo # ERROR: One or more tablespaces.open.* files were dropped. |
| 131 | + SELECT * FROM tsof_dropped ORDER BY object; |
| 132 | + SELECT when_taken, object FROM tablespaces_open_content |
| 133 | + ORDER BY object, when_taken; |
| 134 | + SELECT object FROM tablespaces_open_files |
| 135 | + ORDER BY object; |
| 136 | + --echo # Abort |
| 137 | + exit; |
| 138 | +} |
| 139 | + |
| 140 | +if(`SELECT COUNT(*) <> 0 FROM tsof_added`) |
| 141 | +{ |
| 142 | + # Case: Some additional tablespaces_open file showed up. |
| 143 | + # ------------------------------------------------------ |
| 144 | + # 1. Reset counter2 to 0 for the already known tablespaces_open files. |
| 145 | + # =~ Declare a restart of secondary measurement queue between previous |
| 146 | + # and current collection of data. |
| 147 | + UPDATE tablespaces_open_files SET counter2 = 0; |
| 148 | + # 2. Add the new tablespaces_open files to tablespaces_open_files with |
| 149 | + # counter1 = 1 |
| 150 | + # == Update the first measurement queue because that file was used. |
| 151 | + # counter2 = 1 |
| 152 | + # == The file was used after the restart of the secondary measurement |
| 153 | + # queue. |
| 154 | + INSERT INTO tablespaces_open_files (object, counter1, counter2) |
| 155 | + SELECT object, 1, 1 FROM tsof_added; |
| 156 | +} |
| 157 | + |
| 158 | +if($when_taken == $point_after) |
| 159 | +{ |
| 160 | + # Case: Some tablespaces_open file was changed. |
| 161 | + # --------------------------------------------- |
| 162 | + # Increment counter1 and counter2 for such tablespaces_open files. |
| 163 | + # Charging for : 'before' ==>> 'after' |
| 164 | + UPDATE tablespaces_open_files |
| 165 | + SET counter1 = counter1 + 1, counter2 = counter2 + 1 |
| 166 | + WHERE object IN (SELECT object FROM tablespaces_open_content_diff_a_b |
| 167 | + WHERE state = 'changed'); |
| 168 | +} |
| 169 | + |
| 170 | +--enable_query_log |
| 171 | + |
| 172 | +#### For testing the scripts |
| 173 | +if($script_debug) |
| 174 | +{ |
| 175 | + --echo # INFO: when_taken : $when_taken |
| 176 | + SELECT * FROM tablespaces_open_content ORDER BY object, when_taken; |
| 177 | + SELECT * FROM tablespaces_open_content_diff_a_b ORDER BY state, object; |
| 178 | + SELECT * FROM tablespaces_open_files ORDER BY object; |
| 179 | +} |
| 180 | + |
0 commit comments