Commit 3ce1f7ce authored by Vincenzo Liberatore's avatar Vincenzo Liberatore

Addresses #337

Fixes the tests with a bound on the number of ranges, and fixes a bug
in lock tree unlock

git-svn-id: file:///svn/tokudb@2125 c7de825b-a66e-492c-adef-691d508d4ae1
parent ccb9a0f1
# On OSX do: # On OSX do:
# make OSX=OSX # make OSX=OSX
LIBNAME=liblocktree LIBNAME=liblocktree_linear
ifneq ($(OPT),) ifneq ($(OPT),)
OPTFLAGS = -O3 OPTFLAGS = -O0 -g3 -ggdb3
else else
OPTFLAGS = -O2 -g3 -ggdb3 OPTFLAGS = -O2 -g3 -ggdb3
endif endif
......
...@@ -1186,14 +1186,15 @@ int toku_lt_unlock(toku_lock_tree* tree, DB_TXN* txn) { ...@@ -1186,14 +1186,15 @@ int toku_lt_unlock(toku_lock_tree* tree, DB_TXN* txn) {
toku_range_tree *selfread = __toku_lt_ifexist_selfread (tree, txn); toku_range_tree *selfread = __toku_lt_ifexist_selfread (tree, txn);
u_int32_t ranges = 0; u_int32_t ranges = 0;
if (selfwrite) {
ranges = toku_rt_get_size(selfwrite); if (selfread) {
ranges = toku_rt_get_size(selfread);
r = __toku_lt_free_contents(tree, selfread, tree->mainread); r = __toku_lt_free_contents(tree, selfread, tree->mainread);
if (r!=0) return __toku_lt_panic(tree, r); if (r!=0) return __toku_lt_panic(tree, r);
} }
if (selfread) { if (selfwrite) {
ranges += toku_rt_get_size(selfread); ranges += toku_rt_get_size(selfwrite);
r = __toku_lt_border_delete(tree, selfwrite); r = __toku_lt_border_delete(tree, selfwrite);
if (r!=0) return __toku_lt_panic(tree, r); if (r!=0) return __toku_lt_panic(tree, r);
} }
......
...@@ -40,7 +40,8 @@ int dbcmp (DB *db __attribute__((__unused__)), const DBT *a, const DBT*b) { ...@@ -40,7 +40,8 @@ int dbcmp (DB *db __attribute__((__unused__)), const DBT *a, const DBT*b) {
BOOL panicked = FALSE; BOOL panicked = FALSE;
int dbpanic(DB* db) { int dbpanic(DB* db, int r) {
r++;
if (verbose) printf("AHH!!!! Run away %p!!!\n", db); if (verbose) printf("AHH!!!! Run away %p!!!\n", db);
panicked = TRUE; panicked = TRUE;
assert(want_panic); assert(want_panic);
......
...@@ -5,10 +5,11 @@ int main() { ...@@ -5,10 +5,11 @@ int main() {
toku_lock_tree* lt = NULL; toku_lock_tree* lt = NULL;
DB* db = (DB*)1; DB* db = (DB*)1;
u_int32_t mem = 4096 * 1000; u_int32_t mem = 4096 * 1000;
u_int32_t memcnt; u_int32_t memcnt = 0;
BOOL duplicates; BOOL duplicates;
for (duplicates = 0; duplicates < 2; duplicates++) { for (duplicates = 0; duplicates < 2; duplicates++) {
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt, r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt,
dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc); dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc);
CKERR(r); CKERR(r);
......
...@@ -7,7 +7,7 @@ static DBT _data; ...@@ -7,7 +7,7 @@ static DBT _data;
DBT* key; DBT* key;
DBT* data; DBT* data;
u_int32_t mem = 4096 * 1000; u_int32_t mem = 4096 * 1000;
u_int32_t memcnt; u_int32_t memcnt = 0;
static void do_range_test(int (*acquire)(toku_lock_tree*, DB_TXN*, static void do_range_test(int (*acquire)(toku_lock_tree*, DB_TXN*,
const DBT*, const DBT*, const DBT*, const DBT*,
...@@ -40,6 +40,7 @@ static void do_range_test(int (*acquire)(toku_lock_tree*, DB_TXN*, ...@@ -40,6 +40,7 @@ static void do_range_test(int (*acquire)(toku_lock_tree*, DB_TXN*,
reverse_data_l = &_data_l; reverse_data_l = &_data_l;
reverse_data_r = &_data_r; reverse_data_r = &_data_r;
} }
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt, r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt,
dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc); dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc);
CKERR(r); CKERR(r);
...@@ -142,6 +143,7 @@ static void do_point_test(int (*acquire)(toku_lock_tree*, DB_TXN*, ...@@ -142,6 +143,7 @@ static void do_point_test(int (*acquire)(toku_lock_tree*, DB_TXN*,
reverse_data = &_data; reverse_data = &_data;
data = NULL; data = NULL;
} }
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt, r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt,
dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc); dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc);
CKERR(r); CKERR(r);
...@@ -195,42 +197,52 @@ int main(int argc, const char *argv[]) { ...@@ -195,42 +197,52 @@ int main(int argc, const char *argv[]) {
/* create tests. */ /* create tests. */
for (duplicates = 0; duplicates < 2; duplicates++) { for (duplicates = 0; duplicates < 2; duplicates++) {
memcnt = 0;
r = toku_lt_create(NULL, db, duplicates, dbpanic, mem, &memcnt, r = toku_lt_create(NULL, db, duplicates, dbpanic, mem, &memcnt,
dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc); dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc);
CKERR2(r, EINVAL); CKERR2(r, EINVAL);
memcnt = 0;
r = toku_lt_create(&lt, NULL, duplicates, dbpanic, mem, &memcnt, r = toku_lt_create(&lt, NULL, duplicates, dbpanic, mem, &memcnt,
dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc); dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc);
CKERR2(r, EINVAL); CKERR2(r, EINVAL);
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, NULL, mem, &memcnt, r = toku_lt_create(&lt, db, duplicates, NULL, mem, &memcnt,
dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc); dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc);
CKERR2(r, EINVAL); CKERR2(r, EINVAL);
u_int32_t old_mem = mem; u_int32_t old_mem = mem;
mem = 0; mem = 0;
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt, r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt,
dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc); dbcmp, dbcmp, toku_malloc, toku_free, toku_realloc);
CKERR2(r, EINVAL); CKERR2(r, EINVAL);
mem = old_mem; mem = old_mem;
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, NULL, r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, NULL,
NULL, dbcmp, toku_malloc, toku_free, toku_realloc); NULL, dbcmp, toku_malloc, toku_free, toku_realloc);
CKERR2(r, EINVAL); CKERR2(r, EINVAL);
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt, r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt,
NULL, dbcmp, toku_malloc, toku_free, toku_realloc); NULL, dbcmp, toku_malloc, toku_free, toku_realloc);
CKERR2(r, EINVAL); CKERR2(r, EINVAL);
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt, r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt,
dbcmp, NULL, dbcmp, NULL,
toku_malloc, toku_free, toku_realloc); toku_malloc, toku_free, toku_realloc);
CKERR2(r, EINVAL); CKERR2(r, EINVAL);
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt, r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt,
dbcmp, dbcmp, dbcmp, dbcmp,
NULL, toku_free, toku_realloc); NULL, toku_free, toku_realloc);
CKERR2(r, EINVAL); CKERR2(r, EINVAL);
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt, r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt,
dbcmp, dbcmp, toku_malloc, NULL, toku_realloc); dbcmp, dbcmp, toku_malloc, NULL, toku_realloc);
CKERR2(r, EINVAL); CKERR2(r, EINVAL);
memcnt = 0;
r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt, r = toku_lt_create(&lt, db, duplicates, dbpanic, mem, &memcnt,
dbcmp, dbcmp, toku_malloc, toku_free, NULL); dbcmp, dbcmp, toku_malloc, toku_free, NULL);
CKERR2(r, EINVAL); CKERR2(r, EINVAL);
......
...@@ -9,7 +9,8 @@ int r; ...@@ -9,7 +9,8 @@ int r;
toku_lock_tree* lt = NULL; toku_lock_tree* lt = NULL;
DB* db = (DB*)1; DB* db = (DB*)1;
DB_TXN* txn = (DB_TXN*)1; DB_TXN* txn = (DB_TXN*)1;
size_t mem = 4096 * 1000; u_int32_t mem = 4096 * 1000;
u_int32_t memcnt = 0;
BOOL duplicates = FALSE; BOOL duplicates = FALSE;
int nums[100]; int nums[100];
...@@ -46,7 +47,8 @@ void init_query(BOOL dups) { ...@@ -46,7 +47,8 @@ void init_query(BOOL dups) {
} }
void setup_tree(BOOL dups) { void setup_tree(BOOL dups) {
r = toku_lt_create(&lt, db, dups, dbpanic, mem, dbcmp, dbcmp, memcnt = 0;
r = toku_lt_create(&lt, db, dups, dbpanic, mem, &memcnt, dbcmp, dbcmp,
toku_malloc, toku_free, toku_realloc); toku_malloc, toku_free, toku_realloc);
CKERR(r); CKERR(r);
assert(lt); assert(lt);
......
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