3207 Magnus Blåudd 2009-11-08 [merge]
Merge 6.3 to 7.0
added:
mysql-test/suite/ndb_big/
mysql-test/suite/ndb_big/bug37983.test
mysql-test/suite/ndb_big/end_timer.inc
mysql-test/suite/ndb_big/my.cnf
mysql-test/suite/ndb_big/run_query_with_retry.inc
mysql-test/suite/ndb_big/start_timer.inc
mysql-test/suite/ndb_big/suite.inc
modified:
mysql-test/Makefile.am
3206 Magnus Blåudd 2009-11-08
ndbinfo
- Change the comments in the sql file generated by ndbinfo_sql to #
so that it can be sourced by mysqltest script
modified:
mysql-test/suite/ndb/t/ndbinfo.test
storage/ndb/tools/ndbinfo_sql.cpp
3205 Magnus Blåudd 2009-11-08
ndbinfo
- Make mtr run testNdbinfo
added:
mysql-test/suite/ndb/t/test_ndbinfo.test
3204 Magnus Blåudd 2009-11-08
ha_ndbcluster
- change return type of 'ndbcluster_disconnect' to void, it should
never fail and return code is not used.
modified:
sql/ha_ndbcluster_connection.cc
sql/ha_ndbcluster_connection.h
3203 Magnus Blåudd 2009-11-08
ha_ndbcluster
- remove unnecessary long variable name prefix from local global variables
modified:
sql/ha_ndbcluster_connection.cc
3202 Magnus Blåudd 2009-11-08
ndbinfo
- add missing filehave_ndbinfo.inc
- fix the SQL for ndbinfo.log_space view
added:
mysql-test/suite/ndb/t/have_ndbinfo.inc
modified:
mysql-test/suite/ndb/r/ndbinfo.result
storage/ndb/tools/ndbinfo_sql.cpp
=== modified file 'mysql-test/Makefile.am'
--- a/mysql-test/Makefile.am 2009-10-01 07:16:52 +0000
+++ b/mysql-test/Makefile.am 2009-11-08 21:20:04 +0000
@@ -101,6 +101,7 @@ TEST_DIRS = t r include std_data std_dat
suite/rpl/t \
suite/stress/include suite/stress/t suite/stress/r \
suite/ndb suite/ndb/t suite/ndb/r suite/ndb/include suite/ndb/std_data \
+ suite/ndb_big \
suite/ndb_binlog suite/ndb_binlog/t suite/ndb_binlog/r \
suite/ndb_team suite/ndb_team/t suite/ndb_team/r \
suite/rpl_ndb suite/rpl_ndb/t suite/rpl_ndb/r \
=== modified file 'mysql-test/suite/ndb/t/ndbinfo.test'
--- a/mysql-test/suite/ndb/t/ndbinfo.test 2009-11-08 12:52:27 +0000
+++ b/mysql-test/suite/ndb/t/ndbinfo.test 2009-11-08 21:16:50 +0000
@@ -11,7 +11,11 @@ CREATE TEMPORARY TABLE `t1` (
) ENGINE=NDBINFO;
# Run the ndbinfo.sql script that creates ndbinfo database, tables and views
---exec $MYSQL < $NDBINFO_SQL 2>&1
+--disable_warnings
+--disable_query_log
+source $NDBINFO_SQL;
+--enable_query_log
+--enable_warnings
USE ndbinfo;
=== added file 'mysql-test/suite/ndb/t/test_ndbinfo.test'
--- a/mysql-test/suite/ndb/t/test_ndbinfo.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb/t/test_ndbinfo.test 2009-11-08 19:47:39 +0000
@@ -0,0 +1,52 @@
+--result_format 2
+--perl
+use strict;
+
+use strict;
+use lib "lib/";
+use My::Find;
+use File::Basename;
+use IO::File;
+
+#
+# Check if the needed executable is available
+#
+my $mysql_test_dir = $ENV{MYSQL_TEST_DIR} or die "Need MYSQL_TEST_DIR";
+my $basedir = dirname($mysql_test_dir);
+my $test_exe = my_find_bin($basedir,
+ ["storage/ndb/test/ndbapi", "bin"],
+ "testNdbinfo", NOT_REQUIRED);
+
+#
+# Communicate the location of the executable to the test
+# by creating a temporary include file
+#
+
+my $vardir = $ENV{MYSQLTEST_VARDIR} or die "Need MYSQLTEST_VARDIR";
+
+my $F = IO::File->new("$vardir/tmp/test_ndbinfo.inc", "w") or die;
+if ($test_exe)
+{
+ print $F "let \$TEST_NDBINFO=$test_exe;\n";
+}
+else
+{
+ print $F "skip Could not find testNdbinfo;";
+}
+EOF
+
+--source $MYSQLTEST_VARDIR/tmp/test_ndbinfo.inc
+
+let $log_file=$MYSQLTEST_VARDIR/tmp/test_ndbinfo.log;
+
+--exec $TEST_NDBINFO -n Ndbinfo > $log_file 2>&1
+--exec $TEST_NDBINFO -n Ndbinfo10 > $log_file 2>&1
+--exec $TEST_NDBINFO -n ScanAll > $log_file 2>&1
+--exec $TEST_NDBINFO -n ScanStop > $log_file 2>&1
+## Disable RateLimit temporarily, it hangs when scanning log_space
+#--exec $TEST_NDBINFO -n RateLimit > $log_file 2>&1
+--exec $TEST_NDBINFO -n TestTable > $log_file 2>&1
+
+echo Sucessfully executed $TEST_NDBINFO;
+
+exit;
=== added directory 'mysql-test/suite/ndb_big'
=== added file 'mysql-test/suite/ndb_big/bug37983.test'
--- a/mysql-test/suite/ndb_big/bug37983.test 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb_big/bug37983.test 2009-11-08 21:12:10 +0000
@@ -0,0 +1,56 @@
+source suite.inc;
+source include/have_ndb.inc;
+result_format 2;
+
+select version();
+
+CREATE TABLE `t1` (
+ `c1` int(11) NOT NULL,
+ `c3` text,
+ PRIMARY KEY (`c1`) USING BTREE
+) ENGINE=ndbcluster DEFAULT CHARSET=utf8;
+
+## Load table...
+disable_query_log;
+let $i=1000;
+while ($i)
+{
+ let $batch = 400; # Number of values to INSERT per batch
+ let $separator = ;
+ let $sql = INSERT t1 (c1, c3) VALUES;
+ while($batch)
+ {
+ let $sql=$sql$separator($i*1000+$batch, REPEAT('ks87', 512*RAND()));
+ dec $batch;
+ let $separator = ,;
+ }
+
+ source run_query_with_retry.inc;
+
+ dec $i;
+}
+enable_query_log;
+
+## Check number of records in table..
+let $count = `select count(*) from t1`;
+if (!`select $count = 400000`)
+{
+ echo got: $count, expected: 400000;
+ die Wrong number of records loaded into table;
+}
+echo Table has $count number of records;
+
+# Measure the time to run the query three times
+source start_timer.inc;
+# This is currently a very bad query for MySQL Cluster since
+# each record has to be fetched into the mysql in order
+# to see if it fulfills the where clause
+select count(*) from t1 where length(c3) < 256;
+select count(*) from t1 where length(c3) < 256;
+select count(*) from t1 where length(c3) < 256;
+source end_timer.inc;
+
+drop table t1;
+
+## Test suceeded
+exit;
=== added file 'mysql-test/suite/ndb_big/end_timer.inc'
--- a/mysql-test/suite/ndb_big/end_timer.inc 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb_big/end_timer.inc 2009-11-08 21:12:10 +0000
@@ -0,0 +1,6 @@
+--disable_query_log
+set @end = now();
+let $_elapsed = `select TIMEDIFF(@end, @start)`;
+--disable_query_log
+echo Elapsed time: $_elapsed;
+
=== added file 'mysql-test/suite/ndb_big/my.cnf'
--- a/mysql-test/suite/ndb_big/my.cnf 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb_big/my.cnf 2009-11-08 21:12:10 +0000
@@ -0,0 +1,68 @@
+#
+# Real world MySQL Cluster configuration suited
+# to be run on a developer machine
+#
+# The configuration is tuned according to best
+# practice with the limitation that all processes
+# are run on one host with 4Gb RAM
+#
+
+!include include/default_mysqld.cnf
+
+[cluster_config.1]
+ndbd=,
+ndb_mgmd=
+mysqld=
+
+DataMemory=700M
+IndexMemory=220M
+MaxNoOfConcurrentOperations=32768
+StringMemory=25
+MaxNoOfTables=12800
+MaxNoOfOrderedIndexes=12800
+MaxNoOfUniqueHashIndexes=12800
+MaxNoOfAttributes=128000
+DiskCheckpointSpeedInRestart=100M
+FragmentLogFileSize=256M
+InitFragmentLogFiles=FULL
+NoOfFragmentLogFiles=11
+TimeBetweenLocalCheckpoints=20
+TimeBetweenGlobalCheckpoints=2000
+TimeBetweenEpochs=100
+MemReportFrequency=30
+LogLevelStartup=15
+LogLevelShutdown=15
+LogLevelCheckpoint=8
+LogLevelNodeRestart=15
+BackupMaxWriteSize=1M
+BackupDataBufferSize=16M
+BackupLogBufferSize=4M
+BackupMemory=20M
+ODirect=1
+TimeBetweenWatchDogCheckInitial=60000
+TransactionInactiveTimeout=30000
+RealtimeScheduler=1
+SchedulerExecutionTimer=80
+SchedulerSpinTimer=40
+SharedGlobalMemory=20M
+DiskPageBufferMemory=64M
+BatchSizePerLocalScan=512
+
+[cluster_config.TCP.1]
+SendBufferMemory=2M
+ReceiveBufferMemory=2M
+
+[cluster_config.mysqld.1.1]
+BatchSize=512
+BatchByteSize=1024K
+
+[mysqld]
+# Make all mysqlds use cluster
+ndbcluster
+
+ndb-cluster-connection-pool=1
+ndb-force-send=1
+ndb-use-exact-count=0
+ndb-extra-logging=1
+ndb-autoincrement-prefetch-sz=256
+engine-condition-pushdown=1
=== added file 'mysql-test/suite/ndb_big/run_query_with_retry.inc'
--- a/mysql-test/suite/ndb_big/run_query_with_retry.inc 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb_big/run_query_with_retry.inc 2009-11-08 21:12:10 +0000
@@ -0,0 +1,26 @@
+#
+# Run the built query in $sql, retry temporary errors
+#
+
+let $_continue = 1;
+let $_retry = 0;
+while($_continue)
+{
+ error 0,1297; # Allow OK or temporary error
+ eval $sql; # Run the query
+
+ if (!$mysql_errno)
+ {
+ # Query suceeded, break the retry loop
+ let $_continue = 0;
+ }
+
+ if ($mysql_errno)
+ {
+ # Query failed
+ inc $_retry;
+ echo Query failed with temporary error, retry: $_retry;
+
+ sleep 0.1;
+ }
+}
=== added file 'mysql-test/suite/ndb_big/start_timer.inc'
--- a/mysql-test/suite/ndb_big/start_timer.inc 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb_big/start_timer.inc 2009-11-08 21:12:10 +0000
@@ -0,0 +1,4 @@
+--disable_query_log
+echo Starting timer...;
+set @start = now();
+--enable_query_log
=== added file 'mysql-test/suite/ndb_big/suite.inc'
--- a/mysql-test/suite/ndb_big/suite.inc 1970-01-01 00:00:00 +0000
+++ b/mysql-test/suite/ndb_big/suite.inc 2009-11-08 21:12:10 +0000
@@ -0,0 +1,8 @@
+#
+# Setups and checks common for all tests in this suite
+#
+if ($MTR_MEM)
+{
+ die Cant run these tests with filesystem in RAM;
+}
+
=== modified file 'sql/ha_ndbcluster_connection.cc'
--- a/sql/ha_ndbcluster_connection.cc 2009-05-27 15:21:45 +0000
+++ b/sql/ha_ndbcluster_connection.cc 2009-11-08 18:23:30 +0000
@@ -33,10 +33,10 @@ extern ulong opt_ndb_wait_connected;
Ndb* g_ndb= NULL;
Ndb_cluster_connection* g_ndb_cluster_connection= NULL;
-static Ndb_cluster_connection **g_ndb_cluster_connection_pool= NULL;
-static ulong g_ndb_cluster_connection_pool_alloc= 0;
-static ulong g_ndb_cluster_connection_pool_pos= 0;
-static pthread_mutex_t g_ndb_cluster_connection_pool_mutex;
+static Ndb_cluster_connection **g_pool= NULL;
+static ulong g_pool_alloc= 0;
+static ulong g_pool_pos= 0;
+static pthread_mutex_t g_pool_mutex;
/*
Global flag in ndbapi to specify if api should wait to connect
@@ -114,17 +114,16 @@ int ndbcluster_connect(int (*connect_cal
}
{
- g_ndb_cluster_connection_pool_alloc= opt_ndb_cluster_connection_pool;
- g_ndb_cluster_connection_pool= (Ndb_cluster_connection**)
- my_malloc(g_ndb_cluster_connection_pool_alloc *
- sizeof(Ndb_cluster_connection*),
+ g_pool_alloc= opt_ndb_cluster_connection_pool;
+ g_pool= (Ndb_cluster_connection**)
+ my_malloc(g_pool_alloc * sizeof(Ndb_cluster_connection*),
MYF(MY_WME | MY_ZEROFILL));
- pthread_mutex_init(&g_ndb_cluster_connection_pool_mutex,
+ pthread_mutex_init(&g_pool_mutex,
MY_MUTEX_INIT_FAST);
- g_ndb_cluster_connection_pool[0]= g_ndb_cluster_connection;
- for (unsigned i= 1; i < g_ndb_cluster_connection_pool_alloc; i++)
+ g_pool[0]= g_ndb_cluster_connection;
+ for (unsigned i= 1; i < g_pool_alloc; i++)
{
- if ((g_ndb_cluster_connection_pool[i]=
+ if ((g_pool[i]=
new Ndb_cluster_connection(opt_ndb_connectstring,
g_ndb_cluster_connection)) == 0)
{
@@ -138,9 +137,9 @@ int ndbcluster_connect(int (*connect_cal
char buf[128];
my_snprintf(buf, sizeof(buf), "%s --server-id=%lu (connection %u)",
mysqld_name, server_id, i+1);
- g_ndb_cluster_connection_pool[i]->set_name(buf);
+ g_pool[i]->set_name(buf);
}
- g_ndb_cluster_connection_pool[i]->set_optimized_node_selection
+ g_pool[i]->set_optimized_node_selection
(global_system_variables.ndb_optimized_node_selection & 1);
}
}
@@ -148,30 +147,30 @@ int ndbcluster_connect(int (*connect_cal
if (res == 0)
{
connect_callback();
- for (unsigned i= 0; i < g_ndb_cluster_connection_pool_alloc; i++)
+ for (unsigned i= 0; i < g_pool_alloc; i++)
{
- int node_id= g_ndb_cluster_connection_pool[i]->node_id();
+ int node_id= g_pool[i]->node_id();
if (node_id == 0)
{
// not connected to mgmd yet, try again
- g_ndb_cluster_connection_pool[i]->connect(0,0,0);
- if (g_ndb_cluster_connection_pool[i]->node_id() == 0)
+ g_pool[i]->connect(0,0,0);
+ if (g_pool[i]->node_id() == 0)
{
sql_print_warning("NDB[%u]: starting connect thread", i);
- g_ndb_cluster_connection_pool[i]->start_connect_thread();
+ g_pool[i]->start_connect_thread();
continue;
}
- node_id= g_ndb_cluster_connection_pool[i]->node_id();
+ node_id= g_pool[i]->node_id();
}
DBUG_PRINT("info",
("NDBCLUSTER storage engine (%u) at %s on port %d", i,
- g_ndb_cluster_connection_pool[i]->get_connected_host(),
- g_ndb_cluster_connection_pool[i]->get_connected_port()));
+ g_pool[i]->get_connected_host(),
+ g_pool[i]->get_connected_port()));
NDB_TICKS now_time;
do
{
- res= g_ndb_cluster_connection_pool[i]->wait_until_ready(1, 1);
+ res= g_pool[i]->wait_until_ready(1, 1);
now_time= NdbTick_CurrentMillisecond();
} while (res != 0 && now_time < end_time);
@@ -194,9 +193,9 @@ int ndbcluster_connect(int (*connect_cal
}
else if (res == 1)
{
- for (unsigned i= 0; i < g_ndb_cluster_connection_pool_alloc; i++)
+ for (unsigned i= 0; i < g_pool_alloc; i++)
{
- if (g_ndb_cluster_connection_pool[i]->
+ if (g_pool[i]->
start_connect_thread(i == 0 ? connect_callback : NULL))
{
sql_print_error("NDB[%u]: failed to start connect thread", i);
@@ -229,44 +228,42 @@ ndbcluster_connect_error:
DBUG_RETURN(-1);
}
-int ndbcluster_disconnect()
+void ndbcluster_disconnect(void)
{
DBUG_ENTER("ndbcluster_disconnect");
if (g_ndb)
delete g_ndb;
g_ndb= NULL;
{
- if (g_ndb_cluster_connection_pool)
+ if (g_pool)
{
/* first in pool is the main one, wait with release */
- for (unsigned i= 1; i < g_ndb_cluster_connection_pool_alloc; i++)
+ for (unsigned i= 1; i < g_pool_alloc; i++)
{
- if (g_ndb_cluster_connection_pool[i])
- delete g_ndb_cluster_connection_pool[i];
+ if (g_pool[i])
+ delete g_pool[i];
}
- my_free((uchar*) g_ndb_cluster_connection_pool, MYF(MY_ALLOW_ZERO_PTR));
- pthread_mutex_destroy(&g_ndb_cluster_connection_pool_mutex);
- g_ndb_cluster_connection_pool= 0;
+ my_free((uchar*) g_pool, MYF(MY_ALLOW_ZERO_PTR));
+ pthread_mutex_destroy(&g_pool_mutex);
+ g_pool= 0;
}
- g_ndb_cluster_connection_pool_alloc= 0;
- g_ndb_cluster_connection_pool_pos= 0;
+ g_pool_alloc= 0;
+ g_pool_pos= 0;
}
if (g_ndb_cluster_connection)
delete g_ndb_cluster_connection;
g_ndb_cluster_connection= NULL;
- DBUG_RETURN(0);
+ DBUG_VOID_RETURN;
}
Ndb_cluster_connection *ndb_get_cluster_connection()
{
- pthread_mutex_lock(&g_ndb_cluster_connection_pool_mutex);
- Ndb_cluster_connection *connection=
- g_ndb_cluster_connection_pool[g_ndb_cluster_connection_pool_pos];
- g_ndb_cluster_connection_pool_pos++;
- if (g_ndb_cluster_connection_pool_pos ==
- g_ndb_cluster_connection_pool_alloc)
- g_ndb_cluster_connection_pool_pos= 0;
- pthread_mutex_unlock(&g_ndb_cluster_connection_pool_mutex);
+ pthread_mutex_lock(&g_pool_mutex);
+ Ndb_cluster_connection *connection= g_pool[g_pool_pos];
+ g_pool_pos++;
+ if (g_pool_pos == g_pool_alloc)
+ g_pool_pos= 0;
+ pthread_mutex_unlock(&g_pool_mutex);
return connection;
}
@@ -274,9 +271,9 @@ ulonglong ndb_get_latest_trans_gci()
{
unsigned i;
ulonglong val= *g_ndb_cluster_connection->get_latest_trans_gci();
- for (i= 1; i < g_ndb_cluster_connection_pool_alloc; i++)
+ for (i= 1; i < g_pool_alloc; i++)
{
- ulonglong tmp= *g_ndb_cluster_connection_pool[i]->get_latest_trans_gci();
+ ulonglong tmp= *g_pool[i]->get_latest_trans_gci();
if (tmp > val)
val= tmp;
}
@@ -286,18 +283,18 @@ ulonglong ndb_get_latest_trans_gci()
void ndb_set_latest_trans_gci(ulonglong val)
{
unsigned i;
- for (i= 0; i < g_ndb_cluster_connection_pool_alloc; i++)
+ for (i= 0; i < g_pool_alloc; i++)
{
- *g_ndb_cluster_connection_pool[i]->get_latest_trans_gci()= val;
+ *g_pool[i]->get_latest_trans_gci()= val;
}
}
int ndb_has_node_id(uint id)
{
unsigned i;
- for (i= 0; i < g_ndb_cluster_connection_pool_alloc; i++)
+ for (i= 0; i < g_pool_alloc; i++)
{
- if (id == g_ndb_cluster_connection_pool[i]->node_id())
+ if (id == g_pool[i]->node_id())
return 1;
}
return 0;
=== modified file 'sql/ha_ndbcluster_connection.h'
--- a/sql/ha_ndbcluster_connection.h 2009-05-26 18:53:34 +0000
+++ b/sql/ha_ndbcluster_connection.h 2009-11-08 18:23:30 +0000
@@ -16,7 +16,7 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
int ndbcluster_connect(int (*connect_callback)(void));
-int ndbcluster_disconnect();
+void ndbcluster_disconnect(void);
Ndb_cluster_connection *ndb_get_cluster_connection();
ulonglong ndb_get_latest_trans_gci();
=== modified file 'storage/ndb/tools/ndbinfo_sql.cpp'
--- a/storage/ndb/tools/ndbinfo_sql.cpp 2009-11-08 14:17:04 +0000
+++ b/storage/ndb/tools/ndbinfo_sql.cpp 2009-11-08 21:16:50 +0000
@@ -123,20 +123,20 @@ int main(int argc, char** argv){
if ((handle_options(&argc, &argv, my_long_options, NULL)))
return 2;
- printf("--\n");
- printf("-- SQL commands for creating the tables in MySQL Server which \n");
- printf("-- are used by the NDBINFO storage engine to access system \n");
- printf("-- information and statistics from MySQL Cluster\n");
- printf("--\n");
+ printf("#\n");
+ printf("# SQL commands for creating the tables in MySQL Server which \n");
+ printf("# are used by the NDBINFO storage engine to access system \n");
+ printf("# information and statistics from MySQL Cluster\n");
+ printf("#\n");
printf("CREATE DATABASE IF NOT EXISTS `%s`;\n\n", opt_ndbinfo_db);
- printf("-- Only create tables if NDBINFO is enabled\n");
+ printf("# Only create tables if NDBINFO is enabled\n");
printf("SELECT @have_ndbinfo:= COUNT(*) FROM "
"information_schema.engines WHERE engine='NDBINFO' "
"AND support IN ('YES', 'DEFAULT');\n\n");
- printf("-- drop any old views in %s\n", opt_ndbinfo_db);
+ printf("# drop any old views in %s\n", opt_ndbinfo_db);
for (size_t i = 0; i < num_views; i++)
{
printf("DROP VIEW IF EXISTS %s.%s;\n",
@@ -148,7 +148,7 @@ int main(int argc, char** argv){
{
const Ndbinfo::Table& table = Ndbinfo::getTable(i);
- printf("-- %s.%s%s\n",
+ printf("# %s.%s%s\n",
opt_ndbinfo_db, opt_table_prefix, table.m.name);
/* Drop the table if it exists */
@@ -206,15 +206,15 @@ int main(int argc, char** argv){
}
- printf("--\n");
- printf("-- %s views\n", opt_ndbinfo_db);
- printf("--\n\n");
+ printf("#\n");
+ printf("# %s views\n", opt_ndbinfo_db);
+ printf("#\n\n");
for (size_t i = 0; i < num_views; i++)
{
view v = views[i];
- printf("-- %s.%s\n", opt_ndbinfo_db, v.name);
+ printf("# %s.%s\n", opt_ndbinfo_db, v.name);
BaseString view_sql = replace_tags(v.sql);
Attachment: [text/bzr-bundle] bzr/magnus.blaudd@sun.com-20091108212004-vjz5p95da51q7ylu.bundle
| Thread |
|---|
| • bzr push into mysql-5.1-telco-7.0 branch (magnus.blaudd:3202 to 3207) | Magnus Blåudd | 8 Nov 2009 |