Commit 14ff02d3 authored by unknown's avatar unknown

Merge baker@bk-internal.mysql.com:/home/bk/mysql-5.1-new

into  zim.tangent.org:/home/brian/mysql/slap-5.1

parents 684689d1 17bd1288
...@@ -48,6 +48,7 @@ mysqlbinlog_SOURCES = mysqlbinlog.cc $(top_srcdir)/mysys/mf_tempdir.c \ ...@@ -48,6 +48,7 @@ mysqlbinlog_SOURCES = mysqlbinlog.cc $(top_srcdir)/mysys/mf_tempdir.c \
$(top_srcdir)/mysys/my_vle.c \ $(top_srcdir)/mysys/my_vle.c \
$(top_srcdir)/mysys/base64.c $(top_srcdir)/mysys/base64.c
mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS) mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS)
mysqlslap_LDADD = $(LDADD) $(CXXLDFLAGS) -lpthread
mysqltestmanager_pwgen_SOURCES = mysqlmanager-pwgen.c mysqltestmanager_pwgen_SOURCES = mysqlmanager-pwgen.c
mysqltestmanagerc_SOURCES= mysqlmanagerc.c $(yassl_dummy_link_fix) mysqltestmanagerc_SOURCES= mysqlmanagerc.c $(yassl_dummy_link_fix)
mysqlcheck_SOURCES= mysqlcheck.c $(yassl_dummy_link_fix) mysqlcheck_SOURCES= mysqlcheck.c $(yassl_dummy_link_fix)
......
...@@ -53,6 +53,7 @@ enum options_client ...@@ -53,6 +53,7 @@ enum options_client
OPT_MYSQL_ONLY_PRINT, OPT_MYSQL_ONLY_PRINT,
OPT_MYSQL_LOCK_DIRECTORY, OPT_MYSQL_LOCK_DIRECTORY,
OPT_MYSQL_SLAP_SLAVE, OPT_MYSQL_SLAP_SLAVE,
OPT_USE_THREADS,
OPT_MYSQL_NUMBER_OF_QUERY, OPT_MYSQL_NUMBER_OF_QUERY,
OPT_MYSQL_PRESERVE_SCHEMA, OPT_MYSQL_PRESERVE_SCHEMA,
OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE, OPT_IGNORE_TABLE,OPT_INSERT_IGNORE,OPT_SHOW_WARNINGS,OPT_DROP_DATABASE,
......
...@@ -87,6 +87,7 @@ TODO: ...@@ -87,6 +87,7 @@ TODO:
#include <sys/types.h> #include <sys/types.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <ctype.h> #include <ctype.h>
#include <my_pthread.h>
#define MYSLAPLOCK "/myslaplock.lck" #define MYSLAPLOCK "/myslaplock.lck"
#define MYSLAPLOCK_DIR "/tmp" #define MYSLAPLOCK_DIR "/tmp"
...@@ -132,6 +133,7 @@ static uint opt_protocol= 0; ...@@ -132,6 +133,7 @@ static uint opt_protocol= 0;
static int get_options(int *argc,char ***argv); static int get_options(int *argc,char ***argv);
static uint opt_mysql_port= 0; static uint opt_mysql_port= 0;
static uint opt_use_threads;
static const char *load_default_groups[]= { "mysqlslap","client",0 }; static const char *load_default_groups[]= { "mysqlslap","client",0 };
...@@ -151,6 +153,13 @@ struct stats { ...@@ -151,6 +153,13 @@ struct stats {
unsigned long long rows; unsigned long long rows;
}; };
typedef struct thread_context thread_context;
struct thread_context {
statement *stmt;
ulonglong limit;
};
typedef struct conclusions conclusions; typedef struct conclusions conclusions;
struct conclusions { struct conclusions {
...@@ -184,7 +193,7 @@ static int create_schema(MYSQL *mysql, const char *db, statement *stmt, ...@@ -184,7 +193,7 @@ static int create_schema(MYSQL *mysql, const char *db, statement *stmt,
statement *engine_stmt); statement *engine_stmt);
static int run_scheduler(stats *sptr, statement *stmts, uint concur, static int run_scheduler(stats *sptr, statement *stmts, uint concur,
ulonglong limit); ulonglong limit);
int run_task(statement *stmt, ulonglong limit); int run_task(thread_context *con);
void statement_cleanup(statement *stmt); void statement_cleanup(statement *stmt);
static const char ALPHANUMERICS[]= static const char ALPHANUMERICS[]=
...@@ -440,6 +449,10 @@ static struct my_option my_long_options[] = ...@@ -440,6 +449,10 @@ static struct my_option my_long_options[] =
{"socket", 'S', "Socket file to use for connection.", {"socket", 'S', "Socket file to use for connection.",
(gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR, (gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR,
REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"use-threads", OPT_USE_THREADS,
"Use pthread calls instead of fork() calls (default on Windows)",
(gptr*) &opt_use_threads, (gptr*) &opt_use_threads, 0,
GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
#include <sslopt-longopts.h> #include <sslopt-longopts.h>
#ifndef DONT_ALLOW_USER_CHANGE #ifndef DONT_ALLOW_USER_CHANGE
{"user", 'u', "User for login if not current user.", (gptr*) &user, {"user", 'u', "User for login if not current user.", (gptr*) &user,
...@@ -930,8 +943,11 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit) ...@@ -930,8 +943,11 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)
uint x; uint x;
File lock_file; File lock_file;
struct timeval start_time, end_time; struct timeval start_time, end_time;
thread_context con;
DBUG_ENTER("run_scheduler"); DBUG_ENTER("run_scheduler");
con.stmt= stmts;
con.limit= limit;
lock_file= my_open(lock_file_str, O_CREAT|O_WRONLY|O_TRUNC, MYF(0)); lock_file= my_open(lock_file_str, O_CREAT|O_WRONLY|O_TRUNC, MYF(0));
...@@ -943,6 +959,30 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit) ...@@ -943,6 +959,30 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)
exit(0); exit(0);
} }
if (opt_use_threads)
{
pthread_t mainthread; /* Thread descriptor */
pthread_attr_t attr; /* Thread attributes */
for (x= 0; x < concur; x++)
{
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr,
PTHREAD_CREATE_DETACHED);
/* now create the thread */
if (pthread_create(&mainthread, &attr, (void *)run_task,
(void *)&con) != 0)
{
fprintf(stderr,"%s: Could not create thread\n",
my_progname);
exit(0);
}
}
}
else
{
fflush(NULL);
for (x= 0; x < concur; x++) for (x= 0; x < concur; x++)
{ {
int pid; int pid;
...@@ -958,7 +998,7 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit) ...@@ -958,7 +998,7 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)
fprintf(stderr, fprintf(stderr,
"%s: fork returned 0, calling task pid %d gid %d\n", "%s: fork returned 0, calling task pid %d gid %d\n",
my_progname, pid, getgid()); my_progname, pid, getgid());
run_task(stmts, limit); run_task(&con);
exit(0); exit(0);
break; break;
case -1: case -1:
...@@ -979,14 +1019,30 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit) ...@@ -979,14 +1019,30 @@ run_scheduler(stats *sptr, statement *stmts, uint concur, ulonglong limit)
break; break;
} }
} }
}
/* Lets release use some clients! */ /* Lets release use some clients! */
if (!opt_slave) if (!opt_slave)
my_lock(lock_file, F_UNLCK, 0, F_TO_EOF, MYF(0)); my_lock(lock_file, F_UNLCK, 0, F_TO_EOF, MYF(0));
gettimeofday(&start_time, NULL); gettimeofday(&start_time, NULL);
my_close(lock_file, MYF(0)); /*
We look to grab a write lock at this point. Once we get it we know that
all clients have completed their work.
*/
if (opt_use_threads)
{
if (my_lock(lock_file, F_WRLCK, 0, F_TO_EOF, MYF(0)))
{
fprintf(stderr,"%s: Could not get lockfile\n",
my_progname);
exit(0);
}
my_lock(lock_file, F_UNLCK, 0, F_TO_EOF, MYF(0));
}
else
{
WAIT: WAIT:
while (x--) while (x--)
{ {
...@@ -994,8 +1050,11 @@ WAIT: ...@@ -994,8 +1050,11 @@ WAIT:
pid= wait(&status); pid= wait(&status);
DBUG_PRINT("info", ("Parent: child %d status %d", pid, status)); DBUG_PRINT("info", ("Parent: child %d status %d", pid, status));
} }
}
gettimeofday(&end_time, NULL); gettimeofday(&end_time, NULL);
my_close(lock_file, MYF(0));
sptr->timing= timedif(end_time, start_time); sptr->timing= timedif(end_time, start_time);
sptr->users= concur; sptr->users= concur;
sptr->rows= limit; sptr->rows= limit;
...@@ -1004,7 +1063,7 @@ WAIT: ...@@ -1004,7 +1063,7 @@ WAIT:
} }
int int
run_task(statement *qstmt, ulonglong limit) run_task(thread_context *con)
{ {
ulonglong counter= 0, queries; ulonglong counter= 0, queries;
File lock_file; File lock_file;
...@@ -1014,7 +1073,7 @@ run_task(statement *qstmt, ulonglong limit) ...@@ -1014,7 +1073,7 @@ run_task(statement *qstmt, ulonglong limit)
statement *ptr; statement *ptr;
DBUG_ENTER("run_task"); DBUG_ENTER("run_task");
DBUG_PRINT("info", ("task script \"%s\"", qstmt->string)); DBUG_PRINT("info", ("task script \"%s\"", con->stmt->string));
mysql_init(&mysql); mysql_init(&mysql);
...@@ -1036,7 +1095,7 @@ run_task(statement *qstmt, ulonglong limit) ...@@ -1036,7 +1095,7 @@ run_task(statement *qstmt, ulonglong limit)
queries= 0; queries= 0;
limit_not_met: limit_not_met:
for (ptr= qstmt; ptr && ptr->length; ptr= ptr->next) for (ptr= con->stmt; ptr && ptr->length; ptr= ptr->next)
{ {
if (opt_only_print) if (opt_only_print)
{ {
...@@ -1060,11 +1119,11 @@ limit_not_met: ...@@ -1060,11 +1119,11 @@ limit_not_met:
} }
queries++; queries++;
if (limit && queries == limit) if (con->limit && queries == con->limit)
DBUG_RETURN(0); DBUG_RETURN(0);
} }
if (limit && queries < limit) if (con->limit && queries < con->limit)
goto limit_not_met; goto limit_not_met;
my_lock(lock_file, F_UNLCK, 0, F_TO_EOF, MYF(0)); my_lock(lock_file, F_UNLCK, 0, F_TO_EOF, MYF(0));
......
This diff is collapsed.
...@@ -19,6 +19,5 @@ innodb_concurrent : Results are not deterministic, Elliot will fix (BUG#3300) ...@@ -19,6 +19,5 @@ innodb_concurrent : Results are not deterministic, Elliot will fix (BUG#3300)
subselect : Bug#15706 subselect : Bug#15706
type_time : Bug#15805 type_time : Bug#15805
rpl_ddl : Bug#15963 SBR does not show "Definer" correctly rpl_ddl : Bug#15963 SBR does not show "Definer" correctly
mysqlslap : Bug#16167
events : Affects flush test case. A table lock not released somewhere events : Affects flush test case. A table lock not released somewhere
rpl_sp : Bug #16456 rpl_sp : Bug #16456
...@@ -4,6 +4,8 @@ ...@@ -4,6 +4,8 @@
--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql
--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --number-int-cols=2 --number-char-cols=3 --auto-generate-sql --use-threads
--exec $MYSQL_SLAP --only-print --iterations=20 --query="select * from t1" --create="CREATE TABLE t1 (id int, name varchar(64)); INSERT INTO t1 VALUES (1, 'This is a test')" --delimiter=";" --exec $MYSQL_SLAP --only-print --iterations=20 --query="select * from t1" --create="CREATE TABLE t1 (id int, name varchar(64)); INSERT INTO t1 VALUES (1, 'This is a test')" --delimiter=";"
--exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --query="select * from t1" --create="CREATE TABLE t1 (id int, name varchar(64)); INSERT INTO t1 VALUES (1, 'This is a test')" --delimiter=";" --exec $MYSQL_SLAP --silent --concurrency=5 --iterations=20 --query="select * from t1" --create="CREATE TABLE t1 (id int, name varchar(64)); INSERT INTO t1 VALUES (1, 'This is a test')" --delimiter=";"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment