Bug #49156 Creating a lot of tables fails with error 306
Submitted: 27 Nov 2009 9:52 Modified: 9 Dec 2009 14:00
Reporter: Johan Andersson Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Cluster: Cluster (NDB) storage engine Severity:S3 (Non-critical)
Version:mysql-5.1-telco-7.0 OS:Any
Assigned to: Jonas Oreland CPU Architecture:Any
Tags: 306, 7.0.9, tables

[27 Nov 2009 9:52] Johan Andersson
Description:
Trying to create 20320 tables, but fails after 11435 tables with error 306.

I am creating tables using this script:

#!/bin/bash
source /root/env.sh
i=0
j=0
maxtables=$1
maxcols=$2
attrs=""
while [ $i -lt $maxtables ];
do
	sql="CREATE TABLE t$i("
	while [ $j -lt $maxcols ];
	do
		attrs="$attrs a$j INTEGER,"
		j=`expr $j + 1`
	done
 	sql="$sql $attrs PRIMARY KEY USING HASH(a0)"
	sql="$sql ) ENGINE=ndb"
	i=`expr $i + 1`
	echo $sql
	/usr/local/mysql/mysql/bin/mysql -uroot -S/tmp/mysql.sock -uroot test -v -e "$sql"
done

I use the following config.ini:

[NDBD DEFAULT]
NoOfReplicas=2
Datadir=/data1/mysqlcluster/
FileSystemPathDD=/data1/mysqlcluster/
#FileSystemPathUndoFiles=/data1/mysqlcluster/
#FileSystemPathDataFiles=/data1/mysqlcluster/
DataMemory=1024M
IndexMemory=2048M
LockPagesInMainMemory=1

MaxNoOfConcurrentOperations=100000

StringMemory=25
MaxNoOfTables=20320
MaxNoOfOrderedIndexes=2048
MaxNoOfUniqueHashIndexes=512
MaxNoOfAttributes=2861056
DiskCheckpointSpeedInRestart=100M
FragmentLogFileSize=256M
InitFragmentLogFiles=FULL
NoOfFragmentLogFiles=6
RedoBuffer=32M

TimeBetweenLocalCheckpoints=20
TimeBetweenGlobalCheckpoints=1000
TimeBetweenEpochs=100

MemReportFrequency=30
BackupReportFrequency=10

### Params for setting logging 
LogLevelStartup=15
LogLevelShutdown=15
LogLevelCheckpoint=8
LogLevelNodeRestart=15

### Params for increasing Disk throughput 
BackupMaxWriteSize=1M
BackupDataBufferSize=16M
BackupLogBufferSize=4M
BackupMemory=20M
#Reports indicates that odirect=1 can cause io errors (os err code 5) on some systems. You must test.
#ODirect=1

How to repeat:
Run the script above with the [ndb default] above on a two node cluster.

Suggested fix:
-
[4 Dec 2009 12:49] 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/commits/92875

3257 Jonas Oreland	2009-12-04
      ndb - bug#49156 - account for threads when computing size of DIH fragment pools, remove dead code (that I actually thought was the problem :-)
[4 Dec 2009 12:52] Jonas Oreland
pushed to 7.0.10
[9 Dec 2009 14:00] Jon Stephens
Documented in the NDB-7.0.10 changelog as follows:

        Attempting to create more than 11435 tables failed with Error
        306 (Out of fragment records in DIH).

Closed.