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.

112 lines
3.7 KiB

MDEV-24035 Failing assertion: UT_LIST_GET_LEN(lock.trx_locks) == 0 causing disruption and replication failure Under unknown circumstances, the SQL layer may wrongly disregard an invocation of thd_mark_transaction_to_rollback() when an InnoDB transaction had been aborted (rolled back) due to one of the following errors: * HA_ERR_LOCK_DEADLOCK * HA_ERR_RECORD_CHANGED (if innodb_snapshot_isolation=ON) * HA_ERR_LOCK_WAIT_TIMEOUT (if innodb_rollback_on_timeout=ON) Such an error used to cause a crash of InnoDB during transaction commit. These changes aim to catch and report the error earlier, so that not only this crash can be avoided but also the original root cause be found and fixed more easily later. The idea of this fix is from Michael 'Monty' Widenius. HA_ERR_ROLLBACK: A new error code that will be translated into ER_ROLLBACK_ONLY, signalling that the current transaction has been aborted and the only allowed action is ROLLBACK. trx_t::state: Add TRX_STATE_ABORTED that is like TRX_STATE_NOT_STARTED, but noting that the transaction had been rolled back and aborted. trx_t::is_started(): Replaces trx_is_started(). ha_innobase: Check the transaction state in various places. Simplify the logic around SAVEPOINT. ha_innobase::is_valid_trx(): Replaces ha_innobase::is_read_only(). The InnoDB logic around transaction savepoints, commit, and rollback was unnecessarily complex and might have contributed to this inconsistency. So, we are simplifying that logic as well. trx_savept_t: Replace with const undo_no_t*. When we rollback to a savepoint, all we need to know is the number of undo log records that must survive. trx_named_savept_t, DB_NO_SAVEPOINT: Remove. We can store undo_no_t directly in the space allocated at innobase_hton->savepoint_offset. fts_trx_create(): Do not copy previous savepoints. fts_savepoint_rollback(): If a savepoint was not found, roll back everything after the default savepoint of fts_trx_create(). The test innodb_fts.savepoint is extended to cover this code. Reviewed by: Vladislav Lesin Tested by: Matthias Leich
12 months ago
  1. source include/have_innodb.inc;
  2. --disable_query_log
  3. call mtr.add_suppression("InnoDB: Transaction was aborted due to ");
  4. --enable_query_log
  5. #
  6. # MDEV-20354 All but last insert ignored in InnoDB tables when table locked
  7. #
  8. rename table mysql.table_stats to mysql.table_stats_save;
  9. flush tables;
  10. set use_stat_tables= PREFERABLY;
  11. create table t1 (a int) engine=InnoDB;
  12. start transaction;
  13. insert t1 values (1);
  14. insert t1 values (2);
  15. commit;
  16. select * from t1;
  17. drop table t1;
  18. rename table mysql.table_stats_save to mysql.table_stats;
  19. flush tables;
  20. --echo #
  21. --echo # MDEV-26753 Assertion state == TRX_STATE_PREPARED ||... failed
  22. --echo #
  23. CREATE TABLE t1(a INT PRIMARY KEY) ENGINE=InnoDB;
  24. XA START 'test';
  25. SELECT COUNT(*)>0 FROM mysql.innodb_index_stats LOCK IN SHARE MODE;
  26. INSERT INTO t1 VALUES (1),(2);
  27. UPDATE mysql.innodb_table_stats SET last_update=NULL WHERE table_name='t1';
  28. XA END 'test';
  29. XA ROLLBACK 'test';
  30. DROP TABLE t1;
  31. --echo #
  32. --echo # MDEV-30483 After upgrade to 10.6 from Mysql 5.7 seeing "InnoDB: Column last_update in table mysql.innodb_table_stats is BINARY(4) NOT NULL but should be INT UNSIGNED NOT NULL"
  33. --echo #
  34. # The following tests demonstrate that these columns:
  35. # - innodb_table_stats.last_update
  36. # - innodb_index_stats.last_update
  37. # have sane values close to NOW(), rather than any garbage,
  38. # with all TIMESTAMP formats.
  39. --echo #
  40. --echo # Testing a non-default format: Field_timestamp0 - UINT4 based
  41. --echo #
  42. SET @@global.mysql56_temporal_format=0;
  43. ALTER TABLE mysql.innodb_table_stats MODIFY last_update TIMESTAMP;
  44. ALTER TABLE mysql.innodb_index_stats MODIFY last_update TIMESTAMP;
  45. SHOW COLUMNS FROM mysql.innodb_table_stats LIKE 'last_update';
  46. SHOW COLUMNS FROM mysql.innodb_index_stats LIKE 'last_update';
  47. CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB STATS_PERSISTENT=1;
  48. SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_table_stats
  49. WHERE database_name='test' AND table_name='t1';
  50. SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_index_stats
  51. WHERE database_name='test' AND table_name='t1' AND stat_name='size';
  52. DROP TABLE t1;
  53. --echo #
  54. --echo # Now as the table t1 is dropped, expect no statistics
  55. --echo #
  56. SELECT * FROM mysql.innodb_table_stats
  57. WHERE database_name='test' AND table_name='t1';
  58. SELECT * FROM mysql.innodb_index_stats
  59. WHERE database_name='test' AND table_name='t1' AND stat_name='size';
  60. --echo #
  61. --echo # Testing with the default format: Field_timestampf - BINARY(4) based with the UNSIGNED_FLAG
  62. --echo #
  63. SET @@global.mysql56_temporal_format=1;
  64. ALTER TABLE mysql.innodb_table_stats MODIFY last_update TIMESTAMP;
  65. ALTER TABLE mysql.innodb_index_stats MODIFY last_update TIMESTAMP;
  66. SHOW COLUMNS FROM mysql.innodb_table_stats LIKE 'last_update';
  67. SHOW COLUMNS FROM mysql.innodb_index_stats LIKE 'last_update';
  68. CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB STATS_PERSISTENT=1;
  69. SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_table_stats
  70. WHERE database_name='test' AND table_name='t1';
  71. SELECT TIMESTAMPDIFF(DAY,last_update,now())<=1 FROM mysql.innodb_index_stats
  72. WHERE database_name='test' AND table_name='t1' AND stat_name='size';
  73. DROP TABLE t1;
  74. --echo #
  75. --echo # MDEV-34207: ALTER TABLE...STATS_PERSISTENT=0 fails to drop statistics
  76. --echo #
  77. CREATE TABLE t1 (c1 INT) ENGINE=InnoDB STATS_PERSISTENT 1;
  78. ALTER TABLE t1 STATS_PERSISTENT 0;
  79. DROP TABLE t1;
  80. SET @save_persistent=@@GLOBAL.innodb_stats_persistent;
  81. SET GLOBAL innodb_stats_persistent=1;
  82. CREATE TABLE t2 (c1 INT) ENGINE=InnoDB;
  83. RENAME TABLE t2 TO t1;
  84. DROP TABLE t1;
  85. SET GLOBAL innodb_stats_persistent=0;
  86. CREATE TABLE t2 (c1 INT) ENGINE=InnoDB STATS_PERSISTENT 1;
  87. RENAME TABLE t2 TO t1;
  88. SET GLOBAL innodb_stats_persistent=@save_persistent;
  89. DROP TABLE t1;
  90. CREATE TABLE t1 (c1 INT) ENGINE=InnoDB STATS_PERSISTENT 1;
  91. DROP TABLE t1;
  92. --echo # End of 10.6 tests