You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
4.6 KiB

  1. # This is the test case for bug #53756. Alter table operation could
  2. # leave a deleted record for the temp table (later renamed to the altered
  3. # table) in the SYS_TABLES secondary index, we should ignore this row and
  4. # find the first non-deleted row for the specified table_id when load table
  5. # metadata in the function dict_load_table_on_id() during crash recovery.
  6. #
  7. # innobackup needs to connect to the server. Not supported in embedded.
  8. --source include/not_embedded.inc
  9. #
  10. # This test case needs to crash the server. Needs a debug server.
  11. --source include/have_debug.inc
  12. #
  13. # Don't test this under valgrind, memory leaks will occur.
  14. --source include/not_valgrind.inc
  15. #
  16. # This test case needs InnoDB.
  17. -- source include/have_innodb_plugin.inc
  18. # Avoid CrashReporter popup on Mac
  19. --source include/not_crashrep.inc
  20. #
  21. # Precautionary clean up.
  22. #
  23. --disable_warnings
  24. DROP TABLE IF EXISTS bug_53756 ;
  25. --enable_warnings
  26. #
  27. # Create test data.
  28. #
  29. CREATE TABLE bug_53756 (pk INT, c1 INT) ENGINE=InnoDB;
  30. ALTER TABLE bug_53756 ADD PRIMARY KEY (pk);
  31. INSERT INTO bug_53756 VALUES(1, 11), (2, 22), (3, 33), (4, 44);
  32. --echo
  33. --echo # Select a less restrictive isolation level.
  34. # Don't use user variables. They won't survive server crash.
  35. --let $global_isolation= `SELECT @@global.tx_isolation`
  36. --let $session_isolation= `SELECT @@session.tx_isolation`
  37. SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED;
  38. SET SESSION TRANSACTION ISOLATION LEVEL READ COMMITTED;
  39. COMMIT;
  40. --echo
  41. --echo # Start a transaction in the default connection for isolation.
  42. START TRANSACTION;
  43. SELECT @@tx_isolation;
  44. SELECT * FROM bug_53756;
  45. --echo
  46. --echo # connection con1 deletes row 1
  47. --connect (con1,localhost,root,,)
  48. START TRANSACTION;
  49. SELECT @@tx_isolation;
  50. DELETE FROM bug_53756 WHERE pk=1;
  51. --echo
  52. --echo # connection con2 deletes row 2
  53. --connect (con2,localhost,root,,)
  54. START TRANSACTION;
  55. SELECT @@tx_isolation;
  56. DELETE FROM bug_53756 WHERE pk=2;
  57. --echo
  58. --echo # connection con3 updates row 3
  59. --connect (con3,localhost,root,,)
  60. START TRANSACTION;
  61. SELECT @@tx_isolation;
  62. UPDATE bug_53756 SET c1=77 WHERE pk=3;
  63. --echo
  64. --echo # connection con4 updates row 4
  65. --connect (con4,localhost,root,,)
  66. START TRANSACTION;
  67. SELECT @@tx_isolation;
  68. UPDATE bug_53756 SET c1=88 WHERE pk=4;
  69. --echo
  70. --echo # connection con5 inserts row 5
  71. --connect (con5,localhost,root,,)
  72. START TRANSACTION;
  73. SELECT @@tx_isolation;
  74. INSERT INTO bug_53756 VALUES(5, 55);
  75. --echo
  76. --echo # connection con6 inserts row 6
  77. --connect (con6,localhost,root,,)
  78. START TRANSACTION;
  79. SELECT @@tx_isolation;
  80. INSERT INTO bug_53756 VALUES(6, 66);
  81. --echo
  82. --echo # connection con1 commits.
  83. --connection con1
  84. COMMIT;
  85. --echo
  86. --echo # connection con3 commits.
  87. --connection con3
  88. COMMIT;
  89. --echo
  90. --echo # connection con4 rolls back.
  91. --connection con4
  92. ROLLBACK;
  93. --echo
  94. --echo # connection con6 rolls back.
  95. --connection con6
  96. ROLLBACK;
  97. --echo
  98. --echo # The connections 2 and 5 stay open.
  99. --echo
  100. --echo # connection default selects resulting data.
  101. --echo # Delete of row 1 was committed.
  102. --echo # Update of row 3 was committed.
  103. --echo # Due to isolation level read committed, these should be included.
  104. --echo # All other changes should not be included.
  105. --connection default
  106. SELECT * FROM bug_53756;
  107. --echo
  108. --echo # connection default
  109. --connection default
  110. --echo #
  111. --echo # Crash server.
  112. #
  113. # Write file to make mysql-test-run.pl expect the "crash", but don't start
  114. # it until it's told to
  115. --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
  116. #
  117. START TRANSACTION;
  118. INSERT INTO bug_53756 VALUES (666,666);
  119. #
  120. # Request a crash on next execution of commit.
  121. SET SESSION debug="+d,crash_commit_before";
  122. #
  123. # Write file to make mysql-test-run.pl start up the server again
  124. --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
  125. #
  126. # Execute the statement that causes the crash.
  127. --error 2013
  128. COMMIT;
  129. --echo
  130. --echo #
  131. --echo # disconnect con1, con2, con3, con4, con5, con6.
  132. --disconnect con1
  133. --disconnect con2
  134. --disconnect con3
  135. --disconnect con4
  136. --disconnect con5
  137. --disconnect con6
  138. --echo #
  139. --echo # Restart server.
  140. #
  141. # Turn on reconnect
  142. --enable_reconnect
  143. #
  144. # Call script that will poll the server waiting for it to be back online again
  145. --source include/wait_until_connected_again.inc
  146. #
  147. # Turn off reconnect again
  148. --disable_reconnect
  149. --echo
  150. --echo #
  151. --echo # Select recovered data.
  152. --echo # Delete of row 1 was committed.
  153. --echo # Update of row 3 was committed.
  154. --echo # These should be included.
  155. --echo # All other changes should not be included.
  156. --echo # Delete of row 2 and insert of row 5 should be rolled back
  157. SELECT * FROM bug_53756;
  158. --echo
  159. --echo # Clean up.
  160. DROP TABLE bug_53756;
  161. --disable_query_log
  162. eval SET GLOBAL tx_isolation= '$global_isolation';
  163. eval SET SESSION tx_isolation= '$session_isolation';
  164. --enable_query_log