1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

MDEV-22255 SIGABRT: Assertion id' failed in trx_write_trx_id on INSERT | Assertion id > 0' failed in trx_write_trx_id | Assertion val > 0' failed in row_upd_index_entry_sys_field | Assertion thr_get_trx(thr)->id || index->table->no_rollback()' failed.

This commit is contained in:
Eugene Kosov
2021-03-31 16:36:36 +03:00
parent 7fa12b1e34
commit a3871cd283
10 changed files with 212 additions and 12 deletions

View File

@ -663,3 +663,94 @@ DROP TABLE t1;
END// END//
call t1_proc; call t1_proc;
drop procedure t1_proc; drop procedure t1_proc;
CREATE TABLE t (c INT) ENGINE=InnoDB;
INSERT INTO t VALUES(0);
CREATE TEMPORARY TABLE t2 (c INT) ENGINE=InnoDB;
START TRANSACTION READ ONLY;
INSERT INTO t2 SELECT * FROM t;
COMMIT;
DROP TABLE t, t2;
CREATE TEMPORARY TABLE t (c INT,c2 INT) ENGINE=InnoDB;
START TRANSACTION READ ONLY;
INSERT INTO t VALUES(0);
ERROR 21S01: Column count doesn't match value count at row 1
SAVEPOINT s;
INSERT INTO t VALUES(0,0);
COMMIT;
DROP TABLE t;
CREATE TEMPORARY TABLE t (c INT,c2 INT) ENGINE=InnoDB;
START TRANSACTION READ ONLY;
INSERT INTO t VALUES(0);
ERROR 21S01: Column count doesn't match value count at row 1
SAVEPOINT s;
INSERT INTO t VALUES(0,0);
ROLLBACK;
DROP TABLE t;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
START TRANSACTION READ ONLY;
UPDATE t1 SET a= 2;
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE t(c INT) ENGINE=InnoDB;
SET SESSION tx_read_only=TRUE;
LOCK TABLE test.t READ;
SELECT * FROM t;
c
INSERT INTO t VALUES(0xADC3);
SET SESSION tx_read_only=FALSE;
DROP TABLE t;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
START TRANSACTION READ ONLY;
UPDATE t1 SET a= 2;
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY, b int) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, 1);
START TRANSACTION READ ONLY;
UPDATE t1 SET b= 2;
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY, b int, c varchar(255)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, 1, repeat('a', 200));
START TRANSACTION READ ONLY;
UPDATE t1 SET b= 2, c=repeat('a', 250);
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
START TRANSACTION READ ONLY;
UPDATE t1 SET a= 2;
ROLLBACK;
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
START TRANSACTION READ ONLY;
DELETE FROM t1 WHERE a= 2;
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE tmp (a INT) ENGINE=InnoDB;
INSERT INTO tmp () VALUES (),();
SET TX_READ_ONLY= 1;
INSERT INTO tmp SELECT * FROM tmp;
SET TX_READ_ONLY= 0;
DROP TABLE tmp;
SET sql_mode='';
SET GLOBAL tx_read_only=TRUE;
CREATE TEMPORARY TABLE t (c INT);
SET SESSION tx_read_only=DEFAULT;
INSERT INTO t VALUES(1);
INSERT INTO t SELECT * FROM t;
SET SESSION tx_read_only=FALSE;
SET GLOBAL tx_read_only=OFF;
DROP TABLE t;
CREATE TEMPORARY TABLE t(a INT);
SET SESSION tx_read_only=ON;
LOCK TABLE t READ;
SELECT COUNT(*)FROM t;
COUNT(*)
0
INSERT INTO t VALUES (0);
SET SESSION tx_read_only=OFF;
DROP TABLE t;

View File

