[MDEV-28956] Locking is broken if CREATE OR REPLACE fails under LOCK TABLES Created: 2022-06-27  Updated: 2023-05-18  Resolved: 2023-01-25

Status: Closed
Project: MariaDB Server
Component/s: Data Definition - Create Table
Affects Version/s: 10.10
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Lena Startseva Assignee: Aleksey Midenkov
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Duplicate
is duplicated by MDEV-28952 Assertion `t->s->tmp_table || thd->md... Closed
Problem/Incident
is caused by MDEV-25292 Atomic CREATE OR REPLACE TABLE Stalled
Relates
relates to MDEV-29544 SIGSEGV in HA_CREATE_INFO::finalize_l... Closed

 Description   

Query "UNLOCK TABLES" failed after creating table (via "CREATE OR REPLACE") with duplicate column name

Conditions for reproducing the bug:

  • The first time of table creating it must have a reference to another table
  • Replacing the table should fail with an error 'Duplicate column name'

Test:

--source include/have_innodb.inc
 
CREATE TABLE A (pk INT PRIMARY KEY) ENGINE=INNODB;
CREATE OR REPLACE TABLE t7 (a INT PRIMARY KEY REFERENCES A (pk)) ENGINE = INNODB;
 
LOCK TABLES t7 write, `A` write;
--error ER_DUP_FIELDNAME
CREATE OR REPLACE TABLE t7 (c1 INT NOT NULL, c1 VARCHAR(255) ) ENGINE = INNODB;
 
UNLOCK TABLES;
DROP TABLE t7, A;

Actual result:

At line 12: query 'UNLOCK TABLES' failed: <Unknown> (2013): Lost connection to server during query
 
 
Server version: 10.10.0-MariaDB-debug-log
key_buffer_size=1048576
read_buffer_size=131072
max_used_connections=1
max_threads=153
thread_count=1
It is possible that mysqld could use up to 
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_threads = 63948 K  bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
 
Thread pointer: 0x7effc0000db8
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
stack_bottom = 0x7efff804ed78 thread_stack 0x49000
mysys/stacktrace.c:212(my_print_stacktrace)[0x560fe05dc2e9]
sql/signal_handler.cc:226(handle_fatal_signal)[0x560fdfc9fb6f]
addr2line: DWARF error: section .debug_info is larger than its filesize! (0x5b4757 vs 0x429c68)
??:0(__sigaction)[0x7efffd9c5520]
??:0(pthread_kill)[0x7efffda19828]
??:0(raise)[0x7efffd9c5476]
??:0(abort)[0x7efffd9ab7b7]
/lib/x86_64-linux-gnu/libc.so.6(+0x286db)[0x7efffd9ab6db]
??:0(__assert_fail)[0x7efffd9bce26]
sql/table_cache.cc:443(tc_release_table(TABLE*))[0x560fdfbbeaba]
sql/sql_base.cc:1000(close_thread_table(THD*, TABLE**))[0x560fdf801f48]
sql/sql_base.cc:941(close_thread_tables(THD*))[0x560fdf801b5e]
sql/sql_base.cc:2551(Locked_tables_list::unlock_locked_tables(THD*))[0x560fdf805892]
sql/sql_parse.cc:5063(mysql_execute_command(THD*, bool))[0x560fdf8c501f]
sql/sql_parse.cc:8038(mysql_parse(THD*, char*, unsigned int, Parser_state*))[0x560fdf8cef36]
sql/sql_parse.cc:1896(dispatch_command(enum_server_command, THD*, char*, unsigned int, bool))[0x560fdf8babb1]
sql/sql_parse.cc:1407(do_command(THD*, bool))[0x560fdf8b9521]
sql/sql_connect.cc:1418(do_handle_one_connection(CONNECT*, bool))[0x560fdfaa0a89]
sql/sql_connect.cc:1314(handle_one_connection)[0x560fdfaa0716]
perfschema/pfs.cc:2203(pfs_spawn_thread)[0x560fe0017eec]
addr2line: DWARF error: section .debug_info is larger than its filesize! (0x5b4757 vs 0x429c68)
??:0(pthread_condattr_setpshared)[0x7efffda17947]
??:0(clone)[0x7efffdaa7a44]
 
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort.
Query (0x7effc0015570): UNLOCK TABLES



 Comments   
Comment by Aleksey Midenkov [ 2022-06-28 ]

Please review bb-10.10-MDEV-25292

Comment by Aleksey Midenkov [ 2022-06-28 ]

Fixed in bb-10.10-MDEV-25292

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