[MDEV-15733] Crash during Spider-related CREATE TABLE/ALTER TABLE can leave orphaned entry in mysql.spider_tables Created: 2018-03-29  Updated: 2021-11-05  Resolved: 2018-05-08

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - Spider
Affects Version/s: 10.2.13
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Geoff Montee (Inactive) Assignee: Jacob Mathew (Inactive)
Resolution: Cannot Reproduce Votes: 0
Labels: spider


 Description   

If MariaDB crashes during a CREATE TABLE/ALTER TABLE statement that either creates a new spider table or converts an existing table to use the spider engine, then there can be orphaned entries in mysql.spider_tables that reference the spider table that was never actually created.

At that point, if the user tries to recreate the table again, then they run into an error that is difficult to understand:

e.g. if they run this CREATE TABLE statement:

USE spider_test;
 
CREATE TABLE spider_tab (
   id int auto_increment primary key,
   str varchar(50)
) ENGINE=Spider COMMENT='wrapper "mysql", srv "srv1", table "local_tab"';

Then they would see the following error:

ERROR 1062 (23000): Duplicate entry 'spider_test-spider_tab-0' for key 'PRIMARY'

To workaround the problem, the orphaned row needs to be deleted:

DELETE FROM mysql.spider_tables WHERE db_name='spider_test' AND table_name='spider_tab';

And then the table can be created.

To fix this, maybe Spider should do some kind of validation at server startup, like making sure that all rows listed in mysql.spider_tables reference tables that actually exist?



 Comments   
Comment by Jacob Mathew (Inactive) [ 2018-05-08 ]

I am unable to reproduce the issue. I have tried with 10.2.13, 10.2.15, 10.2.4 and 10.3.7, with debug and release builds, on Windows 10 and CentOS 7.

Comment by Philippe Jean [ 2021-11-05 ]

I just had this problem in Galera cluster mode. The problem is that a DROP TABLE on table with Spider engine had to drop the row in mysql.spider_tables locally only, not on other nodes.

I've done some testing and it doesn't happen regularly.

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