Bug #55421 Protocol::end_statement(): Assertion `0' on multi-table UPDATE IGNORE
Submitted: 21 Jul 2010 0:55 Modified: 7 Oct 2010 23:04
Reporter: Elena Stepanova Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.1-debug, 5.5-debug OS:Any
Assigned to: Dmitry Shulga
Triage: Triaged: D1 (Critical)

[21 Jul 2010 0:55] Elena Stepanova
Description:
#6  0x00002ad08ff37286 in __assert_fail () from /lib64/libc.so.6
#7  0x000000000053ce12 in Protocol::end_statement (this=0x1819f30)
    at mysql-5.5.6-m3/sql/protocol.cc:540
#8  0x00000000005ce59c in dispatch_command (command=COM_QUERY, thd=0x1819a80,
    packet=0x18d6b61 "UPDATE IGNORE t_celosia_1 table1, t_celosia_2 table2 \nSET table1.user_num = 192720, table2.user_num = '39582' \nWHERE table1.year = '1937' AND table2.year = '56'", packet_length=160) at mysql-5.5.6-m3/sql/sql_parse.cc:1503
#9  0x00000000005ce964 in do_command (thd=0x1819a80) at mysql-5.5.6-m3/sql/sql_parse.cc:807
#10 0x00000000006a2d94 in do_handle_one_connection (thd_arg=0x1819a80)
    at mysql-5.5.6-m3/sql/sql_connect.cc:1191
#11 0x00000000006a2e5d in handle_one_connection (arg=0x1819a80)
    at mysql-5.5.6-m3/sql/sql_connect.cc:1130
#12 0x0000000000915c37 in pfs_spawn_thread (arg=0x187a6b0)
    at mysql-5.5.6-m3/storage/perfschema/pfs.cc:1015
#13 0x00002ad08f85d143 in start_thread () from /lib64/libpthread.so.0
#14 0x00002ad08ffce8cd in clone () from /lib64/libc.so.6

Version: '5.5.6-m3-debug-log'  socket: 'mysql-5.5.6-m3-linux-x86_64/mysql-test/var/tmp/mysqld.1.sock'  port: 1
3000  Source distribution
mysqld: mysql-5.5.6-m3/sql/protocol.cc:540: void Protocol::end_statement(): Assertion `0' failed.
100721  3:38:52 - mysqld got signal 6 ;

thd->query at 0x189ddc0 = UPDATE IGNORE t_celosia_1 table1, t_celosia_2 table2
SET table1.user_num = 192720, table2.user_num = '39582'
WHERE table1.year = '1937' AND table2.year = '56'
thd->thread_id=2

Reproducible on older 5.1 versions (tried 5.1.39).

How to repeat:
# Non-concurrent MTR test

--disable_warnings
DROP DATABASE IF EXISTS celosia_features;
--enable_warnings

CREATE DATABASE celosia_features;
USE celosia_features;

GRANT ALL ON celosia_features.* TO 'systuser'@'localhost';

--connect(con1,localhost,systuser,,celosia_features)

CREATE TABLE t_celosia_1 (
  `user_num` bigint(20) unsigned DEFAULT NULL,
  `year` year(4) DEFAULT NULL,
  `modified` time DEFAULT NULL
);
INSERT INTO t_celosia_1 VALUES (7197513499,1937,'20:36:48');

CREATE TRIGGER celosia_features.upd_t_celosia_1
BEFORE UPDATE ON t_celosia_1 FOR EACH ROW SET new.modified = NOW();

CREATE TABLE `t_celosia_2` (
  `user_num` char(5) DEFAULT NULL,
  `year` year(2) DEFAULT NULL,
  `modified` timestamp NOT NULL
);

INSERT INTO `t_celosia_2` VALUES ('32264',56,'2010-07-18 17:36:31');

--connection default

REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'systuser'@'localhost';

UPDATE IGNORE t_celosia_1 table1, t_celosia_2 table2
SET table1.user_num = 192720, table2.user_num = '39582'
WHERE table1.year = '1937' AND table2.year = '56';

# Cleanup

DROP DATABASE celosia_features;
DROP USER 'systuser'@'localhost';

--exit
[21 Jul 2010 21:36] Elena Stepanova
See also bug#55458 - test case with a partitioned table getting crashed, causes the same assertion failure if it is run on a debug version with UPDATE IGNORE instead of UPDATE.
[26 Aug 2010 12:49] 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/116875

3485 Dmitry Shulga	2010-08-26
      Fixed bug #55421 - Protocol::end_statement(): Assertion `0' on
      multi-table UPDATE IGNORE.
     @ mysql-test/r/trigger_notembedded.result
        added test case result for bug #55421.
     @ mysql-test/t/trigger_notembedded.test
        added test case for bug #55421.
     @ sql/sql_trigger.cc
        Reset thd->lex->current_select before start trigger execution
        and restore its original value after execution is finished.
        This is neccessery in order to set error status in 
        diagnostic_area in case of trigger execution failure.
