Bug #29329 Explicit commit complaints
Submitted: 25 Jun 2007 3:37 Modified: 13 Dec 2007 20:21
Reporter: Brian Moon Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server: Stored Routines Severity:S3 (Non-critical)
Version:5.0.38 OS:Linux (Gentoo)
Assigned to: Assigned Account CPU Architecture:Any

[25 Jun 2007 3:37] Brian Moon
Description:
We have two identical tables.  One is an archive for inactive records.  We move data back and forth between the two.  We have triggers on the active table.  We occasionally (not always as other bugs about this error seem to indicate) get the error: "Explicit or implicit commit is not allowed in stored function or trigger."

The tables are:

CREATE TABLE `coupon` (
  `coupon_id` int(10) unsigned NOT NULL auto_increment,
  `article_id` int(10) unsigned NOT NULL default '0',
  `vendor_id` int(10) unsigned NOT NULL default '0',
  `type` enum('FIXED','PERCENT','SHIPPING','FREETEXT') NOT NULL default 'FIXED',
  `discount` decimal(14,2) NOT NULL default '0.00',
  `minimum` decimal(14,2) NOT NULL default '0.00',
  `shipping` decimal(14,2) NOT NULL default '0.00',
  `customer_type` enum('NEW','OLD','ALL') NOT NULL default 'ALL',
  `code` varchar(64) NOT NULL default '',
  `url` varchar(255) NOT NULL default '',
  `tos` varchar(255) NOT NULL default '',
  `author_login` varchar(10) NOT NULL default '',
  `editor_login` varchar(10) NOT NULL default '',
  `mod_time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `expiration_time` timestamp NOT NULL default '0000-00-00 00:00:00',
  `requested_publish_time` timestamp NOT NULL default '0000-00-00 00:00:00',
  `requested_end_time` timestamp NOT NULL default '0000-00-00 00:00:00',
  `first_publish_time` timestamp NOT NULL default '0000-00-00 00:00:00',
  `latest_publish_time` timestamp NOT NULL default '0000-00-00 00:00:00',
  `status` char(2) NOT NULL default '',
  `comments` varchar(255) NOT NULL default '',
  `rating` decimal(14,2) NOT NULL default '0.00',
  `tip_id` int(10) unsigned NOT NULL default '0',
  `freetext` varchar(255) NOT NULL default '',
  `pop_score` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`coupon_id`),
  KEY `article_id` (`article_id`),
  KEY `first_publish_time` (`first_publish_time`),
  KEY `latest_publish_time` (`latest_publish_time`),
  KEY `requested_publish_time` (`requested_publish_time`),
  KEY `mod_time` (`mod_time`),
  KEY `vendor_id` (`vendor_id`),
  KEY `type` (`type`),
  KEY `status` (`status`),
  KEY `expiration_time` (`expiration_time`),
  KEY `discount` (`discount`),
  KEY `minimum` (`minimum`),
  KEY `shipping` (`shipping`),
  KEY `tip_id` (`tip_id`),
  KEY `pop_score` (`pop_score`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

CREATE TABLE `coupon_archive` (
  `coupon_id` int(10) unsigned NOT NULL auto_increment,
  `article_id` int(10) unsigned NOT NULL default '0',
  `vendor_id` int(10) unsigned NOT NULL default '0',
  `type` enum('FIXED','PERCENT','SHIPPING','FREETEXT') NOT NULL default 'FIXED',
  `discount` decimal(14,2) NOT NULL default '0.00',
  `minimum` decimal(14,2) NOT NULL default '0.00',
  `shipping` decimal(14,2) NOT NULL default '0.00',
  `customer_type` enum('NEW','OLD','ALL') NOT NULL default 'ALL',
  `code` varchar(64) NOT NULL default '',
  `url` varchar(255) NOT NULL default '',
  `tos` varchar(255) NOT NULL default '',
  `author_login` varchar(10) NOT NULL default '',
  `editor_login` varchar(10) NOT NULL default '',
  `mod_time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  `expiration_time` timestamp NOT NULL default '0000-00-00 00:00:00',
  `requested_publish_time` timestamp NOT NULL default '0000-00-00 00:00:00',
  `requested_end_time` timestamp NOT NULL default '0000-00-00 00:00:00',
  `first_publish_time` timestamp NOT NULL default '0000-00-00 00:00:00',
  `latest_publish_time` timestamp NOT NULL default '0000-00-00 00:00:00',
  `status` char(2) NOT NULL default '',
  `comments` varchar(255) NOT NULL default '',
  `rating` decimal(14,2) NOT NULL default '0.00',
  `tip_id` int(10) unsigned NOT NULL default '0',
  `freetext` varchar(255) NOT NULL default '',
  `pop_score` int(10) unsigned NOT NULL default '0',
  PRIMARY KEY  (`coupon_id`),
  KEY `article_id` (`article_id`),
  KEY `first_publish_time` (`first_publish_time`),
  KEY `latest_publish_time` (`latest_publish_time`),
  KEY `requested_publish_time` (`requested_publish_time`),
  KEY `mod_time` (`mod_time`),
  KEY `vendor_id` (`vendor_id`),
  KEY `type` (`type`),
  KEY `tip_id` (`tip_id`),
  KEY `pop_score` (`pop_score`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

with these triggers:

*************************** 1. row ***************************
  Trigger: queue_coupon_insert
    Event: INSERT
    Table: coupon
Statement: insert ignore into coupon_publish_queue values (NEW.coupon_id, 1, now())
   Timing: AFTER
  Created: NULL
 sql_mode: 
  Definer: admin@10.1.%
*************************** 2. row ***************************
  Trigger: queue_coupon_update
    Event: UPDATE
    Table: coupon
Statement: insert ignore into coupon_publish_queue values (NEW.coupon_id, 1, now())
   Timing: AFTER
  Created: NULL
 sql_mode: 
  Definer: admin@10.1.%
*************************** 3. row ***************************
  Trigger: queue_coupon_delete
    Event: DELETE
    Table: coupon
Statement: insert ignore into coupon_publish_queue values (OLD.coupon_id, 1, now())
   Timing: AFTER
  Created: NULL
 sql_mode: 
  Definer: admin@10.1.%

coupon_publish_queue is as follows:

CREATE TABLE `coupon_publish_queue` (
  `coupon_id` int(10) unsigned NOT NULL default '0',
  `priority` tinyint(3) unsigned NOT NULL default '0',
  `queue_time` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  PRIMARY KEY  (`priority`,`queue_time`,`coupon_id`),
  UNIQUE KEY `coupon_id` (`coupon_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

How to repeat:
using tables above with about 1000 rows in each table, run:

replace into coupon Select * from coupon_archive where coupon_id in (48811, 48812, 49540, 50844, 51018, 52443, 52455, 52467, 52475, 52524, 52537, 52551, 52559)

This query (with different coupon_ids) runs 1000's of times per day.  We see maybe 10-20 of these errors.

Suggested fix:
Well, the other bug reports and pages I have found talking about this error seemed to indicate you should see it all the time.  I do not, so I assume its an error.
[18 Jul 2007 8:56] Sveta Smirnova
This seems to be related to bug #24989

Need to check when fix will be available.
[12 Nov 2007 8:48] Sveta Smirnova
Thank you for the report.

This seems to be related to bug #24989. Please try to repeat with version 5.0.50 and inform as about results.
[12 Nov 2007 15:43] Brian Moon
Unfortunately we have went away from MySQL Cluster at this point.  So, I guess do what you will with this bug.
[13 Nov 2007 20:21] Sveta Smirnova
Thank you for the feedback.

I'll set status of the report to "Need feedback". Please inform us when you can test if this is identical to bug #24989.
[14 Dec 2007 0:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".