Commit dca1d5ce authored by Yoni Fogel's avatar Yoni Fogel

Addresses #1694 Merged checkpoint stress upgrades from 2.0.0 into main

git-svn-id: file:///svn/toku/tokudb@11603 c7de825b-a66e-492c-adef-691d508d4ae1
parent 482ff6bd
...@@ -397,6 +397,7 @@ checkpoint_stress.tdbrun: checkpoint_stress.tdb$(BINSUF) ...@@ -397,6 +397,7 @@ checkpoint_stress.tdbrun: checkpoint_stress.tdb$(BINSUF)
$(VGRIND) ./$< -C -n $(STRESS_SIZE) $(VERBVERBOSE) && \ $(VGRIND) ./$< -C -n $(STRESS_SIZE) $(VERBVERBOSE) && \
($(VGRIND) ./$< -C -i 0 -n $(STRESS_SIZE) $(VERBVERBOSE) && \ ($(VGRIND) ./$< -C -i 0 -n $(STRESS_SIZE) $(VERBVERBOSE) && \
for (( i = 1; i < $(STRESS_RUNS); i++ )); do \ for (( i = 1; i < $(STRESS_RUNS); i++ )); do \
date; \
./$< -c -i $$i -n $(STRESS_SIZE) $(VERBVERBOSE) 2> dir.checkpoint_stress.c.tdb/error.$$i ; \ ./$< -c -i $$i -n $(STRESS_SIZE) $(VERBVERBOSE) 2> dir.checkpoint_stress.c.tdb/error.$$i ; \
if ! grep -q 'HAPPY CRASH' dir.checkpoint_stress.c.tdb/error.$$i; then break; fi; \ if ! grep -q 'HAPPY CRASH' dir.checkpoint_stress.c.tdb/error.$$i; then break; fi; \
done && \ done && \
......
...@@ -23,7 +23,7 @@ checkpoint_test_1(u_int32_t flags, u_int32_t n, int snap_all) { ...@@ -23,7 +23,7 @@ checkpoint_test_1(u_int32_t flags, u_int32_t n, int snap_all) {
fflush(stdout); fflush(stdout);
} }
dir_create(); dir_create();
env_startup(0,0); env_startup(0);
int run; int run;
int r; int r;
DICTIONARY_S db_control; DICTIONARY_S db_control;
...@@ -61,7 +61,7 @@ checkpoint_test_2(u_int32_t flags, u_int32_t n) { ...@@ -61,7 +61,7 @@ checkpoint_test_2(u_int32_t flags, u_int32_t n) {
fflush(stdout); fflush(stdout);
} }
dir_create(); dir_create();
env_startup(0,0); env_startup(0);
int run; int run;
int r; int r;
DICTIONARY_S db_control; DICTIONARY_S db_control;
......
...@@ -66,6 +66,51 @@ scribble(DB* db, int iter) { ...@@ -66,6 +66,51 @@ scribble(DB* db, int iter) {
insert_n_broken(db, NULL, NULL, firstkey, numkeys); insert_n_broken(db, NULL, NULL, firstkey, numkeys);
} }
// scribble over database to make sure that changes made after checkpoint are not saved
// by deleting three of every four rows
static void UU()
thin_out(DB* db, int iter) {
int64_t firstkey; // first key to verify/insert
int64_t numkeys; // number of keys to verify/insert
if (iter > 0){
if (iter == 1) {
firstkey = 0;
numkeys = oper_per_iter;
}
else {
firstkey = (iter - 2) * oper_per_iter;
numkeys = oper_per_iter * 2;
}
}
int r;
DBT keydbt;
int64_t key;
DB_TXN * txn;
dbt_init(&keydbt, &key, sizeof(key));
r = env->txn_begin(env, NULL, &txn, 0);
CKERR(r);
r = db->pre_acquire_table_lock(db, txn);
CKERR(r);
// now delete three of four rows
firstkey = iter * oper_per_iter;
numkeys = oper_per_iter;
for (key = firstkey; key < (firstkey + numkeys); key++) {
if (key & 0x03) { // leave every fourth key alone
r = db->del(db, txn, &keydbt, DB_DELETE_ANY);
CKERR(r);
}
}
r = txn->commit(txn, 0);
CKERR(r);
}
// assert that correct values are in expected rows // assert that correct values are in expected rows
static void static void
...@@ -130,6 +175,10 @@ drop_dead(void) { ...@@ -130,6 +175,10 @@ drop_dead(void) {
fflush(stderr); fflush(stderr);
int zero = 0; int zero = 0;
int infinity = 1/zero; int infinity = 1/zero;
printf("Survived zerodivide!\n");
fflush(stdout);
printf("Infinity = %d\n", infinity);
fflush(stdout);
void * intothevoid = NULL; void * intothevoid = NULL;
(*(int*)intothevoid)++; (*(int*)intothevoid)++;
printf("intothevoid = %p, infinity = %d\n", intothevoid, infinity); printf("intothevoid = %p, infinity = %d\n", intothevoid, infinity);
...@@ -199,6 +248,7 @@ random_acts(void * d) { ...@@ -199,6 +248,7 @@ random_acts(void * d) {
#endif #endif
} }
u_int64_t default_cachesize;
void void
run_test (int iter, int die) { run_test (int iter, int die) {
...@@ -210,8 +260,19 @@ run_test (int iter, int die) { ...@@ -210,8 +260,19 @@ run_test (int iter, int die) {
if (iter == 0) if (iter == 0)
dir_create(); // create directory if first time through dir_create(); // create directory if first time through
// run with 32K cachesize to force lots of disk I/O // Run with cachesize of 256 bytes per iteration
env_startup(0, 1<<15); // to force lots of disk I/O
// (each iteration inserts about 4K rows/dictionary, 16 bytes/row, 4 dictionaries = 256K bytes inserted per iteration)
const int32_t K256 = 256 * 1024;
u_int64_t cachebytes = 0;
cachebytes = K256 * (iter + 1) - (128 * 1024);
if (cachebytes > default_cachesize)
cachebytes = default_cachesize;
if (verbose)
printf("checkpoint_stress: iter = %d, cachesize (bytes) = 0x%08"PRIx64"\n", iter, cachebytes);
env_startup(cachebytes);
// create array of dictionaries // create array of dictionaries
// for each dictionary verify previous iterations and perform new inserts // for each dictionary verify previous iterations and perform new inserts
...@@ -236,7 +297,10 @@ run_test (int iter, int die) { ...@@ -236,7 +297,10 @@ run_test (int iter, int die) {
// this thead will scribble over dictionary 0 before crash to verify that // this thead will scribble over dictionary 0 before crash to verify that
// post-checkpoint inserts are not in the database // post-checkpoint inserts are not in the database
DB* db = dictionaries[0].db; DB* db = dictionaries[0].db;
scribble(db, iter); if (iter & 1)
scribble(db, iter);
else
thin_out(db, iter);
u_int32_t delay = myrandom(); u_int32_t delay = myrandom();
delay &= 0xFFF; // select lower 12 bits, shifted up 8 for random number ... delay &= 0xFFF; // select lower 12 bits, shifted up 8 for random number ...
delay = delay << 8; // ... uniformly distributed between 0 and 1M ... delay = delay << 8; // ... uniformly distributed between 0 and 1M ...
...@@ -299,6 +363,7 @@ test_main (int argc, char *argv[]) { ...@@ -299,6 +363,7 @@ test_main (int argc, char *argv[]) {
} }
} }
if (argc!=optind) { usage(argv[0]); return 1; } if (argc!=optind) { usage(argv[0]); return 1; }
default_cachesize = 256 << 20;
// for developing this test and for exercising with valgrind (no crash) // for developing this test and for exercising with valgrind (no crash)
if (iter <0) { if (iter <0) {
...@@ -309,8 +374,6 @@ test_main (int argc, char *argv[]) { ...@@ -309,8 +374,6 @@ test_main (int argc, char *argv[]) {
} }
} }
else { else {
if (verbose)
printf("checkpoint_stress running one iteration, iter = %d\n", iter);
run_test(iter, crash); run_test(iter, crash);
} }
......
...@@ -96,7 +96,7 @@ dir_create(void) { ...@@ -96,7 +96,7 @@ dir_create(void) {
// pass in zeroes for default cachesize // pass in zeroes for default cachesize
static void UU() static void UU()
env_startup(int32_t gbytes, int32_t bytes) { env_startup(int64_t bytes) {
int r; int r;
r = db_env_create(&env, 0); r = db_env_create(&env, 0);
CKERR(r); CKERR(r);
...@@ -104,8 +104,8 @@ env_startup(int32_t gbytes, int32_t bytes) { ...@@ -104,8 +104,8 @@ env_startup(int32_t gbytes, int32_t bytes) {
CKERR(r); CKERR(r);
r = env->set_default_dup_compare(env, int64_dbt_cmp); r = env->set_default_dup_compare(env, int64_dbt_cmp);
CKERR(r); CKERR(r);
if (gbytes | bytes) { if (bytes) {
r = env->set_cachesize(env, gbytes, bytes, 1); r = env->set_cachesize(env, bytes >> 30, bytes % (1<<30), 1);
CKERR(r); CKERR(r);
} }
r = env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO); r = env->open(env, ENVDIR, DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_MPOOL|DB_INIT_TXN|DB_CREATE|DB_PRIVATE, S_IRWXU+S_IRWXG+S_IRWXO);
......
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