Debian Codegraph @

mysql-test/suite/innodb_undo/t/undo_tablespace_win.test

raw
1 --echo #
2 --echo # InnoDB supports CREATE/ALTER/DROP UNDO TABLESPACE
3 --echo #
4
5 --source include/windows.inc
6 --source include/have_innodb_default_undo_tablespaces.inc
7
8 # Do a slow shutdown and restart to clear out the undo logs
9 SET GLOBAL innodb_fast_shutdown = 0;
10 --let $shutdown_server_timeout = 300
11 --source include/restart_mysqld.inc
12
13 --echo #
14 --echo # Try CREATE UNDO TABLESPACE commands that respond differently on Windows
15 --echo #
16 --echo # Cannot embed a newline character into windows file name
17 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
18 --error ER_CREATE_FILEGROUP_FAILED
19 CREATE UNDO TABLESPACE undo_99 ADD DATAFILE 'undo_\n_99.ibu';
20 --replace_result \\ /
21 SHOW WARNINGS;
22
23 --echo # Cannot embed a CR character into windows file name
24 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
25 --error ER_CREATE_FILEGROUP_FAILED
26 CREATE UNDO TABLESPACE undo_99 ADD DATAFILE 'undo_\r_99.ibu';
27 --replace_result \\ /
28 SHOW WARNINGS;
29
30 --echo # Cannot embed a tab character into a windows file name
31 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
32 --error ER_CREATE_FILEGROUP_FAILED
33 CREATE UNDO TABLESPACE undo_99 ADD DATAFILE 'undo_\t_99.ibu';
34 --replace_result \\ /
35 SHOW WARNINGS;
36
37 --echo #
38 --echo # Cleanup
39 --echo #
40
41 --disable_query_log
42 call mtr.add_suppression("\\[ERROR\\] .* File .*undo.*");
43 call mtr.add_suppression("\\[ERROR\\] .* Operating system error number 123 in a file operation");
44 call mtr.add_suppression("\\[ERROR\\] .* Can't create UNDO tablespace undo_99");
45 --enable_query_log
46
47 --echo #
48 --echo # InnoDB Test UNDO Tablespace truncation on Windows while the tablespace
49 --echo # file is externally opened with and without FILE_SHARE_DELETE flag.
50 --echo #
51
52 let $MYSQLD_DATADIR= `select @@datadir`;
53
54 let $lock_perl_script = $MYSQL_TMP_DIR\lock_tablespace.perl;
55
56 write_file $lock_perl_script;
57 use Win32API::File 0.08 qw( :ALL );
58 my $path = $ARGV[0];
59 my $share = $ARGV[1];
60
61 my $hFile = createFile($path, "re", $share) or die "Can't open $path file";
62
63 sleep(10);
64
65 CloseHandle($hFile);
66 EOF
67
68 CREATE TABLE t1 (id INT) ENGINE=InnoDB;
69 CREATE UNDO TABLESPACE undo_003 ADD DATAFILE 'undo_003.ibu';
70
71 # Test without FILE_SHARE_DELETE flag
72 --exec_in_background perl $lock_perl_script "$MYSQLD_DATADIR\\undo_003.ibu" "rw"
73 let $n=10;
74 begin;
75 while ($n > 0)
76 {
77 --error 0,1533
78 ALTER UNDO TABLESPACE undo_003 SET INACTIVE;
79 # We can't have the include/wait_until_undo_space_is_empty.inc here, as it
80 # requires the SET INACTIVE to succeed, while it should fail.
81 --sleep 1
82 # A write ensures the purge is executed and the tablespace truncation is
83 # re-attempted.
84 INSERT INTO t1 VALUES (1);
85 --error 0,1533
86 ALTER UNDO TABLESPACE undo_003 SET ACTIVE;
87 dec $n;
88 }
89 # Wait for the perl script's 10s sleep to finish.
90 --sleep 5
91 # Now the truncation and deletion should work just fine.
92 ALTER UNDO TABLESPACE undo_003 SET INACTIVE;
93 let $inactive_undo_space = undo_003;
94 source include/wait_until_undo_space_is_empty.inc;
95 ALTER UNDO TABLESPACE undo_003 SET ACTIVE;
96
97 # Test with FILE_SHARE_DELETE flag
98 --exec_in_background perl $lock_perl_script "$MYSQLD_DATADIR\\undo_003.ibu" "rwd"
99 let $n=10;
100 begin;
101 while ($n > 0)
102 {
103 # Alter should succeed, the file should be renamed and all operations work as
104 # intended.
105 ALTER UNDO TABLESPACE undo_003 SET INACTIVE;
106 # We can't have the include/wait_until_undo_space_is_empty.inc here, as it
107 # requires the SET INACTIVE to succeed, while it should fail.
108 --sleep 1
109 # A write ensures the purge is executed and the tablespace truncation is
110 # re-attempted.
111 INSERT INTO t1 VALUES (1);
112 ALTER UNDO TABLESPACE undo_003 SET ACTIVE;
113 dec $n;
114 }
115 # Wait for the perl script's 10s sleep to finish.
116 --sleep 5
117 # Now the truncation and deletion should work just fine.
118 ALTER UNDO TABLESPACE undo_003 SET INACTIVE;
119 let $inactive_undo_space = undo_003;
120 source include/wait_until_undo_space_is_empty.inc;
121 DROP UNDO TABLESPACE undo_003;
122
123 DROP TABLE t1;
124 --remove_file $lock_perl_script
125
126 --disable_query_log
127 call mtr.add_suppression("\\[ERROR\\] .*MY-\\d+.* \\[InnoDB\\] Operating system error number 32 in a file operation");
128 call mtr.add_suppression("\\[ERROR\\] .*MY-\\d+.* \\[InnoDB\\] Operating system error number 80 in a file operation");
129 call mtr.add_suppression("\\[ERROR\\] .*MY-\\d+.* \\[InnoDB\\] The error means that another program is using InnoDB's files.");
130 call mtr.add_suppression("\\[ERROR\\] .*MY-\\d+.* \\[InnoDB\\] Cannot create file '\..undo_003.ibu'");
131 call mtr.add_suppression("\\[ERROR\\] .*MY-\\d+.* \\[InnoDB\\] The file '\..undo_003.ibu' already exists though the corresponding table did not exist.");
132 call mtr.add_suppression("\\[Warning\\] .*MY-\\d+.* \\[InnoDB\\] Failed to delete file '\..undo_003.ibu'. Please check if any other process is using it.");
133 call mtr.add_suppression("\\[Warning\\] .*MY-\\d+.* \\[InnoDB\\] Failed to truncate undo tablespace 'undo_003'");
134 --enable_query_log