Commit a06da5c8 authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-12258 InnoDB: Fix the bogus debug assertion introduced in MDEV-12219

After a partial rollback, an undo log segment that is empty
may carry a duplicate-looking top_undo_no.

Adjust the debug assertions and add a test.
parent 6c5cfbbf
CREATE TABLE t1 (i INT) ENGINE=InnoDB;
CREATE TABLE t2 (i INT) ENGINE=InnoDB;
CREATE OR REPLACE TRIGGER tr1
AFTER UPDATE ON t2
FOR EACH ROW
INSERT INTO tlog (i) VALUES (1);
INSERT IGNORE INTO t2 VALUES (1);
CREATE TRIGGER IF NOT EXISTS tr2
BEFORE INSERT ON t2
FOR EACH ROW
INSERT INTO tlog (i) VALUES (2);
START TRANSACTION;
INSERT INTO t1 VALUES (1);
UPDATE t2 SET i = 3;
ERROR 42S02: Table 'test.tlog' doesn't exist
INSERT INTO t1 VALUES (2);
INSERT INTO t2 VALUES (4);
ERROR 42S02: Table 'test.tlog' doesn't exist
UPDATE t1 SET i = 4 LIMIT 1;
COMMIT;
SELECT * FROM t1;
i
4
2
SELECT * FROM t2;
i
1
DROP TABLE t1,t2;
--source include/have_innodb.inc
CREATE TABLE t1 (i INT) ENGINE=InnoDB;
CREATE TABLE t2 (i INT) ENGINE=InnoDB;
CREATE OR REPLACE TRIGGER tr1
AFTER UPDATE ON t2
FOR EACH ROW
INSERT INTO tlog (i) VALUES (1);
INSERT IGNORE INTO t2 VALUES (1);
CREATE TRIGGER IF NOT EXISTS tr2
BEFORE INSERT ON t2
FOR EACH ROW
INSERT INTO tlog (i) VALUES (2);
START TRANSACTION;
INSERT INTO t1 VALUES (1);
--error ER_NO_SUCH_TABLE
UPDATE t2 SET i = 3;
INSERT INTO t1 VALUES (2);
--error ER_NO_SUCH_TABLE
INSERT INTO t2 VALUES (4);
UPDATE t1 SET i = 4 LIMIT 1;
COMMIT;
SELECT * FROM t1;
SELECT * FROM t2;
DROP TABLE t1,t2;
...@@ -2005,10 +2005,9 @@ trx_undo_report_row_operation( ...@@ -2005,10 +2005,9 @@ trx_undo_report_row_operation(
undo->empty = FALSE; undo->empty = FALSE;
undo->top_page_no = page_no; undo->top_page_no = page_no;
undo->top_offset = offset; undo->top_offset = offset;
undo->top_undo_no = trx->undo_no; undo->top_undo_no = trx->undo_no++;
undo->guess_block = undo_block; undo->guess_block = undo_block;
trx->undo_no++;
trx->undo_rseg_space = rseg->space; trx->undo_rseg_space = rseg->space;
mutex_exit(&trx->undo_mutex); mutex_exit(&trx->undo_mutex);
......
...@@ -990,11 +990,11 @@ trx_roll_pop_top_rec_of_trx(trx_t* trx, roll_ptr_t* roll_ptr, mem_heap_t* heap) ...@@ -990,11 +990,11 @@ trx_roll_pop_top_rec_of_trx(trx_t* trx, roll_ptr_t* roll_ptr, mem_heap_t* heap)
trx_undo_t* temp = trx->rsegs.m_noredo.undo; trx_undo_t* temp = trx->rsegs.m_noredo.undo;
const undo_no_t limit = trx->roll_limit; const undo_no_t limit = trx->roll_limit;
ut_ad(!insert || !update || !insert->top_undo_no ut_ad(!insert || !update || insert->empty || update->empty
|| insert->top_undo_no != update->top_undo_no); || insert->top_undo_no != update->top_undo_no);
ut_ad(!insert || !temp || !insert->top_undo_no ut_ad(!insert || !temp || insert->empty || temp->empty
|| insert->top_undo_no != temp->top_undo_no); || insert->top_undo_no != temp->top_undo_no);
ut_ad(!update || !temp || !update->top_undo_no ut_ad(!update || !temp || update->empty || temp->empty
|| update->top_undo_no != temp->top_undo_no); || update->top_undo_no != temp->top_undo_no);
if (insert && !insert->empty && limit <= insert->top_undo_no) { if (insert && !insert->empty && limit <= insert->top_undo_no) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment