Skip to content

Commit 49e3bd2

Browse files
Daniele SciasciaJan Lindström
authored andcommitted
MDEV-27553 Assertion `inited==INDEX' failed: in ha_index_end()
In wsrep_schema code, call ha_index_end() only if the corresponding ha_index_init() call succeeded. Reviewed-by: Jan Lindström <jan.lindstrom@mariadb.com>
1 parent b915f79 commit 49e3bd2

File tree

4 files changed

+61
-4
lines changed

4 files changed

+61
-4
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
connection node_2;
2+
connection node_1;
3+
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY);
4+
connection node_1;
5+
SET SESSION wsrep_trx_fragment_size=1;
6+
START TRANSACTION;
7+
INSERT INTO t1 VALUES (1);
8+
SET @@global.debug_dbug="+d,ha_index_init_fail";
9+
ROLLBACK;
10+
connection node_2;
11+
SELECT COUNT(*) `Expect 0` FROM mysql.wsrep_streaming_log;
12+
Expect 0
13+
0
14+
connection node_1;
15+
SET @@global.debug_dbug="";
16+
SELECT COUNT(*) `Expect 1` FROM mysql.wsrep_streaming_log;
17+
Expect 1
18+
1
19+
SET SESSION wsrep_on=OFF;
20+
DELETE FROM mysql.wsrep_streaming_log;
21+
SET SESSION wsrep_on=ON;
22+
DROP TABLE t1;
23+
CALL mtr.add_suppression("WSREP: Failed to init table for index scan");
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#
2+
# MDEV-27553 Assertion `inited==INDEX' failed: int handler::ha_index_end()
3+
#
4+
5+
--source include/galera_cluster.inc
6+
7+
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY);
8+
9+
--connection node_1
10+
--let $wsrep_cluster_address_orig = `SELECT @@wsrep_cluster_address`
11+
SET SESSION wsrep_trx_fragment_size=1;
12+
START TRANSACTION;
13+
INSERT INTO t1 VALUES (1);
14+
# This will result in failure to remove fragments
15+
# from streaming log, in the following ROLLBACK.
16+
SET @@global.debug_dbug="+d,ha_index_init_fail";
17+
ROLLBACK;
18+
19+
--connection node_2
20+
SELECT COUNT(*) `Expect 0` FROM mysql.wsrep_streaming_log;
21+
22+
23+
--connection node_1
24+
SET @@global.debug_dbug="";
25+
SELECT COUNT(*) `Expect 1` FROM mysql.wsrep_streaming_log;
26+
27+
SET SESSION wsrep_on=OFF;
28+
DELETE FROM mysql.wsrep_streaming_log;
29+
SET SESSION wsrep_on=ON;
30+
DROP TABLE t1;
31+
32+
CALL mtr.add_suppression("WSREP: Failed to init table for index scan");

sql/wsrep_schema.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,11 @@ static int init_for_index_scan(TABLE* table, const uchar* key,
598598
*/
599599
static int end_index_scan(TABLE* table) {
600600
int error;
601-
if ((error= table->file->ha_index_end())) {
602-
WSREP_ERROR("Failed to end scan: %d", error);
603-
return 1;
601+
if (table->file->inited) {
602+
if ((error= table->file->ha_index_end())) {
603+
WSREP_ERROR("Failed to end scan: %d", error);
604+
return 1;
605+
}
604606
}
605607
return 0;
606608
}

wsrep-lib

0 commit comments

Comments
 (0)