Bug #32872 calling procedure frequenly may cause mysqld crash because of memory short
Submitted: 30 Nov 2007 11:27 Modified: 30 Dec 2007 11:38
Reporter: li david Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.27 OS:Linux (32bit linux)
Assigned to: CPU Architecture:Any

[30 Nov 2007 11:27] li david
Description:
CREATE DEFINER=`root`@`localhost` PROCEDURE `save_iteminfo`(
pcharguid             int,
pguid                 int,
pworld                int,
pserver               int,
pitemtype             int,
ppos                  smallint,
pvisualid             int,
pmaxgemid             int,
pfixattr              varchar(100),
pp1                   int,
pp2                   int,
pp3                   int,
pp4                   int,
pp5                   int,
pp6                   int,
pp7                   int,
pp8                   int,
pp9                   int,
pp10                  int,
pp11                  int,
pp12                  int,
pp13                  int,
pp14                  int,
pp15                  int,
pp16                  int,
pp17                  int,
pisvalid              smallint,
pdbversion            int,
pcreator              varchar(40),
pvar                  varchar(40))
begin
declare rguid      int;
declare rpos       int;
declare raid       bigint;
declare rcount     int default 0;
start transaction;
select aid,charguid,pos into raid,rguid,rpos from t_iteminfo
        where charguid = pcharguid and pos=ppos;
        if rguid = pcharguid then
         update t_iteminfo set charguid = pcharguid,
                guid                    = pguid,
                world                   = pworld,
                server                  = pserver,
                itemtype                = pitemtype,
                pos                     = ppos,
        visualid        = pvisualid,
        maxgemid        = pmaxgemid,
                fixattr                 = pfixattr,
                p1                      = pp1,
                p2                      = pp2,
                p3                      = pp3,
                p4                      = pp4,
                p5                      = pp5,
                p6                      = pp6,
                p7                      = pp7,
                p8                      = pp8,
                p9                      = pp9,
                p10                     = pp10,
                p11                     = pp11,
                p12                     = pp12,
                p13                     = pp13,
                p14                     = pp14,
                p15                     = pp15,
                p16                     = pp16,
                p17                     = pp17,
                isvalid                 = pisvalid,
                dbversion               = pdbversion,
                creator                 = pcreator,
                var                     = pvar where
                aid=raid and dbversion<=pdbversion;
      
      select row_count() into rcount;
      if rcount > 0 then
        update t_iteminfo set isvalid=0 
        where guid=pguid and world=pworld and server=pserver and aid <> raid;
      end if;
        else
                insert into t_iteminfo(charguid,world,server,guid,itemtype,
                pos,visualid,maxgemid,fixattr,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16,p17,
                isvalid,dbversion,creator,var)
                values(pcharguid,pworld,pserver,pguid,pitemtype,ppos,pvisualid,pmaxgemid,
                pfixattr,pp1,pp2,pp3,pp4,pp5,pp6,pp7,pp8,pp9,pp10,
                pp11,pp12,pp13,pp14,pp15,pp16,pp17,pisvalid,pdbversion,pcreator,pvar);
        end if;
commit;
end ;
when mysqld crash, there is the following message in error log.
InnoDB: memory with malloc! Total allocated memory
InnoDB: by InnoDB 2319029454 bytes. Operating system errno: 12
InnoDB: Check if you should increase the swap file or
InnoDB: ulimits of your operating system.
InnoDB: On FreeBSD check you have compiled the OS with
InnoDB: a big enough maximum process size.
InnoDB: Note that in most 32-bit computers the process
InnoDB: memory space is limited to 2 GB or 4 GB.
InnoDB: We keep retrying the allocation for 60 seconds...
071130 18:03:36  InnoDB: We now intentionally generate a seg fault so that
InnoDB: on Linux we get a stack trace.
mysqld got signal 11;
This could be because you hit a bug. It is also possible that this binary
or one of the libraries it was linked against is corrupt, improperly built,
or misconfigured. This error can also be caused by malfunctioning hardware.
We will try our best to scrape up some info that will hopefully help diagnose
the problem, but since we have already crashed, something is definitely wrong
and this may fail.

key_buffer_size=134217728
read_buffer_size=2093056
max_used_connections=46
max_connections=100
threads_connected=11
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 1154671 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.

thd=(nil)
Attempting backtrace. You can use the following information to find out
where mysqld died. If you see no messages after this, something went
terribly wrong...
Cannot determine thread, fp=0x2ad79f2c, backtrace may not be correct.
Stack range sanity check OK, backtrace follows:
0x817e950
0x8379b72
0x8379bac
0x837e62c
0x834e70c
0x8295f95
0x4de371
0x448ffe
New value of fp=(nil) failed sanity check, terminating stack trace!
Please read http://dev.mysql.com/doc/mysql/en/Using_stack_trace.html and follow instructions on how to resolve the stack trace. Resolved
stack trace is much more helpful in diagnosing the problem, so please do
resolve it
The manual page at http://www.mysql.com/doc/en/Crashing.html contains
information that should help you find out what is causing the crash.

Number of processes running now: 0
071130 18:03:37  mysqld restarted

How to repeat:
the same as the above.
[30 Nov 2007 11:38] Sveta Smirnova
Thank you for the report.

But version 5.0.27 is quite old and many bugs were fixed since. Please upgrade to current version 5.0.45, try with it and if problem still exists provide output of SHOW CREATE TABLE t_iteminfo;
[1 Jan 2008 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".