Skip to content

Commit fe65552

Browse files
BenHuddlestondaverigby
authored andcommitted
MB-35133: Cleanup old SyncWrite rollback code
Previously we attempted to rollback SyncWrites individually by setting the correct state in the HashTable and PDM post-rollback. With the new, simpler, approach to rollback where we re-use the warmup code to load prepares we can remove the code added to pass various state through to the PDM and the PDM rollback function. Change-Id: Ia605f04bbb5d32071a669564e58d4990809629ba Reviewed-on: http://review.couchbase.org/113028 Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent ee356e6 commit fe65552

File tree

7 files changed

+6
-91
lines changed

7 files changed

+6
-91
lines changed

engines/ep/src/couch-kvstore/couch-kvstore.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2869,9 +2869,7 @@ RollbackResult CouchKVStore::rollback(Vbid vbid,
28692869
return RollbackResult(true,
28702870
vb_state->highSeqno,
28712871
vb_state->lastSnapStart,
2872-
vb_state->lastSnapEnd,
2873-
vb_state->highCompletedSeqno,
2874-
vb_state->highPreparedSeqno);
2872+
vb_state->lastSnapEnd);
28752873
}
28762874

28772875
int populateAllKeys(Db *db, DocInfo *docinfo, void *ctx) {

engines/ep/src/durability/passive_durability_monitor.cc

Lines changed: 0 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -360,62 +360,6 @@ void PassiveDurabilityMonitor::completeSyncWrite(
360360
folly::assume_unreachable();
361361
}
362362

363-
void PassiveDurabilityMonitor::postProcessRollback(
364-
const RollbackResult& rollbackResult) {
365-
// Sanity check that new HCS <= new HPS <= new high seqno
366-
Expects(rollbackResult.highCompletedSeqno <=
367-
rollbackResult.highPreparedSeqno);
368-
Expects(rollbackResult.highPreparedSeqno <= rollbackResult.highSeqno);
369-
370-
auto s = state.wlock();
371-
372-
// If we rolled back any commits or aborts then we will have put the
373-
// original prepare into the rollbackResult.preparesToAdd container. This
374-
// container should be in seqno order. To maintain the seqno ordering of the
375-
// trackedWrites container, we need to iterate on
376-
// rollbackResult.preparesToAdd in reverse order and push the items to the
377-
// front of trackedWrites.
378-
std::chrono::milliseconds dummy{};
379-
for (const auto& item :
380-
boost::adaptors::reverse(rollbackResult.preparesToAdd)) {
381-
if (static_cast<uint64_t>(item->getBySeqno()) >
382-
rollbackResult.highCompletedSeqno) {
383-
// Need to specify defaultTimeout for SyncWrite ctor, but we don't
384-
// care about the values on replica and have read from disk so give
385-
// it a dummy timeout.
386-
s->trackedWrites.emplace_front(nullptr /*cookie*/,
387-
std::move(item),
388-
dummy,
389-
nullptr /*firstChain*/,
390-
nullptr /*secondChain*/);
391-
}
392-
}
393-
394-
// Remove everything with seqno > rollback point from trackedWrites
395-
auto itr =
396-
std::find_if(s->trackedWrites.begin(),
397-
s->trackedWrites.end(),
398-
[&rollbackResult](const auto& write) {
399-
return static_cast<uint64_t>(write.getBySeqno()) >
400-
rollbackResult.highSeqno;
401-
});
402-
s->trackedWrites.erase(itr, s->trackedWrites.end());
403-
404-
// Post-rollback we should not have any prepares in the PDM that have not
405-
// been completed.
406-
s->highCompletedSeqno.it = s->trackedWrites.end();
407-
s->highCompletedSeqno.lastWriteSeqno.reset(
408-
rollbackResult.highCompletedSeqno);
409-
410-
// The highPreparedSeqno should always point at the last item in
411-
// trackedWrites. Every in-flight prepare should be satisfied locally as it
412-
// will be on disk.
413-
if (!s->trackedWrites.empty()) {
414-
s->highPreparedSeqno.it = --s->trackedWrites.end();
415-
}
416-
s->highPreparedSeqno.lastWriteSeqno.reset(rollbackResult.highPreparedSeqno);
417-
}
418-
419363
int64_t PassiveDurabilityMonitor::getHighestTrackedSeqno() const {
420364
auto s = state.rlock();
421365
if (!s->trackedWrites.empty()) {

engines/ep/src/durability/passive_durability_monitor.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,14 +148,6 @@ class PassiveDurabilityMonitor : public DurabilityMonitor {
148148
*/
149149
void notifyLocalPersistence() override;
150150

151-
/**
152-
* Remove all in-flight prepares after the new high seqno and add any new
153-
* prepares for completions that we may be rolling back.
154-
*
155-
* @param rollbackResult the information required to rollback
156-
*/
157-
void postProcessRollback(const RollbackResult& rollbackResult);
158-
159151
/**
160152
* Get the highest seqno for which there is a SyncWrite in trackedWrites.
161153
* Returns 0 if trackedWrites is empty.

engines/ep/src/magma-kvstore/magma-kvstore.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2084,7 +2084,5 @@ RollbackResult MagmaKVStore::rollback(Vbid vbid,
20842084
return RollbackResult(true,
20852085
vbstate->highSeqno,
20862086
vbstate->lastSnapStart,
2087-
vbstate->lastSnapEnd,
2088-
vbstate->highCompletedSeqno,
2089-
vbstate->highPreparedSeqno);
2087+
vbstate->lastSnapEnd);
20902088
}

engines/ep/src/rollback_result.cc

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,16 @@
1919
#include <gsl.h>
2020

2121
RollbackResult::RollbackResult(bool success)
22-
: success(success),
23-
highSeqno(0),
24-
snapStartSeqno(0),
25-
snapEndSeqno(0),
26-
highCompletedSeqno(0),
27-
highPreparedSeqno(0) {
22+
: success(success), highSeqno(0), snapStartSeqno(0), snapEndSeqno(0) {
2823
Expects(!success);
2924
}
3025

3126
RollbackResult::RollbackResult(bool success,
3227
uint64_t highSeqno,
3328
uint64_t snapStartSeqno,
34-
uint64_t snapEndSeqno,
35-
uint64_t highCompletedSeqno,
36-
uint64_t highPreparedSeqno)
29+
uint64_t snapEndSeqno)
3730
: success(success),
3831
highSeqno(highSeqno),
3932
snapStartSeqno(snapStartSeqno),
40-
snapEndSeqno(snapEndSeqno),
41-
highCompletedSeqno(highCompletedSeqno),
42-
highPreparedSeqno(highPreparedSeqno) {
33+
snapEndSeqno(snapEndSeqno) {
4334
}

engines/ep/src/rollback_result.h

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,10 @@ class RollbackResult {
3939
RollbackResult(bool success,
4040
uint64_t highSeqno,
4141
uint64_t snapStartSeqno,
42-
uint64_t snapEndSeqno,
43-
uint64_t highCompletedSeqno,
44-
uint64_t highPreparedSeqno);
42+
uint64_t snapEndSeqno);
4543

4644
bool success;
4745
uint64_t highSeqno;
4846
uint64_t snapStartSeqno;
4947
uint64_t snapEndSeqno;
50-
uint64_t highCompletedSeqno;
51-
uint64_t highPreparedSeqno;
52-
53-
// Container of prepares that need to be added back to the Passive DM
54-
std::vector<queued_item> preparesToAdd;
5548
};

engines/ep/src/vbucket.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2858,7 +2858,6 @@ void VBucket::postProcessRollback(const RollbackResult& rollbackResult,
28582858
incrRollbackItemCount(prevHighSeqno - rollbackResult.highSeqno);
28592859
checkpointManager->setOpenCheckpointId(1);
28602860
setReceivingInitialDiskSnapshot(false);
2861-
getPassiveDM().postProcessRollback(rollbackResult);
28622861
}
28632862

28642863
void VBucket::collectionsRolledBack(KVStore& kvstore) {

0 commit comments

Comments
 (0)