Index: mysql-test/r/plugin_uninstall_audit_core.result =================================================================== --- mysql-test/r/plugin_uninstall_audit_core.result (版本 0) +++ mysql-test/r/plugin_uninstall_audit_core.result (版本 5999) @@ -0,0 +1,10 @@ +INSTALL plugin NULL_AUDIT soname 'adt_null.so'; +SET DEBUG_SYNC= 'before_my_plugin_lock SIGNAL may_uninstall WAIT_FOR uninstall_plugin'; +SELECT 1+1; +SET DEBUG_SYNC= 'in_mysql_uninstall_plugin WAIT_FOR may_uninstall'; +SET DEBUG_SYNC= 'after_plugin_is_deleted SIGNAL uninstall_plugin'; +UNINSTALL plugin NULL_AUDIT; +Warnings: +Warning 1620 Plugin is busy and will be uninstalled on shutdown +1+1 +2 Index: mysql-test/t/plugin_uninstall_audit_core.test =================================================================== --- mysql-test/t/plugin_uninstall_audit_core.test (版本 0) +++ mysql-test/t/plugin_uninstall_audit_core.test (版本 5999) @@ -0,0 +1,19 @@ +--source include/have_debug_sync.inc + +--connect (conn1, localhost, root, ,) +--connect (conn2, localhost, root, ,) + +--connection conn1 +send INSTALL plugin NULL_AUDIT soname 'adt_null.so'; +reap; +SET DEBUG_SYNC= 'before_my_plugin_lock SIGNAL may_uninstall WAIT_FOR uninstall_plugin'; +send SELECT 1+1; + +--connection conn2 +SET DEBUG_SYNC= 'in_mysql_uninstall_plugin WAIT_FOR may_uninstall'; +SET DEBUG_SYNC= 'after_plugin_is_deleted SIGNAL uninstall_plugin'; +send UNINSTALL plugin NULL_AUDIT; +reap; + +--connection conn1 +reap; Index: sql/sql_plugin.cc =================================================================== --- sql/sql_plugin.cc (版本 5792) +++ sql/sql_plugin.cc (工作副本) @@ -33,6 +33,7 @@ #include "sql_audit.h" #include #include "lock.h" // MYSQL_LOCK_IGNORE_TIMEOUT +#include "debug_sync.h" #define REPORT_TO_LOG 1 #define REPORT_TO_USER 2 @@ -1847,6 +1848,7 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name) { + DEBUG_SYNC(thd, "in_mysql_uninstall_plugin"); TABLE *table; TABLE_LIST tables; struct st_plugin_int *plugin; @@ -1918,6 +1920,7 @@ } plugin->state= PLUGIN_IS_DELETED; + DEBUG_SYNC(thd, "after_plugin_is_deleted"); if (plugin->ref_count) push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, WARN_PLUGIN_BUSY, ER(WARN_PLUGIN_BUSY)); Index: sql/sql_audit.cc =================================================================== --- sql/sql_audit.cc (版本 5792) +++ sql/sql_audit.cc (工作副本) @@ -15,7 +15,7 @@ #include "sql_priv.h" #include "sql_audit.h" - +#include "debug_sync.h" extern int initialize_audit_plugin(st_plugin_int *plugin); extern int finalize_audit_plugin(st_plugin_int *plugin); @@ -160,8 +160,10 @@ } /* lock the plugin and add it to the list */ + DEBUG_SYNC(thd, "before_my_plugin_lock"); plugin= my_plugin_lock(NULL, &plugin); - insert_dynamic(&thd->audit_class_plugins, (uchar*) &plugin); + if (plugin != NULL) + insert_dynamic(&thd->audit_class_plugins, (uchar*) &plugin); return 0; }