Commit e91c4512 authored by John Esmet's avatar John Esmet Committed by Yoni Fogel

fixes #5762 oldest_referenced_xid and oldest_referenced_xid_known now share a...

fixes #5762 oldest_referenced_xid and oldest_referenced_xid_known now share a prefix, which makes searching for them together a little easier


git-svn-id: file:///svn/toku/tokudb@51667 c7de825b-a66e-492c-adef-691d508d4ae1
parent e70486ad
......@@ -730,7 +730,7 @@ static void ftnode_finalize_split(FTNODE node, FTNODE B, MSN max_msn_applied_to_
B->max_msn_applied_to_node_on_disk = max_msn_applied_to_node;
// The new node in the split inherits the oldest known reference xid
B->oldest_known_referenced_xid = node->oldest_known_referenced_xid;
B->oldest_referenced_xid_known = node->oldest_known_referenced_xid;
node->dirty = 1;
B->dirty = 1;
......@@ -1107,7 +1107,7 @@ flush_this_child(
// now we have a bnc to flush to the child. pass down the parent's
// oldest known referenced xid as we flush down to the child.
toku_bnc_flush_to_child(h, bnc, child, node->oldest_known_referenced_xid);
toku_bnc_flush_to_child(h, bnc, child, node->oldest_referenced_xid_known);
destroy_nonleaf_childinfo(bnc);
}
......@@ -1528,7 +1528,7 @@ static void ft_flush_some_child(
NONLEAF_CHILDINFO bnc = NULL;
paranoid_invariant(parent->height>0);
toku_assert_entire_node_in_memory(parent);
TXNID oldest_referenced_xid = parent->oldest_known_referenced_xid;
TXNID oldest_referenced_xid = parent->oldest_referenced_xid_known;
// pick the child we want to flush to
int childnum = fa->pick_child(ft, parent, fa->extra);
......@@ -1917,7 +1917,7 @@ place_node_and_bnc_on_background_thread(
//
void toku_ft_flush_node_on_background_thread(FT h, FTNODE parent)
{
TXNID oldest_known_referenced_xid = parent->oldest_known_referenced_xid;
TXNID oldest_referenced_xid_known = parent->oldest_known_referenced_xid;
//
// first let's see if we can detach buffer on client thread
// and pick the child we want to flush to
......@@ -1934,7 +1934,7 @@ void toku_ft_flush_node_on_background_thread(FT h, FTNODE parent)
// In this case, we could not lock the child, so just place the parent on the background thread
// In the callback, we will use toku_ft_flush_some_child, which checks to
// see if we should blow away the old basement nodes.
place_node_and_bnc_on_background_thread(h, parent, NULL, oldest_known_referenced_xid);
place_node_and_bnc_on_background_thread(h, parent, NULL, oldest_referenced_xid_known);
}
else {
//
......@@ -1963,7 +1963,7 @@ void toku_ft_flush_node_on_background_thread(FT h, FTNODE parent)
// so, because we know for sure the child is not
// reactive, we can unpin the parent
//
place_node_and_bnc_on_background_thread(h, child, bnc, oldest_known_referenced_xid);
place_node_and_bnc_on_background_thread(h, child, bnc, oldest_referenced_xid_known);
toku_unpin_ftnode(h, parent);
}
else {
......@@ -1973,7 +1973,7 @@ void toku_ft_flush_node_on_background_thread(FT h, FTNODE parent)
toku_unpin_ftnode(h, child);
// Again, we'll have the parent on the background thread, so
// we don't need to destroy the basement nodes yet.
place_node_and_bnc_on_background_thread(h, parent, NULL, oldest_known_referenced_xid);
place_node_and_bnc_on_background_thread(h, parent, NULL, oldest_referenced_xid_known);
}
}
}
......
......@@ -258,7 +258,7 @@ struct ftnode {
// A better heuristic would be the oldest live txnid, but we use this since it
// still works well most of the time, and its readily available on the inject
// code path.
TXNID oldest_known_referenced_xid;
TXNID oldest_referenced_xid_known;
// array of size n_children, consisting of ftnode partitions
// each one is associated with a child
......
This diff is collapsed.
......@@ -365,7 +365,7 @@ serialize_ftnode_info_size(FTNODE node)
retval += 4; // nodesize
retval += 4; // flags
retval += 4; // height;
retval += 8; // oldest_known_referenced_xid
retval += 8; // oldest_referenced_xid_known
retval += node->totalchildkeylens; // total length of pivots
retval += (node->n_children-1)*4; // encode length of each pivot
if (node->height > 0) {
......@@ -389,7 +389,7 @@ static void serialize_ftnode_info(FTNODE node,
wbuf_nocrc_uint(&wb, 0); // write a dummy value for where node->nodesize used to be
wbuf_nocrc_uint(&wb, node->flags);
wbuf_nocrc_int (&wb, node->height);
wbuf_TXNID(&wb, node->oldest_known_referenced_xid);
wbuf_TXNID(&wb, node->oldest_referenced_xid_known);
// pivot information
for (int i = 0; i < node->n_children-1; i++) {
......@@ -1259,7 +1259,7 @@ deserialize_ftnode_info(
(void) rbuf_int(&rb); // optimized_for_upgrade
}
if (node->layout_version_read_from_disk >= FT_LAYOUT_VERSION_22) {
rbuf_TXNID(&rb, &node->oldest_known_referenced_xid);
rbuf_TXNID(&rb, &node->oldest_referenced_xid_known);
}
// now create the basement nodes or childinfos, depending on whether this is a
......@@ -1509,7 +1509,7 @@ static FTNODE alloc_ftnode_for_deserialize(uint32_t fullhash, BLOCKNUM blocknum)
node->thisnodename = blocknum;
node->dirty = 0;
node->bp = nullptr;
node->oldest_known_referenced_xid = TXNID_NONE;
node->oldest_referenced_xid_known = TXNID_NONE;
return node;
}
......
......@@ -178,7 +178,7 @@ void toku_le_apply_msg(FT_MSG msg,
void **maybe_free,
int64_t * numbytes_delta_p);
bool toku_le_worth_running_garbage_collection(LEAFENTRY le, TXNID oldest_known_referenced_xid);
bool toku_le_worth_running_garbage_collection(LEAFENTRY le, TXNID oldest_referenced_xid_known);
void toku_le_garbage_collect(LEAFENTRY old_leaf_entry,
LEAFENTRY *new_leaf_entry,
......@@ -189,7 +189,7 @@ void toku_le_garbage_collect(LEAFENTRY old_leaf_entry,
const xid_omt_t &snapshot_xids,
const rx_omt_t &referenced_xids,
const xid_omt_t &live_root_txns,
TXNID oldest_known_referenced_xid,
TXNID oldest_referenced_xid_known,
int64_t * numbytes_delta_p);
#endif /* TOKU_LEAFENTRY_H */
......
......@@ -293,7 +293,7 @@ test_prefetching(void) {
sn.height = 1;
sn.n_children = 3;
sn.dirty = 1;
sn.oldest_known_referenced_xid = TXNID_NONE;
sn.oldest_referenced_xid_known = TXNID_NONE;
uint64_t key1 = 100;
uint64_t key2 = 200;
......
......@@ -246,7 +246,7 @@ test_serialize_nonleaf(void) {
sn.height = 1;
sn.n_children = 2;
sn.dirty = 1;
sn.oldest_known_referenced_xid = TXNID_NONE;
sn.oldest_referenced_xid_known = TXNID_NONE;
hello_string = toku_strdup("hello");
MALLOC_N(2, sn.bp);
MALLOC_N(1, sn.childkeys);
......@@ -345,7 +345,7 @@ test_serialize_leaf(void) {
sn.height = 0;
sn.n_children = 2;
sn.dirty = 1;
sn.oldest_known_referenced_xid = TXNID_NONE;
sn.oldest_referenced_xid_known = TXNID_NONE;
LEAFENTRY elts[3];
elts[0] = le_malloc("a", "aval");
elts[1] = le_malloc("b", "bval");
......
......@@ -74,7 +74,7 @@ test_serialize_leaf(int valsize, int nelts, double entropy) {
sn->height = 0;
sn->n_children = 8;
sn->dirty = 1;
sn->oldest_known_referenced_xid = TXNID_NONE;
sn->oldest_referenced_xid_known = TXNID_NONE;
MALLOC_N(sn->n_children, sn->bp);
MALLOC_N(sn->n_children-1, sn->childkeys);
sn->totalchildkeylens = 0;
......@@ -197,7 +197,7 @@ test_serialize_nonleaf(int valsize, int nelts, double entropy) {
sn.height = 1;
sn.n_children = 8;
sn.dirty = 1;
sn.oldest_known_referenced_xid = TXNID_NONE;
sn.oldest_referenced_xid_known = TXNID_NONE;
MALLOC_N(sn.n_children, sn.bp);
MALLOC_N(sn.n_children-1, sn.childkeys);
sn.totalchildkeylens = 0;
......
......@@ -223,7 +223,7 @@ test_serialize_leaf_check_msn(enum ftnode_verify_type bft, bool do_clone) {
sn.height = 0;
sn.n_children = 2;
sn.dirty = 1;
sn.oldest_known_referenced_xid = TXNID_NONE;
sn.oldest_referenced_xid_known = TXNID_NONE;
MALLOC_N(sn.n_children, sn.bp);
MALLOC_N(1, sn.childkeys);
toku_fill_dbt(&sn.childkeys[0], toku_xmemdup("b", 2), 2);
......@@ -369,7 +369,7 @@ test_serialize_leaf_with_large_pivots(enum ftnode_verify_type bft, bool do_clone
sn.height = 0;
sn.n_children = nrows;
sn.dirty = 1;
sn.oldest_known_referenced_xid = TXNID_NONE;
sn.oldest_referenced_xid_known = TXNID_NONE;
MALLOC_N(sn.n_children, sn.bp);
MALLOC_N(sn.n_children-1, sn.childkeys);
......@@ -515,7 +515,7 @@ test_serialize_leaf_with_many_rows(enum ftnode_verify_type bft, bool do_clone) {
sn.height = 0;
sn.n_children = 1;
sn.dirty = 1;
sn.oldest_known_referenced_xid = TXNID_NONE;
sn.oldest_referenced_xid_known = TXNID_NONE;
MALLOC_N(sn.n_children, sn.bp);
MALLOC_N(sn.n_children-1, sn.childkeys);
......@@ -659,7 +659,7 @@ test_serialize_leaf_with_large_rows(enum ftnode_verify_type bft, bool do_clone)
sn.height = 0;
sn.n_children = 1;
sn.dirty = 1;
sn.oldest_known_referenced_xid = TXNID_NONE;
sn.oldest_referenced_xid_known = TXNID_NONE;
MALLOC_N(sn.n_children, sn.bp);
MALLOC_N(sn.n_children-1, sn.childkeys);
......@@ -810,7 +810,7 @@ test_serialize_leaf_with_empty_basement_nodes(enum ftnode_verify_type bft, bool
sn.height = 0;
sn.n_children = 7;
sn.dirty = 1;
sn.oldest_known_referenced_xid = TXNID_NONE;
sn.oldest_referenced_xid_known = TXNID_NONE;
MALLOC_N(sn.n_children, sn.bp);
MALLOC_N(sn.n_children-1, sn.childkeys);
toku_fill_dbt(&sn.childkeys[0], toku_xmemdup("A", 2), 2);
......@@ -962,7 +962,7 @@ test_serialize_leaf_with_multiple_empty_basement_nodes(enum ftnode_verify_type b
sn.height = 0;
sn.n_children = 4;
sn.dirty = 1;
sn.oldest_known_referenced_xid = TXNID_NONE;
sn.oldest_referenced_xid_known = TXNID_NONE;
MALLOC_N(sn.n_children, sn.bp);
MALLOC_N(sn.n_children-1, sn.childkeys);
toku_fill_dbt(&sn.childkeys[0], toku_xmemdup("A", 2), 2);
......@@ -1083,7 +1083,7 @@ test_serialize_leaf(enum ftnode_verify_type bft, bool do_clone) {
sn.height = 0;
sn.n_children = 2;
sn.dirty = 1;
sn.oldest_known_referenced_xid = TXNID_NONE;
sn.oldest_referenced_xid_known = TXNID_NONE;
MALLOC_N(sn.n_children, sn.bp);
MALLOC_N(1, sn.childkeys);
toku_fill_dbt(&sn.childkeys[0], toku_xmemdup("b", 2), 2);
......@@ -1226,7 +1226,7 @@ test_serialize_nonleaf(enum ftnode_verify_type bft, bool do_clone) {
sn.height = 1;
sn.n_children = 2;
sn.dirty = 1;
sn.oldest_known_referenced_xid = TXNID_NONE;
sn.oldest_referenced_xid_known = TXNID_NONE;
hello_string = toku_strdup("hello");
MALLOC_N(2, sn.bp);
MALLOC_N(1, sn.childkeys);
......
......@@ -702,12 +702,12 @@ test_le_apply_messages(void) {
test_le_committed_apply();
}
static bool ule_worth_running_garbage_collection(ULE ule, TXNID oldest_known_referenced_xid) {
static bool ule_worth_running_garbage_collection(ULE ule, TXNID oldest_referenced_xid_known) {
LEAFENTRY le;
size_t initial_memsize;
int r = le_pack(ule, &initial_memsize, &le, nullptr, nullptr, nullptr); CKERR(r);
invariant_notnull(le);
bool worth_running = toku_le_worth_running_garbage_collection(le, oldest_known_referenced_xid);
bool worth_running = toku_le_worth_running_garbage_collection(le, oldest_referenced_xid_known);
toku_free(le);
return worth_running;
}
......
......@@ -97,7 +97,7 @@ static void test_oldest_referenced_xid_gets_propogated(void) {
assert(node->height == 1);
assert(node->n_children == 1);
assert(BP_BLOCKNUM(node, 0).b == grandchild_leaf_blocknum.b);
assert(node->oldest_known_referenced_xid == TXNID_NONE);
assert(node->oldest_referenced_xid_known == TXNID_NONE);
toku_unpin_ftnode(t->ft, node);
// now verify the root - keep it pinned so we can flush it below
......@@ -115,11 +115,11 @@ static void test_oldest_referenced_xid_gets_propogated(void) {
assert(node->n_children == 1);
assert(BP_BLOCKNUM(node, 0).b == child_nonleaf_blocknum.b);
assert(toku_bnc_nbytesinbuf(BNC(node, 0)) > 0);
assert(node->oldest_known_referenced_xid == TXNID_NONE);
assert(node->oldest_referenced_xid_known == TXNID_NONE);
// set the root's oldest referenced xid to something special
const TXNID flush_xid = 25000;
node->oldest_known_referenced_xid = flush_xid;
node->oldest_referenced_xid_known = flush_xid;
// do the flush
struct flusher_advice fa;
......@@ -147,7 +147,7 @@ static void test_oldest_referenced_xid_gets_propogated(void) {
NULL,
&node
);
assert(node->oldest_known_referenced_xid == flush_xid);
assert(node->oldest_referenced_xid_known == flush_xid);
toku_unpin_ftnode(t->ft, node);
r = toku_close_ft_handle_nolsn(t, 0); assert(r==0);
......
......@@ -91,7 +91,7 @@ setup_ftnode_header(struct ftnode *node)
node->height = 0;
node->dirty = 1;
node->totalchildkeylens = 0;
node->oldest_known_referenced_xid = TXNID_NONE;
node->oldest_referenced_xid_known = TXNID_NONE;
}
static void
......
......@@ -393,7 +393,7 @@ toku_le_apply_msg(FT_MSG msg, // message to apply to leafentry
ule_cleanup(&ule);
}
bool toku_le_worth_running_garbage_collection(LEAFENTRY le, TXNID oldest_known_referenced_xid) {
bool toku_le_worth_running_garbage_collection(LEAFENTRY le, TXNID oldest_referenced_xid_known) {
// Effect: Quickly determines if it's worth trying to run garbage collection on a leafentry
// Return: True if it makes sense to try garbage collection, false otherwise.
// Rationale: Garbage collection is likely to clean up under two circumstances:
......@@ -409,7 +409,7 @@ bool toku_le_worth_running_garbage_collection(LEAFENTRY le, TXNID oldest_known_r
} else {
paranoid_invariant(le->u.mvcc.num_cxrs == 1);
}
return le->u.mvcc.num_pxrs > 0 && le_outermost_uncommitted_xid(le) < oldest_known_referenced_xid;
return le->u.mvcc.num_pxrs > 0 && le_outermost_uncommitted_xid(le) < oldest_referenced_xid_known;
}
// Garbage collect one leaf entry, using the given OMT's.
......@@ -440,7 +440,7 @@ toku_le_garbage_collect(LEAFENTRY old_leaf_entry,
const xid_omt_t &snapshot_xids,
const rx_omt_t &referenced_xids,
const xid_omt_t &live_root_txns,
TXNID oldest_known_referenced_xid,
TXNID oldest_referenced_xid_known,
int64_t * numbytes_delta_p) {
ULE_S ule;
int64_t oldnumbytes = 0;
......@@ -455,7 +455,7 @@ toku_le_garbage_collect(LEAFENTRY old_leaf_entry,
// The oldest known refeferenced xid is a lower bound on the oldest possible
// live xid, so we use that. It's usually close enough to get rid of most
// garbage in leafentries.
TXNID oldest_possible_live_xid = oldest_known_referenced_xid;
TXNID oldest_possible_live_xid = oldest_referenced_xid_known;
ule_try_promote_provisional_outermost(&ule, oldest_possible_live_xid);
ule_garbage_collect(&ule, snapshot_xids, referenced_xids, live_root_txns);
......
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