mirror of
https://github.com/MariaDB/server.git
synced 2026-05-07 23:54:31 +02:00
MDEV-34925 Fix segv on thd in spider recovery.
Create temporary thd whenever needed in spider xa commit / recovery. This prevents crash during recovery.
This commit is contained in:
parent
c69fb1a627
commit
8d6c9ef001
5 changed files with 127 additions and 14 deletions
|
|
@ -0,0 +1,6 @@
|
|||
install soname 'ha_spider';
|
||||
CREATE TABLE t1 (a INT) ENGINE=Innodb;
|
||||
SET SESSION debug_dbug="+d,crash_commit_after_log";
|
||||
INSERT INTO t1 VALUES (1);
|
||||
Got one of the listed errors
|
||||
drop table t1;
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
install soname 'ha_spider';
|
||||
set spider_same_server_link= 1;
|
||||
CREATE SERVER srv FOREIGN DATA WRAPPER mysql
|
||||
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
|
||||
CREATE TABLE t1 (a INT);
|
||||
create table t2 (a int) ENGINE=Spider
|
||||
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t1"';
|
||||
INSERT INTO t2 VALUES (1);
|
||||
SET SESSION debug_dbug="+d,crash_commit_after_log";
|
||||
INSERT INTO t2 VALUES (2);
|
||||
Got one of the listed errors
|
||||
call mtr.add_suppression(".*\\[ERROR\\] mariadbd: Table './test/t1' is marked as crashed and should be repaired");
|
||||
call mtr.add_suppression(".*\\[Warning\\] Checking table: './test/t1'");
|
||||
set spider_same_server_link= 1;
|
||||
select * from t2;
|
||||
a
|
||||
1
|
||||
2
|
||||
Warnings:
|
||||
Error 1034 1 client is using or hasn't closed the table properly
|
||||
Error 1034 Table is fixed
|
||||
drop server srv;
|
||||
drop table t1, t2;
|
||||
Warnings:
|
||||
Warning 1620 Plugin is busy and will be uninstalled on shutdown
|
||||
22
storage/spider/mysql-test/spider/bugfix/t/mdev_27438.test
Normal file
22
storage/spider/mysql-test/spider/bugfix/t/mdev_27438.test
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
--source include/have_debug.inc
|
||||
# Valgrind does not work well with test that crashes the server
|
||||
--source include/not_valgrind.inc
|
||||
install soname 'ha_spider';
|
||||
CREATE TABLE t1 (a INT) ENGINE=Innodb;
|
||||
|
||||
# crash the server.
|
||||
--let $expect_file_name= `select regexp_replace(@@tmpdir, '^.*/','')`
|
||||
--let $expect_file_name= $MYSQLTEST_VARDIR/tmp/$expect_file_name.expect
|
||||
--exec echo wait > $expect_file_name
|
||||
SET SESSION debug_dbug="+d,crash_commit_after_log";
|
||||
--error 2006,2013
|
||||
INSERT INTO t1 VALUES (1);
|
||||
|
||||
# restart the server
|
||||
--exec echo restart >> $expect_file_name
|
||||
--enable_reconnect
|
||||
--source include/wait_until_connected_again.inc
|
||||
|
||||
drop table t1;
|
||||
--disable_query_log
|
||||
--source ../../include/clean_up_spider.inc
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
--source include/have_debug.inc
|
||||
# Valgrind does not work well with test that crashes the server
|
||||
--source include/not_valgrind.inc
|
||||
|
||||
# Same as spider/bugfix.mdev_27438, but actually using a spider table.
|
||||
install soname 'ha_spider';
|
||||
set spider_same_server_link= 1;
|
||||
evalp CREATE SERVER srv FOREIGN DATA WRAPPER mysql
|
||||
OPTIONS (SOCKET "$MASTER_1_MYSOCK", DATABASE 'test',user 'root');
|
||||
|
||||
CREATE TABLE t1 (a INT);
|
||||
create table t2 (a int) ENGINE=Spider
|
||||
COMMENT='WRAPPER "mysql", srv "srv",TABLE "t1"';
|
||||
INSERT INTO t2 VALUES (1);
|
||||
|
||||
# crash the server.
|
||||
--let $expect_file_name= `select regexp_replace(@@tmpdir, '^.*/','')`
|
||||
--let $expect_file_name= $MYSQLTEST_VARDIR/tmp/$expect_file_name.expect
|
||||
--exec echo wait > $expect_file_name
|
||||
SET SESSION debug_dbug="+d,crash_commit_after_log";
|
||||
--error 2006,2013
|
||||
INSERT INTO t2 VALUES (2);
|
||||
|
||||
# restart the server
|
||||
--exec echo restart >> $expect_file_name
|
||||
--enable_reconnect
|
||||
--source include/wait_until_connected_again.inc
|
||||
|
||||
call mtr.add_suppression(".*\\[ERROR\\] mariadbd: Table './test/t1' is marked as crashed and should be repaired");
|
||||
call mtr.add_suppression(".*\\[Warning\\] Checking table: './test/t1'");
|
||||
set spider_same_server_link= 1;
|
||||
--disable_ps_protocol
|
||||
select * from t2;
|
||||
--enable_ps_protocol
|
||||
drop server srv;
|
||||
drop table t1, t2;
|
||||
--disable_query_log
|
||||
--source ../../include/clean_up_spider.inc
|
||||
|
|
@ -2598,7 +2598,17 @@ int spider_internal_xa_commit_by_xid(
|
|||
SPIDER_Open_tables_backup open_tables_backup;
|
||||
bool table_xa_opened = FALSE;
|
||||
bool table_xa_member_opened = FALSE;
|
||||
bool created_tmp_thd = FALSE;
|
||||
DBUG_ENTER("spider_internal_xa_commit_by_xid");
|
||||
if (!thd)
|
||||
{
|
||||
if (!(thd = spider_create_tmp_thd()))
|
||||
{
|
||||
error_num = HA_ERR_OUT_OF_MEM;
|
||||
goto error;
|
||||
}
|
||||
created_tmp_thd= TRUE;
|
||||
}
|
||||
/*
|
||||
select
|
||||
status
|
||||
|
|
@ -2798,6 +2808,8 @@ xa_delete:
|
|||
goto error;
|
||||
spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE);
|
||||
table_xa_opened = FALSE;
|
||||
if (created_tmp_thd)
|
||||
spider_free_tmp_thd(thd);
|
||||
DBUG_RETURN(0);
|
||||
|
||||
error:
|
||||
|
|
@ -2806,6 +2818,8 @@ error:
|
|||
if (table_xa_member_opened)
|
||||
spider_close_sys_table(thd, table_xa_member, &open_tables_backup, TRUE);
|
||||
error_open_table:
|
||||
if (created_tmp_thd)
|
||||
spider_free_tmp_thd(thd);
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
|
||||
|
|
@ -2830,7 +2844,17 @@ int spider_internal_xa_rollback_by_xid(
|
|||
SPIDER_Open_tables_backup open_tables_backup;
|
||||
bool table_xa_opened = FALSE;
|
||||
bool table_xa_member_opened = FALSE;
|
||||
bool created_tmp_thd= FALSE;
|
||||
DBUG_ENTER("spider_internal_xa_rollback_by_xid");
|
||||
if (!thd)
|
||||
{
|
||||
if (!(thd = spider_create_tmp_thd()))
|
||||
{
|
||||
error_num = HA_ERR_OUT_OF_MEM;
|
||||
goto error;
|
||||
}
|
||||
created_tmp_thd= TRUE;
|
||||
}
|
||||
/*
|
||||
select
|
||||
status
|
||||
|
|
@ -3028,6 +3052,8 @@ xa_delete:
|
|||
goto error;
|
||||
spider_close_sys_table(thd, table_xa, &open_tables_backup, TRUE);
|
||||
table_xa_opened = FALSE;
|
||||
if (created_tmp_thd)
|
||||
spider_free_tmp_thd(thd);
|
||||
DBUG_RETURN(0);
|
||||
|
||||
error:
|
||||
|
|
@ -3036,6 +3062,8 @@ error:
|
|||
if (table_xa_member_opened)
|
||||
spider_close_sys_table(thd, table_xa_member, &open_tables_backup, TRUE);
|
||||
error_open_table:
|
||||
if (created_tmp_thd)
|
||||
spider_free_tmp_thd(thd);
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
|
||||
|
|
@ -3360,15 +3388,12 @@ int spider_xa_commit_by_xid(
|
|||
DBUG_ENTER("spider_xa_commit_by_xid");
|
||||
|
||||
if (!(trx = spider_get_trx(thd, TRUE, &error_num)))
|
||||
goto error_get_trx;
|
||||
DBUG_RETURN(error_num);
|
||||
|
||||
if ((error_num = spider_internal_xa_commit_by_xid(thd, trx, xid)))
|
||||
goto error;
|
||||
error_num = spider_internal_xa_commit_by_xid(thd, trx, xid);
|
||||
|
||||
DBUG_RETURN(0);
|
||||
|
||||
error:
|
||||
error_get_trx:
|
||||
if (!thd)
|
||||
spider_free_trx(trx, FALSE);
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
|
||||
|
|
@ -3382,15 +3407,12 @@ int spider_xa_rollback_by_xid(
|
|||
DBUG_ENTER("spider_xa_rollback_by_xid");
|
||||
|
||||
if (!(trx = spider_get_trx(thd, TRUE, &error_num)))
|
||||
goto error_get_trx;
|
||||
DBUG_RETURN(error_num);
|
||||
|
||||
if ((error_num = spider_internal_xa_rollback_by_xid(thd, trx, xid)))
|
||||
goto error;
|
||||
error_num = spider_internal_xa_rollback_by_xid(thd, trx, xid);
|
||||
|
||||
DBUG_RETURN(0);
|
||||
|
||||
error:
|
||||
error_get_trx:
|
||||
if (!thd)
|
||||
spider_free_trx(trx, FALSE);
|
||||
DBUG_RETURN(error_num);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue