mirror of
https://github.com/MariaDB/server.git
synced 2025-02-02 03:51:50 +01:00
#4429 get test_set_lk_max_locks running on BDB 5.3 refs[t:4429]
git-svn-id: file:///svn/toku/tokudb@39193 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
d73ff757b4
commit
a2dacff9c8
1 changed files with 37 additions and 30 deletions
|
@ -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
|
||||
|
@ -31,34 +31,39 @@ static void make_db (int n_locks) {
|
|||
|
||||
r = system("rm -rf " ENVDIR);
|
||||
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
|
||||
r = toku_os_mkdir(ENVDIR, S_IRWXU+S_IRWXG+S_IRWXO); assert(r == 0);
|
||||
r = db_env_create(&env, 0); assert(r == 0);
|
||||
#if TOKUDB
|
||||
r = env->set_redzone(env, 0); assert(r == 0);
|
||||
#endif
|
||||
env->set_errfile(env, 0);
|
||||
if (n_locks>0) {
|
||||
r=env->set_lk_max_locks(env, n_locks+EXTRA_LOCK_NEEDED); CKERR(r);
|
||||
#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);
|
||||
r = env->get_lk_max_locks(env, 0);
|
||||
assert(r == EINVAL);
|
||||
#endif
|
||||
r=env->get_lk_max_locks(env, &actual_n_locks);
|
||||
r = env->get_lk_max_locks(env, &actual_n_locks);
|
||||
assert(r == 0 && actual_n_locks == (u_int32_t)n_locks+EXTRA_LOCK_NEEDED);
|
||||
}
|
||||
else {
|
||||
r=env->get_lk_max_locks(env, &actual_n_locks);
|
||||
r = env->get_lk_max_locks(env, &actual_n_locks);
|
||||
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); CKERR(r);
|
||||
r=db_create(&db, env, 0); CKERR(r);
|
||||
r=env->txn_begin(env, 0, &tid, 0); assert(r==0);
|
||||
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);
|
||||
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); CKERR(r);
|
||||
r = db_create(&db, env, 0); CKERR(r);
|
||||
r = env->txn_begin(env, 0, &tid, 0); assert(r == 0);
|
||||
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;
|
||||
|
@ -68,7 +73,7 @@ static void make_db (int n_locks) {
|
|||
int effective_n_locks = (n_locks<0) ? (int)actual_n_locks-EXTRA_LOCK_NEEDED : n_locks;
|
||||
// create even numbered keys 0 2 4 ... (effective_n_locks*32-2)
|
||||
|
||||
r=env->txn_begin(env, 0, &tid, 0); CKERR(r);
|
||||
r = env->txn_begin(env, 0, &tid, 0); CKERR(r);
|
||||
for (i=0; i<effective_n_locks*16; i++) {
|
||||
char hello[30], there[datasize+30];
|
||||
DBT key,data;
|
||||
|
@ -79,20 +84,20 @@ static void make_db (int n_locks) {
|
|||
key.data = hello; key.size=strlen(hello)+1;
|
||||
data.data = there; data.size=strlen(there)+1;
|
||||
if (i%50==49) {
|
||||
r=tid->commit(tid, 0); CKERR(r);
|
||||
r=env->txn_begin(env, 0, &tid, 0); CKERR(r);
|
||||
r = tid->commit(tid, 0); CKERR(r);
|
||||
r = env->txn_begin(env, 0, &tid, 0); CKERR(r);
|
||||
}
|
||||
r=db->put(db, tid, &key, &data, 0); CKERR(r);
|
||||
r = db->put(db, tid, &key, &data, 0); CKERR(r);
|
||||
}
|
||||
r=tid->commit(tid, 0); CKERR(r);
|
||||
r = tid->commit(tid, 0); CKERR(r);
|
||||
|
||||
// Now using two different transactions have one transaction create keys
|
||||
// 1 17 33 ... (1 mod 16)
|
||||
// and another do
|
||||
// 9 25 41 ... (9 mod 16)
|
||||
|
||||
r=env->txn_begin(env, 0, &tid, 0); CKERR(r);
|
||||
r=env->txn_begin(env, 0, &tid2, 0); CKERR(r);
|
||||
r = env->txn_begin(env, 0, &tid, 0); CKERR(r);
|
||||
r = env->txn_begin(env, 0, &tid2, 0); CKERR(r);
|
||||
|
||||
for (i=0; i<effective_n_locks*2; i++) {
|
||||
int j;
|
||||
|
@ -107,19 +112,20 @@ static void make_db (int n_locks) {
|
|||
//printf("Writing %s in %d\n", hello, j);
|
||||
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
|
||||
r = db->put(db, j==0 ? tid : tid2, &key, &data, 0);
|
||||
#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
|
||||
if (i*2+j+2<effective_n_locks) {
|
||||
#endif
|
||||
if (r!=0) printf("r=%d on i=%d j=%d eff=%d\n", r, i, j, effective_n_locks);
|
||||
if (r!=0) printf("r = %d on i=%d j=%d eff=%d\n", r, i, j, effective_n_locks);
|
||||
CKERR(r);
|
||||
} else {
|
||||
CKERR2(r, ENOMEM);
|
||||
|
@ -127,14 +133,15 @@ static void make_db (int n_locks) {
|
|||
#endif
|
||||
}
|
||||
}
|
||||
r=tid->commit(tid2, 0); assert(r==0);
|
||||
r=tid->commit(tid, 0); assert(r==0);
|
||||
r=db->close(db, 0); assert(r==0);
|
||||
r=env->close(env, 0); assert(r==0);
|
||||
r = tid->commit(tid2, 0); assert(r == 0);
|
||||
r = tid->commit(tid, 0); assert(r == 0);
|
||||
r = db->close(db, 0); assert(r == 0);
|
||||
r = env->close(env, 0); assert(r == 0);
|
||||
}
|
||||
|
||||
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…
Add table
Reference in a new issue