[27 Aug 2010 9:13] 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/116966

3485 Dmitry Shulga	2010-08-27
      Fixed bug #55421 - Protocol::end_statement(): Assertion `0' on
      multi-table UPDATE IGNORE.
      The problem was that if there was an active SELECT statement
      during trigger execution, an error risen during the execution
      may cause a crash. The fix is to temporary reset LEX::current_select
      before trigger execution and restore it afterwards. This way
      errors risen during the trigger execution are processed as
      if there was no active SELECT.
     @ mysql-test/r/trigger_notembedded.result
        added test case result for bug #55421.
     @ mysql-test/t/trigger_notembedded.test
        added test case for bug #55421.
     @ sql/sql_trigger.cc
        Reset thd->lex->current_select before start trigger execution
        and restore its original value after execution is finished.
        This is neccessery in order to set error status in 
        diagnostic_area in case of trigger execution failure.
[7 Sep 2010 8: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/117678

3501 Dmitry Shulga	2010-09-07
      Fixed bug #55421 - Protocol::end_statement(): Assertion `0' on
      multi-table UPDATE IGNORE.
      The problem was that if there was an active SELECT statement
      during trigger execution, an error risen during the execution
      may cause a crash. The fix is to temporary reset LEX::current_select
      before trigger execution and restore it afterwards. This way
      errors risen during the trigger execution are processed as
      if there was no active SELECT.
     @ mysql-test/r/trigger_notembedded.result
        added test case result for bug #55421.
     @ mysql-test/t/trigger_notembedded.test
        added test case for bug #55421.
     @ sql/sql_trigger.cc
        Reset thd->lex->current_select before start trigger execution
        and restore its original value after execution is finished.
        This is neccessery in order to set error status in 
        diagnostic_area in case of trigger execution failure.
[10 Sep 2010 8:29] Dmitry Shulga
Pushed to mysql-5.1-bugteam. Merged and pushed to mysql-5.5-merge.
[28 Sep 2010 15:39] Bugs System
Pushed into mysql-trunk 5.6.1-m4 (revid:alik@sun.com-20100928153607-tdsxkdm5cmuym5sq) (version source revid:alik@sun.com-20100928153508-0saa6v93dinqx1u7) (merge vers: 5.6.1-m4) (pib:21)
[28 Sep 2010 15:41] Bugs System
Pushed into mysql-next-mr (revid:alik@sun.com-20100928153646-pqp8o1a92mxtuj3h) (version source revid:alik@sun.com-20100928153532-lr3gtvnyp2en4y75) (pib:21)
[28 Sep 2010 15:44] Bugs System
Pushed into mysql-5.5 5.5.7-rc (revid:alik@sun.com-20100928153459-4nudf4zgzlou4s7q) (version source revid:alik@sun.com-20100928153459-4nudf4zgzlou4s7q) (merge vers: 5.5.7-rc) (pib:21)
[1 Oct 2010 17:59] Paul Dubois
Noted in 5.5.7, 5.6.1 changelogs.

If there was an active SELECT statement, an error arising during
trigger execution could cause a server crash.

Setting report to Need Merge pending push to 5.1.x.
[3 Oct 2010 1:21] Paul Dubois
Setting to Need Merge pending push to 5.1.x.
[7 Oct 2010 23:04] Paul Dubois
Noted in 5.1.52 changelog.
[1 Nov 2010 19:00] 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)