Bug #56595 RENAME TABLE causes assert on OS X
Submitted: 6 Sep 2010 13:19 Modified: 20 Nov 2010 18:15
Reporter: Jon Olav Hauglid Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: DDL Severity:S3 (Non-critical)
Version:5.5 OS:Mac OS X (10.6.4, 64 bit )
Assigned to: Jon Olav Hauglid CPU Architecture:Any

[6 Sep 2010 13:19] Jon Olav Hauglid
Description:
Running lowercase_table2.test from mysql-5.5-runtime causes the assert at sql_trigger.cc:1910 (Table_triggers_list::change_table_name()) to be triggered:

  /*
    This method interfaces the mysql server code protected by
    an exclusive metadata lock.
  */
  DBUG_ASSERT(thd->mdl_context.is_lock_owner(MDL_key::TABLE, db, old_table,
                                             MDL_EXCLUSIVE));

Line 24 in the test: "RENAME TABLE T1 TO T2".

old_table is "T1", while the lock held is on "t1".

How to repeat:
CREATE TABLE T1 (a INT);
RENAME TABLE T1 TO T2;

Or run lowercase_table2.test.
[6 Sep 2010 15:07] Valeriy Kravchuk
Verified with current mysql-5.5 from bzr:

Version: '5.5.7-m3-debug'  socket: '/tmp/mysql.sock'  port: 3306  Source distribution
Assertion failed: (thd->mdl_context.is_lock_owner(MDL_key::TABLE, db, old_table, MDL_EXCLUSIVE)), function change_table_name, file sql_trigger.cc, line 1911.
100906 18:05:32 - mysqld got signal 6 ;
...
[8 Sep 2010 8:33] 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/117757

3134 Jon Olav Hauglid	2010-09-08
      Bug #56595 RENAME TABLE causes assert on OS X
      
      The problem was that RENAME TABLE caused an assert if the system variable
      lower_case_table_names was 2 (default on Mac OS X) and the old table name
      was given in upper case. This was also seen in the lowercase_table2.test.
      
      The assert checks that an exclusive metadata lock is held by the connection
      trying to do RENAME TABLE - specificially during updates of triggers.
      The assert was triggered since the check is case sensitive and the lock
      was held on the lower case table name.
      
      This patch fixes the problem by making sure the lower case version of the
      table name is used for Table_triggers_list::change_table_name() and thus
      also the metadata lock check, similar to what is already done for
      ALTER TABLE ... RENAME.
      
      No test case added since this problem is already covered by 
      lowercase_table2.test
[8 Sep 2010 10:00] 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/117766

3133 Jon Olav Hauglid	2010-09-08
      Bug #56595 RENAME TABLE causes assert on OS X
      
      The problem was that RENAME TABLE caused an assert if the system variable
      lower_case_table_names was 2 (default on Mac OS X) and the old table name
      was given in upper case. This was also seen in the lowercase_table2.test.
      
      The assert checks that an exclusive metadata lock is held by the connection
      trying to do RENAME TABLE - specificially during updates of triggers.
      The assert was triggered since the check is case sensitive and the lock
      was held on the lower case table name.
      
      This patch fixes the problem by making sure the lower case version of the
      table name is used for Table_triggers_list::change_table_name() and thus
      also the metadata lock check, similar to what is already done for
      ALTER TABLE ... RENAME.
      
      No test case added since this problem is already covered by 
      lowercase_table2.test
[13 Sep 2010 17:02] 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/118110

3136 Jon Olav Hauglid	2010-09-13
      Bug #56595 RENAME TABLE causes assert on OS X
      
      The problem was that RENAME TABLE caused an assert if the system variable
      lower_case_table_names was 2 (default on Mac OS X) and the old table name
      was given in upper case. This caused lowercase_table2.test to fail.
      
      The assert checks that an exclusive metadata lock is held by the connection
      trying to do RENAME TABLE - specificially during updates of table triggers.
      The assert was triggered since the check is case sensitive and the lock
      was held on the normalized (lower case) version of the table name.
      
      This patch fixes the problem by making sure a normalized version of the
      table name is used for the metadata lock check, while using a non-normalized
      version of the table name for the rename of trigger files. The same is done
      for ALTER TABLE ... RENAME.
      
      No test case added since this problem is already covered by 
      lowercase_table2.test
[15 Sep 2010 9:10] 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/118283

3137 Jon Olav Hauglid	2010-09-15
      Bug #56595 RENAME TABLE causes assert on OS X
      
      The problem was that RENAME TABLE caused an assert if the system variable
      lower_case_table_names was 2 (default on Mac OS X) and the old table name
      was given in upper case. This caused lowercase_table2.test to fail.
      
      The assert checks that an exclusive metadata lock is held by the connection
      trying to do RENAME TABLE - specificially during updates of table triggers.
      The assert was triggered since the check is case sensitive and the lock
      was held on the normalized (lower case) version of the table name.
      
      This patch fixes the problem by making sure a normalized version of the
      table name is used for the metadata lock check, while using a non-normalized
      version of the table name for the rename of trigger files. The same is done
      for ALTER TABLE ... RENAME.
      
      No test case added since this problem is already covered by 
      lowercase_table2.test
[16 Sep 2010 9: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/118352

3138 Jon Olav Hauglid	2010-09-16
      Bug #56595 RENAME TABLE causes assert on OS X
      
      The problem was that RENAME TABLE caused an assert if the system variable
      lower_case_table_names was 2 (default on Mac OS X) and the old table name
      was given in upper case. This caused lowercase_table2.test to fail.
      
      The assert checks that an exclusive metadata lock is held by the connection
      trying to do RENAME TABLE - specificially during updates of table triggers.
      The assert was triggered since the check is case sensitive and the lock
      was held on the normalized (lower case) version of the table name.
      
      This patch fixes the problem by making sure a normalized version of the
      table name is used for the metadata lock check, while using a non-normalized
      version of the table name for the rename of trigger files. The same is done
      for ALTER TABLE ... RENAME.
      
      Regression testing for the bug itself is already covered by
      lowercase_table2.test. Additional coverage added to lowercase_fs_off.test.
[16 Sep 2010 10:33] Jon Olav Hauglid
Pushed to mysql-5.5-runtime (5.5.7-m3).
[23 Sep 2010 11:53] Mattias Jonsson
Marked bug#56777 as duplicate of this.
[9 Nov 2010 19:44] Bugs System
Pushed into mysql-5.5 5.5.7-rc (revid:sunanda.menon@sun.com-20101109182959-otkxq8vo2dcd13la) (version source revid:marko.makela@oracle.com-20100824081003-v4ecy0tga99cpxw2) (merge vers: 5.1.50) (pib:21)
[12 Nov 2010 1:48] Paul Dubois
Noted in 5.5.7 changelog,

On Mac OS X, RENAME TABLE raised an assertion if the
lower_case_table_names system variable was 2 and the old table name
was specified in uppercase.
[13 Nov 2010 16:11] Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:marko.makela@oracle.com-20100824081003-v4ecy0tga99cpxw2) (merge vers: 5.1.50) (pib:21)
[13 Nov 2010 16:31] Bugs System
Pushed into mysql-next-mr (revid:alexander.nozdrin@oracle.com-20101113160336-atmtmfb3mzm4pz4i) (version source revid:marko.makela@oracle.com-20100824081003-v4ecy0tga99cpxw2) (pib:21)