Bug #17137 Running "truncate table" on temporary table leaves the table open on a slave
Submitted: 5 Feb 2006 17:53 Modified: 14 Mar 2006 18:35
Reporter: [ name withheld ] Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:4.1.19-BK, 4.1.11a-4sarge2 OS:Linux (Linux)
Assigned to: Magnus Blåudd CPU Architecture:Any

[5 Feb 2006 17:53] [ name withheld ]
Description:
Master-slave replication set up with 4.1.11a.

How to repeat:
On the master, execute:

create temporary table foo (a int); truncate foo; drop temporary table foo;

On the slave, observe that Slave_open_temp_tables increases by 1 for each time your execute that sequence of queries.

[Note that delete from foo does not do this, only truncate foo]
[12 Feb 2006 14:48] Valeriy Kravchuk
Thank you for a bug report. Verified just as described with 4.1.19-BK (ChangeSet@1.2469, 2006-02-11 23:35:23+01:00) build on Linux.
[17 Feb 2006 13:45] 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/2785
[8 Mar 2006 8:42] Magnus Blåudd
When the temp table is truncated it will be closed, "regenerated" and then reopened. During this process it forgets to decrease the counter of open temp tables when it closes the temp table, but it will increase when it's repoened. This means that the temp table are closed/opened correctly, but the counter is wrong.
[8 Mar 2006 8:43] Magnus Blåudd
Patch is approved, will just rework it a little before pushing.
[8 Mar 2006 9:16] 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/3575
[8 Mar 2006 13:30] Magnus Blåudd
Pushed to 4.1.19
[8 Mar 2006 14:41] Magnus Blåudd
Pushed to 5.0.20
[9 Mar 2006 4:01] [ name withheld ]
Thanks!
[9 Mar 2006 11:10] Magnus Blåudd
Pushed to 5.1.8
[9 Mar 2006 12:02] Magnus Blåudd
Bug existed only in 4.1 and 5.0. Worked without patch in 5.1 although the testcase was pushed there as well.
[14 Mar 2006 18:35] Paul Dubois
Noted in 4.1.19, 5.0.20, 5.1.8 changelogs.

Use of <literal>TRUNCATE TABLE</literal> for a
<literal>TEMPORARY</literal> table on a master server was
propagated to slaves properly, but slaves did not decrement
the <literal>Slave_open_temp_tables</literal> counter
properly. (Bug #17137)