Bug #45493 In ndbcluster, existing tables are droped shorkingly
Submitted: 15 Jun 2009 9:20 Modified: 15 Jun 2009 9:58
Reporter: ws lee Email Updates:
Status: Duplicate Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S1 (Critical)
Version:mysql-5.1.27-ndb-6.3.17 OS:Solaris (5.10)
Assigned to: Assigned Account CPU Architecture:Any

[15 Jun 2009 9:20] ws lee
Description:
I am using mysql-5.1.27-ndb-6.3.17 in real service.
recently, shorking accident was occured.

I run "show tables" mysql command.
and thus,  Existing tables was dropped suddenly.

How to repeat:
1.
Use this config.ini in testing.([NDBD DEFAULT] part must same this config.ini)
---------------------------------
[NDBD DEFAULT]
NoOfReplicas=2
DataMemory=1000M
IndexMemory=100M

MaxNoOfAttributes=5000 
MaxNoOfOrderedIndexes=1000 
MaxNoOfUniqueHashIndexes=1000
MaxNoOfTables=500 
MaxNoOfTriggers=1000

[NDB_MGMD]
hostname=192.168.1.9
datadir=/var/lib/mysql-cluster5.1.27-ndb6.3.17
ID=1
[NDB_MGMD]
hostname=192.168.1.10
datadir=/var/lib/mysql-cluster5.1.27-ndb6.3.17  
ID=2
[NDB_MGMD]
hostname=192.168.1.11
datadir=/var/lib/mysql-cluster5.1.27-ndb6.3.17 
ID=3

[NDBD]    
hostname=192.168.1.10
datadir=/var/lib/mysql-cluster5.1.27-ndb6.3.17
ID=4
[NDBD]
hostname=192.168.1.11
datadir=/var/lib/mysql-cluster5.1.27-ndb6.3.17  
ID=5

[MYSQLD]
hostname=192.168.1.10
[MYSQLD]
hostname=192.168.1.11
---------------------------------

2. 
firstly, this script run.
cat create1.sh
---------------------------------
#!/bin/sh

MYSQL_DIR=/usr/local/mysql5.1.27-ndb6.3.17

create(){
        SQL="CREATE TABLE a${1} (
         c1 int(11) NOT NULL AUTO_INCREMENT,
         c2 int(11) NOT NULL DEFAULT '0',
         c3 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
         c4 timestamp NULL DEFAULT NULL,
         c5 decimal(38,0) NOT NULL,
         c6 int(11) NOT NULL DEFAULT '0',
         c7 tinyint(4) NOT NULL,
         c8 tinyint(4) NOT NULL,
         c9 date DEFAULT NULL,
         c10 date DEFAULT NULL,
         c11 date DEFAULT NULL,
         c12 date DEFAULT NULL,
         c13 varchar(10) NOT NULL,
         c14 varchar(10) DEFAULT NULL,
         c15 varchar(20) DEFAULT NULL,
         PRIMARY KEY (c1),
         KEY idx1 (c2),
         KEY idx2 (c3),
         KEY idx3 (c4),
         KEY idx4 (c5),
         KEY idx5 (c6)
         ) ENGINE=ndbcluster DEFAULT CHARSET=utf8"
        RESULT=`/usr/local/mysql5.1.27-ndb6.3.17/bin/mysql -uroot $2 -e"$SQL" 2>&1`
}

run(){
        $MYSQL_DIR/bin/mysql -uroot -e"drop database if exists $1"
        $MYSQL_DIR/bin/mysql -uroot -e"create database $1"
        echo "creating table of $1"
        i=1
        while [ $i -lt $2 ]
        do
                echo $i
                create $i $1 
                if [ -n "$RESULT" ]; then
                        echo $RESULT     
                        exit        
                fi
                i=`expr $i + 1`
        done 
}

# don't change dbname. use dbname written in this script 
run db_aaaa_aaa 79 
run db_bbbb_bbbb 28 
run db_cccccc 13 
------------------------------------------------

#./create1.sh

and thus, confirm table created.

# mysql -uroot 

# use db_bbbb_bbbb;

