Bug #11560 server crashed creating index whilst big load was going.
Submitted: 25 Jun 2005 5:24 Modified: 4 Jul 2005 19:05
Reporter: Paul McArdle Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:Ver 5.0.7-beta-standard for pc-l OS:Linux (red hat 9)
Assigned to: CPU Architecture:Any

[25 Jun 2005 5:24] Paul McArdle
Description:
was thrashing local server with inserts, retrieves & deletes over 250 req. per second at the time. Thought I'd create an index on table in question through msql-administrator/sql-browser, Killed everything.

let me know how to get a log of this stuff & i'll set it up.

How to repeat:
had a table create table animal name char(40), description char(40)

trigger on insert before change animal.name to i + _ + i

i =  1..1000000 insert into animal i i

i = 1..1000000 select *  from animal where name = i_i

i = 1..1000000 delete from animal where name = i_i

etc.

had nearly 6mil 

Suggested fix:
get server to reject stupid requests under load maybe.
[25 Jun 2005 19:09] Jorge del Conde
I was unable to reporduce this bug.  This is the script that I used to test it out:

printf ("inserting values...\n");
  for (i=0;i<=NUM;i++)
  {
    sprintf (qry, "INSERT INTO animal VALUES ('%d_%d', %d)", i, i, i);
    mysql_query(MySQL,qry);
    res = mysql_store_result(MySQL);
    mysql_free_result(res);  
    printf(".");
  }

  getchar();
  printf ("\nselecting values...\n");
  for (i=0;i<=NUM;i++)
  {
    sprintf (qry, "SELECT * FROM animal WHERE name = '%d_%d'", i, i);
    mysql_query(MySQL,qry);
    res = mysql_store_result(MySQL);
    mysql_free_result(res);  
    printf(".");
  }
  getchar();

  printf ("\ndeleting values...\n");
  for (i=0;i<=NUM;i++)
  {
    sprintf (qry, "DELETE FROM animal WHERE name = '%d_%d'", i, i);
    mysql_query(MySQL,qry);
    res = mysql_store_result(MySQL);
    mysql_free_result(res);  
    printf(".");
  }

Can you please give me a fully working script that reproduces this behaviour ?

Also, running the above script took too long, would it be ok (for testing purposes) to create 'name' as a primary key ?
[26 Jun 2005 1:03] Paul McArdle
Hi, was using ruby1.6.8 & ruby-mysql,

START SERVER
[root@localhost root]# mysqld -uroot --sock=/tmp/mysql.sock &
[1] 2416
050626 10:17:39 [Warning] Asked for 196608 thread stack, but got 126976
[root@localhost root]# 050626 10:17:40  InnoDB: Started; log sequence number 0 43644
050626 10:17:40 [Note] mysqld: ready for connections.
Version: '5.0.7-beta-standard'  socket: '/tmp/mysql.sock'  port: 3306  MySQL Community Edition - Standard (GPL)
 
[root@localhost root]#
opened 4 or five teminals under red hat 9 kernel 2.4.20.31.9

ADD CLIENTS
connected to server with ruby in each terminal using ('localhost', 'mysql', '','test')

teminal 1 
irb
>require '/var/www/cgi-bin/oldruby/lib/ruby/1.8/mysql'
=> true
irb(main):002:0> require '/var/www/cgi-bin/oldruby/lib/ruby/1.8/mysql411'
=> true
irb(main):007:0> my = Mysql.connect('localhost','mysql','','test')
=> #<Mysql>
irb(main):008:0> (1..1000000).each do |i|
irb(main):009:1* res = my.query("select * from animal where name = '#{i.to_s}_#{i.to_s}'")
irb(main):010:1> sleep .00005
irb(main):010:1> puts i
irb(main):011:1> end
1
2
3
4
...........

i've got 1 terminal going now.

did similar in next terminal
(1..1000000).each do |i|
  my.query("insert into animal values('#{i.to_s}','#{i.to_s}' )")
  sleep .00005
end #off it goes will run all night

teminal 2 (1..1000000).each do |i|
  my.query("select from animal where name = '#{i.to_s}_#{i.to_s}' ") 
  # trigger converts animal.name to name + "_" + name
  sleep .00005
end #off it goes will run all night

etc.
teminal 3 (1..1000000).each do |i|
  my.query("select from animal where name = '#{i.to_s}_#{i.to_s}' ") 
  # trigger converts animal.name to name + "_" + name
  sleep .00005
end #off it goes will run all night

mysqladmin -uroot -prooted -S/tmp/mysql.sock status
Uptime: 939  Threads: 3  Questions: 311930  Slow queries: 0  Opens: 0  Flush tables: 1  Open tables: 2  Queries per second avg: 332.194
[root@localhost root]#

START MYSQLADMINISTRATOR
create an index on animal.name through the various dialogs use defaults.

got sucess message
got error retrieving info for table test.animal object not found

got  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=8388600
read_buffer_size=131072
max_used_connections=6
max_connections=100
threads_connected=5
It is possible that mysqld could use up to
key_buffer_size + (read_buffer_size + sort_buffer_size)*max_connections = 225791 K
bytes of memory
Hope that's ok; if not, decrease some variables in the equation.
 
thd=0x89d9c10
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=0xbfe5eac8, backtrace may not be correct.
Stack range sanity check OK, backtrace follows:
0x809cc37
0x834a258
0x8053f19
0x805ca7b
0x817953a
0x81770c4
0x81774cd
0x80d3f41
0x80f2609
0x80afaaa
0x80b4309
0x80ac7f4
0x80ac124
0x80ab6b4
0x8347a0c
0x837141a
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
Trying to get some variables.
Some pointers may be invalid and cause the dump to abort...
thd->query at 0x8a063a8 = insert into animal values('808334','808334' )
thd->thread_id=1
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.
 
from terminal where I statred mysqld.
was up to 450 per sec before crash.
Uptime: 2013  Threads: 6  Questions: 910456  Slow queries: 0  Opens: 0  Flush tables: 1  Open tables: 26  Queries per second
avg: 452.288

time to fix the test database.
[4 Jul 2005 19:05] Jorge del Conde
I was still unable to reproduce this bug using the latest 5.0 from bk.