Bug #10968 Stored procedures: crash if long loop
Submitted: 30 May 2005 21:22 Modified: 10 Jun 2005 18:35
Reporter: Peter Gulutzan
Status: Closed
Category:Server Severity:S3 (Non-critical)
Version:5.0.7-beta-debug OS:Linux (SUSE 9.2)
Assigned to: Bugs System Target Version:

[30 May 2005 21:22] Peter Gulutzan
Description:
I have a procedure with a long loop, calling another procedure, doing some displays,
but not accessing any tables. After about 800 iterations the procedure becomes slow,
and eventually stops entirely, or crashes, or is killed because I give up on it.

The test case is not much different from the one in bug#6048, which was closed last
week.

How to repeat:
CREATE PROCEDURE pt1(param1 int, param2 int)
begin declare v int default 0; while v < param2 do select param1, v; set v = v + 1; end
while; end //
CREATE PROCEDURE pt2()
begin declare v int default 0; while v < 99999 do call pt1(v,v); set v = v + 1; end
while; end //
CALL pt2()//
... now wait, patiently, until it crashes or until you give up
[3 Jun 2005 19:46] 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/25582
[3 Jun 2005 19:55] Per-Erik Martin
No test case added, since it would be a 5-15 minutes run attempting to make the machine
run out of memory and swap space.
[10 Jun 2005 16:48] 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/25871
[10 Jun 2005 18:35] Per-Erik Martin
An additional patch with some post-review and valgrind fixes has been pushed too.
There's still a leak with function that turned out to be too involved, so to avoid
stalling
this fix too long, it will be treated separately (BUG#11247).

With this fix, it now runs the test case (and a few other, similar ones) for 10 minutes
or until the loop count passes at least 1500, without slowing down or thrashing.