Bug #12297 SP crashes the server if data inserted inside a lon loop
Submitted: 1 Aug 2005 12:54 Modified: 18 Aug 2005 20:59
Reporter: Victoria Reznichenko Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0 from BK OS:Linux (linux)
Assigned to: Petr Chardin CPU Architecture:Any

[1 Aug 2005 12:54] Victoria Reznichenko
Description:
MySQL server crashes because of stored procedure that inserts data into table within a long loop.

I might be the same bug as #11333, but I'm not sure so I report this bug separately.

Bakctrace:

(gdb) bt
#0  0x08263d25 in MYSQL_LOG::write (this=0x87d8bc0, event_info=0xbddff450) at log.cc:1677
#1  0x081f1be2 in mysql_execute_command (thd=0x8e41e30) at sql_parse.cc:4234
#2  0x081f4e06 in mysql_parse (thd=0x8e41e30, inBuf=0x8e6aee0 "call sp1()", length=10) at sql_parse.cc:5384
#3  0x081ea5dd in dispatch_command (command=COM_QUERY, thd=0x8e41e30, packet=0x8e62e81 "call sp1()", packet_length=11)
    at sql_parse.cc:1664
#4  0x081e9dfb in do_command (thd=0x8e41e30) at sql_parse.cc:1467
#5  0x081e8f12 in handle_one_connection (arg=0x8e41e30) at sql_parse.cc:1116
#6  0xb7dfef1b in pthread_start_thread () from /lib/libpthread.so.0
#7  0xb7dfef9f in pthread_start_thread_event () from /lib/libpthread.so.0
#8  0xb7d2dfda in clone () from /lib/libc.so.6

How to repeat:
CREATE TABLE tbl1 (col1 INTEGER PRIMARY KEY, col2 TEXT) ENGINE=InnoDB;

DELIMITER //
CREATE PROCEDURE sp1()
DETERMINISTIC
BEGIN
SET @x = 0;
REPEAT
INSERT INTO tbl1(col1,col2) VALUES(@x,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
SET @x = @x + 1;
UNTIL @x >= 100000
END REPEAT;
COMMIT;
END
//
DELIMITER ;
call sp1();
[2 Aug 2005 8:58] Andrey Hristov
seems it is related to bug #9819 - Cursors: Mysql Server Crash while fetching from table with 5 million records.
[16 Aug 2005 20:03] 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/internals/28350
[18 Aug 2005 9:24] 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/internals/28445
[18 Aug 2005 19:55] Petr Chardin
The fix will go into 5.0.12
[18 Aug 2005 20:59] Mike Hillyer
Documented in 5.0.12 changelog:

<listitem><para>Stored procedures with particularly long loops could crash server due to memory leak. (Bug #12297)</para></listitem>