Bug #56085 Embedded server tests fails with assert in check_if_table_exists()
Submitted: 18 Aug 2010 12:07 Modified: 23 Sep 2010 22:12
Reporter: Jon Olav Hauglid Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Locking Severity:S1 (Critical)
Version:mysql-5.5-runtime OS:Any
Assigned to: Jon Olav Hauglid CPU Architecture:Any

[18 Aug 2010 12:07] Jon Olav Hauglid
Description:
Any MTR test run with --embedded-server in debug mode will cause an assert.

  DBUG_ASSERT(thd->mdl_context.
              is_lock_owner(MDL_key::TABLE, table->db,
                            table->table_name, MDL_SHARED));

in check_if_table_exists() is triggered.

With embedded server, check_if_table_exists() is called from plugin_load()
without a metadata lock on the table. This triggers the assert.

Only happens in the mysql-5.5-runtime tree.

How to repeat:
./mtr 1st --embbeded-server
[18 Aug 2010 13:12] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/116113

3113 Jon Olav Hauglid	2010-08-18
      Bug #56085 Embedded server tests fails with assert in
                 check_if_table_exists()
      
      This assert was triggered when the server tried to load plugins
      while running in embedded server mode. In embedded server mode,
      check_if_table_exists() was used to check if mysql.plugin existed
      so that ER_NO_SUCH_TABLE could be silently ignored.
      The problem was that this check was done without acquiring a metadata
      lock on mysql.plugin first. This triggered the assert.
      
      This patch fixes the problem by removing the call to
      check_if_table_exists() from plugin_load(). Instead an error handler
      which traps ER_NO_SUCH_TABLE is installed before trying to open
      mysql.plugin when running in embedded server mode.
      
      No test coverage added since this assert was triggered by 
      existing tests running in embedded server mode.
[19 Aug 2010 8:15] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/116183

3113 Jon Olav Hauglid	2010-08-19
      Bug #56085 Embedded server tests fails with assert in
                 check_if_table_exists()
      
      This assert was triggered when the server tried to load plugins
      while running in embedded server mode. In embedded server mode,
      check_if_table_exists() was used to check if mysql.plugin existed
      so that ER_NO_SUCH_TABLE could be silently ignored.
      The problem was that this check was done without acquiring a metadata
      lock on mysql.plugin first. This triggered the assert.
      
      This patch fixes the problem by removing the call to
      check_if_table_exists() from plugin_load(). Instead an error handler
      which traps ER_NO_SUCH_TABLE is installed before trying to open
      mysql.plugin when running in embedded server mode.
      
      No test coverage added since this assert was triggered by 
      existing tests running in embedded server mode.
[19 Aug 2010 9:15] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/116210

3113 Jon Olav Hauglid	2010-08-19
      Bug #56085 Embedded server tests fails with assert in
                 check_if_table_exists()
      
      This assert was triggered when the server tried to load plugins
      while running in embedded server mode. In embedded server mode,
      check_if_table_exists() was used to check if mysql.plugin existed
      so that ER_NO_SUCH_TABLE could be silently ignored.
      The problem was that this check was done without acquiring a metadata
      lock on mysql.plugin first. This triggered the assert.
      
      This patch fixes the problem by removing the call to
      check_if_table_exists() from plugin_load(). Instead an error handler
      which traps ER_NO_SUCH_TABLE is installed before trying to open
      mysql.plugin when running in embedded server mode.
      
      No test coverage added since this assert was triggered by 
      existing tests running in embedded server mode.
     @ sql/sql_base.cc
        Renamed Prelock_error_handler to No_such_table_error_handler
        and moved the declaration to sql_base.h to make it usable
        in plugin_load().
     @ sql/sql_base.h
        Renamed Prelock_error_handler to No_such_table_error_handler
        and moved the declaration to sql_base.h to make it usable
        in plugin_load().
     @ sql/sql_plugin.cc
        Removed call to check_if_table_exists() used to check for mysql.plugin 
        in plugin_load() for embedded server. Instead installs error handler
        which traps ER_NO_SUCH_TABLE during open_and_lock_tables().
[19 Aug 2010 10:16] Jon Olav Hauglid
Pushed to mysql-5.5-runtime (Ver 5.5.6-m3).
[19 Aug 2010 14:18] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/116265

3113 Jon Olav Hauglid	2010-08-19
      Bug #56085 Embedded server tests fails with assert in
                 check_if_table_exists()
      
      This assert was triggered when the server tried to load plugins
      while running in embedded server mode. In embedded server mode,
      check_if_table_exists() was used to check if mysql.plugin existed
      so that ER_NO_SUCH_TABLE could be silently ignored.
      The problem was that this check was done without acquiring a metadata
      lock on mysql.plugin first. This triggered the assert.
      
      This patch fixes the problem by removing the call to
      check_if_table_exists() from plugin_load(). Instead an error handler
      which traps ER_NO_SUCH_TABLE is installed before trying to open
      mysql.plugin when running in embedded server mode.
      
      No test coverage added since this assert was triggered by 
      existing tests running in embedded server mode.
     @ sql/sql_base.cc
        Renamed Prelock_error_handler to No_such_table_error_handler
        and moved the declaration to sql_base.h to make it usable
        in plugin_load().
     @ sql/sql_base.h
        Renamed Prelock_error_handler to No_such_table_error_handler
        and moved the declaration to sql_base.h to make it usable
        in plugin_load().
     @ sql/sql_plugin.cc
        Removed call to check_if_table_exists() used to check for mysql.plugin 
        in plugin_load() for embedded server. Instead install error handler
        which traps ER_NO_SUCH_TABLE during open_and_lock_tables().
[25 Aug 2010 9:22] Bugs System
Pushed into mysql-5.5 5.5.6-m3 (revid:alik@ibmvm-20100825092002-2yvkb3iwu43ycpnm) (version source revid:alik@ibmvm-20100825092002-2yvkb3iwu43ycpnm) (merge vers: 5.5.6-m3) (pib:20)
[30 Aug 2010 8:31] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@sun.com-20100830082732-n2eyijnv86exc5ci) (version source revid:alik@sun.com-20100830082732-n2eyijnv86exc5ci) (merge vers: 5.6.1-m4) (pib:21)
[30 Aug 2010 8:34] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100830082745-n6sh01wlwh3itasv) (version source revid:alik@sun.com-20100830082745-n6sh01wlwh3itasv) (pib:21)
[23 Sep 2010 22:12] Paul DuBois
Noted in 5.5.6, 5.6.1 changelogs.

The embedded server raised an assertion when it attempted to load plugins.