fix broken merge logic. it was sometimes dropping live tuples, and never dropping tombstones...
git-svn-id: svn+ssh://svn.corp.yahoo.com/yahoo/yrl/labs/pnuts/code/logstore@2449 8dad8b1f-cf64-0410-95b6-bcf113ffbcfe
This commit is contained in:
parent
4f74dfd45f
commit
5343f3021e
1 changed files with 18 additions and 13 deletions
13
merger.cpp
13
merger.cpp
|
@ -391,9 +391,11 @@ void merge_iterators(int xid,
|
||||||
while(t1 != 0 && datatuple::compare(t1->key(), t1->keylen(), t2->key(), t2->keylen()) < 0) // t1 is less than t2
|
while(t1 != 0 && datatuple::compare(t1->key(), t1->keylen(), t2->key(), t2->keylen()) < 0) // t1 is less than t2
|
||||||
{
|
{
|
||||||
//insert t1
|
//insert t1
|
||||||
|
if((!t1->isDelete()) || !dropDeletes) {
|
||||||
scratch_tree->insertTuple(xid, t1);
|
scratch_tree->insertTuple(xid, t1);
|
||||||
i+=t1->byte_length();
|
i+=t1->byte_length();
|
||||||
ltable->merge_mgr->wrote_tuple(stats->merge_level, t1);
|
ltable->merge_mgr->wrote_tuple(stats->merge_level, t1);
|
||||||
|
}
|
||||||
datatuple::freetuple(t1);
|
datatuple::freetuple(t1);
|
||||||
|
|
||||||
//advance itrA
|
//advance itrA
|
||||||
|
@ -409,12 +411,12 @@ void merge_iterators(int xid,
|
||||||
stats->merged_tuples(mtuple, t2, t1); // this looks backwards, but is right.
|
stats->merged_tuples(mtuple, t2, t1); // this looks backwards, but is right.
|
||||||
|
|
||||||
//insert merged tuple, drop deletes
|
//insert merged tuple, drop deletes
|
||||||
if(dropDeletes && !mtuple->isDelete()) {
|
if((!mtuple->isDelete()) || !dropDeletes) {
|
||||||
scratch_tree->insertTuple(xid, mtuple);
|
scratch_tree->insertTuple(xid, mtuple);
|
||||||
i+=mtuple->byte_length();
|
i+=mtuple->byte_length();
|
||||||
|
ltable->merge_mgr->wrote_tuple(stats->merge_level, mtuple);
|
||||||
}
|
}
|
||||||
datatuple::freetuple(t1);
|
datatuple::freetuple(t1);
|
||||||
ltable->merge_mgr->wrote_tuple(stats->merge_level, mtuple);
|
|
||||||
t1 = itrA->next_callerFrees(); //advance itrA
|
t1 = itrA->next_callerFrees(); //advance itrA
|
||||||
ltable->merge_mgr->read_tuple_from_large_component(stats->merge_level, t1);
|
ltable->merge_mgr->read_tuple_from_large_component(stats->merge_level, t1);
|
||||||
datatuple::freetuple(mtuple);
|
datatuple::freetuple(mtuple);
|
||||||
|
@ -423,10 +425,11 @@ void merge_iterators(int xid,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//insert t2
|
//insert t2
|
||||||
|
if((!t2->isDelete()) || !dropDeletes) {
|
||||||
scratch_tree->insertTuple(xid, t2);
|
scratch_tree->insertTuple(xid, t2);
|
||||||
i+=t2->byte_length();
|
i+=t2->byte_length();
|
||||||
|
|
||||||
ltable->merge_mgr->wrote_tuple(stats->merge_level, t2);
|
ltable->merge_mgr->wrote_tuple(stats->merge_level, t2);
|
||||||
|
}
|
||||||
periodically_force(xid, &i, forceMe, log);
|
periodically_force(xid, &i, forceMe, log);
|
||||||
// cannot free any tuples here; they may still be read through a lookup
|
// cannot free any tuples here; they may still be read through a lookup
|
||||||
}
|
}
|
||||||
|
@ -444,10 +447,12 @@ void merge_iterators(int xid,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while(t1 != 0) {// t1 is less than t2
|
while(t1 != 0) {// t2 is empty, but t1 still has stuff in it.
|
||||||
|
if((!t1->isDelete()) || !dropDeletes) {
|
||||||
scratch_tree->insertTuple(xid, t1);
|
scratch_tree->insertTuple(xid, t1);
|
||||||
ltable->merge_mgr->wrote_tuple(stats->merge_level, t1);
|
ltable->merge_mgr->wrote_tuple(stats->merge_level, t1);
|
||||||
i += t1->byte_length();
|
i += t1->byte_length();
|
||||||
|
}
|
||||||
datatuple::freetuple(t1);
|
datatuple::freetuple(t1);
|
||||||
|
|
||||||
//advance itrA
|
//advance itrA
|
||||||
|
|
Loading…
Reference in a new issue