Skip to content

Commit c8e309a

Browse files
committed
Merge 10.6 into 10.7
2 parents 2897ef0 + 58fe6b4 commit c8e309a

File tree

5 files changed

+58
-1
lines changed

5 files changed

+58
-1
lines changed

mysql-test/suite/innodb/r/innodb-alter-debug.result

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,4 +132,14 @@ ALTER TABLE t1 RENAME KEY idx TO idx1, ALGORITHM=COPY;
132132
disconnect con1;
133133
connection default;
134134
DROP TABLE t1;
135+
#
136+
# MDEV-26903 Assertion ctx->trx->state == TRX_STATE_ACTIVE on DROP INDEX
137+
#
138+
CREATE TABLE t1(a INT PRIMARY KEY, b INT, INDEX(b)) ENGINE=InnoDB;
139+
SET @save_dbug=@@debug_dbug;
140+
SET debug_dbug='+d,innodb_table_deadlock';
141+
ALTER TABLE t1 DROP INDEX b, ALGORITHM=INPLACE;
142+
ERROR 40001: Deadlock found when trying to get lock; try restarting transaction
143+
SET debug_dbug=@save_dbug;
144+
DROP TABLE t1;
135145
# End of 10.6 tests

mysql-test/suite/innodb/t/innodb-alter-debug.test

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,18 @@ disconnect con1;
177177
connection default;
178178
DROP TABLE t1;
179179

180+
--echo #
181+
--echo # MDEV-26903 Assertion ctx->trx->state == TRX_STATE_ACTIVE on DROP INDEX
182+
--echo #
183+
184+
CREATE TABLE t1(a INT PRIMARY KEY, b INT, INDEX(b)) ENGINE=InnoDB;
185+
SET @save_dbug=@@debug_dbug;
186+
SET debug_dbug='+d,innodb_table_deadlock';
187+
--error ER_LOCK_DEADLOCK
188+
ALTER TABLE t1 DROP INDEX b, ALGORITHM=INPLACE;
189+
SET debug_dbug=@save_dbug;
190+
DROP TABLE t1;
191+
180192
--echo # End of 10.6 tests
181193

182194
# Wait till all disconnects are completed

storage/innobase/handler/ha_innodb.cc

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ void close_thread_tables(THD* thd);
150150
#include "wsrep_sst.h"
151151
#endif /* WITH_WSREP */
152152

153+
#ifdef HAVE_URING
154+
/** The Linux kernel version if io_uring() is considered unsafe */
155+
static const char *io_uring_may_be_unsafe;
156+
#endif
157+
153158
#define INSIDE_HA_INNOBASE_CC
154159

155160
#define EQ_CURRENT_THD(thd) ((thd) == current_thd)
@@ -4041,6 +4046,14 @@ static int innodb_init_params()
40414046
cases, we ignore the setting of innodb_use_native_aio. */
40424047
srv_use_native_aio = FALSE;
40434048
#endif
4049+
#ifdef HAVE_URING
4050+
if (srv_use_native_aio && io_uring_may_be_unsafe) {
4051+
sql_print_warning("innodb_use_native_aio may cause "
4052+
"hangs with this kernel %s; see "
4053+
"https://jira.mariadb.org/browse/MDEV-26674",
4054+
io_uring_may_be_unsafe);
4055+
}
4056+
#endif
40444057

40454058
#ifndef _WIN32
40464059
ut_ad(srv_file_flush_method <= SRV_O_DIRECT_NO_FSYNC);
@@ -19401,10 +19414,29 @@ static MYSQL_SYSVAR_STR(version, innodb_version_str,
1940119414
PLUGIN_VAR_NOCMDOPT | PLUGIN_VAR_READONLY,
1940219415
"InnoDB version", NULL, NULL, INNODB_VERSION_STR);
1940319416

19417+
#ifdef HAVE_URING
19418+
# include <sys/utsname.h>
19419+
static utsname uname_for_io_uring;
19420+
#endif
19421+
19422+
static bool innodb_use_native_aio_default()
19423+
{
19424+
#ifdef HAVE_URING
19425+
utsname &u= uname_for_io_uring;
19426+
if (!uname(&u) && u.release[0] == '5' && u.release[1] == '.' &&
19427+
u.release[2] == '1' && u.release[3] > '0' && u.release[3] < '6')
19428+
{
19429+
io_uring_may_be_unsafe= u.release;
19430+
return false; /* working around io_uring hangs (MDEV-26674) */
19431+
}
19432+
#endif
19433+
return true;
19434+
}
19435+
1940419436
static MYSQL_SYSVAR_BOOL(use_native_aio, srv_use_native_aio,
1940519437
PLUGIN_VAR_NOCMDARG | PLUGIN_VAR_READONLY,
1940619438
"Use native AIO if supported on this platform.",
19407-
NULL, NULL, TRUE);
19439+
NULL, NULL, innodb_use_native_aio_default());
1940819440

1940919441
#ifdef HAVE_LIBNUMA
1941019442
static MYSQL_SYSVAR_BOOL(numa_interleave, srv_numa_interleave,

storage/innobase/handler/handler0alter.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8678,6 +8678,8 @@ inline bool rollback_inplace_alter_table(Alter_inplace_info *ha_alter_info,
86788678
/* If we have not started a transaction yet,
86798679
(almost) nothing has been or needs to be done. */
86808680
dict_sys.lock(SRW_LOCK_CALL);
8681+
else if (ctx->trx->state == TRX_STATE_NOT_STARTED)
8682+
goto free_and_exit;
86818683
else if (ctx->new_table)
86828684
{
86838685
ut_ad(ctx->trx->state == TRX_STATE_ACTIVE);

storage/innobase/lock/lock0lock.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3433,6 +3433,7 @@ lock_table_other_has_incompatible(
34333433
static dberr_t lock_table_low(dict_table_t *table, lock_mode mode,
34343434
que_thr_t *thr, trx_t *trx)
34353435
{
3436+
DBUG_EXECUTE_IF("innodb_table_deadlock", return DB_DEADLOCK;);
34363437
lock_t *wait_for=
34373438
lock_table_other_has_incompatible(trx, LOCK_WAIT, table, mode);
34383439
dberr_t err= DB_SUCCESS;

0 commit comments

Comments
 (0)