@ -493,3 +493,105 @@ delimiter ;//
call t1_proc; call t1_proc;
drop procedure t1_proc; drop procedure t1_proc;
CREATE TABLE t (c INT) ENGINE=InnoDB;
INSERT INTO t VALUES(0);
CREATE TEMPORARY TABLE t2 (c INT) ENGINE=InnoDB;
START TRANSACTION READ ONLY;
INSERT INTO t2 SELECT * FROM t;
COMMIT;
DROP TABLE t, t2;
CREATE TEMPORARY TABLE t (c INT,c2 INT) ENGINE=InnoDB;
START TRANSACTION READ ONLY;
--error ER_WRONG_VALUE_COUNT_ON_ROW
INSERT INTO t VALUES(0);
SAVEPOINT s;
INSERT INTO t VALUES(0,0);
COMMIT;
DROP TABLE t;
CREATE TEMPORARY TABLE t (c INT,c2 INT) ENGINE=InnoDB;
START TRANSACTION READ ONLY;
--error ER_WRONG_VALUE_COUNT_ON_ROW
INSERT INTO t VALUES(0);
SAVEPOINT s;
INSERT INTO t VALUES(0,0);
ROLLBACK;
DROP TABLE t;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
START TRANSACTION READ ONLY;
UPDATE t1 SET a= 2;
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE t(c INT) ENGINE=InnoDB;
SET SESSION tx_read_only=TRUE;
LOCK TABLE test.t READ;
SELECT * FROM t;
INSERT INTO t VALUES(0xADC3);
SET SESSION tx_read_only=FALSE;
DROP TABLE t;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
START TRANSACTION READ ONLY;
UPDATE t1 SET a= 2;
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY, b int) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, 1);
START TRANSACTION READ ONLY;
UPDATE t1 SET b= 2;
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY, b int, c varchar(255)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, 1, repeat('a', 200));
START TRANSACTION READ ONLY;
UPDATE t1 SET b= 2, c=repeat('a', 250);
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
START TRANSACTION READ ONLY;
UPDATE t1 SET a= 2;
ROLLBACK;
DROP TABLE t1;
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
START TRANSACTION READ ONLY;
DELETE FROM t1 WHERE a= 2;
COMMIT;
DROP TABLE t1;
CREATE TEMPORARY TABLE tmp (a INT) ENGINE=InnoDB;
INSERT INTO tmp () VALUES (),();
SET TX_READ_ONLY= 1;
INSERT INTO tmp SELECT * FROM tmp;
SET TX_READ_ONLY= 0;
DROP TABLE tmp;
SET sql_mode='';
SET GLOBAL tx_read_only=TRUE;
CREATE TEMPORARY TABLE t (c INT);
SET SESSION tx_read_only=DEFAULT;
INSERT INTO t VALUES(1);
INSERT INTO t SELECT * FROM t;
SET SESSION tx_read_only=FALSE;
SET GLOBAL tx_read_only=OFF;
DROP TABLE t;
CREATE TEMPORARY TABLE t(a INT);
SET SESSION tx_read_only=ON;
LOCK TABLE t READ;
SELECT COUNT(*)FROM t;
INSERT INTO t VALUES (0);
SET SESSION tx_read_only=OFF;
DROP TABLE t;

View File

