Loading src/tests/test_set_lk_max_locks.c +37 −30 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ // ENVDIR is defined in the Makefile #ifdef TOKUDB #if TOKUDB #define EXTRA_LOCK_NEEDED 2 #else #define EXTRA_LOCK_NEEDED 0 Loading @@ -33,14 +33,19 @@ static void make_db (int n_locks) { CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r == 0); r = db_env_create(&env, 0); assert(r == 0); #ifdef TOKUDB #if TOKUDB r = env->set_redzone(env, 0); assert(r == 0); #endif env->set_errfile(env, 0); if (n_locks>0) { #if !TOKUDB && DB_VERSION_MAJOR >= 5 // BDB configures lock partitons with the number of processors. We set the number of lock partitions to 1 // to override the default and get consistent locking behaviour on many machines. r = env->set_lk_partitions(env, 1); CKERR(r); #endif r = env->set_lk_max_locks(env, n_locks+EXTRA_LOCK_NEEDED); CKERR(r); /* test the get_lk_max_locks method */ #ifdef TOKUDB #if TOKUDB // BDB cannot handle a NULL passed to get_lk_max_locks r = env->get_lk_max_locks(env, 0); assert(r == EINVAL); Loading @@ -58,7 +63,7 @@ static void make_db (int n_locks) { r = db->open(db, tid, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = tid->commit(tid, 0); assert(r == 0); #ifndef TOKUDB #if !TOKUDB u_int32_t pagesize; r = db->get_pagesize(db, &pagesize); CKERR(r); u_int32_t datasize = pagesize/6; Loading Loading @@ -108,12 +113,13 @@ static void make_db (int n_locks) { key.data = hello; key.size=strlen(hello)+1; data.data = there; data.size=strlen(there)+1; r = db->put(db, j==0 ? tid : tid2, &key, &data, 0); #ifdef TOKUDB #if TOKUDB // Lock escalation cannot help here: We require too many locks because we are alternating between tid and tid2 if (i*2+j<effective_n_locks) { CKERR(r); } else CKERR2(r, TOKUDB_OUT_OF_LOCKS); #else if (verbose) printf("%d %d %d\n", i, j, r); #if DB_VERSION_MAJOR >= 5 if (i*2+j+1<effective_n_locks) { #else Loading @@ -134,7 +140,8 @@ static void make_db (int n_locks) { } int test_main (int argc __attribute__((__unused__)), char *const argv[] __attribute__((__unused__))) { test_main (int argc, char * const argv[]) { parse_args(argc, argv); make_db(100); make_db(1000); if (0) { Loading Loading
src/tests/test_set_lk_max_locks.c +37 −30 Original line number Diff line number Diff line Loading @@ -15,7 +15,7 @@ // ENVDIR is defined in the Makefile #ifdef TOKUDB #if TOKUDB #define EXTRA_LOCK_NEEDED 2 #else #define EXTRA_LOCK_NEEDED 0 Loading @@ -33,14 +33,19 @@ static void make_db (int n_locks) { CKERR(r); r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r == 0); r = db_env_create(&env, 0); assert(r == 0); #ifdef TOKUDB #if TOKUDB r = env->set_redzone(env, 0); assert(r == 0); #endif env->set_errfile(env, 0); if (n_locks>0) { #if !TOKUDB && DB_VERSION_MAJOR >= 5 // BDB configures lock partitons with the number of processors. We set the number of lock partitions to 1 // to override the default and get consistent locking behaviour on many machines. r = env->set_lk_partitions(env, 1); CKERR(r); #endif r = env->set_lk_max_locks(env, n_locks+EXTRA_LOCK_NEEDED); CKERR(r); /* test the get_lk_max_locks method */ #ifdef TOKUDB #if TOKUDB // BDB cannot handle a NULL passed to get_lk_max_locks r = env->get_lk_max_locks(env, 0); assert(r == EINVAL); Loading @@ -58,7 +63,7 @@ static void make_db (int n_locks) { r = db->open(db, tid, "foo.db", 0, DB_BTREE, DB_CREATE, S_IRWXU+S_IRWXG+S_IRWXO); CKERR(r); r = tid->commit(tid, 0); assert(r == 0); #ifndef TOKUDB #if !TOKUDB u_int32_t pagesize; r = db->get_pagesize(db, &pagesize); CKERR(r); u_int32_t datasize = pagesize/6; Loading Loading @@ -108,12 +113,13 @@ static void make_db (int n_locks) { key.data = hello; key.size=strlen(hello)+1; data.data = there; data.size=strlen(there)+1; r = db->put(db, j==0 ? tid : tid2, &key, &data, 0); #ifdef TOKUDB #if TOKUDB // Lock escalation cannot help here: We require too many locks because we are alternating between tid and tid2 if (i*2+j<effective_n_locks) { CKERR(r); } else CKERR2(r, TOKUDB_OUT_OF_LOCKS); #else if (verbose) printf("%d %d %d\n", i, j, r); #if DB_VERSION_MAJOR >= 5 if (i*2+j+1<effective_n_locks) { #else Loading @@ -134,7 +140,8 @@ static void make_db (int n_locks) { } int test_main (int argc __attribute__((__unused__)), char *const argv[] __attribute__((__unused__))) { test_main (int argc, char * const argv[]) { parse_args(argc, argv); make_db(100); make_db(1000); if (0) { Loading