Skip to content

Commit e433b30

Browse files
committed
MB-41985: Set 'persistenceSeqno' when vbucket has rolled back
The persistence seqno after rollback was still left at the pre-rollback (future value). Change-Id: Ia9deebb6c0b6f099d793ed7968da9f82d560e630 Reviewed-on: http://review.couchbase.org/c/kv_engine/+/137943 Tested-by: Jim Walker <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent f682037 commit e433b30

File tree

5 files changed

+25
-16
lines changed

5 files changed

+25
-16
lines changed

engines/ep/src/kv_bucket.cc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2489,12 +2489,10 @@ TaskStatus KVBucket::rollback(Vbid vbid, uint64_t rollbackSeqno) {
24892489
*/) {
24902490
rollbackUnpersistedItems(*vb, result.highSeqno);
24912491
loadPreparedSyncWrites(wlh, *vb);
2492-
vb->postProcessRollback(result, prevHighSeqno);
2493-
2494-
// And update collections post rollback
2495-
vb->collectionsRolledBack(
2496-
*vbMap.getShardByVbId(vbid)->getROUnderlying());
2497-
2492+
vb->postProcessRollback(
2493+
result,
2494+
prevHighSeqno,
2495+
*vbMap.getShardByVbId(vbid)->getRWUnderlying());
24982496
engine.getDcpConnMap().closeStreamsDueToRollback(vbid);
24992497
return TaskStatus::Complete;
25002498
}

engines/ep/src/vbucket.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3052,14 +3052,19 @@ bool VBucket::removeItemFromMemory(const Item& item) {
30523052
}
30533053

30543054
void VBucket::postProcessRollback(const RollbackResult& rollbackResult,
3055-
uint64_t prevHighSeqno) {
3055+
uint64_t prevHighSeqno,
3056+
KVStore& kvstore) {
30563057
failovers->pruneEntries(rollbackResult.highSeqno);
30573058
checkpointManager->clear(*this, rollbackResult.highSeqno);
30583059
setPersistedSnapshot(
30593060
{rollbackResult.snapStartSeqno, rollbackResult.snapEndSeqno});
30603061
incrRollbackItemCount(prevHighSeqno - rollbackResult.highSeqno);
30613062
checkpointManager->setOpenCheckpointId(1);
30623063
setReceivingInitialDiskSnapshot(false);
3064+
setPersistenceSeqno(kvstore.getLastPersistedSeqno(getId()));
3065+
3066+
// And update collections post rollback
3067+
collectionsRolledBack(kvstore);
30633068
}
30643069

30653070
void VBucket::collectionsRolledBack(KVStore& kvstore) {
@@ -3174,7 +3179,7 @@ void VBucket::_addStats(VBucketStatsDetailLevel detail,
31743179
checkpointManager->getMaxVisibleSeqno(),
31753180
add_stat,
31763181
c);
3177-
3182+
addStat("persistence_seqno", getPersistenceSeqno(), add_stat, c);
31783183
hlc.addStats(statPrefix, add_stat, c);
31793184
}
31803185
// fallthrough

engines/ep/src/vbucket.h

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,16 +1488,11 @@ class VBucket : public std::enable_shared_from_this<VBucket> {
14881488
* snapshot end seqno of the last snapshot in the
14891489
* vBucket after the rollback
14901490
* @param prevHighSeqno high seqno before the rollback
1491-
*/
1492-
void postProcessRollback(const RollbackResult& rollbackResult,
1493-
uint64_t prevHighSeqno);
1494-
1495-
/**
1496-
* Update collections following a rollback
1497-
*
14981491
* @param kvstore A KVStore that is used for retrieving stored metadata
14991492
*/
1500-
void collectionsRolledBack(KVStore& kvstore);
1493+
void postProcessRollback(const RollbackResult& rollbackResult,
1494+
uint64_t prevHighSeqno,
1495+
KVStore& kvstore);
15011496

15021497
/**
15031498
* Debug - print a textual description of the VBucket to stderr.
@@ -2050,6 +2045,13 @@ class VBucket : public std::enable_shared_from_this<VBucket> {
20502045
UseActiveVBMemThreshold useActiveVBMemThrehsold =
20512046
UseActiveVBMemThreshold::No);
20522047

2048+
/**
2049+
* Update collections following a rollback
2050+
*
2051+
* @param kvstore A KVStore that is used for retrieving stored metadata
2052+
*/
2053+
void collectionsRolledBack(KVStore& kvstore);
2054+
20532055
void _addStats(VBucketStatsDetailLevel detail,
20542056
const AddStatFn& add_stat,
20552057
const void* c);

engines/ep/tests/ep_testsuite.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6875,6 +6875,7 @@ static enum test_result test_mb19687_fixed(EngineIface* h) {
68756875
"vb_0:ops_reject",
68766876
"vb_0:ops_update",
68776877
"vb_0:pending_writes",
6878+
"vb_0:persistence_seqno",
68786879
"vb_0:purge_seqno",
68796880
"vb_0:queue_age",
68806881
"vb_0:queue_drain",

engines/ep/tests/module_tests/evp_store_rollback_test.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,8 @@ class RollbackTest
540540
store->getVBucket(vbid)->getHighSeqno());
541541
}
542542
EXPECT_EQ(0, store->getVBucket(vbid)->ht.getNumSystemItems());
543+
EXPECT_EQ(store->getVBucket(vbid)->getHighSeqno(),
544+
store->getVBucket(vbid)->getPersistenceSeqno());
543545
}
544546

545547
void rollback_to_zero(int64_t rollbackSeqno) {
@@ -577,6 +579,7 @@ class RollbackTest
577579
.lock()
578580
.getPersistedHighSeqno(CollectionID::Default));
579581
EXPECT_EQ(0, store->getVBucket(vbid)->getNumItems());
582+
EXPECT_EQ(0, store->getVBucket(vbid)->getPersistenceSeqno());
580583
}
581584

582585
protected:

0 commit comments

Comments
 (0)