Bug #34306 Can't make copy of log tables when server binary log is enabled

Submitted: 5 Feb 2008 11:40 Modified: 29 Jun 2009 16:00
Reporter: Carsten Pedersen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Locking Severity:S2 (Serious)
Version:5.1.26-rc OS:Any
Assigned to: Davi Arnaut CPU Architecture:Any
Tags: csv engine, slow log

[5 Feb 2008 11:40] Carsten Pedersen
Description:
The following statement:

  CREATE TABLE slow SELECT * FROM mysql.slow_log;

Throws an error:

  ERROR 1553 (HY000): You can't use locks with log tables.

I can't for the life of me think why this is necessary. There's nothing that prevents me from doing SELECT * FROM mysql.slow_log, so why should the fact that I do an insert at the same time do so?

More information + workaround: http://www.bitbybit.dk/carsten/blog/?p=115

How to repeat:
CREATE TABLE slow SELECT * FROM mysql.slow_log;

Suggested fix:
Don't lock the table.
[5 Feb 2008 14:49] MySQL Verification Team
Thank you for the bug report. Verified as described.
[9 Jul 2008 17:46] Sveta Smirnova
Bug #37998 about general log was marked as duplicate of this one.
[26 Aug 2008 21:21] Davi Arnaut
Related to Bug#25422 (which contains explanations on the prohibition of locking log tables). Ssee also Bug#29129 and Bug#27858
[4 Sep 2008 3:58] Davi Arnaut
Test case:

--source include/have_log_bin.inc
CREATE TABLE slow SELECT * FROM mysql.slow_log;
[13 Sep 2008 0:44] 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/54021

2683 Davi Arnaut	2008-09-12
      Bug#34306: Can't make copy of log tables when server binary log is enabled
      
      The problem is that when statement-based replication was enabled,
      statements such as INSERT INTO .. SELECT FROM .. and CREATE TABLE
      .. SELECT FROM need to grab a read lock on the source table that
      does not permit concurrent inserts, which would in turn be denied
      if the source table is a log table because log tables can't be
      locked exclusively.
      
      The solution is to not take such a lock when the source table is
      a log table as it is unsafe to replicate log tables under statement
      based replication. Furthermore, the read lock that does not permits
      concurrent inserts is now only taken if statement-based replication
      is enabled and if the source table is not a log table.
[13 Sep 2008 23:31] 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/54035

2683 Davi Arnaut	2008-09-13
      Bug#34306: Can't make copy of log tables when server binary log is enabled
      
      The problem is that when statement-based replication was enabled,
      statements such as INSERT INTO .. SELECT FROM .. and CREATE TABLE
      .. SELECT FROM need to grab a read lock on the source table that
      does not permit concurrent inserts, which would in turn be denied
      if the source table is a log table because log tables can't be
      locked exclusively.
      
      The solution is to not take such a lock when the source table is
      a log table as it is unsafe to replicate log tables under statement
      based replication. Furthermore, the read lock that does not permits
      concurrent inserts is now only taken if statement-based replication
      is enabled and if the source table is not a log table.
[29 Sep 2008 13:54] 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/54659

2690 Davi Arnaut	2008-09-29
      Bug#34306: Can't make copy of log tables when server binary log is enabled
      
      The problem is that when statement-based replication was enabled,
      statements such as INSERT INTO .. SELECT FROM .. and CREATE TABLE
      .. SELECT FROM need to grab a read lock on the source table that
      does not permit concurrent inserts, which would in turn be denied
      if the source table is a log table because log tables can't be
      locked exclusively.
      
      The solution is to not take such a lock when the source table is
      a log table as it is unsafe to replicate log tables under statement
      based replication. Furthermore, the read lock that does not permits
      concurrent inserts is now only taken if statement-based replication
      is enabled and if the source table is not a log table.
[29 Sep 2008 18:38] Davi Arnaut
Queued to 5.1.29-rc
[30 Sep 2008 13:47] 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/54775

2692 Davi Arnaut	2008-09-30
      Bug#34306: Can't make copy of log tables when server binary log is enabled
      
      Post-merge bug fix: lock_type is a enumeration type and not a bit mask.
[30 Sep 2008 13: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/54778

2692 Davi Arnaut	2008-09-30
      Bug#34306: Can't make copy of log tables when server binary log is enabled
      
      Post-merge bug fix: lock_type is a enumeration type and not a bit mask.
[7 Oct 2008 19:15] Paul DuBois
Noted in 5.1.29 changelog.

With binary logging enabled, CREATE TABLE ... SELECT failed if the
source table was a log table. 

Leaving report status unchanged; this is early documentation of an upcoming push into 5.1.29.
[9 Oct 2008 17:59] Bugs System
Pushed into 5.1.30  (revid:davi.arnaut@sun.com-20080930134701-mmn4c1r41qx48l2k) (version source revid:kgeorge@mysql.com-20081001094725-vf4mqjkmajlm22qy) (pib:4)
[9 Oct 2008 18:38] Paul DuBois
Setting report to NDI pending push into 6.0.x.
[17 Oct 2008 16:44] Bugs System
Pushed into 6.0.8-alpha  (revid:davi.arnaut@sun.com-20080930134701-mmn4c1r41qx48l2k) (version source revid:kgeorge@mysql.com-20081001100520-exs1tupnfanm1mij) (pib:5)
[17 Oct 2008 17:20] Paul DuBois
Noted in 6.0.8 changelog.
[28 Oct 2008 21:03] Bugs System
Pushed into 5.1.29-ndb-6.2.17  (revid:davi.arnaut@sun.com-20080930134701-mmn4c1r41qx48l2k) (version source revid:tomas.ulin@sun.com-20081028140209-u4emkk1xphi5tkfb) (pib:5)
[28 Oct 2008 22:22] Bugs System
Pushed into 5.1.29-ndb-6.3.19  (revid:davi.arnaut@sun.com-20080930134701-mmn4c1r41qx48l2k) (version source revid:tomas.ulin@sun.com-20081028194045-0353yg8cvd2c7dd1) (pib:5)
[1 Nov 2008 9:47] Bugs System
Pushed into 5.1.29-ndb-6.4.0  (revid:davi.arnaut@sun.com-20080930134701-mmn4c1r41qx48l2k) (version source revid:jonas@mysql.com-20081101082305-qx5a1bj0z7i8ueys) (pib:5)
[18 Jun 2009 11:34] Sven Sandberg
Please update documentation at http://dev.mysql.com/doc/refman/5.1/en/binary-log-mixed.html
The patch added a new condition under which rbl is used when binlog_format=MIXED; namely, if one of the involved tables has table_category == TABLE_CATEGORY_PERFORMANCE (I don't know what such tables are called - log tables?)
[29 Jun 2009 16:00] Paul DuBois
Noted as requested.

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.091 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.