Skip to content
Permalink
Browse files

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

…2219

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.
  • Loading branch information...
dr-m committed Mar 18, 2017
1 parent 6c5cfbb commit a06da5c848e6feeef0b1559e84479890a76c446e
@@ -0,0 +1,28 @@
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;
@@ -0,0 +1,31 @@
--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(
undo->empty = FALSE;
undo->top_page_no = page_no;
undo->top_offset = offset;
undo->top_undo_no = trx->undo_no;
undo->top_undo_no = trx->undo_no++;
undo->guess_block = undo_block;

trx->undo_no++;
trx->undo_rseg_space = rseg->space;

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)
trx_undo_t* temp = trx->rsegs.m_noredo.undo;
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);
ut_ad(!insert || !temp || !insert->top_undo_no
ut_ad(!insert || !temp || insert->empty || temp->empty
|| 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);

if (insert && !insert->empty && limit <= insert->top_undo_no) {

0 comments on commit a06da5c

Please sign in to comment.
You can’t perform that action at this time.