Bug #56114 Disallow trx->dict_operation_lock_mode==RW_X_LATCH in srv_suspend_mysql_thread()
Submitted: 19 Aug 2010 10:10 Modified: 10 Dec 2010 3:40
Reporter: Marko Mäkelä Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: InnoDB storage engine Severity:S3 (Non-critical)
Version:5.1 plugin, 5.5+ OS:Any
Assigned to: Marko Mäkelä CPU Architecture:Any
Tags: DDL, dictionary, innodb, suspend
Triage: Triaged: D4 (Minor) / R1 (None/Negligible) / E1 (None/Negligible)

[19 Aug 2010 10:10] Marko Mäkelä
Description:
In Bug #55028, it was found out that a piece of incorrect code accidentally made it to the InnoDB Plugin.

When I implemented fast index creation aka smart ALTER TABLE (fast DROP INDEX, CREATE INDEX) in the InnoDB Plugin, I initially failed to understand that record or table lock waits (and related deadlocks) are not allowed when accessing the InnoDB data dictionary. This is guaranteed by bracketing all InnoDB dictionary operations with row_mysql_freeze_data_dictionary/row_mysql_unfreeze_data_dictionary or row_mysql_lock_data_dictionary/row_mysql_unlock_data_dictionary, and by creating a separate transaction for DDL operations.

Initially, I failed to create a separate DDL transaction for CREATE INDEX in ha_innobase::add_index(), and I tried to acquire a lock on the user table in the same transaction that accessed the InnoDB data dictionary tables. To remove an assertion failure, I made srv_suspend_mysql_thread() call row_mysql_unlock_data_dictionary() and row_mysql_lock_data_dictionary() when "necessary". That is wrong; a transaction that is holding the data dictionary latch in exclusive mode should never be interrupted by a lock wait.

How to repeat:
N/A (code review)

Suggested fix:
Assert that trx->dict_operation_lock_mode is 0 or RW_S_LATCH in srv_suspend_mysql_thread(). Remove the row_mysql_unlock_data_dictionary() and row_mysql_lock_data_dictionary() calls.
[19 Aug 2010 10:24] 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/116222
[19 Aug 2010 10:24] 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/116223
[19 Aug 2010 10:37] 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/116225
[19 Aug 2010 10:37] 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/116226
[19 Aug 2010 10:48] Sunny Bains
OK to commit!
[19 Aug 2010 12:36] 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/116242
[19 Aug 2010 12:37] 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/116243
[19 Aug 2010 12:39] Marko Mäkelä
In 5.5, we will output an error message if the condition occurs. In 5.6+, an assertion failure will be triggered.
[9 Nov 2010 19:47] 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)
[13 Nov 2010 16:25] Bugs System
Pushed into mysql-trunk 5.6.99-m5 (revid:alexander.nozdrin@oracle.com-20101113155825-czmva9kg4n31anmu) (version source revid:alexander.nozdrin@oracle.com-20101113152450-2zzcm50e7i4j35v7) (merge vers: 5.6.1-m4) (pib:21)
[13 Nov 2010 16:38] Bugs System
Pushed into mysql-next-mr (revid:alexander.nozdrin@oracle.com-20101113160336-atmtmfb3mzm4pz4i) (version source revid:vasil.dimov@oracle.com-20100629074804-359l9m9gniauxr94) (pib:21)
[5 Dec 2010 12:42] Bugs System
Pushed into mysql-trunk 5.6.1 (revid:alexander.nozdrin@oracle.com-20101205122447-6x94l4fmslpbttxj) (version source revid:alexander.nozdrin@oracle.com-20101205122447-6x94l4fmslpbttxj) (merge vers: 5.6.1) (pib:23)