Commit a51493dd authored by Zardosht Kasheff's avatar Zardosht Kasheff Committed by Yoni Fogel

[t:4831], [t:4832], merge to main

git-svn-id: file:///svn/toku/tokudb@43069 c7de825b-a66e-492c-adef-691d508d4ae1
parent 69fc86d8
...@@ -221,11 +221,11 @@ toku_unpin_brtnode_off_client_thread(struct brt_header* h, BRTNODE node) ...@@ -221,11 +221,11 @@ toku_unpin_brtnode_off_client_thread(struct brt_header* h, BRTNODE node)
} }
void void
toku_unpin_brtnode(BRT brt, BRTNODE node) toku_unpin_brtnode(struct brt_header *h, BRTNODE node)
{ {
// printf("%*sUnpin %ld\n", 8-node->height, "", node->thisnodename.b); // printf("%*sUnpin %ld\n", 8-node->height, "", node->thisnodename.b);
VERIFY_NODE(brt,node); //VERIFY_NODE(brt,node);
toku_unpin_brtnode_off_client_thread(brt->h, node); toku_unpin_brtnode_off_client_thread(h, node);
} }
void void
......
...@@ -105,7 +105,7 @@ toku_unpin_brtnode_off_client_thread(struct brt_header* h, BRTNODE node); ...@@ -105,7 +105,7 @@ toku_unpin_brtnode_off_client_thread(struct brt_header* h, BRTNODE node);
* Used for nodes pinned on a client thread * Used for nodes pinned on a client thread
*/ */
void void
toku_unpin_brtnode(BRT brt, BRTNODE node); toku_unpin_brtnode(struct brt_header *h, BRTNODE node);
void void
toku_unpin_brtnode_read_only(BRT brt, BRTNODE node); toku_unpin_brtnode_read_only(BRT brt, BRTNODE node);
......
...@@ -1766,17 +1766,17 @@ static void flush_node_fun(void *fe_v) ...@@ -1766,17 +1766,17 @@ static void flush_node_fun(void *fe_v)
static void static void
place_node_and_bnc_on_background_thread( place_node_and_bnc_on_background_thread(
BRT brt, struct brt_header *h,
BRTNODE node, BRTNODE node,
NONLEAF_CHILDINFO bnc) NONLEAF_CHILDINFO bnc)
{ {
struct flusher_extra* fe = NULL; struct flusher_extra* fe = NULL;
fe = toku_xmalloc(sizeof(struct flusher_extra)); fe = toku_xmalloc(sizeof(struct flusher_extra));
assert(fe); assert(fe);
fe->h = brt->h; fe->h = h;
fe->node = node; fe->node = node;
fe->bnc = bnc; fe->bnc = bnc;
cachefile_kibbutz_enq(brt->cf, flush_node_fun, fe); cachefile_kibbutz_enq(h->cf, flush_node_fun, fe);
} }
// //
...@@ -1793,7 +1793,7 @@ place_node_and_bnc_on_background_thread( ...@@ -1793,7 +1793,7 @@ place_node_and_bnc_on_background_thread(
// The parent will be unlocked on the background thread // The parent will be unlocked on the background thread
// //
void void
flush_node_on_background_thread(BRT brt, BRTNODE parent) flush_node_on_background_thread(struct brt_header *h, BRTNODE parent)
{ {
// //
// first let's see if we can detach buffer on client thread // first let's see if we can detach buffer on client thread
...@@ -1806,9 +1806,9 @@ flush_node_on_background_thread(BRT brt, BRTNODE parent) ...@@ -1806,9 +1806,9 @@ flush_node_on_background_thread(BRT brt, BRTNODE parent)
// //
void *node_v; void *node_v;
BRTNODE child; BRTNODE child;
u_int32_t childfullhash = compute_child_fullhash(brt->cf, parent, childnum); u_int32_t childfullhash = compute_child_fullhash(h->cf, parent, childnum);
int r = toku_cachetable_maybe_get_and_pin_clean ( int r = toku_cachetable_maybe_get_and_pin_clean (
brt->cf, h->cf,
BP_BLOCKNUM(parent,childnum), BP_BLOCKNUM(parent,childnum),
childfullhash, childfullhash,
&node_v &node_v
...@@ -1817,7 +1817,7 @@ flush_node_on_background_thread(BRT brt, BRTNODE parent) ...@@ -1817,7 +1817,7 @@ flush_node_on_background_thread(BRT brt, BRTNODE parent)
// In this case, we could not lock the child, so just place the parent on the background thread // In this case, we could not lock the child, so just place the parent on the background thread
// In the callback, we will use flush_some_child, which checks to // In the callback, we will use flush_some_child, which checks to
// see if we should blow away the old basement nodes. // see if we should blow away the old basement nodes.
place_node_and_bnc_on_background_thread(brt, parent, NULL); place_node_and_bnc_on_background_thread(h, parent, NULL);
} }
else { else {
// //
...@@ -1845,17 +1845,17 @@ flush_node_on_background_thread(BRT brt, BRTNODE parent) ...@@ -1845,17 +1845,17 @@ flush_node_on_background_thread(BRT brt, BRTNODE parent)
// so, because we know for sure the child is not // so, because we know for sure the child is not
// reactive, we can unpin the parent // reactive, we can unpin the parent
// //
place_node_and_bnc_on_background_thread(brt, child, bnc); place_node_and_bnc_on_background_thread(h, child, bnc);
toku_unpin_brtnode(brt, parent); toku_unpin_brtnode(h, parent);
} }
else { else {
// because the child may be reactive, we need to // because the child may be reactive, we need to
// put parent on background thread. // put parent on background thread.
// As a result, we unlock the child here. // As a result, we unlock the child here.
toku_unpin_brtnode(brt, child); toku_unpin_brtnode(h, child);
// Again, we'll have the parent on the background thread, so // Again, we'll have the parent on the background thread, so
// we don't need to destroy the basement nodes yet. // we don't need to destroy the basement nodes yet.
place_node_and_bnc_on_background_thread(brt, parent, NULL); place_node_and_bnc_on_background_thread(h, parent, NULL);
} }
} }
} }
......
...@@ -68,7 +68,7 @@ toku_flusher_thread_set_callback( ...@@ -68,7 +68,7 @@ toku_flusher_thread_set_callback(
*/ */
void void
flush_node_on_background_thread( flush_node_on_background_thread(
BRT brt, struct brt_header *h,
BRTNODE parent BRTNODE parent
); );
......
...@@ -781,7 +781,7 @@ int toku_cmd_leafval_heaviside (OMTVALUE leafentry, void *extra) ...@@ -781,7 +781,7 @@ int toku_cmd_leafval_heaviside (OMTVALUE leafentry, void *extra)
__attribute__((__warn_unused_result__)); __attribute__((__warn_unused_result__));
// toku_brt_root_put_cmd() accepts non-constant cmd because this is where we set the msn // toku_brt_root_put_cmd() accepts non-constant cmd because this is where we set the msn
int toku_brt_root_put_cmd(BRT brt, BRT_MSG_S * cmd) int toku_brt_root_put_cmd(struct brt_header *h, BRT_MSG_S * cmd)
__attribute__((__warn_unused_result__)); __attribute__((__warn_unused_result__));
void *mempool_malloc_from_omt(OMT omt, struct mempool *mp, size_t size, void **maybe_free); void *mempool_malloc_from_omt(OMT omt, struct mempool *mp, size_t size, void **maybe_free);
......
...@@ -49,7 +49,7 @@ int toku_testsetup_leaf(BRT brt, BLOCKNUM *blocknum, int n_children, char **keys ...@@ -49,7 +49,7 @@ int toku_testsetup_leaf(BRT brt, BLOCKNUM *blocknum, int n_children, char **keys
} }
*blocknum = node->thisnodename; *blocknum = node->thisnodename;
toku_unpin_brtnode(brt, node); toku_unpin_brtnode(brt->h, node);
return 0; return 0;
} }
...@@ -71,7 +71,7 @@ int toku_testsetup_nonleaf (BRT brt, int height, BLOCKNUM *blocknum, int n_child ...@@ -71,7 +71,7 @@ int toku_testsetup_nonleaf (BRT brt, int height, BLOCKNUM *blocknum, int n_child
node->totalchildkeylens += keylens[i]; node->totalchildkeylens += keylens[i];
} }
*blocknum = node->thisnodename; *blocknum = node->thisnodename;
toku_unpin_brtnode(brt, node); toku_unpin_brtnode(brt->h, node);
return 0; return 0;
} }
...@@ -103,7 +103,7 @@ int toku_testsetup_get_sersize(BRT brt, BLOCKNUM diskoff) // Return the size on ...@@ -103,7 +103,7 @@ int toku_testsetup_get_sersize(BRT brt, BLOCKNUM diskoff) // Return the size on
); );
assert(r==0); assert(r==0);
int size = toku_serialize_brtnode_size(node_v); int size = toku_serialize_brtnode_size(node_v);
toku_unpin_brtnode(brt, node_v); toku_unpin_brtnode(brt->h, node_v);
return size; return size;
} }
...@@ -153,7 +153,7 @@ int toku_testsetup_insert_to_leaf (BRT brt, BLOCKNUM blocknum, char *key, int ke ...@@ -153,7 +153,7 @@ int toku_testsetup_insert_to_leaf (BRT brt, BLOCKNUM blocknum, char *key, int ke
toku_verify_or_set_counts(node); toku_verify_or_set_counts(node);
toku_unpin_brtnode(brt, node_v); toku_unpin_brtnode(brt->h, node_v);
return 0; return 0;
} }
...@@ -222,6 +222,6 @@ int toku_testsetup_insert_to_nonleaf (BRT brt, BLOCKNUM blocknum, enum brt_msg_t ...@@ -222,6 +222,6 @@ int toku_testsetup_insert_to_nonleaf (BRT brt, BLOCKNUM blocknum, enum brt_msg_t
node->max_msn_applied_to_node_on_disk = msn; node->max_msn_applied_to_node_on_disk = msn;
node->dirty = 1; node->dirty = 1;
toku_unpin_brtnode(brt, node_v); toku_unpin_brtnode(brt->h, node_v);
return 0; return 0;
} }
This diff is collapsed.
...@@ -214,7 +214,7 @@ static int do_insertion (enum brt_msg_type type, FILENUM filenum, BYTESTRING key ...@@ -214,7 +214,7 @@ static int do_insertion (enum brt_msg_type type, FILENUM filenum, BYTESTRING key
? toku_fill_dbt(&data_dbt, data->data, data->len) ? toku_fill_dbt(&data_dbt, data->data, data->len)
: toku_init_dbt(&data_dbt) }}; : toku_init_dbt(&data_dbt) }};
r = toku_brt_root_put_cmd(brt, &brtcmd); r = toku_brt_root_put_cmd(brt->h, &brtcmd);
if (r == 0 && reset_root_xid_that_created) { if (r == 0 && reset_root_xid_that_created) {
TXNID new_root_xid_that_created = xids_get_outermost_xid(xids); TXNID new_root_xid_that_created = xids_get_outermost_xid(xids);
toku_reset_root_xid_that_created(brt, new_root_xid_that_created); toku_reset_root_xid_that_created(brt, new_root_xid_that_created);
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
TOKUROOT=../../ TOKUROOT=../../
INCLUDEDIRS=-I. -I.. -I../../include INCLUDEDIRS=-I. -I.. -I../../include
CFLAGS+=-Werror
ifeq ($(CYGWIN),) ifeq ($(CYGWIN),)
LINK_FILES += $(NEWBRT) LINK_FILES += $(NEWBRT)
else ifneq ($(CC),icc) else ifneq ($(CC),icc)
......
...@@ -89,7 +89,7 @@ make_tree(BRT brt, int height, int fanout, int nperleaf, int *seq, int *minkey, ...@@ -89,7 +89,7 @@ make_tree(BRT brt, int height, int fanout, int nperleaf, int *seq, int *minkey,
struct kv_pair *pivotkey = kv_pair_malloc(&k, sizeof k, NULL, 0); struct kv_pair *pivotkey = kv_pair_malloc(&k, sizeof k, NULL, 0);
toku_brt_nonleaf_append_child(node, child, pivotkey, sizeof k); toku_brt_nonleaf_append_child(node, child, pivotkey, sizeof k);
} }
toku_unpin_brtnode(brt, child); toku_unpin_brtnode(brt->h, child);
insert_into_child_buffer(brt, node, childnum, minkeys[childnum], maxkeys[childnum]); insert_into_child_buffer(brt, node, childnum, minkeys[childnum], maxkeys[childnum]);
} }
*minkey = minkeys[0]; *minkey = minkeys[0];
...@@ -144,7 +144,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) { ...@@ -144,7 +144,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) {
newroot->max_msn_applied_to_node_on_disk = last_dummymsn(); // capture msn of last message injected into tree newroot->max_msn_applied_to_node_on_disk = last_dummymsn(); // capture msn of last message injected into tree
// unpin the new root // unpin the new root
toku_unpin_brtnode(brt, newroot); toku_unpin_brtnode(brt->h, newroot);
if (do_verify) { if (do_verify) {
r = toku_verify_brt(brt); r = toku_verify_brt(brt);
......
...@@ -138,7 +138,7 @@ test_msnfilter(int do_verify) { ...@@ -138,7 +138,7 @@ test_msnfilter(int do_verify) {
// node and unlock it again before and after each message injection, but that requires more // node and unlock it again before and after each message injection, but that requires more
// work than it's worth (setting up dummy callbacks, etc.) // work than it's worth (setting up dummy callbacks, etc.)
// //
toku_unpin_brtnode(brt, newroot); toku_unpin_brtnode(brt->h, newroot);
populate_leaf(brt, newroot, htonl(2), 1); populate_leaf(brt, newroot, htonl(2), 1);
......
...@@ -172,7 +172,7 @@ doit (BOOL after_child_pin) { ...@@ -172,7 +172,7 @@ doit (BOOL after_child_pin) {
assert(node->height == 1); assert(node->height == 1);
assert(node->n_children == 1); assert(node->n_children == 1);
assert(toku_bnc_nbytesinbuf(BNC(node, 0)) == 0); assert(toku_bnc_nbytesinbuf(BNC(node, 0)) == 0);
toku_unpin_brtnode(t, node); toku_unpin_brtnode(t->h, node);
void *ret; void *ret;
r = toku_pthread_join(checkpoint_tid, &ret); r = toku_pthread_join(checkpoint_tid, &ret);
......
...@@ -150,10 +150,10 @@ doit (int state) { ...@@ -150,10 +150,10 @@ doit (int state) {
BRTNODE node = NULL; BRTNODE node = NULL;
toku_pin_node_with_min_bfe(&node, node_leaves[0], t); toku_pin_node_with_min_bfe(&node, node_leaves[0], t);
BLB_SEQINSERT(node, node->n_children-1) = FALSE; BLB_SEQINSERT(node, node->n_children-1) = FALSE;
toku_unpin_brtnode(t, node); toku_unpin_brtnode(t->h, node);
toku_pin_node_with_min_bfe(&node, node_leaves[1], t); toku_pin_node_with_min_bfe(&node, node_leaves[1], t);
BLB_SEQINSERT(node, node->n_children-1) = FALSE; BLB_SEQINSERT(node, node->n_children-1) = FALSE;
toku_unpin_brtnode(t, node); toku_unpin_brtnode(t->h, node);
struct brtnode_fetch_extra bfe; struct brtnode_fetch_extra bfe;
...@@ -188,7 +188,7 @@ doit (int state) { ...@@ -188,7 +188,7 @@ doit (int state) {
); );
assert(node->height == 1); assert(node->height == 1);
assert(node->n_children == 1); assert(node->n_children == 1);
toku_unpin_brtnode(t, node); toku_unpin_brtnode(t->h, node);
void *ret; void *ret;
r = toku_pthread_join(checkpoint_tid, &ret); r = toku_pthread_join(checkpoint_tid, &ret);
......
...@@ -170,10 +170,10 @@ doit (int state) { ...@@ -170,10 +170,10 @@ doit (int state) {
BRTNODE node = NULL; BRTNODE node = NULL;
toku_pin_node_with_min_bfe(&node, node_leaves[0], t); toku_pin_node_with_min_bfe(&node, node_leaves[0], t);
BLB_SEQINSERT(node, node->n_children-1) = FALSE; BLB_SEQINSERT(node, node->n_children-1) = FALSE;
toku_unpin_brtnode(t, node); toku_unpin_brtnode(t->h, node);
toku_pin_node_with_min_bfe(&node, node_leaves[1], t); toku_pin_node_with_min_bfe(&node, node_leaves[1], t);
BLB_SEQINSERT(node, node->n_children-1) = FALSE; BLB_SEQINSERT(node, node->n_children-1) = FALSE;
toku_unpin_brtnode(t, node); toku_unpin_brtnode(t->h, node);
struct brtnode_fetch_extra bfe; struct brtnode_fetch_extra bfe;
...@@ -208,7 +208,7 @@ doit (int state) { ...@@ -208,7 +208,7 @@ doit (int state) {
); );
assert(node->height == 1); assert(node->height == 1);
assert(node->n_children == 2); assert(node->n_children == 2);
toku_unpin_brtnode(t, node); toku_unpin_brtnode(t->h, node);
void *ret; void *ret;
r = toku_pthread_join(checkpoint_tid, &ret); r = toku_pthread_join(checkpoint_tid, &ret);
......
...@@ -184,7 +184,7 @@ doit (BOOL after_split) { ...@@ -184,7 +184,7 @@ doit (BOOL after_split) {
); );
assert(node->height == 1); assert(node->height == 1);
assert(node->n_children == 2); assert(node->n_children == 2);
toku_unpin_brtnode(t, node); toku_unpin_brtnode(t->h, node);
void *ret; void *ret;
r = toku_pthread_join(checkpoint_tid, &ret); r = toku_pthread_join(checkpoint_tid, &ret);
......
...@@ -143,7 +143,7 @@ doit (void) { ...@@ -143,7 +143,7 @@ doit (void) {
toku_pin_node_with_min_bfe(&node, node_leaf[1], brt); toku_pin_node_with_min_bfe(&node, node_leaf[1], brt);
// hack to get merge going // hack to get merge going
BLB_SEQINSERT(node, node->n_children-1) = FALSE; BLB_SEQINSERT(node, node->n_children-1) = FALSE;
toku_unpin_brtnode(brt, node); toku_unpin_brtnode(brt->h, node);
// now do a lookup on one of the keys, this should bring a leaf node up to date // now do a lookup on one of the keys, this should bring a leaf node up to date
DBT k; DBT k;
......
...@@ -195,7 +195,7 @@ doit (void) { ...@@ -195,7 +195,7 @@ doit (void) {
// child 1 should still have message in buffer // child 1 should still have message in buffer
assert(toku_bnc_n_entries(node->bp[0].ptr.u.nonleaf) == 0); assert(toku_bnc_n_entries(node->bp[0].ptr.u.nonleaf) == 0);
assert(toku_bnc_n_entries(node->bp[1].ptr.u.nonleaf) > 0); assert(toku_bnc_n_entries(node->bp[1].ptr.u.nonleaf) > 0);
toku_unpin_brtnode(t, node); toku_unpin_brtnode(t->h, node);
r = toku_checkpoint(ct, NULL, NULL, NULL, NULL, NULL, CLIENT_CHECKPOINT); r = toku_checkpoint(ct, NULL, NULL, NULL, NULL, NULL, CLIENT_CHECKPOINT);
assert_zero(r); assert_zero(r);
toku_pin_node_with_min_bfe(&node, node_internal, t); toku_pin_node_with_min_bfe(&node, node_internal, t);
...@@ -213,7 +213,7 @@ doit (void) { ...@@ -213,7 +213,7 @@ doit (void) {
assert(toku_bnc_n_entries(node->bp[0].ptr.u.nonleaf) == 0); assert(toku_bnc_n_entries(node->bp[0].ptr.u.nonleaf) == 0);
assert(toku_bnc_n_entries(node->bp[1].ptr.u.nonleaf) == 0); assert(toku_bnc_n_entries(node->bp[1].ptr.u.nonleaf) == 0);
// now let's do a flush with an empty buffer, make sure it is ok // now let's do a flush with an empty buffer, make sure it is ok
toku_unpin_brtnode(t, node); toku_unpin_brtnode(t->h, node);
r = toku_checkpoint(ct, NULL, NULL, NULL, NULL, NULL, CLIENT_CHECKPOINT); r = toku_checkpoint(ct, NULL, NULL, NULL, NULL, NULL, CLIENT_CHECKPOINT);
assert_zero(r); assert_zero(r);
toku_pin_node_with_min_bfe(&node, node_internal, t); toku_pin_node_with_min_bfe(&node, node_internal, t);
...@@ -230,7 +230,7 @@ doit (void) { ...@@ -230,7 +230,7 @@ doit (void) {
// both buffers should be empty now // both buffers should be empty now
assert(toku_bnc_n_entries(node->bp[0].ptr.u.nonleaf) == 0); assert(toku_bnc_n_entries(node->bp[0].ptr.u.nonleaf) == 0);
assert(toku_bnc_n_entries(node->bp[1].ptr.u.nonleaf) == 0); assert(toku_bnc_n_entries(node->bp[1].ptr.u.nonleaf) == 0);
toku_unpin_brtnode(t, node); toku_unpin_brtnode(t->h, node);
// now let's start a flush from the root, that always recursively flushes // now let's start a flush from the root, that always recursively flushes
flusher_advice_init( flusher_advice_init(
...@@ -254,13 +254,13 @@ doit (void) { ...@@ -254,13 +254,13 @@ doit (void) {
toku_pin_node_with_min_bfe(&node, node_internal, t); toku_pin_node_with_min_bfe(&node, node_internal, t);
assert(!node->dirty); // nothing was flushed, so node better not be dirty assert(!node->dirty); // nothing was flushed, so node better not be dirty
toku_unpin_brtnode(t, node); toku_unpin_brtnode(t->h, node);
toku_pin_node_with_min_bfe(&node, node_leaf[0], t); toku_pin_node_with_min_bfe(&node, node_leaf[0], t);
assert(!node->dirty); // nothing was flushed, so node better not be dirty assert(!node->dirty); // nothing was flushed, so node better not be dirty
toku_unpin_brtnode(t, node); toku_unpin_brtnode(t->h, node);
toku_pin_node_with_min_bfe(&node, node_leaf[1], t); toku_pin_node_with_min_bfe(&node, node_leaf[1], t);
assert(!node->dirty); // nothing was flushed, so node better not be dirty assert(!node->dirty); // nothing was flushed, so node better not be dirty
toku_unpin_brtnode(t, node); toku_unpin_brtnode(t->h, node);
} }
// now one more test to show a bug was fixed // now one more test to show a bug was fixed
...@@ -288,7 +288,7 @@ doit (void) { ...@@ -288,7 +288,7 @@ doit (void) {
toku_brtnode_pe_callback(node, make_pair_attr(0xffffffff), &attr, NULL); toku_brtnode_pe_callback(node, make_pair_attr(0xffffffff), &attr, NULL);
} }
assert(BP_STATE(node,0) == PT_COMPRESSED); assert(BP_STATE(node,0) == PT_COMPRESSED);
toku_unpin_brtnode(t, node); toku_unpin_brtnode(t->h, node);
//now let's do the same test as above //now let's do the same test as above
toku_pin_node_with_min_bfe(&node, node_root, t); toku_pin_node_with_min_bfe(&node, node_root, t);
......
...@@ -175,7 +175,7 @@ test_split_on_boundary(void) ...@@ -175,7 +175,7 @@ test_split_on_boundary(void)
verify_basement_node_msns(nodea, dummy_msn_3884); verify_basement_node_msns(nodea, dummy_msn_3884);
verify_basement_node_msns(nodeb, dummy_msn_3884); verify_basement_node_msns(nodeb, dummy_msn_3884);
toku_unpin_brtnode(brt, nodeb); toku_unpin_brtnode(brt->h, nodeb);
r = toku_close_brt_nolsn(brt, NULL); assert(r == 0); r = toku_close_brt_nolsn(brt, NULL); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0); r = toku_cachetable_close(&ct); assert(r == 0);
...@@ -245,7 +245,7 @@ test_split_with_everything_on_the_left(void) ...@@ -245,7 +245,7 @@ test_split_with_everything_on_the_left(void)
// if we haven't done it right, we should hit the assert in the top of move_leafentries // if we haven't done it right, we should hit the assert in the top of move_leafentries
brtleaf_split(brt->h, &sn, &nodea, &nodeb, &splitk, TRUE, 0, NULL); brtleaf_split(brt->h, &sn, &nodea, &nodeb, &splitk, TRUE, 0, NULL);
toku_unpin_brtnode(brt, nodeb); toku_unpin_brtnode(brt->h, nodeb);
r = toku_close_brt_nolsn(brt, NULL); assert(r == 0); r = toku_close_brt_nolsn(brt, NULL); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0); r = toku_cachetable_close(&ct); assert(r == 0);
...@@ -320,7 +320,7 @@ test_split_on_boundary_of_last_node(void) ...@@ -320,7 +320,7 @@ test_split_on_boundary_of_last_node(void)
// if we haven't done it right, we should hit the assert in the top of move_leafentries // if we haven't done it right, we should hit the assert in the top of move_leafentries
brtleaf_split(brt->h, &sn, &nodea, &nodeb, &splitk, TRUE, 0, NULL); brtleaf_split(brt->h, &sn, &nodea, &nodeb, &splitk, TRUE, 0, NULL);
toku_unpin_brtnode(brt, nodeb); toku_unpin_brtnode(brt->h, nodeb);
r = toku_close_brt_nolsn(brt, NULL); assert(r == 0); r = toku_close_brt_nolsn(brt, NULL); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0); r = toku_cachetable_close(&ct); assert(r == 0);
...@@ -388,7 +388,7 @@ test_split_at_begin(void) ...@@ -388,7 +388,7 @@ test_split_at_begin(void)
// if we haven't done it right, we should hit the assert in the top of move_leafentries // if we haven't done it right, we should hit the assert in the top of move_leafentries
brtleaf_split(brt->h, &sn, &nodea, &nodeb, &splitk, TRUE, 0, NULL); brtleaf_split(brt->h, &sn, &nodea, &nodeb, &splitk, TRUE, 0, NULL);
toku_unpin_brtnode(brt, nodeb); toku_unpin_brtnode(brt->h, nodeb);
r = toku_close_brt_nolsn(brt, NULL); assert(r == 0); r = toku_close_brt_nolsn(brt, NULL); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0); r = toku_cachetable_close(&ct); assert(r == 0);
...@@ -452,7 +452,7 @@ test_split_at_end(void) ...@@ -452,7 +452,7 @@ test_split_at_end(void)
// if we haven't done it right, we should hit the assert in the top of move_leafentries // if we haven't done it right, we should hit the assert in the top of move_leafentries
brtleaf_split(brt->h, &sn, &nodea, &nodeb, &splitk, TRUE, 0, NULL); brtleaf_split(brt->h, &sn, &nodea, &nodeb, &splitk, TRUE, 0, NULL);
toku_unpin_brtnode(brt, nodeb); toku_unpin_brtnode(brt->h, nodeb);
r = toku_close_brt_nolsn(brt, NULL); assert(r == 0); r = toku_close_brt_nolsn(brt, NULL); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0); r = toku_cachetable_close(&ct); assert(r == 0);
...@@ -509,7 +509,7 @@ test_split_odd_nodes(void) ...@@ -509,7 +509,7 @@ test_split_odd_nodes(void)
verify_basement_node_msns(nodea, dummy_msn_3884); verify_basement_node_msns(nodea, dummy_msn_3884);
verify_basement_node_msns(nodeb, dummy_msn_3884); verify_basement_node_msns(nodeb, dummy_msn_3884);
toku_unpin_brtnode(brt, nodeb); toku_unpin_brtnode(brt->h, nodeb);
r = toku_close_brt_nolsn(brt, NULL); assert(r == 0); r = toku_close_brt_nolsn(brt, NULL); assert(r == 0);
r = toku_cachetable_close(&ct); assert(r == 0); r = toku_cachetable_close(&ct); assert(r == 0);
......
...@@ -95,7 +95,7 @@ make_tree(BRT brt, int height, int fanout, int nperleaf, int *seq, int *minkey, ...@@ -95,7 +95,7 @@ make_tree(BRT brt, int height, int fanout, int nperleaf, int *seq, int *minkey,
struct kv_pair *pivotkey = kv_pair_malloc(&k, sizeof k, NULL, 0); struct kv_pair *pivotkey = kv_pair_malloc(&k, sizeof k, NULL, 0);
toku_brt_nonleaf_append_child(node, child, pivotkey, sizeof k); toku_brt_nonleaf_append_child(node, child, pivotkey, sizeof k);
} }
toku_unpin_brtnode(brt, child); toku_unpin_brtnode(brt->h, child);
insert_into_child_buffer(brt, node, childnum, minkeys[childnum], maxkeys[childnum]); insert_into_child_buffer(brt, node, childnum, minkeys[childnum], maxkeys[childnum]);
} }
*minkey = minkeys[0]; *minkey = minkeys[0];
...@@ -151,7 +151,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) { ...@@ -151,7 +151,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) {
// newroot->max_msn_applied_to_node = last_dummymsn(); // capture msn of last message injected into tree // newroot->max_msn_applied_to_node = last_dummymsn(); // capture msn of last message injected into tree
// unpin the new root // unpin the new root
toku_unpin_brtnode(brt, newroot); toku_unpin_brtnode(brt->h, newroot);
if (do_verify) { if (do_verify) {
r = toku_verify_brt(brt); r = toku_verify_brt(brt);
......
...@@ -66,7 +66,7 @@ make_tree(BRT brt, int height, int fanout, int nperleaf, int *seq, int *minkey, ...@@ -66,7 +66,7 @@ make_tree(BRT brt, int height, int fanout, int nperleaf, int *seq, int *minkey,
struct kv_pair *pivotkey = kv_pair_malloc(&k, sizeof k, NULL, 0); struct kv_pair *pivotkey = kv_pair_malloc(&k, sizeof k, NULL, 0);
toku_brt_nonleaf_append_child(node, child, pivotkey, sizeof k); toku_brt_nonleaf_append_child(node, child, pivotkey, sizeof k);
} }
toku_unpin_brtnode(brt, child); toku_unpin_brtnode(brt->h, child);
} }
*minkey = minkeys[0]; *minkey = minkeys[0];
*maxkey = maxkeys[0]; *maxkey = maxkeys[0];
...@@ -118,7 +118,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) { ...@@ -118,7 +118,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) {
*rootp = newroot->thisnodename; *rootp = newroot->thisnodename;
// unpin the new root // unpin the new root
toku_unpin_brtnode(brt, newroot); toku_unpin_brtnode(brt->h, newroot);
if (do_verify) { if (do_verify) {
r = toku_verify_brt(brt); r = toku_verify_brt(brt);
......
...@@ -76,7 +76,7 @@ test_dup_in_leaf(int do_verify) { ...@@ -76,7 +76,7 @@ test_dup_in_leaf(int do_verify) {
*rootp = newroot->thisnodename; *rootp = newroot->thisnodename;
// unpin the new root // unpin the new root
toku_unpin_brtnode(brt, newroot); toku_unpin_brtnode(brt->h, newroot);
if (do_verify) { if (do_verify) {
r = toku_verify_brt(brt); r = toku_verify_brt(brt);
......
...@@ -66,7 +66,7 @@ make_tree(BRT brt, int height, int fanout, int nperleaf, int *seq, int *minkey, ...@@ -66,7 +66,7 @@ make_tree(BRT brt, int height, int fanout, int nperleaf, int *seq, int *minkey,
struct kv_pair *pivotkey = kv_pair_malloc(&k, sizeof k, NULL, 0); struct kv_pair *pivotkey = kv_pair_malloc(&k, sizeof k, NULL, 0);
toku_brt_nonleaf_append_child(node, child, pivotkey, sizeof k); toku_brt_nonleaf_append_child(node, child, pivotkey, sizeof k);
} }
toku_unpin_brtnode(brt, child); toku_unpin_brtnode(brt->h, child);
} }
*minkey = minkeys[0]; *minkey = minkeys[0];
*maxkey = maxkeys[0]; *maxkey = maxkeys[0];
...@@ -118,7 +118,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) { ...@@ -118,7 +118,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) {
*rootp = newroot->thisnodename; *rootp = newroot->thisnodename;
// unpin the new root // unpin the new root
toku_unpin_brtnode(brt, newroot); toku_unpin_brtnode(brt->h, newroot);
if (do_verify) { if (do_verify) {
r = toku_verify_brt(brt); r = toku_verify_brt(brt);
......
...@@ -80,7 +80,7 @@ make_tree(BRT brt, int height, int fanout, int nperleaf, int *seq, int *minkey, ...@@ -80,7 +80,7 @@ make_tree(BRT brt, int height, int fanout, int nperleaf, int *seq, int *minkey,
struct kv_pair *pivotkey = kv_pair_malloc(&k, sizeof k, NULL, 0); struct kv_pair *pivotkey = kv_pair_malloc(&k, sizeof k, NULL, 0);
toku_brt_nonleaf_append_child(node, child, pivotkey, sizeof k); toku_brt_nonleaf_append_child(node, child, pivotkey, sizeof k);
} }
toku_unpin_brtnode(brt, child); toku_unpin_brtnode(brt->h, child);
insert_into_child_buffer(brt, node, childnum, minkeys[childnum], maxkeys[childnum]); insert_into_child_buffer(brt, node, childnum, minkeys[childnum], maxkeys[childnum]);
} }
*minkey = minkeys[0]; *minkey = minkeys[0];
...@@ -133,7 +133,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) { ...@@ -133,7 +133,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) {
*rootp = newroot->thisnodename; *rootp = newroot->thisnodename;
// unpin the new root // unpin the new root
toku_unpin_brtnode(brt, newroot); toku_unpin_brtnode(brt->h, newroot);
if (do_verify) { if (do_verify) {
r = toku_verify_brt(brt); r = toku_verify_brt(brt);
......
...@@ -76,7 +76,7 @@ test_dup_in_leaf(int do_verify) { ...@@ -76,7 +76,7 @@ test_dup_in_leaf(int do_verify) {
*rootp = newroot->thisnodename; *rootp = newroot->thisnodename;
// unpin the new root // unpin the new root
toku_unpin_brtnode(brt, newroot); toku_unpin_brtnode(brt->h, newroot);
if (do_verify) { if (do_verify) {
r = toku_verify_brt(brt); r = toku_verify_brt(brt);
......
...@@ -66,7 +66,7 @@ make_tree(BRT brt, int height, int fanout, int nperleaf, int *seq, int *minkey, ...@@ -66,7 +66,7 @@ make_tree(BRT brt, int height, int fanout, int nperleaf, int *seq, int *minkey,
struct kv_pair *pivotkey = kv_pair_malloc(&k, sizeof k, NULL, 0); struct kv_pair *pivotkey = kv_pair_malloc(&k, sizeof k, NULL, 0);
toku_brt_nonleaf_append_child(node, child, pivotkey, sizeof k); toku_brt_nonleaf_append_child(node, child, pivotkey, sizeof k);
} }
toku_unpin_brtnode(brt, child); toku_unpin_brtnode(brt->h, child);
} }
*minkey = minkeys[0]; *minkey = minkeys[0];
*maxkey = maxkeys[0]; *maxkey = maxkeys[0];
...@@ -118,7 +118,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) { ...@@ -118,7 +118,7 @@ test_make_tree(int height, int fanout, int nperleaf, int do_verify) {
*rootp = newroot->thisnodename; *rootp = newroot->thisnodename;
// unpin the new root // unpin the new root
toku_unpin_brtnode(brt, newroot); toku_unpin_brtnode(brt->h, newroot);
if (do_verify) { if (do_verify) {
r = toku_verify_brt(brt); r = toku_verify_brt(brt);
......
...@@ -40,8 +40,9 @@ struct __toku_ltm { ...@@ -40,8 +40,9 @@ struct __toku_ltm {
struct __toku_lock_tree { struct __toku_lock_tree {
/** Lock tree manager */ /** Lock tree manager */
toku_ltm* mgr; toku_ltm* mgr;
/** The database for which this locktree will be handling locks */ // for comparisons
DB* db; struct __toku_db fake_db; // dummy db used for comparisons
DESCRIPTOR_S desc_s;
#if TOKU_LT_USE_BORDERWRITE #if TOKU_LT_USE_BORDERWRITE
toku_range_tree* borderwrite; /**< See design document */ toku_range_tree* borderwrite; /**< See design document */
#endif #endif
...@@ -54,9 +55,7 @@ struct __toku_lock_tree { ...@@ -54,9 +55,7 @@ struct __toku_lock_tree {
uint32_t ref_count; uint32_t ref_count;
/** DICTIONARY_ID associated with the lock tree */ /** DICTIONARY_ID associated with the lock tree */
DICTIONARY_ID dict_id; DICTIONARY_ID dict_id;
OMT dbs; //The extant dbs using this lock tree.
OMT lock_requests; OMT lock_requests;
toku_rth* txns_to_unlock; // set of txn's that could not release their locks because there was no db for the comparison function
toku_pthread_mutex_t mutex; toku_pthread_mutex_t mutex;
bool mutex_locked; bool mutex_locked;
......
This diff is collapsed.
...@@ -108,10 +108,14 @@ void toku_ltm_set_lock_wait_time(toku_ltm *mgr, uint64_t lock_wait_time_msec); ...@@ -108,10 +108,14 @@ void toku_ltm_set_lock_wait_time(toku_ltm *mgr, uint64_t lock_wait_time_msec);
// get the default lock timeout // get the default lock timeout
void toku_ltm_get_lock_wait_time(toku_ltm *mgr, uint64_t *lock_wait_time_msec); void toku_ltm_get_lock_wait_time(toku_ltm *mgr, uint64_t *lock_wait_time_msec);
void
toku_lt_update_descriptor(toku_lock_tree* tree, DESCRIPTOR desc);
/** /**
Gets a lock tree for a given DB with id dict_id Gets a lock tree for a given DB with id dict_id
*/ */
int toku_ltm_get_lt(toku_ltm* mgr, toku_lock_tree** ptree, DICTIONARY_ID dict_id, DB *dbp, toku_dbt_cmp compare_fun); int toku_ltm_get_lt(toku_ltm* mgr, toku_lock_tree** ptree, DICTIONARY_ID dict_id, DESCRIPTOR desc, toku_dbt_cmp compare_fun);
void toku_ltm_invalidate_lt(toku_ltm* mgr, DICTIONARY_ID dict_id); void toku_ltm_invalidate_lt(toku_ltm* mgr, DICTIONARY_ID dict_id);
...@@ -185,7 +189,7 @@ int toku_lt_close(toku_lock_tree* tree); ...@@ -185,7 +189,7 @@ int toku_lt_close(toku_lock_tree* tree);
no transactions). This can cause conflicts, nobody was able (so far) no transactions). This can cause conflicts, nobody was able (so far)
to verify that MySQL does or does not use this. to verify that MySQL does or does not use this.
*/ */
int toku_lt_acquire_read_lock(toku_lock_tree* tree, DB* db, TXNID txn, int toku_lt_acquire_read_lock(toku_lock_tree* tree, TXNID txn,
const DBT* key); const DBT* key);
/* /*
...@@ -220,7 +224,7 @@ int toku_lt_acquire_read_lock(toku_lock_tree* tree, DB* db, TXNID txn, ...@@ -220,7 +224,7 @@ int toku_lt_acquire_read_lock(toku_lock_tree* tree, DB* db, TXNID txn,
no transactions). This can cause conflicts, nobody was able (so far) no transactions). This can cause conflicts, nobody was able (so far)
to verify that MySQL does or does not use this. to verify that MySQL does or does not use this.
*/ */
int toku_lt_acquire_range_read_lock(toku_lock_tree* tree, DB* db, TXNID txn, int toku_lt_acquire_range_read_lock(toku_lock_tree* tree, TXNID txn,
const DBT* key_left, const DBT* key_left,
const DBT* key_right); const DBT* key_right);
...@@ -250,7 +254,7 @@ int toku_lt_acquire_range_read_lock(toku_lock_tree* tree, DB* db, TXNID txn, ...@@ -250,7 +254,7 @@ int toku_lt_acquire_range_read_lock(toku_lock_tree* tree, DB* db, TXNID txn,
If the lock tree needs to hold onto the key or data, it will make copies If the lock tree needs to hold onto the key or data, it will make copies
to its local memory. to its local memory.
*/ */
int toku_lt_acquire_write_lock(toku_lock_tree* tree, DB* db, TXNID txn, int toku_lt_acquire_write_lock(toku_lock_tree* tree, TXNID txn,
const DBT* key); const DBT* key);
//In BDB, txn can actually be NULL (mixed operations with transactions and no transactions). //In BDB, txn can actually be NULL (mixed operations with transactions and no transactions).
...@@ -285,7 +289,7 @@ int toku_lt_acquire_write_lock(toku_lock_tree* tree, DB* db, TXNID txn, ...@@ -285,7 +289,7 @@ int toku_lt_acquire_write_lock(toku_lock_tree* tree, DB* db, TXNID txn,
* to its local memory. * to its local memory.
* *** Note that txn == NULL is not supported at this time. * *** Note that txn == NULL is not supported at this time.
*/ */
int toku_lt_acquire_range_write_lock(toku_lock_tree* tree, DB* db, TXNID txn, int toku_lt_acquire_range_write_lock(toku_lock_tree* tree, TXNID txn,
const DBT* key_left, const DBT* key_left,
const DBT* key_right); const DBT* key_right);
...@@ -311,9 +315,9 @@ void toku_lt_add_ref(toku_lock_tree* tree); ...@@ -311,9 +315,9 @@ void toku_lt_add_ref(toku_lock_tree* tree);
int toku_lt_remove_ref(toku_lock_tree* tree); int toku_lt_remove_ref(toku_lock_tree* tree);
void toku_lt_remove_db_ref(toku_lock_tree* tree, DB *db); void toku_lt_remove_db_ref(toku_lock_tree* tree);
void toku_lt_verify(toku_lock_tree *tree, DB *db); void toku_lt_verify(toku_lock_tree *tree);
typedef enum { typedef enum {
LOCK_REQUEST_INIT = 0, LOCK_REQUEST_INIT = 0,
...@@ -342,7 +346,6 @@ typedef enum { ...@@ -342,7 +346,6 @@ typedef enum {
// this is exposed so that we can allocate these as local variables. don't touch // this is exposed so that we can allocate these as local variables. don't touch
typedef struct { typedef struct {
DB *db;
TXNID txnid; TXNID txnid;
const DBT *key_left; const DBT *key_right; const DBT *key_left; const DBT *key_right;
DBT key_left_copy, key_right_copy; DBT key_left_copy, key_right_copy;
...@@ -359,10 +362,10 @@ void toku_lock_request_default_init(toku_lock_request *lock_request); ...@@ -359,10 +362,10 @@ void toku_lock_request_default_init(toku_lock_request *lock_request);
// initialize the lock request parameters. // initialize the lock request parameters.
// this API allows a lock request to be reused. // this API allows a lock request to be reused.
void toku_lock_request_set(toku_lock_request *lock_request, DB *db, TXNID txnid, const DBT *key_left, const DBT *key_right, toku_lock_type type); void toku_lock_request_set(toku_lock_request *lock_request, TXNID txnid, const DBT *key_left, const DBT *key_right, toku_lock_type type);
// initialize and set the parameters for a lock request. it is equivalent to _default_init followed by _set. // initialize and set the parameters for a lock request. it is equivalent to _default_init followed by _set.
void toku_lock_request_init(toku_lock_request *lock_request, DB *db, TXNID txnid, const DBT *key_left, const DBT *key_right, toku_lock_type type); void toku_lock_request_init(toku_lock_request *lock_request, TXNID txnid, const DBT *key_left, const DBT *key_right, toku_lock_type type);
// destroy a lock request. // destroy a lock request.
void toku_lock_request_destroy(toku_lock_request *lock_request); void toku_lock_request_destroy(toku_lock_request *lock_request);
......
...@@ -41,10 +41,8 @@ int main(int argc, const char *argv[]) { ...@@ -41,10 +41,8 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *db_a = (DB *) 2;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, db_a, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
TXNID txn_a = 1; TXNID txn_a = 1;
...@@ -52,14 +50,14 @@ int main(int argc, const char *argv[]) { ...@@ -52,14 +50,14 @@ int main(int argc, const char *argv[]) {
// acquire the locks on keys 0 .. nrows-1 // acquire the locks on keys 0 .. nrows-1
for (uint64_t k = 0; k < nrows; k++) { for (uint64_t k = 0; k < nrows; k++) {
DBT key = { .data = &k, .size = sizeof k }; DBT key = { .data = &k, .size = sizeof k };
r = toku_lt_acquire_write_lock(lt, db_a, txn_a, &key); assert(r == 0); r = toku_lt_acquire_write_lock(lt, txn_a, &key); assert(r == 0);
} }
// release the locks // release the locks
r = toku_lt_unlock_txn(lt, txn_a); assert(r == 0); r = toku_lt_unlock_txn(lt, txn_a); assert(r == 0);
// shutdown // shutdown
toku_lt_remove_db_ref(lt, db_a); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -38,7 +38,6 @@ static void release_locks(uint64_t keys[], int n, TXNID txn) { ...@@ -38,7 +38,6 @@ static void release_locks(uint64_t keys[], int n, TXNID txn) {
} }
struct test_arg { struct test_arg {
DB *db;
TXNID txn; TXNID txn;
toku_ltm *ltm; toku_ltm *ltm;
toku_lock_tree *lt; toku_lock_tree *lt;
...@@ -47,7 +46,7 @@ struct test_arg { ...@@ -47,7 +46,7 @@ struct test_arg {
uint64_t iterations; uint64_t iterations;
}; };
static void runtest(DB *db, TXNID txn, toku_ltm *ltm UU(), toku_lock_tree *lt, uint64_t locks_per_txn, uint64_t nrows, uint64_t iterations) { static void runtest(TXNID txn, toku_ltm *ltm UU(), toku_lock_tree *lt, uint64_t locks_per_txn, uint64_t nrows, uint64_t iterations) {
int r; int r;
uint64_t notgranted = 0, deadlocked = 0; uint64_t notgranted = 0, deadlocked = 0;
...@@ -59,7 +58,7 @@ static void runtest(DB *db, TXNID txn, toku_ltm *ltm UU(), toku_lock_tree *lt, u ...@@ -59,7 +58,7 @@ static void runtest(DB *db, TXNID txn, toku_ltm *ltm UU(), toku_lock_tree *lt, u
for (i = 0; i < locks_per_txn; i++) { for (i = 0; i < locks_per_txn; i++) {
DBT key = { .data = &keys[i], .size = sizeof keys[i] }; DBT key = { .data = &keys[i], .size = sizeof keys[i] };
toku_lock_request lr; toku_lock_request lr;
toku_lock_request_init(&lr, db, txn, &key, &key, LOCK_REQUEST_WRITE); toku_lock_request_init(&lr, txn, &key, &key, LOCK_REQUEST_WRITE);
r = toku_lt_acquire_lock_request_with_default_timeout(lt, &lr); r = toku_lt_acquire_lock_request_with_default_timeout(lt, &lr);
if (r == 0) { if (r == 0) {
get_lock(keys[i], txn); get_lock(keys[i], txn);
...@@ -87,7 +86,7 @@ static void runtest(DB *db, TXNID txn, toku_ltm *ltm UU(), toku_lock_tree *lt, u ...@@ -87,7 +86,7 @@ static void runtest(DB *db, TXNID txn, toku_ltm *ltm UU(), toku_lock_tree *lt, u
static void *runtest_wrapper(void *arg_wrapper) { static void *runtest_wrapper(void *arg_wrapper) {
struct test_arg *arg = (struct test_arg *) arg_wrapper; struct test_arg *arg = (struct test_arg *) arg_wrapper;
runtest(arg->db, arg->txn, arg->ltm, arg->lt, arg->locks_per_txn, arg->nrows, arg->iterations); runtest(arg->txn, arg->ltm, arg->lt, arg->locks_per_txn, arg->nrows, arg->iterations);
return arg; return arg;
} }
...@@ -142,20 +141,18 @@ int main(int argc, const char *argv[]) { ...@@ -142,20 +141,18 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *fake_db = (DB *) 1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
toku_pthread_t tids[nthreads]; toku_pthread_t tids[nthreads];
struct test_arg args[nthreads]; struct test_arg args[nthreads];
for (uint64_t i = 1; i < nthreads; i++) { for (uint64_t i = 1; i < nthreads; i++) {
args[i] = (struct test_arg) { fake_db, (TXNID) i, ltm, lt, locks_per_txn, nrows, iterations }; args[i] = (struct test_arg) { (TXNID) i, ltm, lt, locks_per_txn, nrows, iterations };
toku_pthread_create(&tids[i], NULL, runtest_wrapper, &args[i]); toku_pthread_create(&tids[i], NULL, runtest_wrapper, &args[i]);
} }
runtest(fake_db, (TXNID)nthreads, ltm, lt, locks_per_txn, nrows, iterations); runtest((TXNID)nthreads, ltm, lt, locks_per_txn, nrows, iterations);
for (uint64_t i = 1; i < nthreads; i++) { for (uint64_t i = 1; i < nthreads; i++) {
void *retptr; void *retptr;
...@@ -163,7 +160,7 @@ int main(int argc, const char *argv[]) { ...@@ -163,7 +160,7 @@ int main(int argc, const char *argv[]) {
} }
// shutdown // shutdown
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -10,12 +10,11 @@ uint32_t max_locks = MAX_LT_LOCKS; ...@@ -10,12 +10,11 @@ uint32_t max_locks = MAX_LT_LOCKS;
uint64_t max_lock_memory = MAX_LT_LOCKS*64; uint64_t max_lock_memory = MAX_LT_LOCKS*64;
toku_ltm* ltm = NULL; toku_ltm* ltm = NULL;
static void do_range_test(int (*acquire)(toku_lock_tree*, DB*, TXNID, static void do_range_test(int (*acquire)(toku_lock_tree*, TXNID,
const DBT*, const DBT*,
const DBT*)) { const DBT*)) {
int r; int r;
toku_lock_tree* lt = NULL; toku_lock_tree* lt = NULL;
DB* db = (DB*)1;
TXNID txn = (TXNID)1; // Fake. TXNID txn = (TXNID)1; // Fake.
DBT _key_l = _key; DBT _key_l = _key;
DBT _key_r = _key; DBT _key_r = _key;
...@@ -27,21 +26,21 @@ static void do_range_test(int (*acquire)(toku_lock_tree*, DB*, TXNID, ...@@ -27,21 +26,21 @@ static void do_range_test(int (*acquire)(toku_lock_tree*, DB*, TXNID,
CKERR(r); CKERR(r);
assert(lt); assert(lt);
r = acquire(NULL, db, txn, key_l, key_r); r = acquire(NULL, txn, key_l, key_r);
CKERR2(r, EINVAL); CKERR2(r, EINVAL);
r = acquire(lt, db, txn, NULL, key_r); r = acquire(lt, txn, NULL, key_r);
CKERR2(r, EINVAL); CKERR2(r, EINVAL);
r = acquire(lt, db, txn, key_l, NULL); r = acquire(lt, txn, key_l, NULL);
CKERR2(r, EINVAL); CKERR2(r, EINVAL);
/* left > right tests. */ /* left > right tests. */
const DBT* inf = toku_lt_infinity; const DBT* inf = toku_lt_infinity;
const DBT* ninf = toku_lt_neg_infinity; const DBT* ninf = toku_lt_neg_infinity;
r = acquire(lt, db, txn, inf, key_r); r = acquire(lt, txn, inf, key_r);
CKERR2(r, EDOM); CKERR2(r, EDOM);
r = acquire(lt, db, txn, key_l, ninf); r = acquire(lt, txn, key_l, ninf);
CKERR2(r, EDOM); CKERR2(r, EDOM);
r = acquire(lt, db, txn, inf, ninf); r = acquire(lt, txn, inf, ninf);
CKERR2(r, EDOM); CKERR2(r, EDOM);
/* Cleanup. */ /* Cleanup. */
...@@ -52,12 +51,11 @@ static void do_range_test(int (*acquire)(toku_lock_tree*, DB*, TXNID, ...@@ -52,12 +51,11 @@ static void do_range_test(int (*acquire)(toku_lock_tree*, DB*, TXNID,
} }
} }
static void do_point_test(int (*acquire)(toku_lock_tree*, DB*, TXNID, static void do_point_test(int (*acquire)(toku_lock_tree*, TXNID,
const DBT*)) { const DBT*)) {
int r; int r;
toku_lock_tree* lt = NULL; toku_lock_tree* lt = NULL;
TXNID txn = (TXNID)1; // Fake. TXNID txn = (TXNID)1; // Fake.
DB* db = (DB*)0x1;
lt = NULL; lt = NULL;
...@@ -71,10 +69,10 @@ static void do_point_test(int (*acquire)(toku_lock_tree*, DB*, TXNID, ...@@ -71,10 +69,10 @@ static void do_point_test(int (*acquire)(toku_lock_tree*, DB*, TXNID,
r = toku_lt_unlock_txn(NULL, (TXNID)1); r = toku_lt_unlock_txn(NULL, (TXNID)1);
CKERR2(r, EINVAL); CKERR2(r, EINVAL);
r = acquire(NULL, db, txn, key); r = acquire(NULL, txn, key);
CKERR2(r, EINVAL); CKERR2(r, EINVAL);
r = acquire(lt, db, txn, NULL); r = acquire(lt, txn, NULL);
CKERR2(r, EINVAL); CKERR2(r, EINVAL);
/* Cleanup. */ /* Cleanup. */
......
...@@ -40,14 +40,12 @@ static void init_query(void) { ...@@ -40,14 +40,12 @@ static void init_query(void) {
query.right = &qright; query.right = &qright;
} }
static DB *fake_db = (DB *) 1;
static void setup_tree(void) { static void setup_tree(void) {
assert(!lt && !ltm); assert(!lt && !ltm);
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
CKERR(r); CKERR(r);
assert(ltm); assert(ltm);
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
CKERR(r); CKERR(r);
assert(lt); assert(lt);
init_query(); init_query();
...@@ -56,7 +54,7 @@ static void setup_tree(void) { ...@@ -56,7 +54,7 @@ static void setup_tree(void) {
static void close_tree(void) { static void close_tree(void) {
r = toku_lt_unlock_txn(lt, txn); CKERR(r); r = toku_lt_unlock_txn(lt, txn); CKERR(r);
assert(lt && ltm); assert(lt && ltm);
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); CKERR(r); r = toku_ltm_close(ltm); CKERR(r);
lt = NULL; lt = NULL;
ltm = NULL; ltm = NULL;
...@@ -84,9 +82,9 @@ static void lt_insert(int key_l, int key_r) { ...@@ -84,9 +82,9 @@ static void lt_insert(int key_l, int key_r) {
assert(key_left); assert(key_left);
assert(key_right); assert(key_right);
r = toku_lt_acquire_range_read_lock(lt, db, txn, key_left, key_right); r = toku_lt_acquire_range_read_lock(lt, txn, key_left, key_right);
CKERR(r); CKERR(r);
toku_lt_verify(lt, db); toku_lt_verify(lt);
} }
static void setup_payload_len(void** payload, uint32_t* len, int val) { static void setup_payload_len(void** payload, uint32_t* len, int val) {
...@@ -142,11 +140,11 @@ static void insert_1(int key_l, int key_r, ...@@ -142,11 +140,11 @@ static void insert_1(int key_l, int key_r,
setup_tree(); setup_tree();
r = toku_lt_acquire_range_read_lock(lt, db, txn, key_left, key_right); CKERR(r); r = toku_lt_acquire_range_read_lock(lt, txn, key_left, key_right); CKERR(r);
close_tree(); close_tree();
setup_tree(); setup_tree();
r = toku_lt_acquire_read_lock(lt, db, txn, key_left); CKERR(r); r = toku_lt_acquire_read_lock(lt, txn, key_left); CKERR(r);
close_tree(); close_tree();
} }
......
...@@ -34,14 +34,12 @@ static void init_query(void) { ...@@ -34,14 +34,12 @@ static void init_query(void) {
query.right = &qright; query.right = &qright;
} }
static DB *fake_db = (DB *) 1;
static void setup_tree(void) { static void setup_tree(void) {
assert(!lt && !ltm); assert(!lt && !ltm);
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
CKERR(r); CKERR(r);
assert(ltm); assert(ltm);
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
CKERR(r); CKERR(r);
assert(lt); assert(lt);
init_query(); init_query();
...@@ -49,7 +47,7 @@ static void setup_tree(void) { ...@@ -49,7 +47,7 @@ static void setup_tree(void) {
static void close_tree(void) { static void close_tree(void) {
assert(lt && ltm); assert(lt && ltm);
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); r = toku_ltm_close(ltm);
CKERR(r); CKERR(r);
lt = NULL; lt = NULL;
...@@ -84,11 +82,11 @@ static void lt_insert(int r_expect, char txn, int key_l, ...@@ -84,11 +82,11 @@ static void lt_insert(int r_expect, char txn, int key_l,
TXNID local_txn = (TXNID) (size_t) txn; TXNID local_txn = (TXNID) (size_t) txn;
if (read_flag) if (read_flag)
r = toku_lt_acquire_range_read_lock(lt, db, local_txn, r = toku_lt_acquire_range_read_lock(lt, local_txn,
key_left, key_left,
key_right); key_right);
else else
r = toku_lt_acquire_write_lock(lt, db, local_txn, key_left); r = toku_lt_acquire_write_lock(lt, local_txn, key_left);
CKERR2(r, r_expect); CKERR2(r, r_expect);
} }
...@@ -110,13 +108,13 @@ static void lt_unlock(char ctxn) { ...@@ -110,13 +108,13 @@ static void lt_unlock(char ctxn) {
static void runtest(void) { static void runtest(void) {
setup_tree(); setup_tree();
lt_insert_write(0, 'a', 1); lt_insert_write(0, 'a', 1);
toku_lt_verify(lt, NULL); toku_lt_verify(lt);
lt_insert_write(0, 'a', 5); lt_insert_write(0, 'a', 5);
toku_lt_verify(lt, NULL); toku_lt_verify(lt);
lt_insert_write(0, 'a', 20); lt_insert_write(0, 'a', 20);
toku_lt_verify(lt, NULL); toku_lt_verify(lt);
lt_insert_write(0, 'b', 10); lt_insert_write(0, 'b', 10);
toku_lt_verify(lt, NULL); toku_lt_verify(lt);
lt_unlock('a'); lt_unlock('a');
lt_unlock('b'); lt_unlock('b');
close_tree(); close_tree();
......
...@@ -42,7 +42,7 @@ static void setup_tree(void) { ...@@ -42,7 +42,7 @@ static void setup_tree(void) {
assert(ltm); assert(ltm);
//ask ltm for lock tree //ask ltm for lock tree
DICTIONARY_ID dict_id = {0x1234}; DICTIONARY_ID dict_id = {0x1234};
r = toku_ltm_get_lt(ltm, &lt, dict_id, db, intcmp); r = toku_ltm_get_lt(ltm, &lt, dict_id, NULL, intcmp);
CKERR(r); CKERR(r);
assert(lt); assert(lt);
...@@ -52,7 +52,7 @@ static void setup_tree(void) { ...@@ -52,7 +52,7 @@ static void setup_tree(void) {
static void close_tree(void) { static void close_tree(void) {
assert(lt && ltm); assert(lt && ltm);
toku_lt_remove_db_ref(lt, db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); r = toku_ltm_close(ltm);
CKERR(r); CKERR(r);
lt = NULL; lt = NULL;
...@@ -86,16 +86,16 @@ static void lt_insert(int r_expect, char txn, int key_l, int key_r, bool read_fl ...@@ -86,16 +86,16 @@ static void lt_insert(int r_expect, char txn, int key_l, int key_r, bool read_fl
TXNID local_txn = (TXNID) (size_t) txn; TXNID local_txn = (TXNID) (size_t) txn;
if (read_flag) if (read_flag)
r = toku_lt_acquire_range_read_lock(lt, db, local_txn, key_left, key_right); r = toku_lt_acquire_range_read_lock(lt, local_txn, key_left, key_right);
else else
r = toku_lt_acquire_write_lock(lt, db, local_txn, key_left); r = toku_lt_acquire_write_lock(lt, local_txn, key_left);
CKERR2(r, r_expect); CKERR2(r, r_expect);
} }
static int lt_insert_write_no_check(char txn, int key_p) { static int lt_insert_write_no_check(char txn, int key_p) {
DBT key; DBT key;
TXNID local_txn = (TXNID) (size_t) txn; TXNID local_txn = (TXNID) (size_t) txn;
r = toku_lt_acquire_write_lock(lt, db, local_txn, dbt_init(&key, &nums[key_p], sizeof(nums[0]))); r = toku_lt_acquire_write_lock(lt, local_txn, dbt_init(&key, &nums[key_p], sizeof(nums[0])));
return r; return r;
} }
......
...@@ -34,14 +34,12 @@ static void init_query(void) { ...@@ -34,14 +34,12 @@ static void init_query(void) {
query.right = &qright; query.right = &qright;
} }
static DB *fake_db = (DB *) 1;
static void setup_tree(void) { static void setup_tree(void) {
assert(!lt && !ltm); assert(!lt && !ltm);
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
CKERR(r); CKERR(r);
assert(ltm); assert(ltm);
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
CKERR(r); CKERR(r);
assert(lt); assert(lt);
init_query(); init_query();
...@@ -49,7 +47,7 @@ static void setup_tree(void) { ...@@ -49,7 +47,7 @@ static void setup_tree(void) {
static void close_tree(void) { static void close_tree(void) {
assert(lt && ltm); assert(lt && ltm);
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); CKERR(r); r = toku_ltm_close(ltm); CKERR(r);
lt = NULL; lt = NULL;
ltm = NULL; ltm = NULL;
...@@ -69,7 +67,7 @@ static DBT* set_to_infty(DBT *dbt, int value) { ...@@ -69,7 +67,7 @@ static DBT* set_to_infty(DBT *dbt, int value) {
} }
static void lt_verify(void) { static void lt_verify(void) {
toku_lt_verify(lt, NULL); toku_lt_verify(lt);
} }
static void lt_insert_write_range(int r_expect, char txn, int key_l, int key_r) { static void lt_insert_write_range(int r_expect, char txn, int key_l, int key_r) {
...@@ -83,7 +81,7 @@ static void lt_insert_write_range(int r_expect, char txn, int key_l, int key_r) ...@@ -83,7 +81,7 @@ static void lt_insert_write_range(int r_expect, char txn, int key_l, int key_r)
TXNID local_txn = (TXNID) (size_t) txn; TXNID local_txn = (TXNID) (size_t) txn;
r = toku_lt_acquire_range_write_lock(lt, db, local_txn, key_left, key_right); r = toku_lt_acquire_range_write_lock(lt, local_txn, key_left, key_right);
CKERR2(r, r_expect); CKERR2(r, r_expect);
lt_verify(); lt_verify();
} }
......
...@@ -41,10 +41,9 @@ int main(int argc, const char *argv[]) { ...@@ -41,10 +41,9 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *fake_db = (DB *) 1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
const TXNID txn_a = 1; const TXNID txn_a = 1;
...@@ -54,32 +53,32 @@ int main(int argc, const char *argv[]) { ...@@ -54,32 +53,32 @@ int main(int argc, const char *argv[]) {
DBT key_m = { .data = "M", .size = 1 }; DBT key_m = { .data = "M", .size = 1 };
// txn_a gets W(L) // txn_a gets W(L)
toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, fake_db, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0); r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0);
assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0); assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0);
toku_lock_request_destroy(&a_w_l); toku_lock_request_destroy(&a_w_l);
toku_lt_add_ref(lt); toku_lt_add_ref(lt);
// txn_b gets W(M) // txn_b gets W(M)
toku_lock_request b_w_m; toku_lock_request_init(&b_w_m, fake_db, txn_b, &key_m, &key_m, LOCK_REQUEST_WRITE); toku_lock_request b_w_m; toku_lock_request_init(&b_w_m, txn_b, &key_m, &key_m, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&b_w_m, lt, false); assert(r == 0); r = toku_lock_request_start(&b_w_m, lt, false); assert(r == 0);
assert(b_w_m.state == LOCK_REQUEST_COMPLETE && b_w_m.complete_r == 0); assert(b_w_m.state == LOCK_REQUEST_COMPLETE && b_w_m.complete_r == 0);
toku_lock_request_destroy(&b_w_m); toku_lock_request_destroy(&b_w_m);
toku_lt_add_ref(lt); toku_lt_add_ref(lt);
// start closing the lock tree // start closing the lock tree
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
// txn_a unlocks // txn_a unlocks
r = toku_lt_unlock_txn(lt, txn_a); r = toku_lt_unlock_txn(lt, txn_a);
toku_lt_remove_ref(lt); toku_lt_remove_ref(lt);
// reopen the lock tree // reopen the lock tree
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
// txn_b gets W(L) // txn_b gets W(L)
toku_lock_request b_w_l; toku_lock_request_init(&b_w_l, fake_db, txn_b, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request b_w_l; toku_lock_request_init(&b_w_l, txn_b, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&b_w_l, lt, false); assert(r == 0); r = toku_lock_request_start(&b_w_l, lt, false); assert(r == 0);
assert(b_w_l.state == LOCK_REQUEST_COMPLETE && b_w_l.complete_r == 0); assert(b_w_l.state == LOCK_REQUEST_COMPLETE && b_w_l.complete_r == 0);
toku_lock_request_destroy(&b_w_l); toku_lock_request_destroy(&b_w_l);
......
...@@ -46,10 +46,9 @@ int main(int argc, const char *argv[]) { ...@@ -46,10 +46,9 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *fake_db = (DB *) 1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
DBT key_l; dbt_init(&key_l, "L", 1); DBT key_l; dbt_init(&key_l, "L", 1);
...@@ -57,7 +56,7 @@ int main(int argc, const char *argv[]) { ...@@ -57,7 +56,7 @@ int main(int argc, const char *argv[]) {
txnid_set conflicts; txnid_set conflicts;
const TXNID txn_a = 1; const TXNID txn_a = 1;
toku_lock_request a_r_t; toku_lock_request_init(&a_r_t, fake_db, txn_a, toku_lt_neg_infinity, toku_lt_infinity, LOCK_REQUEST_READ); toku_lock_request a_r_t; toku_lock_request_init(&a_r_t, txn_a, toku_lt_neg_infinity, toku_lt_infinity, LOCK_REQUEST_READ);
r = toku_lock_request_start(&a_r_t, lt, false); assert(r == 0); r = toku_lock_request_start(&a_r_t, lt, false); assert(r == 0);
assert(a_r_t.state == LOCK_REQUEST_COMPLETE && a_r_t.complete_r == 0); assert(a_r_t.state == LOCK_REQUEST_COMPLETE && a_r_t.complete_r == 0);
txnid_set_init(&conflicts); txnid_set_init(&conflicts);
...@@ -68,7 +67,7 @@ int main(int argc, const char *argv[]) { ...@@ -68,7 +67,7 @@ int main(int argc, const char *argv[]) {
toku_lock_request_destroy(&a_r_t); toku_lock_request_destroy(&a_r_t);
const TXNID txn_b = 2; const TXNID txn_b = 2;
toku_lock_request b_r_l; toku_lock_request_init(&b_r_l, fake_db, txn_b, &key_l, &key_l, LOCK_REQUEST_READ); toku_lock_request b_r_l; toku_lock_request_init(&b_r_l, txn_b, &key_l, &key_l, LOCK_REQUEST_READ);
r = toku_lock_request_start(&b_r_l, lt, false); assert(r == 0); r = toku_lock_request_start(&b_r_l, lt, false); assert(r == 0);
assert(b_r_l.state == LOCK_REQUEST_COMPLETE && b_r_l.complete_r == 0); assert(b_r_l.state == LOCK_REQUEST_COMPLETE && b_r_l.complete_r == 0);
txnid_set_init(&conflicts); txnid_set_init(&conflicts);
...@@ -79,7 +78,7 @@ int main(int argc, const char *argv[]) { ...@@ -79,7 +78,7 @@ int main(int argc, const char *argv[]) {
toku_lock_request_destroy(&b_r_l); toku_lock_request_destroy(&b_r_l);
const TXNID txn_c = 3; const TXNID txn_c = 3;
toku_lock_request c_w_l; toku_lock_request_init(&c_w_l, fake_db, txn_c, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request c_w_l; toku_lock_request_init(&c_w_l, txn_c, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&c_w_l, lt, false); assert(r != 0); r = toku_lock_request_start(&c_w_l, lt, false); assert(r != 0);
assert(c_w_l.state == LOCK_REQUEST_PENDING); assert(c_w_l.state == LOCK_REQUEST_PENDING);
...@@ -107,7 +106,7 @@ int main(int argc, const char *argv[]) { ...@@ -107,7 +106,7 @@ int main(int argc, const char *argv[]) {
r = toku_lt_unlock_txn(lt, txn_c); assert(r == 0); r = toku_lt_unlock_txn(lt, txn_c); assert(r == 0);
// shutdown // shutdown
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -46,10 +46,8 @@ int main(int argc, const char *argv[]) { ...@@ -46,10 +46,8 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *fake_db = (DB *) 1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
DBT key_l; dbt_init(&key_l, "L", 1); DBT key_l; dbt_init(&key_l, "L", 1);
...@@ -57,7 +55,7 @@ int main(int argc, const char *argv[]) { ...@@ -57,7 +55,7 @@ int main(int argc, const char *argv[]) {
txnid_set conflicts; txnid_set conflicts;
const TXNID txn_a = 1; const TXNID txn_a = 1;
toku_lock_request a_r_l; toku_lock_request_init(&a_r_l, fake_db, txn_a, &key_l, &key_l, LOCK_REQUEST_READ); toku_lock_request a_r_l; toku_lock_request_init(&a_r_l, txn_a, &key_l, &key_l, LOCK_REQUEST_READ);
r = toku_lock_request_start(&a_r_l, lt, false); assert(r == 0); r = toku_lock_request_start(&a_r_l, lt, false); assert(r == 0);
assert(a_r_l.state == LOCK_REQUEST_COMPLETE && a_r_l.complete_r == 0); assert(a_r_l.state == LOCK_REQUEST_COMPLETE && a_r_l.complete_r == 0);
txnid_set_init(&conflicts); txnid_set_init(&conflicts);
...@@ -68,7 +66,7 @@ int main(int argc, const char *argv[]) { ...@@ -68,7 +66,7 @@ int main(int argc, const char *argv[]) {
toku_lock_request_destroy(&a_r_l); toku_lock_request_destroy(&a_r_l);
const TXNID txn_b = 2; const TXNID txn_b = 2;
toku_lock_request b_r_l; toku_lock_request_init(&b_r_l, fake_db, txn_b, &key_l, &key_l, LOCK_REQUEST_READ); toku_lock_request b_r_l; toku_lock_request_init(&b_r_l, txn_b, &key_l, &key_l, LOCK_REQUEST_READ);
r = toku_lock_request_start(&b_r_l, lt, false); assert(r == 0); r = toku_lock_request_start(&b_r_l, lt, false); assert(r == 0);
assert(b_r_l.state == LOCK_REQUEST_COMPLETE && b_r_l.complete_r == 0 assert(b_r_l.state == LOCK_REQUEST_COMPLETE && b_r_l.complete_r == 0
); );
...@@ -80,7 +78,7 @@ int main(int argc, const char *argv[]) { ...@@ -80,7 +78,7 @@ int main(int argc, const char *argv[]) {
toku_lock_request_destroy(&b_r_l); toku_lock_request_destroy(&b_r_l);
const TXNID txn_c = 3; const TXNID txn_c = 3;
toku_lock_request c_w_l; toku_lock_request_init(&c_w_l, fake_db, txn_c, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request c_w_l; toku_lock_request_init(&c_w_l, txn_c, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&c_w_l, lt, false); assert(r != 0); r = toku_lock_request_start(&c_w_l, lt, false); assert(r != 0);
assert(c_w_l.state == LOCK_REQUEST_PENDING); assert(c_w_l.state == LOCK_REQUEST_PENDING);
...@@ -108,7 +106,7 @@ int main(int argc, const char *argv[]) { ...@@ -108,7 +106,7 @@ int main(int argc, const char *argv[]) {
r = toku_lt_unlock_txn(lt, txn_c); assert(r == 0); r = toku_lt_unlock_txn(lt, txn_c); assert(r == 0);
// shutdown // shutdown
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -36,15 +36,13 @@ int main(int argc, const char *argv[]) { ...@@ -36,15 +36,13 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *fake_db = (DB *) 1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
const TXNID txn_a = 1; const TXNID txn_a = 1;
DBT key_l; dbt_init(&key_l, "L", 1); DBT key_l; dbt_init(&key_l, "L", 1);
toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, fake_db, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0); r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0);
assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0); assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0);
...@@ -59,7 +57,7 @@ int main(int argc, const char *argv[]) { ...@@ -59,7 +57,7 @@ int main(int argc, const char *argv[]) {
toku_lock_request_destroy(&a_w_l); toku_lock_request_destroy(&a_w_l);
const TXNID txn_b = 2; const TXNID txn_b = 2;
toku_lock_request b_r_l; toku_lock_request_init(&b_r_l, fake_db, txn_b, &key_l, &key_l, LOCK_REQUEST_READ); toku_lock_request b_r_l; toku_lock_request_init(&b_r_l, txn_b, &key_l, &key_l, LOCK_REQUEST_READ);
r = toku_lock_request_start(&b_r_l, lt, false); assert(r != 0); r = toku_lock_request_start(&b_r_l, lt, false); assert(r != 0);
assert(b_r_l.state == LOCK_REQUEST_PENDING); assert(b_r_l.state == LOCK_REQUEST_PENDING);
...@@ -76,7 +74,7 @@ int main(int argc, const char *argv[]) { ...@@ -76,7 +74,7 @@ int main(int argc, const char *argv[]) {
r = toku_lt_unlock_txn(lt, txn_b); assert(r == 0); r = toku_lt_unlock_txn(lt, txn_b); assert(r == 0);
// shutdown // shutdown
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -36,16 +36,14 @@ int main(int argc, const char *argv[]) { ...@@ -36,16 +36,14 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *fake_db = (DB *) 1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
DBT key_l; dbt_init(&key_l, "L", 1); DBT key_l; dbt_init(&key_l, "L", 1);
const TXNID txn_a = 1; const TXNID txn_a = 1;
toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, fake_db, txn_a, toku_lt_neg_infinity, toku_lt_infinity, LOCK_REQUEST_WRITE); toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, txn_a, toku_lt_neg_infinity, toku_lt_infinity, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0); r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0);
assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0); assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0);
...@@ -60,7 +58,7 @@ int main(int argc, const char *argv[]) { ...@@ -60,7 +58,7 @@ int main(int argc, const char *argv[]) {
toku_lock_request_destroy(&a_w_l); toku_lock_request_destroy(&a_w_l);
const TXNID txn_b = 2; const TXNID txn_b = 2;
toku_lock_request b_r_l; toku_lock_request_init(&b_r_l, fake_db, txn_b, &key_l, &key_l, LOCK_REQUEST_READ); toku_lock_request b_r_l; toku_lock_request_init(&b_r_l, txn_b, &key_l, &key_l, LOCK_REQUEST_READ);
r = toku_lock_request_start(&b_r_l, lt, false); assert(r != 0); r = toku_lock_request_start(&b_r_l, lt, false); assert(r != 0);
assert(b_r_l.state == LOCK_REQUEST_PENDING); assert(b_r_l.state == LOCK_REQUEST_PENDING);
...@@ -76,7 +74,7 @@ int main(int argc, const char *argv[]) { ...@@ -76,7 +74,7 @@ int main(int argc, const char *argv[]) {
r = toku_lt_unlock_txn(lt, txn_b); assert(r == 0); r = toku_lt_unlock_txn(lt, txn_b); assert(r == 0);
// shutdown // shutdown
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -36,16 +36,14 @@ int main(int argc, const char *argv[]) { ...@@ -36,16 +36,14 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *fake_db = (DB *) 1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
DBT key_l; dbt_init(&key_l, "L", 1); DBT key_l; dbt_init(&key_l, "L", 1);
const TXNID txn_a = 1; const TXNID txn_a = 1;
toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, fake_db, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0); r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0);
assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0); assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0);
...@@ -60,7 +58,7 @@ int main(int argc, const char *argv[]) { ...@@ -60,7 +58,7 @@ int main(int argc, const char *argv[]) {
toku_lock_request_destroy(&a_w_l); toku_lock_request_destroy(&a_w_l);
const TXNID txn_b = 2; const TXNID txn_b = 2;
toku_lock_request b_w_l; toku_lock_request_init(&b_w_l, fake_db, txn_b, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request b_w_l; toku_lock_request_init(&b_w_l, txn_b, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&b_w_l, lt, false); assert(r != 0); r = toku_lock_request_start(&b_w_l, lt, false); assert(r != 0);
assert(b_w_l.state == LOCK_REQUEST_PENDING); assert(b_w_l.state == LOCK_REQUEST_PENDING);
...@@ -76,7 +74,7 @@ int main(int argc, const char *argv[]) { ...@@ -76,7 +74,7 @@ int main(int argc, const char *argv[]) {
r = toku_lt_unlock_txn(lt, txn_a); assert(r == 0); r = toku_lt_unlock_txn(lt, txn_a); assert(r == 0);
// shutdown // shutdown
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
static int read_lock(toku_lock_tree *lt, TXNID txnid, char *k) { static int read_lock(toku_lock_tree *lt, TXNID txnid, char *k) {
DBT key; dbt_init(&key, k, strlen(k)); DBT key; dbt_init(&key, k, strlen(k));
toku_lock_request lr; toku_lock_request lr;
toku_lock_request_init(&lr, (DB*)1, txnid, &key, &key, LOCK_REQUEST_READ); toku_lock_request_init(&lr, txnid, &key, &key, LOCK_REQUEST_READ);
int r = toku_lt_acquire_lock_request_with_default_timeout(lt, &lr); int r = toku_lt_acquire_lock_request_with_default_timeout(lt, &lr);
toku_lock_request_destroy(&lr); toku_lock_request_destroy(&lr);
return r; return r;
...@@ -16,7 +16,7 @@ static int read_lock(toku_lock_tree *lt, TXNID txnid, char *k) { ...@@ -16,7 +16,7 @@ static int read_lock(toku_lock_tree *lt, TXNID txnid, char *k) {
static int write_lock(toku_lock_tree *lt, TXNID txnid, char *k) { static int write_lock(toku_lock_tree *lt, TXNID txnid, char *k) {
DBT key; dbt_init(&key, k, strlen(k)); DBT key; dbt_init(&key, k, strlen(k));
toku_lock_request lr; toku_lock_request lr;
toku_lock_request_init(&lr, (DB*)1, txnid, &key, &key, LOCK_REQUEST_WRITE); toku_lock_request_init(&lr, txnid, &key, &key, LOCK_REQUEST_WRITE);
int r = toku_lt_acquire_lock_request_with_default_timeout(lt, &lr); int r = toku_lt_acquire_lock_request_with_default_timeout(lt, &lr);
toku_lock_request_destroy(&lr); toku_lock_request_destroy(&lr);
return r; return r;
...@@ -53,10 +53,8 @@ int main(int argc, const char *argv[]) { ...@@ -53,10 +53,8 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *fake_db = (DB *) 1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
const TXNID txn_a = 1; const TXNID txn_a = 1;
...@@ -73,7 +71,7 @@ int main(int argc, const char *argv[]) { ...@@ -73,7 +71,7 @@ int main(int argc, const char *argv[]) {
r = toku_lt_unlock_txn(lt, txn_a); assert(r == 0); r = toku_lt_unlock_txn(lt, txn_a); assert(r == 0);
// shutdown // shutdown
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -104,10 +104,8 @@ int main(int argc, const char *argv[]) { ...@@ -104,10 +104,8 @@ int main(int argc, const char *argv[]) {
assert(s.max_lock_memory == max_lock_memory); assert(s.max_lock_memory == max_lock_memory);
assert(s.curr_lock_memory == 0); assert(s.curr_lock_memory == 0);
DB *db_a = (DB *) 2;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, db_a, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
TXNID txn_a = 1; TXNID txn_a = 1;
...@@ -116,7 +114,7 @@ int main(int argc, const char *argv[]) { ...@@ -116,7 +114,7 @@ int main(int argc, const char *argv[]) {
for (uint64_t i = 1; i <= nrows; i++) { for (uint64_t i = 1; i <= nrows; i++) {
uint64_t k = htonl64(i); uint64_t k = htonl64(i);
DBT key = { .data = &k, .size = sizeof k }; DBT key = { .data = &k, .size = sizeof k };
r = toku_lt_acquire_write_lock(lt, db_a, txn_a, &key); r = toku_lt_acquire_write_lock(lt, txn_a, &key);
if (r != 0) { if (r != 0) {
assert(r == TOKUDB_OUT_OF_LOCKS); assert(r == TOKUDB_OUT_OF_LOCKS);
break; break;
...@@ -143,7 +141,7 @@ int main(int argc, const char *argv[]) { ...@@ -143,7 +141,7 @@ int main(int argc, const char *argv[]) {
assert(s.curr_locks == 0); assert(s.curr_locks == 0);
// shutdown // shutdown
toku_lt_remove_db_ref(lt, db_a); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -106,10 +106,8 @@ int main(int argc, const char *argv[]) { ...@@ -106,10 +106,8 @@ int main(int argc, const char *argv[]) {
assert(s.max_lock_memory == max_lock_memory); assert(s.max_lock_memory == max_lock_memory);
assert(s.curr_lock_memory == 0); assert(s.curr_lock_memory == 0);
DB *db_a = (DB *) 2;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, db_a, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
TXNID txn_a = 1; TXNID txn_a = 1;
...@@ -120,7 +118,7 @@ int main(int argc, const char *argv[]) { ...@@ -120,7 +118,7 @@ int main(int argc, const char *argv[]) {
uint64_t k_right = htonl64(2*i+1); uint64_t k_right = htonl64(2*i+1);
DBT key_left = { .data = &k_left, .size = sizeof k_left }; DBT key_left = { .data = &k_left, .size = sizeof k_left };
DBT key_right = { .data = &k_right, .size = sizeof k_right }; DBT key_right = { .data = &k_right, .size = sizeof k_right };
r = toku_lt_acquire_range_write_lock(lt, db_a, txn_a, &key_left, &key_right); r = toku_lt_acquire_range_write_lock(lt, txn_a, &key_left, &key_right);
if (r != 0) { if (r != 0) {
assert(r == TOKUDB_OUT_OF_LOCKS); assert(r == TOKUDB_OUT_OF_LOCKS);
break; break;
...@@ -147,7 +145,7 @@ int main(int argc, const char *argv[]) { ...@@ -147,7 +145,7 @@ int main(int argc, const char *argv[]) {
assert(s.curr_locks == 0); assert(s.curr_locks == 0);
// shutdown // shutdown
toku_lt_remove_db_ref(lt, db_a); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -34,14 +34,12 @@ static void init_query(void) { ...@@ -34,14 +34,12 @@ static void init_query(void) {
query.right = &qright; query.right = &qright;
} }
static DB *fake_db = (DB *) 1;
static void setup_tree(void) { static void setup_tree(void) {
assert(!lt && !ltm); assert(!lt && !ltm);
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
CKERR(r); CKERR(r);
assert(ltm); assert(ltm);
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
CKERR(r); CKERR(r);
assert(lt); assert(lt);
init_query(); init_query();
...@@ -49,7 +47,7 @@ static void setup_tree(void) { ...@@ -49,7 +47,7 @@ static void setup_tree(void) {
static void close_tree(void) { static void close_tree(void) {
assert(lt && ltm); assert(lt && ltm);
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); CKERR(r); r = toku_ltm_close(ltm); CKERR(r);
lt = NULL; lt = NULL;
ltm = NULL; ltm = NULL;
...@@ -69,7 +67,7 @@ static DBT* set_to_infty(DBT *dbt, int value) { ...@@ -69,7 +67,7 @@ static DBT* set_to_infty(DBT *dbt, int value) {
} }
static void lt_verify(void) { static void lt_verify(void) {
toku_lt_verify(lt, NULL); toku_lt_verify(lt);
} }
static void lt_insert_read_range(int r_expect, char txn, int key_l, int key_r) { static void lt_insert_read_range(int r_expect, char txn, int key_l, int key_r) {
...@@ -83,7 +81,7 @@ static void lt_insert_read_range(int r_expect, char txn, int key_l, int key_r) { ...@@ -83,7 +81,7 @@ static void lt_insert_read_range(int r_expect, char txn, int key_l, int key_r) {
TXNID local_txn = (TXNID) (size_t) txn; TXNID local_txn = (TXNID) (size_t) txn;
r = toku_lt_acquire_range_read_lock(lt, db, local_txn, key_left, key_right); r = toku_lt_acquire_range_read_lock(lt, local_txn, key_left, key_right);
CKERR2(r, r_expect); CKERR2(r, r_expect);
lt_verify(); lt_verify();
} }
...@@ -99,7 +97,7 @@ static void lt_insert_write_range(int r_expect, char txn, int key_l, int key_r) ...@@ -99,7 +97,7 @@ static void lt_insert_write_range(int r_expect, char txn, int key_l, int key_r)
TXNID local_txn = (TXNID) (size_t) txn; TXNID local_txn = (TXNID) (size_t) txn;
r = toku_lt_acquire_range_write_lock(lt, db, local_txn, key_left, key_right); r = toku_lt_acquire_range_write_lock(lt, local_txn, key_left, key_right);
CKERR2(r, r_expect); CKERR2(r, r_expect);
lt_verify(); lt_verify();
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
static int read_lock(toku_lock_tree *lt, TXNID txnid, char *k, struct timeval *wait_time) { static int read_lock(toku_lock_tree *lt, TXNID txnid, char *k, struct timeval *wait_time) {
DBT key; dbt_init(&key, k, strlen(k)); DBT key; dbt_init(&key, k, strlen(k));
toku_lock_request lr; toku_lock_request lr;
toku_lock_request_init(&lr, (DB*)1, txnid, &key, &key, LOCK_REQUEST_READ); toku_lock_request_init(&lr, txnid, &key, &key, LOCK_REQUEST_READ);
int r = toku_lt_acquire_lock_request_with_timeout(lt, &lr, wait_time); int r = toku_lt_acquire_lock_request_with_timeout(lt, &lr, wait_time);
toku_lock_request_destroy(&lr); toku_lock_request_destroy(&lr);
return r; return r;
...@@ -16,7 +16,7 @@ static int read_lock(toku_lock_tree *lt, TXNID txnid, char *k, struct timeval *w ...@@ -16,7 +16,7 @@ static int read_lock(toku_lock_tree *lt, TXNID txnid, char *k, struct timeval *w
static int write_lock(toku_lock_tree *lt, TXNID txnid, char *k, struct timeval *wait_time) { static int write_lock(toku_lock_tree *lt, TXNID txnid, char *k, struct timeval *wait_time) {
DBT key; dbt_init(&key, k, strlen(k)); DBT key; dbt_init(&key, k, strlen(k));
toku_lock_request lr; toku_lock_request lr;
toku_lock_request_init(&lr, (DB*)1, txnid, &key, &key, LOCK_REQUEST_WRITE); toku_lock_request_init(&lr, txnid, &key, &key, LOCK_REQUEST_WRITE);
int r = toku_lt_acquire_lock_request_with_timeout(lt, &lr, wait_time); int r = toku_lt_acquire_lock_request_with_timeout(lt, &lr, wait_time);
toku_lock_request_destroy(&lr); toku_lock_request_destroy(&lr);
return r; return r;
...@@ -53,10 +53,8 @@ int main(int argc, const char *argv[]) { ...@@ -53,10 +53,8 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *fake_db = (DB *) 1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
const TXNID txn_a = 1; const TXNID txn_a = 1;
...@@ -73,7 +71,7 @@ int main(int argc, const char *argv[]) { ...@@ -73,7 +71,7 @@ int main(int argc, const char *argv[]) {
r = toku_lt_unlock_txn(lt, txn_a); assert(r == 0); r = toku_lt_unlock_txn(lt, txn_a); assert(r == 0);
// shutdown // shutdown
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
#include <string.h>
#include <stdbool.h>
#include "test.h"
// verify that updating a lock tree's descriptor works properly.
static toku_ltm *ltm;
static toku_lock_tree *tree;
enum { MAX_LOCKS = 1000, MAX_LOCK_MEMORY = MAX_LOCKS * 64 };
#define verbose_printf(...) \
do { \
if (verbose) { \
printf(__VA_ARGS__);\
} \
} while (0)
#define MAKE_DESCRIPTOR(buf) \
{ .dbt = { .data = buf, .size = sizeof(buf) } }
static DESCRIPTOR_S descriptors[] = {
MAKE_DESCRIPTOR("cats"),
MAKE_DESCRIPTOR("elephants"),
MAKE_DESCRIPTOR("snakes"),
MAKE_DESCRIPTOR("catsarecute"),
MAKE_DESCRIPTOR("elephantsarelarge"),
MAKE_DESCRIPTOR("snakesonaplane")
};
static const int num_descriptors = sizeof(descriptors) / sizeof(DESCRIPTOR_S);
static DESCRIPTOR current_descriptor;
static bool same_descriptor(DESCRIPTOR a, DESCRIPTOR b)
{
verbose_printf("a %p b %p\n", a, b);
if (a == NULL && b == NULL) {
return true;
}
if (a != NULL && b != NULL) {
verbose_printf("a.size %d b.size %d\n", a->dbt.size, b->dbt.size);
verbose_printf("a.data %s b.data %s\n", (char*)a->dbt.data, (char*)b->dbt.data);
return a->dbt.size == b->dbt.size &&
memcmp(a->dbt.data, b->dbt.data, a->dbt.size) == 0;
}
return false;
}
static int cmp_function(DB * db, const DBT * a, const DBT * b)
{
// clearly the db should not be null.
assert(db);
// the descriptor in the DB should be the descriptor we expect
assert(same_descriptor(current_descriptor, db->cmp_descriptor));
// doesn't really matter what we return here
(void) a; (void) b;
return 0;
}
int main(int argc, const char *argv[])
{
int r;
parse_args(argc, argv);
// get a lock manager and a lock tree.
r = toku_ltm_create(&ltm, MAX_LOCKS, MAX_LOCK_MEMORY, dbpanic);
CKERR(r);
current_descriptor = NULL;
toku_ltm_get_lt(ltm, &tree, (DICTIONARY_ID) {1}, current_descriptor, cmp_function);
CKERR(r);
for (int d = 0; d < num_descriptors; d++) {
current_descriptor = &descriptors[d];
toku_lt_update_descriptor(tree, current_descriptor);
// check that we can call this point comparison a couple
// of times and pass the comparison function's assertion
for (int i = 0; i < 10; i++) {
const toku_point x = { .lt = tree, .key_payload = "" };
const toku_point y = { .lt = tree, .key_payload = "" };
toku_lt_point_cmp(&x, &y);
}
}
// cleanup
toku_ltm_close(ltm);
return 0;
}
...@@ -11,13 +11,13 @@ ...@@ -11,13 +11,13 @@
static int read_lock(toku_lock_tree *lt, TXNID txnid, char *k) { static int read_lock(toku_lock_tree *lt, TXNID txnid, char *k) {
DBT key; dbt_init(&key, k, strlen(k)); DBT key; dbt_init(&key, k, strlen(k));
int r = toku_lt_acquire_read_lock(lt, (DB*)1, txnid, &key); int r = toku_lt_acquire_read_lock(lt, txnid, &key);
return r; return r;
} }
static int write_lock(toku_lock_tree *lt, TXNID txnid, char *k) { static int write_lock(toku_lock_tree *lt, TXNID txnid, char *k) {
DBT key; dbt_init(&key, k, strlen(k)); DBT key; dbt_init(&key, k, strlen(k));
int r = toku_lt_acquire_write_lock(lt, (DB*)1, txnid, &key); int r = toku_lt_acquire_write_lock(lt, txnid, &key);
return r; return r;
} }
...@@ -52,10 +52,8 @@ int main(int argc, const char *argv[]) { ...@@ -52,10 +52,8 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *fake_db = (DB *) 1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
const TXNID txn_a = 1; const TXNID txn_a = 1;
...@@ -74,7 +72,7 @@ int main(int argc, const char *argv[]) { ...@@ -74,7 +72,7 @@ int main(int argc, const char *argv[]) {
r = toku_lt_unlock_txn(lt, txn_c); assert(r == 0); r = toku_lt_unlock_txn(lt, txn_c); assert(r == 0);
// shutdown // shutdown
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -41,26 +41,24 @@ int main(int argc, const char *argv[]) { ...@@ -41,26 +41,24 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *fake_db = (DB *) 1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
const TXNID txn_a = 1; const TXNID txn_a = 1;
DBT key_l; dbt_init(&key_l, "L", 1); DBT key_l; dbt_init(&key_l, "L", 1);
toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, fake_db, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0); r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0);
assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0); assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0);
toku_lock_request_destroy(&a_w_l); toku_lock_request_destroy(&a_w_l);
const TXNID txn_b = 2; const TXNID txn_b = 2;
toku_lock_request b_w_l; toku_lock_request_init(&b_w_l, fake_db, txn_b, &key_l, &key_l, LOCK_REQUEST_READ); toku_lock_request b_w_l; toku_lock_request_init(&b_w_l, txn_b, &key_l, &key_l, LOCK_REQUEST_READ);
r = toku_lock_request_start(&b_w_l, lt, false); assert(r != 0); r = toku_lock_request_start(&b_w_l, lt, false); assert(r != 0);
assert(b_w_l.state == LOCK_REQUEST_PENDING); assert(b_w_l.state == LOCK_REQUEST_PENDING);
const TXNID txn_c = 3; const TXNID txn_c = 3;
toku_lock_request c_w_l; toku_lock_request_init(&c_w_l, fake_db, txn_c, &key_l, &key_l, LOCK_REQUEST_READ); toku_lock_request c_w_l; toku_lock_request_init(&c_w_l, txn_c, &key_l, &key_l, LOCK_REQUEST_READ);
r = toku_lock_request_start(&c_w_l, lt, false); assert(r != 0); r = toku_lock_request_start(&c_w_l, lt, false); assert(r != 0);
assert(c_w_l.state == LOCK_REQUEST_PENDING); assert(c_w_l.state == LOCK_REQUEST_PENDING);
...@@ -73,7 +71,7 @@ int main(int argc, const char *argv[]) { ...@@ -73,7 +71,7 @@ int main(int argc, const char *argv[]) {
r = toku_lt_unlock_txn(lt, txn_c); assert(r == 0); r = toku_lt_unlock_txn(lt, txn_c); assert(r == 0);
// shutdown // shutdown
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -40,26 +40,24 @@ int main(int argc, const char *argv[]) { ...@@ -40,26 +40,24 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *fake_db = (DB *) 1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
const TXNID txn_a = 1; const TXNID txn_a = 1;
DBT key_l; dbt_init(&key_l, "L", 1); DBT key_l; dbt_init(&key_l, "L", 1);
toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, fake_db, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0); r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0);
assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0); assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0);
toku_lock_request_destroy(&a_w_l); toku_lock_request_destroy(&a_w_l);
const TXNID txn_b = 2; const TXNID txn_b = 2;
toku_lock_request b_w_l; toku_lock_request_init(&b_w_l, fake_db, txn_b, &key_l, &key_l, LOCK_REQUEST_READ); toku_lock_request b_w_l; toku_lock_request_init(&b_w_l, txn_b, &key_l, &key_l, LOCK_REQUEST_READ);
r = toku_lock_request_start(&b_w_l, lt, false); assert(r != 0); r = toku_lock_request_start(&b_w_l, lt, false); assert(r != 0);
assert(b_w_l.state == LOCK_REQUEST_PENDING); assert(b_w_l.state == LOCK_REQUEST_PENDING);
const TXNID txn_c = 3; const TXNID txn_c = 3;
toku_lock_request c_w_l; toku_lock_request_init(&c_w_l, fake_db, txn_c, &key_l, &key_l, LOCK_REQUEST_READ); toku_lock_request c_w_l; toku_lock_request_init(&c_w_l, txn_c, &key_l, &key_l, LOCK_REQUEST_READ);
r = toku_lock_request_start(&c_w_l, lt, false); assert(r != 0); r = toku_lock_request_start(&c_w_l, lt, false); assert(r != 0);
assert(c_w_l.state == LOCK_REQUEST_PENDING); assert(c_w_l.state == LOCK_REQUEST_PENDING);
...@@ -72,7 +70,7 @@ int main(int argc, const char *argv[]) { ...@@ -72,7 +70,7 @@ int main(int argc, const char *argv[]) {
r = toku_lt_unlock_txn(lt, txn_c); assert(r == 0); r = toku_lt_unlock_txn(lt, txn_c); assert(r == 0);
// shutdown // shutdown
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -39,31 +39,29 @@ int main(int argc, const char *argv[]) { ...@@ -39,31 +39,29 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *fake_db = (DB *) 1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
const TXNID txn_a = 1; const TXNID txn_a = 1;
DBT key_l; dbt_init(&key_l, "L", 1); DBT key_l; dbt_init(&key_l, "L", 1);
toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, fake_db, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0); r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0);
assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0); assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0);
toku_lock_request_destroy(&a_w_l); toku_lock_request_destroy(&a_w_l);
const TXNID txn_b = 2; const TXNID txn_b = 2;
DBT key_m; dbt_init(&key_m, "M", 1); DBT key_m; dbt_init(&key_m, "M", 1);
toku_lock_request b_w_m; toku_lock_request_init(&b_w_m, fake_db, txn_b, &key_m, &key_m, LOCK_REQUEST_WRITE); toku_lock_request b_w_m; toku_lock_request_init(&b_w_m, txn_b, &key_m, &key_m, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&b_w_m, lt, false); assert(r == 0); r = toku_lock_request_start(&b_w_m, lt, false); assert(r == 0);
assert(b_w_m.state == LOCK_REQUEST_COMPLETE && b_w_m.complete_r == 0); assert(b_w_m.state == LOCK_REQUEST_COMPLETE && b_w_m.complete_r == 0);
toku_lock_request_destroy(&b_w_m); toku_lock_request_destroy(&b_w_m);
toku_lock_request a_w_m; toku_lock_request_init(&a_w_m, fake_db, txn_a, &key_m, &key_m, LOCK_REQUEST_WRITE); toku_lock_request a_w_m; toku_lock_request_init(&a_w_m, txn_a, &key_m, &key_m, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&a_w_m, lt, false); assert(r == DB_LOCK_NOTGRANTED); r = toku_lock_request_start(&a_w_m, lt, false); assert(r == DB_LOCK_NOTGRANTED);
assert(a_w_m.state == LOCK_REQUEST_PENDING); assert(a_w_m.state == LOCK_REQUEST_PENDING);
toku_lock_request b_w_l; toku_lock_request_init(&b_w_l, fake_db, txn_b, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request b_w_l; toku_lock_request_init(&b_w_l, txn_b, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&b_w_l, lt, false); assert(r == DB_LOCK_DEADLOCK); r = toku_lock_request_start(&b_w_l, lt, false); assert(r == DB_LOCK_DEADLOCK);
assert(b_w_l.state == LOCK_REQUEST_COMPLETE && b_w_l.complete_r == DB_LOCK_DEADLOCK); assert(b_w_l.state == LOCK_REQUEST_COMPLETE && b_w_l.complete_r == DB_LOCK_DEADLOCK);
...@@ -77,7 +75,7 @@ int main(int argc, const char *argv[]) { ...@@ -77,7 +75,7 @@ int main(int argc, const char *argv[]) {
r = toku_lt_unlock_txn(lt, txn_a); assert(r == 0); r = toku_lt_unlock_txn(lt, txn_a); assert(r == 0);
// shutdown // shutdown
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -37,16 +37,14 @@ int main(int argc, const char *argv[]) { ...@@ -37,16 +37,14 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *fake_db = (DB *) 1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
// add a lock for a transaction // add a lock for a transaction
const TXNID txn_a = 1; const TXNID txn_a = 1;
DBT key_l; dbt_init(&key_l, "L", 1); DBT key_l; dbt_init(&key_l, "L", 1);
toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, fake_db, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0); r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0);
assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0); assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0);
toku_lock_request_destroy(&a_w_l); toku_lock_request_destroy(&a_w_l);
...@@ -55,7 +53,7 @@ int main(int argc, const char *argv[]) { ...@@ -55,7 +53,7 @@ int main(int argc, const char *argv[]) {
toku_lt_add_ref(lt); toku_lt_add_ref(lt);
// start closing the lock tree // start closing the lock tree
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
// release all locks for the transaction // release all locks for the transaction
r = toku_lt_unlock_txn(lt, txn_a); assert(r == 0); r = toku_lt_unlock_txn(lt, txn_a); assert(r == 0);
......
...@@ -39,30 +39,28 @@ int main(int argc, const char *argv[]) { ...@@ -39,30 +39,28 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *fake_db = (DB *) 1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
const TXNID txn_a = 1; const TXNID txn_a = 1;
DBT key_l; dbt_init(&key_l, "L", 1); DBT key_l; dbt_init(&key_l, "L", 1);
toku_lock_request a_r_l; toku_lock_request_init(&a_r_l, fake_db, txn_a, &key_l, &key_l, LOCK_REQUEST_READ); toku_lock_request a_r_l; toku_lock_request_init(&a_r_l, txn_a, &key_l, &key_l, LOCK_REQUEST_READ);
r = toku_lock_request_start(&a_r_l, lt, false); assert(r == 0); r = toku_lock_request_start(&a_r_l, lt, false); assert(r == 0);
assert(a_r_l.state == LOCK_REQUEST_COMPLETE && a_r_l.complete_r == 0); assert(a_r_l.state == LOCK_REQUEST_COMPLETE && a_r_l.complete_r == 0);
toku_lock_request_destroy(&a_r_l); toku_lock_request_destroy(&a_r_l);
const TXNID txn_b = 2; const TXNID txn_b = 2;
toku_lock_request b_r_l; toku_lock_request_init(&b_r_l, fake_db, txn_b, &key_l, &key_l, LOCK_REQUEST_READ); toku_lock_request b_r_l; toku_lock_request_init(&b_r_l, txn_b, &key_l, &key_l, LOCK_REQUEST_READ);
r = toku_lock_request_start(&b_r_l, lt, false); assert(r == 0); r = toku_lock_request_start(&b_r_l, lt, false); assert(r == 0);
assert(b_r_l.state == LOCK_REQUEST_COMPLETE && b_r_l.complete_r == 0); assert(b_r_l.state == LOCK_REQUEST_COMPLETE && b_r_l.complete_r == 0);
toku_lock_request_destroy(&b_r_l); toku_lock_request_destroy(&b_r_l);
toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, fake_db, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&a_w_l, lt, false); assert(r == DB_LOCK_NOTGRANTED); r = toku_lock_request_start(&a_w_l, lt, false); assert(r == DB_LOCK_NOTGRANTED);
assert(a_w_l.state == LOCK_REQUEST_PENDING); assert(a_w_l.state == LOCK_REQUEST_PENDING);
toku_lock_request b_w_l; toku_lock_request_init(&b_w_l, fake_db, txn_b, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request b_w_l; toku_lock_request_init(&b_w_l, txn_b, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&b_w_l, lt, false); assert(r == DB_LOCK_DEADLOCK); r = toku_lock_request_start(&b_w_l, lt, false); assert(r == DB_LOCK_DEADLOCK);
assert(b_w_l.state == LOCK_REQUEST_COMPLETE && b_w_l.complete_r == DB_LOCK_DEADLOCK); assert(b_w_l.state == LOCK_REQUEST_COMPLETE && b_w_l.complete_r == DB_LOCK_DEADLOCK);
...@@ -75,7 +73,7 @@ int main(int argc, const char *argv[]) { ...@@ -75,7 +73,7 @@ int main(int argc, const char *argv[]) {
r = toku_lt_unlock_txn(lt, txn_a); assert(r == 0); r = toku_lt_unlock_txn(lt, txn_a); assert(r == 0);
// shutdown // shutdown
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -39,30 +39,28 @@ int main(int argc, const char *argv[]) { ...@@ -39,30 +39,28 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *fake_db = (DB *) 1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
const TXNID txn_a = 1; const TXNID txn_a = 1;
DBT key_l; dbt_init(&key_l, "L", 1); DBT key_l; dbt_init(&key_l, "L", 1);
toku_lock_request a_r_l; toku_lock_request_init(&a_r_l, fake_db, txn_a, &key_l, &key_l, LOCK_REQUEST_READ); toku_lock_request a_r_l; toku_lock_request_init(&a_r_l, txn_a, &key_l, &key_l, LOCK_REQUEST_READ);
r = toku_lock_request_start(&a_r_l, lt, false); assert(r == 0); r = toku_lock_request_start(&a_r_l, lt, false); assert(r == 0);
assert(a_r_l.state == LOCK_REQUEST_COMPLETE && a_r_l.complete_r == 0); assert(a_r_l.state == LOCK_REQUEST_COMPLETE && a_r_l.complete_r == 0);
toku_lock_request_destroy(&a_r_l); toku_lock_request_destroy(&a_r_l);
const TXNID txn_b = 2; const TXNID txn_b = 2;
toku_lock_request b_r_l; toku_lock_request_init(&b_r_l, fake_db, txn_b, &key_l, &key_l, LOCK_REQUEST_READ); toku_lock_request b_r_l; toku_lock_request_init(&b_r_l, txn_b, &key_l, &key_l, LOCK_REQUEST_READ);
r = toku_lock_request_start(&b_r_l, lt, true); assert(r == 0); r = toku_lock_request_start(&b_r_l, lt, true); assert(r == 0);
assert(b_r_l.state == LOCK_REQUEST_COMPLETE && b_r_l.complete_r == 0); assert(b_r_l.state == LOCK_REQUEST_COMPLETE && b_r_l.complete_r == 0);
toku_lock_request_destroy(&b_r_l); toku_lock_request_destroy(&b_r_l);
toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, fake_db, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&a_w_l, lt, true); assert(r == DB_LOCK_NOTGRANTED); r = toku_lock_request_start(&a_w_l, lt, true); assert(r == DB_LOCK_NOTGRANTED);
assert(a_w_l.state == LOCK_REQUEST_PENDING); assert(a_w_l.state == LOCK_REQUEST_PENDING);
toku_lock_request b_w_l; toku_lock_request_init(&b_w_l, fake_db, txn_b, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request b_w_l; toku_lock_request_init(&b_w_l, txn_b, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&b_w_l, lt, true); assert(r == DB_LOCK_DEADLOCK); r = toku_lock_request_start(&b_w_l, lt, true); assert(r == DB_LOCK_DEADLOCK);
assert(b_w_l.state == LOCK_REQUEST_COMPLETE && b_w_l.complete_r == DB_LOCK_DEADLOCK); assert(b_w_l.state == LOCK_REQUEST_COMPLETE && b_w_l.complete_r == DB_LOCK_DEADLOCK);
...@@ -75,7 +73,7 @@ int main(int argc, const char *argv[]) { ...@@ -75,7 +73,7 @@ int main(int argc, const char *argv[]) {
r = toku_lt_unlock_txn(lt, txn_a); assert(r == 0); r = toku_lt_unlock_txn(lt, txn_a); assert(r == 0);
// shutdown // shutdown
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
static int write_lock(toku_lock_tree *lt, TXNID txnid, char *k) { static int write_lock(toku_lock_tree *lt, TXNID txnid, char *k) {
DBT key; dbt_init(&key, k, strlen(k)); DBT key; dbt_init(&key, k, strlen(k));
toku_lock_request lr; toku_lock_request lr;
toku_lock_request_init(&lr, (DB*)1, txnid, &key, &key, LOCK_REQUEST_WRITE); toku_lock_request_init(&lr, txnid, &key, &key, LOCK_REQUEST_WRITE);
int r; int r;
if (0) { if (0) {
r = toku_lt_acquire_lock_request_with_timeout(lt, &lr, NULL); r = toku_lt_acquire_lock_request_with_timeout(lt, &lr, NULL);
...@@ -76,10 +76,8 @@ int main(int argc, const char *argv[]) { ...@@ -76,10 +76,8 @@ int main(int argc, const char *argv[]) {
assert(r == 0 && ltm); assert(r == 0 && ltm);
toku_ltm_set_lock_wait_time(ltm, UINT64_MAX); toku_ltm_set_lock_wait_time(ltm, UINT64_MAX);
DB *fake_db = (DB *) 1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
const TXNID txn_a = 1; const TXNID txn_a = 1;
...@@ -104,7 +102,7 @@ int main(int argc, const char *argv[]) { ...@@ -104,7 +102,7 @@ int main(int argc, const char *argv[]) {
} }
// shutdown // shutdown
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
static int write_lock(toku_lock_tree *lt, TXNID txnid, char *k) { static int write_lock(toku_lock_tree *lt, TXNID txnid, char *k) {
DBT key; dbt_init(&key, k, strlen(k)); DBT key; dbt_init(&key, k, strlen(k));
int r = toku_lt_acquire_write_lock(lt, (DB*)1, txnid, &key); int r = toku_lt_acquire_write_lock(lt, txnid, &key);
return r; return r;
} }
...@@ -43,10 +43,8 @@ int main(int argc, const char *argv[]) { ...@@ -43,10 +43,8 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *fake_db = (DB *) 1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
const TXNID txn_a = 1; const TXNID txn_a = 1;
...@@ -59,7 +57,7 @@ int main(int argc, const char *argv[]) { ...@@ -59,7 +57,7 @@ int main(int argc, const char *argv[]) {
r = toku_lt_unlock_txn(lt, txn_b); assert(r == 0); r = toku_lt_unlock_txn(lt, txn_b); assert(r == 0);
// shutdown // shutdown
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -34,14 +34,12 @@ static void init_query(void) { ...@@ -34,14 +34,12 @@ static void init_query(void) {
query.right = &qright; query.right = &qright;
} }
static DB *fake_db = (DB *) 1;
static void setup_tree(void) { static void setup_tree(void) {
assert(!lt && !ltm); assert(!lt && !ltm);
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
CKERR(r); CKERR(r);
assert(ltm); assert(ltm);
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
CKERR(r); CKERR(r);
assert(lt); assert(lt);
init_query(); init_query();
...@@ -49,14 +47,14 @@ static void setup_tree(void) { ...@@ -49,14 +47,14 @@ static void setup_tree(void) {
static void close_tree(void) { static void close_tree(void) {
assert(lt && ltm); assert(lt && ltm);
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); CKERR(r); r = toku_ltm_close(ltm); CKERR(r);
lt = NULL; lt = NULL;
ltm = NULL; ltm = NULL;
} }
static void lt_verify(void) { static void lt_verify(void) {
toku_lt_verify(lt, NULL); toku_lt_verify(lt);
} }
typedef enum { null = -1, infinite = -2, neg_infinite = -3 } lt_infty; typedef enum { null = -1, infinite = -2, neg_infinite = -3 } lt_infty;
...@@ -89,11 +87,11 @@ static void lt_insert(int r_expect, char txn, int key_l, ...@@ -89,11 +87,11 @@ static void lt_insert(int r_expect, char txn, int key_l,
TXNID local_txn = (TXNID) (size_t) txn; TXNID local_txn = (TXNID) (size_t) txn;
if (read_flag) if (read_flag)
r = toku_lt_acquire_range_read_lock(lt, db, local_txn, r = toku_lt_acquire_range_read_lock(lt, local_txn,
key_left, key_left,
key_right); key_right);
else else
r = toku_lt_acquire_write_lock(lt, db, local_txn, key_left); r = toku_lt_acquire_write_lock(lt, local_txn, key_left);
CKERR2(r, r_expect); CKERR2(r, r_expect);
lt_verify(); lt_verify();
} }
...@@ -119,7 +117,7 @@ static void lt_insert_write_range(int r_expect, char txn, int key_l, int key_r) ...@@ -119,7 +117,7 @@ static void lt_insert_write_range(int r_expect, char txn, int key_l, int key_r)
TXNID local_txn = (TXNID) (size_t) txn; TXNID local_txn = (TXNID) (size_t) txn;
r = toku_lt_acquire_range_write_lock(lt, db, local_txn, key_left, key_right); r = toku_lt_acquire_range_write_lock(lt, local_txn, key_left, key_right);
CKERR2(r, r_expect); CKERR2(r, r_expect);
lt_verify(); lt_verify();
} }
......
...@@ -34,14 +34,12 @@ static void init_query(void) { ...@@ -34,14 +34,12 @@ static void init_query(void) {
query.right = &qright; query.right = &qright;
} }
static DB *fake_db = (DB *) 1;
static void setup_tree(void) { static void setup_tree(void) {
assert(!lt && !ltm); assert(!lt && !ltm);
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
CKERR(r); CKERR(r);
assert(ltm); assert(ltm);
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
CKERR(r); CKERR(r);
assert(lt); assert(lt);
init_query(); init_query();
...@@ -49,7 +47,7 @@ static void setup_tree(void) { ...@@ -49,7 +47,7 @@ static void setup_tree(void) {
static void close_tree(void) { static void close_tree(void) {
assert(lt && ltm); assert(lt && ltm);
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); CKERR(r); r = toku_ltm_close(ltm); CKERR(r);
lt = NULL; lt = NULL;
ltm = NULL; ltm = NULL;
...@@ -79,7 +77,7 @@ static void lt_insert_read_range(int r_expect, char txn, int key_l, int key_r) { ...@@ -79,7 +77,7 @@ static void lt_insert_read_range(int r_expect, char txn, int key_l, int key_r) {
TXNID local_txn = (TXNID) (size_t) txn; TXNID local_txn = (TXNID) (size_t) txn;
r = toku_lt_acquire_range_read_lock(lt, db, local_txn, r = toku_lt_acquire_range_read_lock(lt, local_txn,
key_left, key_left,
key_right); key_right);
CKERR2(r, r_expect); CKERR2(r, r_expect);
...@@ -96,7 +94,7 @@ static void lt_insert_write_range(int r_expect, char txn, int key_l, int key_r) ...@@ -96,7 +94,7 @@ static void lt_insert_write_range(int r_expect, char txn, int key_l, int key_r)
TXNID local_txn = (TXNID) (size_t) txn; TXNID local_txn = (TXNID) (size_t) txn;
r = toku_lt_acquire_range_write_lock(lt, db, local_txn, key_left, key_right); r = toku_lt_acquire_range_write_lock(lt, local_txn, key_left, key_right);
CKERR2(r, r_expect); CKERR2(r, r_expect);
} }
......
...@@ -34,14 +34,12 @@ static void init_query(void) { ...@@ -34,14 +34,12 @@ static void init_query(void) {
query.right = &qright; query.right = &qright;
} }
static DB *fake_db = (DB *) 1;
static void setup_tree(void) { static void setup_tree(void) {
assert(!lt && !ltm); assert(!lt && !ltm);
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
CKERR(r); CKERR(r);
assert(ltm); assert(ltm);
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
CKERR(r); CKERR(r);
assert(lt); assert(lt);
init_query(); init_query();
...@@ -49,7 +47,7 @@ static void setup_tree(void) { ...@@ -49,7 +47,7 @@ static void setup_tree(void) {
static void close_tree(void) { static void close_tree(void) {
assert(lt && ltm); assert(lt && ltm);
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); CKERR(r); r = toku_ltm_close(ltm); CKERR(r);
lt = NULL; lt = NULL;
ltm = NULL; ltm = NULL;
...@@ -80,7 +78,7 @@ static void lt_insert_read_range(int r_expect, char txn, int key_l, int key_r) { ...@@ -80,7 +78,7 @@ static void lt_insert_read_range(int r_expect, char txn, int key_l, int key_r) {
TXNID local_txn = (TXNID) (size_t) txn; TXNID local_txn = (TXNID) (size_t) txn;
r = toku_lt_acquire_range_read_lock(lt, db, local_txn, r = toku_lt_acquire_range_read_lock(lt, local_txn,
key_left, key_left,
key_right); key_right);
CKERR2(r, r_expect); CKERR2(r, r_expect);
...@@ -97,7 +95,7 @@ static void lt_insert_write_range(int r_expect, char txn, int key_l, int key_r) ...@@ -97,7 +95,7 @@ static void lt_insert_write_range(int r_expect, char txn, int key_l, int key_r)
TXNID local_txn = (TXNID) (size_t) txn; TXNID local_txn = (TXNID) (size_t) txn;
r = toku_lt_acquire_range_write_lock(lt, db, local_txn, key_left, key_right); r = toku_lt_acquire_range_write_lock(lt, local_txn, key_left, key_right);
CKERR2(r, r_expect); CKERR2(r, r_expect);
} }
......
...@@ -37,22 +37,20 @@ int main(int argc, const char *argv[]) { ...@@ -37,22 +37,20 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *fake_db = (DB *)1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
const TXNID txn_a = 1; const TXNID txn_a = 1;
const TXNID txn_b = 2; const TXNID txn_b = 2;
DBT key_l; dbt_init(&key_l, "L", 1); DBT key_l; dbt_init(&key_l, "L", 1);
toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, fake_db, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0); r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0);
assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0); assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0);
toku_lock_request_destroy(&a_w_l); toku_lock_request_destroy(&a_w_l);
toku_lock_request b_w_l; toku_lock_request_init(&b_w_l, fake_db, txn_b, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request b_w_l; toku_lock_request_init(&b_w_l, txn_b, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&b_w_l, lt, false); assert(r != 0); r = toku_lock_request_start(&b_w_l, lt, false); assert(r != 0);
assert(b_w_l.state == LOCK_REQUEST_PENDING); assert(b_w_l.state == LOCK_REQUEST_PENDING);
...@@ -62,7 +60,7 @@ int main(int argc, const char *argv[]) { ...@@ -62,7 +60,7 @@ int main(int argc, const char *argv[]) {
r = toku_lt_unlock_txn(lt, txn_b); assert(r == 0); r = toku_lt_unlock_txn(lt, txn_b); assert(r == 0);
// shutdown // shutdown
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -36,25 +36,23 @@ int main(int argc, const char *argv[]) { ...@@ -36,25 +36,23 @@ int main(int argc, const char *argv[]) {
r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic); r = toku_ltm_create(&ltm, max_locks, max_lock_memory, dbpanic);
assert(r == 0 && ltm); assert(r == 0 && ltm);
DB *fake_db = (DB *) 1;
toku_lock_tree *lt = NULL; toku_lock_tree *lt = NULL;
r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, fake_db, dbcmp); r = toku_ltm_get_lt(ltm, &lt, (DICTIONARY_ID){1}, NULL, dbcmp);
assert(r == 0 && lt); assert(r == 0 && lt);
const TXNID txn_a = 1; const TXNID txn_a = 1;
DBT key_l; dbt_init(&key_l, "L", 1); DBT key_l; dbt_init(&key_l, "L", 1);
toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, fake_db, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request a_w_l; toku_lock_request_init(&a_w_l, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0); r = toku_lock_request_start(&a_w_l, lt, false); assert(r == 0);
assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0); assert(a_w_l.state == LOCK_REQUEST_COMPLETE && a_w_l.complete_r == 0);
toku_lock_request_destroy(&a_w_l); toku_lock_request_destroy(&a_w_l);
toku_lock_request a_r_l; toku_lock_request_init(&a_r_l, fake_db, txn_a, &key_l, &key_l, LOCK_REQUEST_READ); toku_lock_request a_r_l; toku_lock_request_init(&a_r_l, txn_a, &key_l, &key_l, LOCK_REQUEST_READ);
r = toku_lock_request_start(&a_r_l, lt, false); assert(r == 0); r = toku_lock_request_start(&a_r_l, lt, false); assert(r == 0);
assert(a_r_l.state == LOCK_REQUEST_COMPLETE && a_r_l.complete_r == 0); assert(a_r_l.state == LOCK_REQUEST_COMPLETE && a_r_l.complete_r == 0);
toku_lock_request_destroy(&a_r_l); toku_lock_request_destroy(&a_r_l);
toku_lock_request a_w_l_2; toku_lock_request_init(&a_w_l_2, fake_db, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE); toku_lock_request a_w_l_2; toku_lock_request_init(&a_w_l_2, txn_a, &key_l, &key_l, LOCK_REQUEST_WRITE);
r = toku_lock_request_start(&a_w_l_2, lt, false); assert(r == 0); r = toku_lock_request_start(&a_w_l_2, lt, false); assert(r == 0);
assert(a_w_l_2.state == LOCK_REQUEST_COMPLETE && a_w_l_2.complete_r == 0); assert(a_w_l_2.state == LOCK_REQUEST_COMPLETE && a_w_l_2.complete_r == 0);
toku_lock_request_destroy(&a_w_l_2); toku_lock_request_destroy(&a_w_l_2);
...@@ -62,7 +60,7 @@ int main(int argc, const char *argv[]) { ...@@ -62,7 +60,7 @@ int main(int argc, const char *argv[]) {
r = toku_lt_unlock_txn(lt, txn_a); assert(r == 0); r = toku_lt_unlock_txn(lt, txn_a); assert(r == 0);
// shutdown // shutdown
toku_lt_remove_db_ref(lt, fake_db); toku_lt_remove_db_ref(lt);
r = toku_ltm_close(ltm); assert(r == 0); r = toku_ltm_close(ltm); assert(r == 0);
return 0; return 0;
......
...@@ -203,6 +203,19 @@ static void run_test(void) { ...@@ -203,6 +203,19 @@ static void run_test(void) {
do_inserts_and_queries(db); do_inserts_and_queries(db);
CHK(db->close(db, 0)); CHK(db->close(db, 0));
cmp_desc_is_four = TRUE;
CHK(db_create(&db, env, 0));
CHK(db->open(db, NULL, "foo.db", NULL, DB_BTREE, DB_AUTO_COMMIT, 0666));
IN_TXN_COMMIT(env, NULL, txn_1, 0, {
CHK(db->change_descriptor(db, txn_1, &orig_desc, DB_UPDATE_CMP_DESCRIPTOR));
assert_desc_four(db);
assert_cmp_desc_valid(db);
});
assert_desc_four(db);
assert_cmp_desc_valid(db);
do_inserts_and_queries(db);
CHK(db->close(db, 0));
} }
int test_main (int argc, char * const argv[]) { int test_main (int argc, char * const argv[]) {
......
...@@ -137,7 +137,7 @@ db_close_before_brt(DB *db, u_int32_t UU(flags), bool oplsn_valid, LSN oplsn) ...@@ -137,7 +137,7 @@ db_close_before_brt(DB *db, u_int32_t UU(flags), bool oplsn_valid, LSN oplsn)
} }
else { else {
if (db->i->lt) { if (db->i->lt) {
toku_lt_remove_db_ref(db->i->lt, db); toku_lt_remove_db_ref(db->i->lt);
} }
// printf("%s:%d %d=__toku_db_close(%p)\n", __FILE__, __LINE__, r, db); // printf("%s:%d %d=__toku_db_close(%p)\n", __FILE__, __LINE__, r, db);
toku_sdbt_cleanup(&db->i->skey); toku_sdbt_cleanup(&db->i->skey);
...@@ -429,7 +429,7 @@ db_open_iname(DB * db, DB_TXN * txn, const char *iname_in_env, u_int32_t flags, ...@@ -429,7 +429,7 @@ db_open_iname(DB * db, DB_TXN * txn, const char *iname_in_env, u_int32_t flags,
db->i->opened = 1; db->i->opened = 1;
if (need_locktree) { if (need_locktree) {
db->i->dict_id = toku_brt_get_dictionary_id(db->i->brt); db->i->dict_id = toku_brt_get_dictionary_id(db->i->brt);
r = toku_ltm_get_lt(db->dbenv->i->ltm, &db->i->lt, db->i->dict_id, db, toku_brt_get_bt_compare(db->i->brt)); r = toku_ltm_get_lt(db->dbenv->i->ltm, &db->i->lt, db->i->dict_id, db->cmp_descriptor, toku_brt_get_bt_compare(db->i->brt));
if (r!=0) { goto error_cleanup; } if (r!=0) { goto error_cleanup; }
} }
//Add to transaction's list of 'must close' if necessary. //Add to transaction's list of 'must close' if necessary.
...@@ -445,7 +445,7 @@ db_open_iname(DB * db, DB_TXN * txn, const char *iname_in_env, u_int32_t flags, ...@@ -445,7 +445,7 @@ db_open_iname(DB * db, DB_TXN * txn, const char *iname_in_env, u_int32_t flags,
db->i->dict_id = DICTIONARY_ID_NONE; db->i->dict_id = DICTIONARY_ID_NONE;
db->i->opened = 0; db->i->opened = 0;
if (db->i->lt) { if (db->i->lt) {
toku_lt_remove_db_ref(db->i->lt, db); toku_lt_remove_db_ref(db->i->lt);
db->i->lt = NULL; db->i->lt = NULL;
} }
return r; return r;
...@@ -529,7 +529,7 @@ toku_db_change_descriptor(DB *db, DB_TXN* txn, const DBT* descriptor, u_int32_t ...@@ -529,7 +529,7 @@ toku_db_change_descriptor(DB *db, DB_TXN* txn, const DBT* descriptor, u_int32_t
r = toku_db_pre_acquire_fileops_lock(db, txn); r = toku_db_pre_acquire_fileops_lock(db, txn);
if (r != 0) { goto cleanup; } if (r != 0) { goto cleanup; }
} }
old_descriptor.size = db->descriptor->dbt.size; old_descriptor.size = db->descriptor->dbt.size;
old_descriptor.data = toku_memdup(db->descriptor->dbt.data, db->descriptor->dbt.size); old_descriptor.data = toku_memdup(db->descriptor->dbt.data, db->descriptor->dbt.size);
r = toku_brt_change_descriptor( r = toku_brt_change_descriptor(
...@@ -540,6 +540,14 @@ toku_db_change_descriptor(DB *db, DB_TXN* txn, const DBT* descriptor, u_int32_t ...@@ -540,6 +540,14 @@ toku_db_change_descriptor(DB *db, DB_TXN* txn, const DBT* descriptor, u_int32_t
ttxn, ttxn,
update_cmp_descriptor update_cmp_descriptor
); );
if (r != 0) { goto cleanup; }
// the lock tree uses a copy of the header's descriptor for comparisons.
// if we need to update the cmp descriptor, we need to make sure the lock
// tree can get a copy of the new descriptor.
if (update_cmp_descriptor) {
toku_lt_update_descriptor(db->i->lt, db->cmp_descriptor);
}
cleanup: cleanup:
if (old_descriptor.data) toku_free(old_descriptor.data); if (old_descriptor.data) toku_free(old_descriptor.data);
return r; return r;
......
...@@ -63,7 +63,7 @@ get_range_lock(DB *db, DB_TXN *txn, const DBT *left_key, const DBT *right_key, t ...@@ -63,7 +63,7 @@ get_range_lock(DB *db, DB_TXN *txn, const DBT *left_key, const DBT *right_key, t
if (r == 0) { if (r == 0) {
TXNID txn_anc_id = toku_txn_get_txnid(db_txn_struct_i(txn_anc)->tokutxn); TXNID txn_anc_id = toku_txn_get_txnid(db_txn_struct_i(txn_anc)->tokutxn);
toku_lock_request lock_request; toku_lock_request lock_request;
toku_lock_request_init(&lock_request, db, txn_anc_id, left_key, right_key, lock_type); toku_lock_request_init(&lock_request, txn_anc_id, left_key, right_key, lock_type);
r = toku_lt_acquire_lock_request_with_default_timeout(db->i->lt, &lock_request); r = toku_lt_acquire_lock_request_with_default_timeout(db->i->lt, &lock_request);
toku_lock_request_destroy(&lock_request); toku_lock_request_destroy(&lock_request);
} }
...@@ -78,7 +78,7 @@ start_range_lock(DB *db, DB_TXN *txn, const DBT *left_key, const DBT *right_key, ...@@ -78,7 +78,7 @@ start_range_lock(DB *db, DB_TXN *txn, const DBT *left_key, const DBT *right_key,
r = toku_txn_add_lt(txn_anc, db->i->lt); r = toku_txn_add_lt(txn_anc, db->i->lt);
if (r == 0) { if (r == 0) {
TXNID txn_anc_id = toku_txn_get_txnid(db_txn_struct_i(txn_anc)->tokutxn); TXNID txn_anc_id = toku_txn_get_txnid(db_txn_struct_i(txn_anc)->tokutxn);
toku_lock_request_set(lock_request, db, txn_anc_id, left_key, right_key, lock_type); toku_lock_request_set(lock_request, txn_anc_id, left_key, right_key, lock_type);
r = toku_lock_request_start(lock_request, db->i->lt, true); r = toku_lock_request_start(lock_request, db->i->lt, true);
} }
return r; return r;
...@@ -99,7 +99,7 @@ toku_grab_write_lock (DB *db, DBT *key, TOKUTXN tokutxn) { ...@@ -99,7 +99,7 @@ toku_grab_write_lock (DB *db, DBT *key, TOKUTXN tokutxn) {
int r = toku_txn_add_lt(txn_anc, db->i->lt); int r = toku_txn_add_lt(txn_anc, db->i->lt);
if (r == 0) { if (r == 0) {
TXNID txn_anc_id = toku_txn_get_txnid(db_txn_struct_i(txn_anc)->tokutxn); TXNID txn_anc_id = toku_txn_get_txnid(db_txn_struct_i(txn_anc)->tokutxn);
r = toku_lt_acquire_write_lock(db->i->lt, db, txn_anc_id, key); r = toku_lt_acquire_write_lock(db->i->lt, txn_anc_id, key);
} }
return r; return r;
} }
......
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