# show tables;
mysql> show tables;
+------------------------+
| Tables_in_db_core_bill |
+------------------------+
| b1                     | 
| b10                    | 
| b11                    | 
| b12                    | 
| b13                    | 
| b14                    | 
| b15                    | 
| b16                    | 
| b17                    | 
| b18                    | 
| b19                    | 
| b2                     | 
| b20                    | 
| b21                    | 
| b22                    | 
| b23                    | 
| b24                    | 
| b25                    | 
| b26                    | 
| b27                    | 
| b3                     | 
| b4                     | 
| b5                     | 
| b6                     | 
| b7                     | 
| b8                     | 
| b9                     | 
+------------------------+

apparently, table exists, this timing.

3. nextly, run this script.
cat create2.sh
-----------------------------------------------
#!/bin/sh

MYSQL_DIR=/usr/local/mysql5.1.27-ndb6.3.17

create(){
SQL="CREATE TABLE a${1} (
  c1 int(11) NOT NULL AUTO_INCREMENT,
  c2 int(11) NOT NULL DEFAULT '0',
  c3 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  c4 timestamp NULL DEFAULT NULL,
  c5 decimal(38,0) NOT NULL,

MYSQL_DIR=/usr/local/mysql5.1.27-ndb6.3.17

create(){
        SQL="CREATE TABLE a${1} (
         c1 int(11) NOT NULL AUTO_INCREMENT,
         c2 int(11) NOT NULL DEFAULT '0',
         c3 timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
         c4 timestamp NULL DEFAULT NULL,
         c5 decimal(38,0) NOT NULL,
         c6 int(11) NOT NULL DEFAULT '0',
         c7 tinyint(4) NOT NULL,
         c8 tinyint(4) NOT NULL,
         c9 date DEFAULT NULL,
         c10 date DEFAULT NULL,
         c11 date DEFAULT NULL,
         c12 date DEFAULT NULL,
         c13 varchar(10) NOT NULL,
         c14 varchar(10) DEFAULT NULL,
         c15 varchar(20) DEFAULT NULL,
         PRIMARY KEY (c1),
         KEY idx1 (c2),
         KEY idx2 (c3),
         KEY idx3 (c4),
         KEY idx4 (c5),
         KEY idx5 (c6)
         ) ENGINE=ndbcluster DEFAULT CHARSET=utf8"
        RESULT=`/usr/local/mysql5.1.27-ndb6.3.17/bin/mysql -uroot $2 -e"$SQL" 2>&1`
}

run(){
        $MYSQL_DIR/bin/mysql -uroot -e"drop database if exists $1"
        $MYSQL_DIR/bin/mysql -uroot -e"create database $1"
        echo "creating table of $1"       
        i=1
        while [ $i -lt $2 ]
        do
                echo $i
                create $i $1
                if [ -n "$RESULT" ]; then
                        echo $RESULT    
                        exit            
                fi                 
                i=`expr $i + 1`
        done   
}

# don't change dbname. use dbname written in this script 
run db_ppp 46
-----------------------------------------------

# ./create2.sh

and thus, check tables created by create1.sh 

# mysql -uroot
 
mysql> use db_bbbb_bbbb;
Database changed

upper query taked long time.

but, shorking problem is next.

mysql> show tables;
Empty set (0.00 sec)

tables created create1.sh, all droped.
[15 Jun 2009 9:27] Jonas Oreland
this is a duplicate of http://bugs.mysql.com/bug.php?id=40854
very very sorry about this :-(
[15 Jun 2009 9:42] ws lee
To. Jonas Oreland
thanks about fast reply.

this problem is concerned with config.ini parameter?
[15 Jun 2009 9:44] Jonas Oreland
not related to config.ini related to bug in code,
that triggers this behavior if sum(object name in ndbd) % 64 == 0
(or something like that)
[15 Jun 2009 9:58] ws lee
To. Jonas Oreland
thannks.

it seems not occured if below paramter value set bigger than before value.
MaxNoOfAttributes=
MaxNoOfOrderedIndexes=
MaxNoOfUniqueHashIndexes=
MaxNoOfTables=500 
MaxNoOfTriggers=

by the way, 
>sum(object name in ndbd) % 64 == 0

I want to know how to calculate upper sum(object name) in detaily.
pleas, teach me that query!