[MDEV-29664] Assertion `!n_mysql_tables_in_use' failed in innobase_close_connection Created: 2022-09-29  Updated: 2023-05-18  Resolved: 2023-01-25

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Create Table, Storage Engine - Spider
Affects Version/s: None
Fix Version/s: N/A

Type: Bug Priority: Critical
Reporter: Roel Van de Paar Assignee: Aleksey Midenkov
Resolution: Fixed Votes: 0
Labels: regression, spider

Issue Links:
Problem/Incident
is caused by MDEV-25292 Atomic CREATE OR REPLACE TABLE Stalled
Relates
relates to MDEV-29663 Incorrect, confusing error message: E... Stalled

 Description   

Replay using the CLI. Deemed non-sporadic. Interestingly, the crash does not repeat on UBASAN builds (at all).

INSTALL PLUGIN Spider SONAME 'ha_spider.so';
CREATE USER Spider@localhost IDENTIFIED BY 'PWD1';
CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET '../socket.sock',DATABASE 'test',user 'Spider',PASSWORD 'PWD1');
CREATE TABLE t (c INT);
CREATE TABLE t1 (c1 TEXT) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE "t"';
CREATE OR REPLACE TABLE t2 AS SELECT FORMAT (c1,0) AS c1 FROM t1;  # 'OR REPLACE' is required
# Exit the CLI here to trigger the bug

Leads to:

10.11.0 6ebdd3013a18b01dbecec76b870810329eb76586 (Debug)

mysqld: /test/10.11_dbg/storage/innobase/trx/trx0trx.cc:377: void trx_t::free(): Assertion `!n_mysql_tables_in_use' failed.

10.11.0 6ebdd3013a18b01dbecec76b870810329eb76586 (Debug)

