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.

66 lines
2.1 KiB

  1. --source include/have_innodb.inc
  2. --source include/have_debug.inc
  3. --source include/have_debug_sync.inc
  4. --source include/have_binlog_format_row.inc
  5. # Valgrind does not work well with test that crashes the server
  6. --source include/not_valgrind.inc
  7. # (We do not need to restore these settings, as we crash the server).
  8. SET GLOBAL max_binlog_size= 4096;
  9. SET GLOBAL innodb_flush_log_at_trx_commit= 1;
  10. RESET MASTER;
  11. CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb;
  12. # One connection does an insert that causes a binlog rotate.
  13. # The rotate is paused after writing new file but before updating index.
  14. connect(con1,localhost,root,,);
  15. SET DEBUG_SYNC= "binlog_open_before_update_index SIGNAL con1_ready WAIT_FOR con1_cont";
  16. SET SESSION debug_dbug="+d,crash_create_critical_before_update_index";
  17. send INSERT INTO t1 VALUES (1, REPEAT("x", 4100));
  18. connection default;
  19. SET DEBUG_SYNC= "now WAIT_FOR con1_ready";
  20. # Another connection creates a prepared transaction.
  21. # After the transaction is prepared, it will hang waiting for LOCK_log.
  22. connect(con2,localhost,root,,);
  23. SET DEBUG_SYNC= "ha_commit_trans_after_prepare SIGNAL con2_ready";
  24. send INSERT INTO t1 VALUES (2, NULL);
  25. connection default;
  26. SET DEBUG_SYNC= "now WAIT_FOR con2_ready";
  27. # Now crash the server in con1, with old binlog closed, new binlog not yet in
  28. # index, and one transaction in prepared-but-not-committed state.
  29. --write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
  30. wait-binlog_mdev342.test
  31. EOF
  32. # If con1 manages to race ahead and crash, we can see the crash already in the
  33. # SET DEBUG_SYNC statement, so need --error here also.
  34. --error 0,2006,2013
  35. SET DEBUG_SYNC= "now SIGNAL con1_cont";
  36. connection con1;
  37. --error 2006,2013
  38. reap;
  39. --remove_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
  40. --write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
  41. restart-binlog_mdev342.test
  42. EOF
  43. connection default;
  44. --enable_reconnect
  45. --source include/wait_until_connected_again.inc
  46. # Check that all transactions are recovered.
  47. SELECT a FROM t1 ORDER BY a;
  48. --source include/show_binary_logs.inc
  49. --let $binlog_file= master-bin.000001
  50. --let $binlog_start= 4
  51. --source include/show_binlog_events.inc
  52. # Cleanup
  53. connection default;
  54. DROP TABLE t1;