@ -3242,7 +3242,8 @@ fail_err:
ut_ad(thr->graph->trx->id ut_ad(thr->graph->trx->id
== trx_read_trx_id( == trx_read_trx_id(
static_cast<const byte*>( static_cast<const byte*>(
trx_id->data))); trx_id->data))
|| index->table->is_temporary());
} }
} }
#endif #endif
@ -3844,7 +3845,8 @@ btr_cur_update_in_place(
index = cursor->index; index = cursor->index;
ut_ad(rec_offs_validate(rec, index, offsets)); ut_ad(rec_offs_validate(rec, index, offsets));
ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table)); ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table));
ut_ad(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG)); ut_ad(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG)
|| index->table->is_temporary());
/* The insert buffer tree should never be updated in place. */ /* The insert buffer tree should never be updated in place. */
ut_ad(!dict_index_is_ibuf(index)); ut_ad(!dict_index_is_ibuf(index));
ut_ad(dict_index_is_online_ddl(index) == !!(flags & BTR_CREATE_FLAG) ut_ad(dict_index_is_online_ddl(index) == !!(flags & BTR_CREATE_FLAG)
@ -4017,7 +4019,8 @@ btr_cur_optimistic_update(
page = buf_block_get_frame(block); page = buf_block_get_frame(block);
rec = btr_cur_get_rec(cursor); rec = btr_cur_get_rec(cursor);
index = cursor->index; index = cursor->index;
ut_ad(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG)); ut_ad(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG)
|| index->table->is_temporary());
ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table)); ut_ad(!!page_rec_is_comp(rec) == dict_table_is_comp(index->table));
ut_ad(mtr_is_block_fix(mtr, block, MTR_MEMO_PAGE_X_FIX, index->table)); ut_ad(mtr_is_block_fix(mtr, block, MTR_MEMO_PAGE_X_FIX, index->table));
/* This is intended only for leaf page updates */ /* This is intended only for leaf page updates */
@ -4354,8 +4357,8 @@ btr_cur_pessimistic_update(
ut_ad(!page_zip || !dict_table_is_temporary(index->table)); ut_ad(!page_zip || !dict_table_is_temporary(index->table));
/* The insert buffer tree should never be updated in place. */ /* The insert buffer tree should never be updated in place. */
ut_ad(!dict_index_is_ibuf(index)); ut_ad(!dict_index_is_ibuf(index));
ut_ad(trx_id > 0 ut_ad(trx_id > 0 || (flags & BTR_KEEP_SYS_FLAG)
|| (flags & BTR_KEEP_SYS_FLAG)); || index->table->is_temporary());
ut_ad(dict_index_is_online_ddl(index) == !!(flags & BTR_CREATE_FLAG) ut_ad(dict_index_is_online_ddl(index) == !!(flags & BTR_CREATE_FLAG)
|| dict_index_is_clust(index)); || dict_index_is_clust(index));
ut_ad(thr_get_trx(thr)->id == trx_id ut_ad(thr_get_trx(thr)->id == trx_id

View File

@ -185,7 +185,6 @@ trx_write_trx_id(
#if DATA_TRX_ID_LEN != 6 #if DATA_TRX_ID_LEN != 6
# error "DATA_TRX_ID_LEN != 6" # error "DATA_TRX_ID_LEN != 6"
#endif #endif
ut_ad(id > 0);
mach_write_to_6(ptr, id); mach_write_to_6(ptr, id);
} }

View File

@ -1219,6 +1219,7 @@ pars_update_statement(
sel_node->row_lock_mode = LOCK_X; sel_node->row_lock_mode = LOCK_X;
} else { } else {
node->has_clust_rec_x_lock = sel_node->set_x_locks; node->has_clust_rec_x_lock = sel_node->set_x_locks;
ut_ad(node->has_clust_rec_x_lock);
} }
ut_a(sel_node->n_tables == 1); ut_a(sel_node->n_tables == 1);

View File

@ -3250,7 +3250,7 @@ row_ins_index_entry(
dtuple_t* entry, /*!< in/out: index entry to insert */ dtuple_t* entry, /*!< in/out: index entry to insert */
que_thr_t* thr) /*!< in: query thread */ que_thr_t* thr) /*!< in: query thread */
{ {
ut_ad(thr_get_trx(thr)->id != 0); ut_ad(thr_get_trx(thr)->id != 0 || index->table->is_temporary());
DBUG_EXECUTE_IF("row_ins_index_entry_timeout", { DBUG_EXECUTE_IF("row_ins_index_entry_timeout", {
DBUG_SET("-d,row_ins_index_entry_timeout"); DBUG_SET("-d,row_ins_index_entry_timeout");
@ -3613,12 +3613,16 @@ row_ins_step(
table during the search operation, and there is no need to set table during the search operation, and there is no need to set
it again here. But we must write trx->id to node->sys_buf. */ it again here. But we must write trx->id to node->sys_buf. */
trx_write_trx_id(&node->sys_buf[DATA_ROW_ID_LEN], trx->id); trx_write_trx_id(&node->sys_buf[DATA_TRX_ID_LEN], trx->id);
if (node->state == INS_NODE_SET_IX_LOCK) { if (node->state == INS_NODE_SET_IX_LOCK) {
node->state = INS_NODE_ALLOC_ROW_ID; node->state = INS_NODE_ALLOC_ROW_ID;
if (node->table->is_temporary()) {
node->trx_id = trx->id;
}
/* It may be that the current session has not yet started /* It may be that the current session has not yet started
its transaction, or it has been committed: */ its transaction, or it has been committed: */

View File

@ -106,7 +106,7 @@ row_undo_ins_remove_clust_rec(
btr_cur = btr_pcur_get_btr_cur(&node->pcur); btr_cur = btr_pcur_get_btr_cur(&node->pcur);
ut_ad(rec_get_trx_id(btr_cur_get_rec(btr_cur), btr_cur->index) ut_ad(rec_get_trx_id(btr_cur_get_rec(btr_cur), btr_cur->index)
== node->trx->id); == node->trx->id || node->table->is_temporary());
ut_ad(!rec_get_deleted_flag( ut_ad(!rec_get_deleted_flag(
btr_cur_get_rec(btr_cur), btr_cur_get_rec(btr_cur),
dict_table_is_comp(btr_cur->index->table))); dict_table_is_comp(btr_cur->index->table)));

View File

@ -109,7 +109,7 @@ row_undo_mod_clust_low(
ut_ad(success); ut_ad(success);
ut_ad(rec_get_trx_id(btr_cur_get_rec(btr_cur), ut_ad(rec_get_trx_id(btr_cur_get_rec(btr_cur),
btr_cur_get_index(btr_cur)) btr_cur_get_index(btr_cur))
== thr_get_trx(thr)->id); == thr_get_trx(thr)->id || node->index->table->is_temporary());
if (mode != BTR_MODIFY_LEAF if (mode != BTR_MODIFY_LEAF
&& dict_index_is_online_ddl(btr_cur_get_index(btr_cur))) { && dict_index_is_online_ddl(btr_cur_get_index(btr_cur))) {

View File

@ -194,7 +194,7 @@ row_undo_search_clust_to_pcur(
if (found) { if (found) {
ut_ad(row_get_rec_trx_id(rec, clust_index, offsets) ut_ad(row_get_rec_trx_id(rec, clust_index, offsets)
== node->trx->id); == node->trx->id || node->table->is_temporary());
if (dict_table_get_format(node->table) >= UNIV_FORMAT_B) { if (dict_table_get_format(node->table) >= UNIV_FORMAT_B) {
/* In DYNAMIC or COMPRESSED format, there is /* In DYNAMIC or COMPRESSED format, there is

View File

@ -549,7 +549,7 @@ row_upd_index_entry_sys_field(
field = static_cast<byte*>(dfield_get_data(dfield)); field = static_cast<byte*>(dfield_get_data(dfield));
if (type == DATA_TRX_ID) { if (type == DATA_TRX_ID) {
ut_ad(val > 0); ut_ad(val > 0 || index->table->is_temporary());
trx_write_trx_id(field, val); trx_write_trx_id(field, val);
} else { } else {
ut_ad(type == DATA_ROLL_PTR); ut_ad(type == DATA_ROLL_PTR);