Core was generated by `/test/MD190922-mariadb-10.11.0-linux-x86_64-dbg/bin/mysqld --no-defaults --core'.
Program terminated with signal SIGABRT, Aborted.
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
[Current thread is 1 (Thread 0x1522fca0e700 (LWP 3124377))]
(gdb) bt
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:50
#1  0x0000152315567859 in __GI_abort () at abort.c:79
#2  0x0000152315567729 in __assert_fail_base (fmt=0x1523156fd588 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", assertion=0x56248ffe99f0 "!n_mysql_tables_in_use", file=0x56248ffe9c08 "/test/10.11_dbg/storage/innobase/trx/trx0trx.cc", line=377, function=<optimized out>) at assert.c:92
#3  0x0000152315578fd6 in __GI___assert_fail (assertion=assertion@entry=0x56248ffe99f0 "!n_mysql_tables_in_use", file=file@entry=0x56248ffe9c08 "/test/10.11_dbg/storage/innobase/trx/trx0trx.cc", line=line@entry=377, function=function@entry=0x56248ffe9a07 "void trx_t::free()") at assert.c:101
#4  0x000056248f9b8b7d in trx_t::free (this=this@entry=0x15230ce01b80) at /test/10.11_dbg/storage/innobase/trx/trx0trx.cc:377
#5  0x000056248f7797ce in innobase_close_connection (hton=<optimized out>, thd=0x1522c0000d48) at /test/10.11_dbg/storage/innobase/handler/ha_innodb.cc:4956
#6  0x000056248f479f70 in ha_close_connection (thd=thd@entry=0x1522c0000d48) at /test/10.11_dbg/sql/handler.cc:906
#7  0x000056248f120d55 in THD::free_connection (this=this@entry=0x1522c0000d48) at /test/10.11_dbg/sql/sql_class.cc:1599
#8  0x000056248f05518e in unlink_thd (thd=0x1522c0000d48) at /test/10.11_dbg/sql/mysqld.cc:2766
#9  0x000056248f2f2185 in do_handle_one_connection (connect=<optimized out>, connect@entry=0x562492a89fc8, put_in_cache=put_in_cache@entry=true) at /test/10.11_dbg/sql/sql_connect.cc:1427
#10 0x000056248f2f24c3 in handle_one_connection (arg=0x562492a89fc8) at /test/10.11_dbg/sql/sql_connect.cc:1318
#11 0x0000152315a78609 in start_thread (arg=<optimized out>) at pthread_create.c:477
#12 0x0000152315664133 in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:95

Single error in client:

10.11.0 6ebdd3013a18b01dbecec76b870810329eb76586 (Debug)

10.11.0-dbg>CREATE OR REPLACE TABLE t2 AS SELECT FORMAT (c1,0) AS c1 FROM t1;  # 'OR REPLACE' is required
ERROR 1054 (42S22): Unknown column 't0.c1' in 'field list'

Bug confirmed present in:
MariaDB: 10.11.0 (dbg)

Bug (or feature/syntax) confirmed not present in:
MariaDB: 10.3.37 (dbg), 10.3.37 (opt), 10.4.27 (dbg), 10.4.27 (opt), 10.5.18 (dbg), 10.5.18 (opt), 10.6.10 (dbg), 10.6.10 (opt), 10.7.6 (dbg), 10.7.6 (opt), 10.8.5 (dbg), 10.8.5 (opt), 10.9.3 (dbg), 10.9.3 (opt), 10.10.0 (opt), 10.10.2 (dbg), 10.10.0 (dbg), 10.10.2 (opt), 10.11.0 (opt)



 Comments   
Comment by Roel Van de Paar [ 2022-09-29 ]

commit 93c8252f02faa8ad8dc5f005e52f1990c29d4a0d
Author: Aleksey Midenkov <midenok@gmail.com>
Date:   Wed Aug 31 11:55:04 2022 +0300
 
    MDEV-25292 Atomic CREATE OR REPLACE TABLE

Is the first bad commit.

Comment by Aleksey Midenkov [ 2022-09-29 ]

Please prepare MTR test case or provide full info on the setup. Better is to provide MTR test case.

MariaDB [test]> CREATE USER Spider@localhost IDENTIFIED BY 'PWD1';
Query OK, 0 rows affected (0.002 sec)
 
MariaDB [test]> CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET '../socket.sock',DATABASE 'test',user 'Spider',PASSWORD 'PWD1');
Query OK, 0 rows affected (0.001 sec)
 
MariaDB [test]> CREATE TABLE t (c INT);
Query OK, 0 rows affected (0.005 sec)
 
MariaDB [test]> CREATE TABLE t1 (c1 TEXT) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE "t"';
Query OK, 0 rows affected (0.003 sec)
 
MariaDB [test]> CREATE OR REPLACE TABLE t2 AS SELECT FORMAT (c1,0) AS c1 FROM t1;  # 'OR REPLACE' is required
ERROR 1429 (HY000): Unable to connect to foreign data source: srv

Comment by Aleksey Midenkov [ 2022-09-30 ]

Please review bb-10.11-midenok

Comment by Oleksandr Byelkin [ 2022-09-30 ]

The last variant is OK to push after moving the assignment I mentioned on slack

Comment by Sergei Golubchik [ 2022-10-01 ]

Please, add a non-debug test. using Spider or anything. We test with debug on one builder out of 47. So whenever possible we should try to create non-debug tests.

There's an almost usable test in the bug description

Comment by Roel Van de Paar [ 2022-10-05 ]

midenok FYI, see https://jira.mariadb.org/browse/MDEV-29676?focusedCommentId=236586&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-236586 for a relevant example.

Comment by Aleksey Midenkov [ 2022-10-11 ]

The test case has been committed to bb-10.11-midenok and will be pushed with other 10.11 fixes.

Comment by Roel Van de Paar [ 2022-10-14 ]

Confirmed bb-10.11-midenok is free of the crash with the given testcase.

Comment by Roel Van de Paar [ 2023-01-20 ]

bb-11.0-midenok-MDEV-25292 also does not crash.

11.0.1 bb-11.0-midenok-MDEV-25292 b986107a777e3f900f235d969d569358c7a5edfe (Debug)

11.0.1-dbg>INSTALL PLUGIN Spider SONAME 'ha_spider.so';
Query OK, 0 rows affected, 1 warning (0.017 sec)
 
11.0.1-dbg>CREATE USER Spider@localhost IDENTIFIED BY 'PWD1';
Query OK, 0 rows affected (0.002 sec)
 
11.0.1-dbg>CREATE SERVER srv FOREIGN DATA WRAPPER MYSQL OPTIONS (SOCKET '../socket.sock',DATABASE 'test',user 'Spider',PASSWORD 'PWD1');
Query OK, 0 rows affected (0.001 sec)
 
11.0.1-dbg>CREATE TABLE t (c INT);
Query OK, 0 rows affected (0.013 sec)
 
11.0.1-dbg>CREATE TABLE t1 (c1 TEXT) ENGINE=Spider COMMENT='WRAPPER "mysql",srv "srv",TABLE "t"';
Query OK, 0 rows affected (0.269 sec)
 
11.0.1-dbg>CREATE OR REPLACE TABLE t2 AS SELECT FORMAT (c1,0) AS c1 FROM t1;  # 'OR REPLACE' is required
ERROR 1054 (42S22): Unknown column 't0.c1' in 'field list'

The incorrect t0 mention is discussed in MDEV-29663, and is unlikely to be related to this bug.

It would seem that this bug has been fixed.

Generated at Thu Feb 08 10:10:20 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.