Bug #51851 | Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table | ||
---|---|---|---|
Submitted: | 9 Mar 2010 5:32 | Modified: | 16 Nov 2010 15:48 |
Reporter: | Elena Stepanova | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Partitions | Severity: | S2 (Serious) |
Version: | 5.1, 5.6.99-m4, 5.5.3-m3 | OS: | Any |
Assigned to: | Mattias Jonsson | CPU Architecture: | Any |
[9 Mar 2010 5:32]
Elena Stepanova
[23 Mar 2010 8:57]
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/104055 3001 Dao-Gang.Qu@sun.com 2010-03-23 Bug #51851 Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table In a multi-row insert statement like INSERT SELECT and LOAD DATA where the number of candidate rows to insert is not known in advance we must hold a lock/mutex for the whole statement if we have statement based replication. Because the statement-based binary log contains only the first generated value used by the statement, and slaves assumes all other generated values used by this statement were consecutive to this first one, we must exclusively lock the generator until the statement is done. It will be unlocked at the end of the statement by ha_partition::release_auto_increment. During the process, the thread tries to lock it when updating the MyISAM table share info. So the mutex is locked twice on LOAD DATA into partitioned MyISAM table. To fix the problem, updating the MyISAM table share info before the lock is held by a multi-row insert statement. @ mysql-test/extra/rpl_tests/rpl_loaddata.test Added test case to verify whether server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table. @ mysql-test/suite/ndb/r/ndb_load.result The test result is updated by the patch of bug#51851. @ mysql-test/suite/ndb/t/ndb_load.test Update the test to adapt the patch of Bug#51851. @ mysql-test/suite/rpl/r/rpl_loaddata.result Test result for the patch of Bug#51851. @ sql/sql_load.cc
[26 Mar 2010 6:04]
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/104405 3001 Dao-Gang.Qu@sun.com 2010-03-26 Bug #51851 Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table In a multi-row insert statement like INSERT SELECT and LOAD DATA where the number of candidate rows to insert is not known in advance we must hold a lock/mutex for the whole statement if we have statement based replication. Because the statement-based binary log contains only the first generated value used by the statement, and slaves assumes all other generated values used by this statement were consecutive to this first one, we must exclusively lock the generator until the statement is done. It will be unlocked at the end of the statement by ha_partition::release_auto_increment. During the process, the thread tries to lock it when updating the MyISAM table share info. So the mutex is locked twice on LOAD DATA into partitioned MyISAM table. To fix the problem, release the auto increment after all the rows are inserted and before the MyISAM table share info is updated.
[26 Mar 2010 11:26]
Mattias Jonsson
The bug is that ha_data is used for storage engine specific data, but since partitioning uses storage engines itself there is a conflict here. I will probably solve this by creating a partition specific data area.
[26 Mar 2010 11:26]
Daogang Qu
Discussed with Mattias and he think this is a pure HANDLER bug. So reassigned the bug to Mattias as Mattias recommended.
[30 Mar 2010 21:23]
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/104667 3008 Mattias Jonsson 2010-03-30 Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Problem was that the ha_data structure was introduced in 5.1 and only used for partitioning first, but with the intention of be of use for others engines as well, and when used by other engines it would clash if it also was partitioned. Solution is to move the partitioning specific data to a separate structure, with its own mutex (which is used for auto_increment). Also did rename PARTITION_INFO to PARTITION_STATS since there already exist a class named partition_info, also cleaned up some related variables. @ mysql-test/r/partition_binlog_stmt.result Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table New result file @ mysql-test/t/partition_binlog_stmt.test Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table New result file @ sql/ha_ndbcluster.cc Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Rename of PARTITION_INFO to PARTITION_STATS to better match the use (and there is also a class named partition_info...) @ sql/ha_ndbcluster.h Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Rename of PARTITION_INFO to PARTITION_STATS to better match the use (and there is also a class named partition_info...) @ sql/ha_partition.cc Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Removed the partitioning engines use of ha_data in TABLE_SHARE and added ha_part_data instead, since they collide if used in the same time. Rename of PARTITION_INFO to PARTITION_STATS to better match the use (and there is also a class named partition_info...) Removed some dead code. @ sql/ha_partition.h Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Removed some dead code. Rename of PARTITION_INFO to PARTITION_STATS to better match the use (and there is also a class named partition_info...) Removed the partitioning engines use of ha_data in TABLE_SHARE and added ha_part_data instead, since they collide if used in the same time. @ sql/handler.cc Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Rename of PARTITION_INFO to PARTITION_STATS to better match the use (and there is also a class named partition_info...) @ sql/handler.h Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Rename of PARTITION_INFO to PARTITION_STATS to better match the use (and there is also a class named partition_info...) @ sql/mysql_priv.h Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Removed the partitioning engines use of ha_data in TABLE_SHARE and added ha_part_data instead, since they collide if used in the same time. Added key_PARTITION_LOCK_auto_inc for instrumentation. @ sql/mysqld.cc Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Removed the partitioning engines use of ha_data in TABLE_SHARE and added ha_part_data instead, since they collide if used in the same time. Added key_PARTITION_LOCK_auto_inc for instrumentation. @ sql/partition_info.h Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Removed part_state* since it was not in use. @ sql/sql_partition.cc Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Removed part_state* since it was not in use. @ sql/sql_partition.h Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Cleaned up old commented out code. Removed part_state* since it was not in use. @ sql/sql_show.cc Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Rename of PARTITION_INFO to PARTITION_STATS to better match the use (and there is also a class named partition_info...) Renamed partition_info to partition_info_str, since partition_info is a name of a class. @ sql/sql_table.cc Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Renamed partition_info to partition_info_str, since partition_info is a name of a class. @ sql/table.cc Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Removed the partitioning engines use of ha_data in TABLE_SHARE and added ha_part_data instead, since they collide if used in the same time. Renamed partition_info to partition_info_str, since partition_info is a name of a class. removed part_state* since it was not in use. @ sql/table.h Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Removed the partitioning engines use of ha_data in TABLE_SHARE and added ha_part_data instead, since they collide if used in the same time. Renamed partition_info to partition_info_str, since partition_info is a name of a class. removed part_state* since it was not in use.
[29 Apr 2010 10:29]
Mikael Ronström
Could consider declaring as HA_DATA_PARTITION* in TABLE_SHARE instead of as void*
[24 May 2010 12:53]
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/109057 3057 Mattias Jonsson 2010-05-24 [merge] Merge of bug#51851. Also moved HA_DATA_PARTITION from ha_partition.cc to table.h.
[25 May 2010 7:18]
Mattias Jonsson
pushed into mysql-trunk-bugfixing, mysql-next-mr-bugfixing and mysql-6.0-codebase-bugfixing
[15 Jun 2010 8:14]
Bugs System
Pushed into 5.5.5-m3 (revid:alik@sun.com-20100615080459-smuswd9ooeywcxuc) (version source revid:mmakela@bk-internal.mysql.com-20100415070122-1nxji8ym4mao13ao) (merge vers: 5.1.47) (pib:16)
[15 Jun 2010 8:30]
Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100615080558-cw01bzdqr1bdmmec) (version source revid:mmakela@bk-internal.mysql.com-20100415070122-1nxji8ym4mao13ao) (pib:16)
[5 Jul 2010 16:58]
Jon Stephens
Documented in the 5.5.5 changelog as follows: Attempting to execute LOAD DATA on a partitioned MyISAM table while using statement-based logging mode caused the master to hang or crash. Set to Needs Merge.
[12 Aug 2010 0:13]
Chris Ferraro
related bug? http://bugs.mysql.com/46300 If so, seeing in 5.1 also.
[2 Sep 2010 15:56]
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/117437 3498 Mattias Jonsson 2010-09-02 Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Problem was that both partitioning and myisam used the same table_share->mutex for different protections (auto inc and repair). Solved by adding a specific mutex for the partitioning auto_increment. This is a 5.1 ONLY patch, already fixed in 5.5+.
[1 Oct 2010 11: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/119631 3498 Mattias Jonsson 2010-10-01 Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Problem was that both partitioning and myisam used the same table_share->mutex for different protections (auto inc and repair). Solved by adding a specific mutex for the partitioning auto_increment. Also adding destroying the ha_data structure in free_table_share (which is to be propagated into 5.5). This is a 5.1 ONLY patch, already fixed in 5.5+.
[1 Oct 2010 11:40]
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/119634 3498 Mattias Jonsson 2010-10-01 Bug#51851: Server with SBR locks mutex twice on LOAD DATA into partitioned MyISAM table Problem was that both partitioning and myisam used the same table_share->mutex for different protections (auto inc and repair). Solved by adding a specific mutex for the partitioning auto_increment. Also adding destroying the ha_data structure in free_table_share (which is to be propagated into 5.5). This is a 5.1 ONLY patch, already fixed in 5.5+.
[1 Oct 2010 12:19]
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/119653 3213 Mattias Jonsson 2010-10-01 [merge] Manual merge of bug#51851 from mysql-5.1-bugteam into mysql-5.5-bugteam
[1 Oct 2010 19:42]
Mattias Jonsson
pushed to mysql-5.1-bugteam, mysql-5.5-bugteam and mysql-trunk-merge
[4 Oct 2010 12:56]
Jon Stephens
Set Need Merge status, as this is already documented in 5.5, and it appears that we're still waiting for a push to 5.1.
[5 Oct 2010 14:46]
Mattias Jonsson
Closed bug#43477 as a duplicate of this.
[6 Oct 2010 12:31]
Jon Stephens
Bugfix also documented in the 5.1.52 changelog. Closed.
[1 Nov 2010 19:01]
Bugs System
Pushed into mysql-5.1 5.1.53 (revid:build@mysql.com-20101101184443-o2olipi8vkaxzsqk) (version source revid:build@mysql.com-20101101184443-o2olipi8vkaxzsqk) (merge vers: 5.1.53) (pib:21)
[9 Nov 2010 19:45]
Bugs System
Pushed into mysql-5.5 5.5.7-rc (revid:sunanda.menon@sun.com-20101109182959-otkxq8vo2dcd13la) (version source revid:sunanda.menon@sun.com-20101109182959-otkxq8vo2dcd13la) (merge vers: 5.5.7-rc) (pib:21)
[13 Nov 2010 16:07]
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:36]
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)
[16 Nov 2010 13:46]
Jon Stephens
No new changelog entries required. Returning to Closed state.