Skip to content

Commit 6449d9f

Browse files
committed
Revert "MB-34017 [SR]: Include the prepared-seqno in Commit queued items"
Conflicts with 233945f. Reverting while it is re-worked. This reverts commit c7e524a. Change-Id: I8f1cdcc0ff4591fe86c083584438e5fb2c5814fa Reviewed-on: http://review.couchbase.org/109986 Reviewed-by: Dave Rigby <[email protected]> Tested-by: Dave Rigby <[email protected]>
1 parent c7e524a commit 6449d9f

File tree

4 files changed

+19
-63
lines changed

4 files changed

+19
-63
lines changed

engines/ep/src/item.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -515,10 +515,10 @@ class Item : public RCValue {
515515
std::atomic<int64_t> bySeqno;
516516

517517
// @todo: Try to avoid this, as it increases mem_usage of 8 bytes per Item.
518-
// This is added for Durability items Commit and Abort, for which need the
519-
// associated Prepare's seqno at persistence for writing the correct High
520-
// Completed Seqno (HCS) to disk. Note that the HCS is the seqno of the
521-
// last Committed or Aborted Prepare.
518+
// This is added for Durability items Commit and Abort, which both carry
519+
// 2 seqnos:
520+
// 1) the seqno of this (Commit/Abort) Item (encoded in bySeqno)
521+
// 2) the seqno of the Committed/Aborted Prepare
522522
cb::uint48_t prepareSeqno;
523523

524524
uint32_t queuedTime;

engines/ep/src/vbucket.cc

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -798,9 +798,6 @@ ENGINE_ERROR_CODE VBucket::commit(
798798
// it may have been set explicitly.
799799
queueItmCtx.genCas = GenerateCas::No;
800800

801-
queueItmCtx.durability =
802-
DurabilityItemCtx{res.pending->getBySeqno(), nullptr /*cookie*/};
803-
804801
auto notify = commitStoredValue(res, queueItmCtx, commitSeqno);
805802

806803
notifyNewSeqno(notify);
@@ -1148,26 +1145,17 @@ VBNotifyCtx VBucket::queueDirty(const HashTable::HashBucketLock& hbl,
11481145
setMaxCasAndTrackDrift(v.getCas());
11491146
}
11501147

1151-
// If we are queueing a SyncWrite StoredValue; extract the durability
1148+
// If we are queuing a SyncWrite StoredValue; extract the durability
11521149
// requirements to use to create the Item.
11531150
boost::optional<cb::durability::Requirements> durabilityReqs;
1154-
if (v.isPending()) {
1155-
Expects(ctx.durability.is_initialized());
1156-
durabilityReqs = boost::get<cb::durability::Requirements>(
1157-
ctx.durability->requirementsOrPreparedSeqno);
1151+
if (ctx.durability) {
1152+
durabilityReqs = ctx.durability->requirements;
11581153
}
1159-
11601154
queued_item qi(v.toItem(getId(),
11611155
StoredValue::HideLockedCas::No,
11621156
StoredValue::IncludeValue::Yes,
11631157
durabilityReqs));
11641158

1165-
if (qi->isCommitSyncWrite()) {
1166-
Expects(ctx.durability.is_initialized());
1167-
qi->setPrepareSeqno(boost::get<int64_t>(
1168-
ctx.durability->requirementsOrPreparedSeqno));
1169-
}
1170-
11711159
// MB-27457: Timestamp deletes only when they don't already have a timestamp
11721160
// assigned. This is here to ensure all deleted items have a timestamp which
11731161
// our tombstone purger can use to determine which tombstones to purge. A

engines/ep/src/vbucket.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@
2828
#include "vbucket_bgfetch_item.h"
2929
#include "vbucket_fwd.h"
3030

31-
#include "boost/variant.hpp"
32-
3331
#include <folly/Synchronized.h>
3432
#include <memcached/engine.h>
3533
#include <nlohmann/json.hpp>
@@ -80,13 +78,8 @@ struct VBNotifyCtx {
8078
* has Durability requirements.
8179
*/
8280
struct DurabilityItemCtx {
83-
/**
84-
* Stores:
85-
* - the Durability Requirements, if we queue a Prepare
86-
* - the prepared-seqno, if we queue a Commit
87-
*/
88-
boost::variant<cb::durability::Requirements, int64_t>
89-
requirementsOrPreparedSeqno;
81+
/// The durability requirements for this item.
82+
cb::durability::Requirements requirements;
9083
/**
9184
* The client cookie associated with the Durability operation. If non-null
9285
* then notifyIOComplete will be called on it when operation is committed.
@@ -1802,7 +1795,6 @@ class VBucket : public std::enable_shared_from_this<VBucket> {
18021795
*
18031796
* @param hbl The lock to the HashTable-bucket containing the StoredValue
18041797
* @param v The StoredValue of the Pending being aborted.
1805-
* @param prepareSeqno The seqno of the Prepare being aborted
18061798
* @param ctx The VBQueueItemCtx. Holds info needed to enqueue the item,
18071799
* look at the structure for details.
18081800
* @return the notification context used for notifying the Flusher and

engines/ep/tests/module_tests/vbucket_durability_test.cc

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ TEST_P(VBucketDurabilityTest, Active_Commit_MultipleReplicas) {
491491
CheckpointManagerTestIntrospector::public_getCheckpointList(
492492
*ckptMgr);
493493

494-
auto checkPending = [this, &key, &ckptList, preparedSeqno]() -> void {
494+
auto checkPending = [this, &key, &ckptList]() -> void {
495495
EXPECT_EQ(nullptr, ht->findForRead(key).storedValue);
496496
const auto sv = ht->findForWrite(key).storedValue;
497497
ASSERT_NE(nullptr, sv);
@@ -501,13 +501,11 @@ TEST_P(VBucketDurabilityTest, Active_Commit_MultipleReplicas) {
501501
for (const auto& qi : *ckptList.front()) {
502502
if (!qi->isCheckPointMetaItem()) {
503503
EXPECT_EQ(queue_op::pending_sync_write, qi->getOperation());
504-
EXPECT_EQ(preparedSeqno, qi->getBySeqno());
505-
EXPECT_EQ("value", qi->getValue()->to_s());
506504
}
507505
}
508506
};
509507

510-
auto checkCommitted = [this, &key, &ckptList, preparedSeqno]() -> void {
508+
auto checkCommitted = [this, &key, &ckptList]() -> void {
511509
const auto sv = ht->findForRead(key).storedValue;
512510
ASSERT_NE(nullptr, sv);
513511
EXPECT_NE(nullptr, ht->findForWrite(key).storedValue);
@@ -517,9 +515,6 @@ TEST_P(VBucketDurabilityTest, Active_Commit_MultipleReplicas) {
517515
for (const auto& qi : *ckptList.front()) {
518516
if (!qi->isCheckPointMetaItem()) {
519517
EXPECT_EQ(queue_op::commit_sync_write, qi->getOperation());
520-
EXPECT_GT(qi->getBySeqno() /*commitSeqno*/, preparedSeqno);
521-
EXPECT_EQ(preparedSeqno, qi->getPrepareSeqno());
522-
EXPECT_EQ("value", qi->getValue()->to_s());
523518
}
524519
}
525520
};
@@ -684,8 +679,7 @@ TEST_P(VBucketDurabilityTest, NonPendingKeyAtAbort) {
684679
* 3) the abort_sync_write is not added to the DurabilityMonitor
685680
*/
686681
TEST_P(VBucketDurabilityTest, Active_AbortSyncWrite) {
687-
const int64_t preparedSeqno = 1;
688-
storeSyncWrites({preparedSeqno});
682+
storeSyncWrites({1} /*seqno*/);
689683
ASSERT_EQ(1,
690684
VBucketTestIntrospector::public_getActiveDM(*vbucket)
691685
.getNumTracked());
@@ -701,9 +695,9 @@ TEST_P(VBucketDurabilityTest, Active_AbortSyncWrite) {
701695
// Visible at write
702696
auto storedItem = ht->findForWrite(key);
703697
ASSERT_TRUE(storedItem.storedValue);
698+
// item pending
704699
EXPECT_EQ(CommittedState::Pending,
705700
storedItem.storedValue->getCommitted());
706-
EXPECT_EQ(preparedSeqno, storedItem.storedValue->getBySeqno());
707701
}
708702

709703
const auto& ckptList =
@@ -725,7 +719,6 @@ TEST_P(VBucketDurabilityTest, Active_AbortSyncWrite) {
725719
it++;
726720
ASSERT_EQ(1, ckpt->getNumItems());
727721
EXPECT_EQ(queue_op::pending_sync_write, (*it)->getOperation());
728-
EXPECT_EQ(preparedSeqno, (*it)->getBySeqno());
729722
EXPECT_EQ("value", (*it)->getValue()->to_s());
730723

731724
// The Pending is tracked by the DurabilityMonitor
@@ -772,8 +765,6 @@ TEST_P(VBucketDurabilityTest, Active_AbortSyncWrite) {
772765
EXPECT_EQ(queue_op::abort_sync_write, (*it)->getOperation());
773766
EXPECT_TRUE((*it)->isDeleted());
774767
EXPECT_FALSE((*it)->getValue());
775-
EXPECT_GT((*it)->getBySeqno(), preparedSeqno);
776-
EXPECT_EQ(preparedSeqno, (*it)->getPrepareSeqno());
777768

778769
// The Aborted item is not added for tracking.
779770
// Note: The Pending has not been removed as we are testing at VBucket
@@ -1035,9 +1026,8 @@ void VBucketDurabilityTest::testHTSyncDeleteCommit() {
10351026
auto* writeView = ht->findForWrite(key).storedValue;
10361027
ASSERT_TRUE(writeView);
10371028
VBQueueItemCtx ctx;
1038-
ctx.durability = DurabilityItemCtx{
1039-
cb::durability::Requirements{cb::durability::Level::Majority, {}},
1040-
cookie};
1029+
ctx.durability =
1030+
DurabilityItemCtx{{cb::durability::Level::Majority, {}}, cookie};
10411031
ASSERT_EQ(MutationStatus::WasDirty,
10421032
public_processSoftDelete(key, ctx).first);
10431033

@@ -1472,28 +1462,14 @@ void VBucketDurabilityTest::testCompleteSWInPassiveDM(vbucket_state_t state,
14721462
const auto& ckptList =
14731463
CheckpointManagerTestIntrospector::public_getCheckpointList(
14741464
*ckptMgr);
1475-
// 1 checkpoint
14761465
ASSERT_EQ(1, ckptList.size());
1477-
// empty-item
1478-
const auto& ckpt = *ckptList.front();
1479-
auto it = ckpt.begin();
1480-
ASSERT_EQ(queue_op::empty, (*it)->getOperation());
1481-
// 1 metaitem (checkpoint-start)
1482-
it++;
1483-
ASSERT_EQ(1, ckpt.getNumMetaItems());
1484-
EXPECT_EQ(queue_op::checkpoint_start, (*it)->getOperation());
1485-
// 3 non-metaitem are Committed or Aborted
1486-
ASSERT_EQ(writes.size(), ckpt.getNumItems());
1466+
EXPECT_EQ(writes.size(), ckptList.front()->getNumItems());
14871467
const auto expectedOp =
14881468
(res == Resolution::Commit ? queue_op::commit_sync_write
14891469
: queue_op::abort_sync_write);
1490-
for (const auto& prepare : writes) {
1491-
it++;
1492-
EXPECT_EQ(expectedOp, (*it)->getOperation());
1493-
EXPECT_GT((*it)->getBySeqno() /*commitSeqno*/, prepare.seqno);
1494-
EXPECT_EQ(prepare.seqno, (*it)->getPrepareSeqno());
1495-
if (expectedOp == queue_op::commit_sync_write) {
1496-
EXPECT_EQ("value", (*it)->getValue()->to_s());
1470+
for (const auto& qi : *ckptList.front()) {
1471+
if (!qi->isCheckPointMetaItem()) {
1472+
EXPECT_EQ(expectedOp, qi->getOperation());
14971473
}
14981474
}
14991475

0 commit comments

Comments
 (0)