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

[t:4923], use brtnode_put_cmd in push_something_at_root. In Maxwell we changed...

[t:4923], use brtnode_put_cmd in push_something_at_root. In Maxwell we changed it because we applied messages to in-memory leaves. Now, we have indexed buffers, so we can consolidate some code. I am not too happy with how max_msn_applied_on_disk is handled, but I will deal with that in another checkin

git-svn-id: file:///svn/toku/tokudb@37957 c7de825b-a66e-492c-adef-691d508d4ae1
parent c0c53722
...@@ -2060,16 +2060,13 @@ brtnode_put_cmd ( ...@@ -2060,16 +2060,13 @@ brtnode_put_cmd (
) )
// Effect: Push CMD into the subtree rooted at NODE. // Effect: Push CMD into the subtree rooted at NODE.
// If NODE is a leaf, then // If NODE is a leaf, then
// put CMD into leaf, applying it to the leafentries // put CMD into leaf, applying it to the leafentries
// If NODE is a nonleaf, then push the cmd into the FIFO(s) of the relevent child(ren). // If NODE is a nonleaf, then push the cmd into the FIFO(s) of the relevent child(ren).
// The node may become overfull. That's not our problem. // The node may become overfull. That's not our problem.
{ {
toku_assert_entire_node_in_memory(node); toku_assert_entire_node_in_memory(node);
if (node->height==0) { if (node->height==0) {
// we need to make sure that after doing all the put_cmd operations bool made_change = false;
// that the tree above is completely flushed out,
// otherwise may have an inconsistency (part of the data is there, and part isn't)
bool made_change = false;
uint64_t workdone = 0; uint64_t workdone = 0;
toku_apply_cmd_to_leaf( toku_apply_cmd_to_leaf(
compare_fun, compare_fun,
...@@ -2083,7 +2080,7 @@ brtnode_put_cmd ( ...@@ -2083,7 +2080,7 @@ brtnode_put_cmd (
live_list_reverse live_list_reverse
); );
} else { } else {
brt_nonleaf_put_cmd(compare_fun, desc, node, cmd, is_fresh); brt_nonleaf_put_cmd(compare_fun, desc, node, cmd, is_fresh);
} }
} }
...@@ -2184,46 +2181,38 @@ static void push_something_at_root (BRT brt, BRTNODE *nodep, BRT_MSG cmd) ...@@ -2184,46 +2181,38 @@ static void push_something_at_root (BRT brt, BRTNODE *nodep, BRT_MSG cmd)
{ {
BRTNODE node = *nodep; BRTNODE node = *nodep;
toku_assert_entire_node_in_memory(node); toku_assert_entire_node_in_memory(node);
if (node->height==0) { TOKULOGGER logger = toku_cachefile_logger(brt->cf);
// Must special case height 0, since brtnode_put_cmd() doesn't modify leaves. OMT snapshot_txnids = logger ? logger->snapshot_txnids : NULL;
// Part of the problem is: if the node is in memory, then it was updated as part of the in-memory operation. OMT live_list_reverse = logger ? logger->live_list_reverse : NULL;
// If the root node is not in memory, then we must apply it. brtnode_put_cmd(
bool made_dirty = 0; brt->compare_fun,
uint64_t workdone_ignore = 0; // ignore workdone for root-leaf node brt->update_fun,
// not up to date, which means the get_and_pin actually fetched it &brt->h->descriptor,
// into memory. node,
TOKULOGGER logger = toku_cachefile_logger(brt->cf); cmd,
OMT snapshot_txnids = logger ? logger->snapshot_txnids : NULL; true,
OMT live_list_reverse = logger ? logger->live_list_reverse : NULL; snapshot_txnids,
// passing down snapshot_txnids and live_list_reverse directly live_list_reverse
// since we're holding the ydb lock. TODO: verify this is correct );
toku_apply_cmd_to_leaf( if (node->height == 0) {
brt->compare_fun,
brt->update_fun,
&brt->h->descriptor,
node,
cmd,
&made_dirty,
&workdone_ignore,
snapshot_txnids,
live_list_reverse
);
MSN cmd_msn = cmd->msn; MSN cmd_msn = cmd->msn;
invariant(cmd_msn.msn > node->max_msn_applied_to_node_on_disk.msn); invariant(cmd_msn.msn > node->max_msn_applied_to_node_on_disk.msn);
// max_msn_applied_to_node_on_disk is normally set only when leaf is serialized, // max_msn_applied_to_node_on_disk is normally set only when leaf is serialized,
// but needs to be done here (for root leaf) so msn can be set in new commands. // but needs to be done here (for root leaf) so msn can be set in new commands.
node->max_msn_applied_to_node_on_disk = cmd_msn; node->max_msn_applied_to_node_on_disk = cmd_msn;
toku_mark_node_dirty(node); toku_mark_node_dirty(node);
} else { }
uint64_t msgsize = brt_msg_size(cmd); else {
brt_status.msg_bytes_in += msgsize; uint64_t msgsize = brt_msg_size(cmd);
brt_status.msg_bytes_curr += msgsize; brt_status.msg_bytes_in += msgsize;
if (brt_status.msg_bytes_curr > brt_status.msg_bytes_max) brt_status.msg_bytes_curr += msgsize;
brt_status.msg_bytes_max = brt_status.msg_bytes_curr; if (brt_status.msg_bytes_curr > brt_status.msg_bytes_max) {
brt_status.msg_num++; brt_status.msg_bytes_max = brt_status.msg_bytes_curr;
if (brt_msg_applies_all(cmd)) }
brt_status.msg_num_broadcast++; brt_status.msg_num++;
brt_nonleaf_put_cmd(brt->compare_fun, &brt->h->descriptor, node, cmd, true); if (brt_msg_applies_all(cmd)) {
brt_status.msg_num_broadcast++;
}
} }
} }
......
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