MB-24066/MB-22178: Set opencheckpointid to 1 after rollback 37/77837/3
authorDaniel Owen <owend@couchbase.com>
Mon, 8 May 2017 17:00:09 +0000 (18:00 +0100)
committerDave Rigby <daver@couchbase.com>
Mon, 8 May 2017 19:41:53 +0000 (19:41 +0000)
An opencheckpoint of 0 has the special meaning of being in a backfill
phase.

Therefore after performing a rollback we must ensure the
opencheckpointid is reset to 1.  This is the value used when the
vbucket is originally intialised.

Change-Id: I6b97faa7b502406961a4b48ad7affdbf6bc30512
Reviewed-on: http://review.couchbase.org/77837
Well-Formed: Build Bot <build@couchbase.com>
Reviewed-by: Dave Rigby <daver@couchbase.com>
Tested-by: Build Bot <build@couchbase.com>
src/ep.cc
tests/module_tests/evp_store_rollback_test.cc

index dcd2c78..96bfdff 100644 (file)
--- a/src/ep.cc
+++ b/src/ep.cc
@@ -4003,6 +4003,7 @@ EventuallyPersistentStore::rollback(uint16_t vbid,
                 vb->checkpointManager.clear(vb, result.highSeqno);
                 vb->setPersistedSnapshot(result.snapStartSeqno, result.snapEndSeqno);
                 vb->incrRollbackItemCount(prevHighSeqno - result.highSeqno);
+                vb->checkpointManager.setOpenCheckpointId(1);
                 return ENGINE_SUCCESS;
             }
         }
index b4d9ffc..da51919 100644 (file)
@@ -278,12 +278,9 @@ TEST_P(RollbackTest, RollbackToMiddleOfAnUnPersistedSnapshot) {
 #endif
 
 /*
- * The opencheckpointid of a bucket can be zero after a rollback.
- * From MB21784 if an opencheckpointid was zero it was assumed that the
- * vbucket was in backfilling state.  This caused the producer stream
- * request to be stuck waiting for backfilling to complete.
+ * The opencheckpointid of a bucket is one after a rollback.
  */
-TEST_P(RollbackTest, DISABLED_MB21784) {
+TEST_P(RollbackTest, MB21784) {
     // Make the vbucket a replica
     store->setVBucketState(vbid, vbucket_state_replica, false);
     // Perform a rollback
@@ -291,10 +288,10 @@ TEST_P(RollbackTest, DISABLED_MB21784) {
         << "rollback did not return ENGINE_SUCCESS";
 
     // Assert the checkpointmanager clear function (called during rollback)
-    // has set the opencheckpointid to zero
+    // has set the opencheckpointid to one
     auto vb = store->getVbMap().getBucket(vbid);
     auto& ckpt_mgr = vb->checkpointManager;
-    EXPECT_EQ(0, ckpt_mgr.getOpenCheckpointId()) << "opencheckpointId not zero";
+    EXPECT_EQ(1, ckpt_mgr.getOpenCheckpointId()) << "opencheckpointId not one";
 
     // Create a new Dcp producer, reserving its cookie.
     get_mock_server_api()->cookie->reserve(cookie);