[MDEV-32796] Spider uninstall fails with "plugin busy" Created: 2023-11-14  Updated: 2023-12-19

Status: Open
Project: MariaDB Server
Component/s: Storage Engine - Spider
Affects Version/s: 10.4, 10.10
Fix Version/s: 10.4, 10.11

Type: Bug Priority: Major
Reporter: Yuchen Pei Assignee: Yuchen Pei
Resolution: Unresolved Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-7914 spider/bg.ha, spider/bg.ha_part crash... Closed

 Description   

10.10 21822625aa675b36a5c2548f78e8d3d8cde8b7cd

install soname 'ha_spider';
create table t (c int) Engine=SPIDER;
drop table t;
uninstall soname 'ha_spider';

The uninstall statement results in warning:

Warnings:
Warning	1620	Plugin is busy and will be uninstalled on shutdown

Initial analysis shows this could be caused by a call to thd_set_ha_data(thd, spider_hton_ptr, trx) which increases the ref count to the plugin which later did not get decreased, from spider_get_trx() during the create table statement. See also kentoku's comment in MDEV-7914[1], whose commit is to blame for this call.

[1] https://jira.mariadb.org/browse/MDEV-7914?focusedCommentId=109258&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-109258

Trace:

intern_plugin_lock > plugin_lock > ha_lock_engine > thd_set_ha_data > ha_spider::create > handler::ha_create > create_table_impl > mysql_create_table_no_lock > Sql_cmd_create_table_like::execute > mysql_parse > dispatch_command > do_command > handle_one_connection > pfs_spawn_thread



 Comments   
Comment by Yuchen Pei [ 2023-12-18 ]

Could reproduce at 10.4 87a5d16911bb94d383480fdd49e20876ed1400f2

Comment by Yuchen Pei [ 2023-12-19 ]

Normally one could counter the call to thd_set_ha_data() with a
call to thd_set_ha_data() with ha_data=NULL. However this is
commonly done when closing a connection, which happens after all
statements have been executed. See also the documentation of
Ha_data::ha_ptr which notes lifetime of one user connection.

If we simply remove the call to thd_set_ha_data() in
spider_get_trx(), or add a call to thd_set_ha_data() with
NULL at the end of ha_spider::create(), then we get memory
leaks.

InnoDB for example, like Spider, may increment the ref_count during a
statement with the same call, and only calls thd_set_ha_data() on
NULL at close_connection. Though one could not uninstall InnoDB which
is an internal plugin so the problem is sidestepped.

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