| Bug #30793 | Add option to set the random seed in mysqlslap | ||
|---|---|---|---|
| Submitted: | 4 Sep 2007 13:19 | Modified: | 1 Feb 2008 18:15 |
| Reporter: | Chad MILLER | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server: Tests | Severity: | S4 (Feature request) |
| Version: | 5.2 | OS: | Any |
| Assigned to: | Chad MILLER | CPU Architecture: | Any |
| Tags: | Contribution | ||
[4 Sep 2007 15:17]
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/33641 ChangeSet@1.2591, 2007-09-04 11:15:32-04:00, cmiller@zippy.cornsilk.net +1 -0 Bug#30793: set random seed for mysqlslap Contributed patch from "mushuiliu". No CLA. Add a new parameter "set-random-seed", which takes an uint as an argument. If the parameter isn't used, then the random_seed is set from time() as usual. If it is used or if the value is zero, then it's set from that. Print the seed value in the output, so a run can be replayed.
[5 Sep 2007 19:08]
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/33759 ChangeSet@1.2591, 2007-09-05 15:06:37-04:00, cmiller@zippy.cornsilk.net +1 -0 Bug#30793: set random seed for mysqlslap Contributed patch from "mushuiliu". No CLA. Add a new parameter "set-random-seed", which takes an uint as an argument. If the parameter isn't used or is used for value "0", then the random_seed is set from time() as usual. Print the seed value in the output, so a run can be replayed.
[5 Sep 2007 21:06]
Chad MILLER
Queued to Maint tree.
[29 Jan 2008 18:12]
Chad MILLER
Brian committed this to 6.0 several months ago, as part of a Google Summer of Code submission.
[1 Feb 2008 18:15]
Paul DuBois
Noted in 5.2.6 changelog. Added the --set-random-seed option to mysqlslap to enable a seed value to be provided for the randomizer.

Description: From: mushuiliu@gmail.com Subject: Add option to set the random number seed for "client/mysqlslap.c" Date: 24 August 2007 13:33:13 GMT-04:00 To: internals@lists.mysql.com Cc: stewart@mysql.com what it does: 1Add option to set the random number seed what's passed to srandom() 2Display what was set for the random number what it applies: Allows the same run to be performed multiple times i.e. if something was hit on a specific run, you can emulate it by calling mysqlslap with --set-random-seed to the value which the failing run was run with How to repeat: . Suggested fix: --- rand.orig/mysqlslap.c 2007-08-25 01:19:02.000000000 +0800 +++ rand/mysqlslap.c 2007-08-25 01:24:07.000000000 +0800 @@ -138,7 +138,7 @@ auto_generate_sql_guid_primary= FALSE, auto_generate_sql= FALSE; const char *auto_generate_sql_type= "mixed"; - +static unsigned int set_random_seed= 0; static unsigned long connect_flags= CLIENT_MULTI_RESULTS; static int verbose, delimiter_length; @@ -299,11 +299,13 @@ my_end(0); exit(1); } - /* Seed the random number generator if we will be using it. */ if (auto_generate_sql) - srandom((uint)time(NULL)); - + { + if(set_random_seed==0) + set_random_seed=(uint)time(NULL); + srandom(set_random_seed); + } /* globals? Yes, so we only have to run strlen once */ delimiter_length= strlen(delimiter); @@ -605,6 +607,10 @@ {"query", 'q', "Query to run or file containing query to run.", (uchar**) &user_supplied_query, (uchar**) &user_supplied_query, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"set-random-seed",'r',"Seed for random number generator (srandom(3))", + (uchar**)&set_random_seed, + (uchar**)&set_random_seed,0, + GET_UINT,REQUIRED_ARG,0,0,0,0,0,0}, #ifdef HAVE_SMEM {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, "Base name of shared memory.", (uchar**) &shared_memory_base_name, @@ -2009,6 +2015,7 @@ printf("Benchmark\n"); if (con->engine) printf("\tRunning for engine %s\n", con->engine); + printf("\tRand Seed:%lu\n",set_random_seed); printf("\tAverage number of seconds to run all queries: %ld.%03ld seconds\n", con->avg_timing / 1000, con->avg_timing % 1000); printf("\tMinimum number of seconds to run all queries: %ld.%03ld seconds\n",