Bug #51226 | mysqlbinlog replay: ERROR 1146 when using temp tables + failing statements | ||
---|---|---|---|
Submitted: | 16 Feb 2010 23:18 | Modified: | 21 Jun 2010 0:55 |
Reporter: | Victor Kirkebo | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Replication | Severity: | S3 (Non-critical) |
Version: | 5.1.44, 6.0-backup | OS: | Any |
Assigned to: | Luis Soares | CPU Architecture: | Any |
Tags: | error 1146, mysqlbinlog, replay, table, temp, temporary |
[16 Feb 2010 23:18]
Victor Kirkebo
[19 Feb 2010 14:48]
Susanne Ebrecht
Verified as described.
[22 Feb 2010 16:46]
Luis Soares
Related: BUG#35583.
[22 Feb 2010 22:46]
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/101142 3341 Luis Soares 2010-02-22 BUG#51226: mysqlbinlog replay: ERROR 1146 when using temp tables + failing statements This is a small regression from BUG@35583 which happens in a very particular situation. Consider two connections con1 and con2, where their pseudo_thread_ids are 1 and 2 respectively. Both connections create a temporary table with the same name, say t1. On both connections several statements are executing concurrently, so their events (lets use E1 to identify an event from con1 and E2 for an event from con2) end up in the binary log inter-leaved. Now, picture the case that we have the following sequence: E1,E2,S*1; in which S*1 is a failing statement in con1. Furthermore, assume that after S*1, con1 disconnects and an implicit 'drop temp table t1' is written to the binary log, before any other event from con2 is logged. This causes the implicit drop event to be logged without the proper pseudo_thread_id=1, thence when replaying the binary log, the drop would be executed under the assumption that it had been originally processed under con2. This happens because right before starting execution of S*1 the thread context is reset, and consequently the thread_specific_used flag is unset (note: this is one of the flags that transitively controls logging and printing of pseudo_thread_id in the event header). Since S*1 fails and right after the connection is be dropped, the thread_specific_used flag would remain unset, the pseudo_thread_id would therefore not be logged. This scenario only happens for the case that we have: E1,E2,S*1 followed by a disconnection. If we had a successful statement executed on con1 before S*1 (E1,E2,E1,S*1 followed by disconnection), there would not be a problem, as the correct pseudo_thread_id would have been logged before S*1. We fix this by setting thread_specific_used whenever we are binlogging a DROP in close_temporary_tables, and resetting it to its previous value afterward.
[3 Mar 2010 12:17]
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/102185 3341 Luis Soares 2010-03-03 BUG#51226: mysqlbinlog replay: ERROR 1146 when using temp tables + failing statements Implicit DROP event for temporary table is not getting LOG_EVENT_THREAD_SPECIFIC_F flag, because, in the previous executed statement in the same thread, which might even be a failed statement, the thread_specific_used flag is set to FALSE (in mysql_reset_thd_for_next_command) and not set to TRUE before connection is shutdown. This means that implicit DROP event will take the FALSE value from thread_specific_used and will not set LOG_EVENT_THREAD_SPECIFIC_F in the event header. As a consequence, mysqlbinlog will not print the pseudo_thread_id from the DROP event, because one of the requirements for the printout is that this flag is set to TRUE. We fix this by setting thread_specific_used whenever we are binlogging a DROP in close_temporary_tables, and resetting it to its previous value afterward.
[26 Mar 2010 8:23]
Bugs System
Pushed into 5.5.4-m3 (revid:alik@sun.com-20100326080914-2pz8ns984e0spu03) (version source revid:alexey.kopytov@sun.com-20100312095153-t4rtoqc7p96lmxvh) (merge vers: 5.5.3-m2) (pib:16)
[26 Mar 2010 8:27]
Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100326081116-m3v4l34yhr43mtsv) (version source revid:alik@sun.com-20100325072612-4sds00ix8ajo1e84) (pib:16)
[26 Mar 2010 8:31]
Bugs System
Pushed into 6.0.14-alpha (revid:alik@sun.com-20100326081944-qja07qklw1p2w7jb) (version source revid:alik@sun.com-20100325073410-4t4i9gu2u1pge7xb) (merge vers: 6.0.14-alpha) (pib:16)
[29 Mar 2010 13:55]
Jon Stephens
DOcumented bugfix in the 5.5.4 and 6.0.14 changelogs as follows: When using temporary tables the binary log needs to insert a pseudo-thread ID for threads that are using temporary tables, each time a switch happens between two threads, both of which are using temporary tables. However, if a thread issued a failing statement before exit, its ID was not recorded in the binary log, and this in turn caused the ID for the next thread that tried to do something with a temporary table not to be logged as well. Subsequent replays of the binary log failed with the error Table ... doesn't exist. Set NM status - waiting for 5.1.
[31 Mar 2010 16:04]
Paul DuBois
5.5.4 changelog entry was moved to 5.5.5.
[6 Apr 2010 7:59]
Bugs System
Pushed into 5.1.46 (revid:sergey.glukhov@sun.com-20100405111026-7kz1p8qlzglqgfmu) (version source revid:luis.soares@sun.com-20100308235726-6kptibjdohgj87dh) (merge vers: 5.1.45) (pib:16)
[6 Apr 2010 11:33]
Jon Stephens
Also documented in the 5.1.46 changelog. Closed.
[17 Jun 2010 12:18]
Bugs System
Pushed into 5.1.47-ndb-7.0.16 (revid:martin.skold@mysql.com-20100617114014-bva0dy24yyd67697) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)
[17 Jun 2010 13:05]
Bugs System
Pushed into 5.1.47-ndb-6.2.19 (revid:martin.skold@mysql.com-20100617115448-idrbic6gbki37h1c) (version source revid:martin.skold@mysql.com-20100609211156-tsac5qhw951miwtt) (merge vers: 5.1.46-ndb-6.2.19) (pib:16)
[17 Jun 2010 13:45]
Bugs System
Pushed into 5.1.47-ndb-6.3.35 (revid:martin.skold@mysql.com-20100617114611-61aqbb52j752y116) (version source revid:vasil.dimov@oracle.com-20100331130613-8ja7n0vh36a80457) (merge vers: 5.1.46) (pib:16)