Skip to content

Commit 63f4eee

Browse files
paolococchidaverigby
authored andcommitted
MB-38444: Remove HighestDedupSeqno/EarlySnapEndSeqno
They were used only for computing the range of a consistent snapshot at Backfill. Now we always set (EndSeqno = HighSeqno) at Backfill, which is a consistent range by definition. Change-Id: I962414a201fcc06d6d58122cfe6189cf98b95624 Reviewed-on: http://review.couchbase.org/c/kv_engine/+/144163 Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]> Reviewed-by: James Harrison <[email protected]> Well-Formed: Build Bot <[email protected]>
1 parent 802eba7 commit 63f4eee

File tree

8 files changed

+7
-148
lines changed

8 files changed

+7
-148
lines changed

engines/ep/src/ephemeral_vb.cc

Lines changed: 6 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,6 @@ void EphemeralVBucket::addStats(VBucketStatsDetailLevel detail,
193193
add_stat,
194194
c);
195195
addStat("seqlist_high_seqno", seqList->getHighSeqno(), add_stat, c);
196-
addStat("seqlist_highest_deduped_seqno",
197-
seqList->getHighestDedupedSeqno(),
198-
add_stat,
199-
c);
200196
addStat("seqlist_purged_count", seqListPurgeCount.load(), add_stat, c);
201197

202198
uint64_t rr_begin, rr_end;
@@ -395,17 +391,15 @@ EphemeralVBucket::updateStoredValue(const HashTable::HashBucketLock& hbl,
395391

396392
std::lock_guard<std::mutex> lh(sequenceLock);
397393

398-
const bool wasTemp = v.isTempItem();
399394
const bool oldValueDeleted = v.isDeleted();
400395
const bool recreatingDeletedItem = v.isDeleted() && !itm.isDeleted();
401396

402397
StoredValue::UniquePtr ownedSv;
403398

404399
{
405-
// Once we update the seqList, there is a short period where the
406-
// highSeqno and highestDedupedSeqno are both incorrect. We have to hold
407-
// this lock to prevent a new rangeRead starting, and covering an
408-
// inconsistent range.
400+
// Once we update the seqList, there is a short period where highSeqno
401+
// is incorrect. We have to hold this lock to prevent a new rangeRead
402+
// starting, and covering an inconsistent range.
409403
std::lock_guard<std::mutex> listWriteLg(seqList->getListWriteLock());
410404

411405
/* Update in the Ordered data structure (seqList) first and then update
@@ -451,12 +445,6 @@ EphemeralVBucket::updateStoredValue(const HashTable::HashBucketLock& hbl,
451445

452446
seqList->maybeUpdateMaxVisibleSeqno(lh, listWriteLg, osv);
453447

454-
/* Temp items are never added to the seqList, hence updating a temp
455-
item should not update the deduped seqno */
456-
if (!wasTemp) {
457-
seqList->updateHighestDedupedSeqno(listWriteLg, osv);
458-
}
459-
460448
if (res == SequenceList::UpdateStatus::Append) {
461449
/* Mark the un-updated storedValue as stale. This must be done after
462450
the new storedvalue for the item is visible for range read in the
@@ -555,10 +543,9 @@ EphemeralVBucket::softDeleteStoredValue(const HashTable::HashBucketLock& hbl,
555543

556544
VBNotifyCtx notifyCtx;
557545
{
558-
// Once we update the seqList, there is a short period where the
559-
// highSeqno and highestDedupedSeqno are both incorrect. We have to hold
560-
// this lock to prevent a new rangeRead starting, and covering an
561-
// inconsistent range.
546+
// Once we update the seqList, there is a short period where highSeqno
547+
// is incorrect. We have to hold this lock to prevent a new rangeRead
548+
// starting, and covering an inconsistent range.
562549
std::lock_guard<std::mutex> listWriteLg(seqList->getListWriteLock());
563550

564551
/* Update the in the Ordered data structure (seqList) first and then
@@ -618,12 +605,6 @@ EphemeralVBucket::softDeleteStoredValue(const HashTable::HashBucketLock& hbl,
618605

619606
seqList->maybeUpdateMaxVisibleSeqno(lh, listWriteLg, osv);
620607

621-
/* Temp items are never added to the seqList, hence updating a temp
622-
item should not update the deduped seqno */
623-
if (wasCommittedNonTemp) {
624-
seqList->updateHighestDedupedSeqno(listWriteLg, osv);
625-
}
626-
627608
if (res == SequenceList::UpdateStatus::Append) {
628609
/* Mark the un-updated storedValue as stale. This must be done after
629610
the new storedvalue for the item is visible for range read in the
@@ -782,11 +763,6 @@ VBNotifyCtx EphemeralVBucket::abortStoredValue(
782763
if (res == SequenceList::UpdateStatus::Append) {
783764
seqList->markItemStale(listWriteLg, std::move(oldSv), newSv);
784765
}
785-
786-
// We de-duped a prepare so we need to update the highest deduped seqno
787-
// to prevent a backfill range read from ending without reaching this
788-
// abort
789-
seqList->updateHighestDedupedSeqno(listWriteLg, osv);
790766
}
791767

792768
return notifyCtx;

engines/ep/src/linked_list.cc

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ BasicLinkedList::BasicLinkedList(Vbid vbucketId, EPStats& st)
2828
staleSize(0),
2929
staleMetaDataSize(0),
3030
highSeqno(0),
31-
highestDedupedSeqno(0),
3231
highestPurgedDeletedSeqno(0),
3332
numStaleItems(0),
3433
numDeletedItems(0),
@@ -100,19 +99,6 @@ void BasicLinkedList::updateHighSeqno(std::lock_guard<std::mutex>& listWriteLg,
10099
highSeqno = v.getBySeqno();
101100
}
102101

103-
void BasicLinkedList::updateHighestDedupedSeqno(
104-
std::lock_guard<std::mutex>& listWriteLg, const OrderedStoredValue& v) {
105-
if (v.getBySeqno() < 1) {
106-
throw std::invalid_argument(
107-
"BasicLinkedList::updateHighestDedupedSeqno(): " +
108-
vbid.to_string() +
109-
"; Cannot set the highestDedupedSeqno to "
110-
"a value " +
111-
std::to_string(v.getBySeqno()) + " which is < 1");
112-
}
113-
highestDedupedSeqno = v.getBySeqno();
114-
}
115-
116102
void BasicLinkedList::maybeUpdateMaxVisibleSeqno(
117103
std::lock_guard<std::mutex>& seqLock,
118104
std::lock_guard<std::mutex>& writeLock,
@@ -337,11 +323,6 @@ uint64_t BasicLinkedList::getHighSeqno() const {
337323
return highSeqno;
338324
}
339325

340-
uint64_t BasicLinkedList::getHighestDedupedSeqno() const {
341-
std::lock_guard<std::mutex> lckGd(getListWriteLock());
342-
return highestDedupedSeqno;
343-
}
344-
345326
seqno_t BasicLinkedList::getHighestPurgedDeletedSeqno() const {
346327
return highestPurgedDeletedSeqno;
347328
}
@@ -438,7 +419,6 @@ BasicLinkedList::RangeIteratorLL::RangeIteratorLL(BasicLinkedList& ll,
438419
: list(ll),
439420
itrRange(0, 0),
440421
numRemaining(0),
441-
earlySnapShotEndSeqno(0),
442422
maxVisibleSeqno(0),
443423
isBackfill(isBackfill) {
444424

@@ -456,10 +436,6 @@ BasicLinkedList::RangeIteratorLL::RangeIteratorLL(BasicLinkedList& ll,
456436
/* Number of items that can be iterated over */
457437
numRemaining = list.seqList.size();
458438

459-
/* The minimum seqno in the iterator that must be read to get a consistent
460-
read snapshot */
461-
earlySnapShotEndSeqno = list.highestDedupedSeqno;
462-
463439
maxVisibleSeqno = list.maxVisibleSeqno;
464440

465441
/* Mark the snapshot range on linked list. The range that can be read by the
@@ -487,12 +463,10 @@ BasicLinkedList::RangeIteratorLL::RangeIteratorLL(BasicLinkedList& ll,
487463
: spdlog::level::level_enum::debug;
488464

489465
EP_LOG_FMT(severity,
490-
"{} Created range iterator from {} to {}, earlySnapEndSeqno:{}, "
491-
"maxVisibleSeqno:{}",
466+
"{} Created range iterator from {} to {}, maxVisibleSeqno:{}",
492467
list.vbid,
493468
itrRange.getBegin(),
494469
itrRange.getEnd(),
495-
earlySnapShotEndSeqno,
496470
maxVisibleSeqno);
497471
}
498472

engines/ep/src/linked_list.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,6 @@ class BasicLinkedList : public SequenceList {
9999
void updateHighSeqno(std::lock_guard<std::mutex>& listWriteLg,
100100
const OrderedStoredValue& v) override;
101101

102-
void updateHighestDedupedSeqno(std::lock_guard<std::mutex>& listWriteLg,
103-
const OrderedStoredValue& v) override;
104-
105102
void maybeUpdateMaxVisibleSeqno(std::lock_guard<std::mutex>& seqLock,
106103
std::lock_guard<std::mutex>& writeLock,
107104
const OrderedStoredValue& newSV) override;
@@ -130,8 +127,6 @@ class BasicLinkedList : public SequenceList {
130127

131128
uint64_t getHighSeqno() const override;
132129

133-
uint64_t getHighestDedupedSeqno() const override;
134-
135130
seqno_t getHighestPurgedDeletedSeqno() const override;
136131

137132
uint64_t getMaxVisibleSeqno() const override;
@@ -233,14 +228,6 @@ class BasicLinkedList : public SequenceList {
233228
*/
234229
Monotonic<seqno_t> highSeqno;
235230

236-
/**
237-
* We need to this to send out point-in-time snapshots in range read
238-
*
239-
* highestDedupedSeqno is monotonically increasing and is reset to a lower
240-
* value only in case of a rollback.
241-
*/
242-
Monotonic<seqno_t> highestDedupedSeqno;
243-
244231
/**
245232
* The sequence number of the highest purged element.
246233
*
@@ -327,10 +314,6 @@ class BasicLinkedList : public SequenceList {
327314
return numRemaining;
328315
}
329316

330-
seqno_t getEarlySnapShotEnd() const override {
331-
return earlySnapShotEndSeqno;
332-
}
333-
334317
uint64_t getMaxVisibleSeqno() const override {
335318
return maxVisibleSeqno;
336319
}
@@ -385,10 +368,6 @@ class BasicLinkedList : public SequenceList {
385368
iterator at that instance */
386369
uint64_t numRemaining;
387370

388-
/* Indicates the minimum seqno in the iterator that can give a
389-
consistent read snapshot */
390-
seqno_t earlySnapShotEndSeqno;
391-
392371
uint64_t maxVisibleSeqno;
393372

394373
/* Indicates if the range iterator is for DCP backfill

engines/ep/src/seqlist.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ uint64_t SequenceList::RangeIterator::count() const {
5252
return rangeIterImpl->count();
5353
}
5454

55-
seqno_t SequenceList::RangeIterator::getEarlySnapShotEnd() const {
56-
return rangeIterImpl->getEarlySnapShotEnd();
57-
}
58-
5955
uint64_t SequenceList::RangeIterator::getMaxVisibleSeqno() const {
6056
return rangeIterImpl->getMaxVisibleSeqno();
6157
}

engines/ep/src/seqlist.h

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,6 @@ class SequenceList {
118118
*/
119119
virtual uint64_t count() const = 0;
120120

121-
/**
122-
* Indicates the minimum seqno in the iterator that must be read to
123-
* get a consistent read snapshot
124-
*/
125-
virtual seqno_t getEarlySnapShotEnd() const = 0;
126-
127121
virtual uint64_t getMaxVisibleSeqno() const = 0;
128122
};
129123

@@ -216,12 +210,6 @@ class SequenceList {
216210
*/
217211
uint64_t count() const;
218212

219-
/**
220-
* Indicates the minimum seqno in the iterator that must be read to
221-
* get a consistent read snapshot
222-
*/
223-
seqno_t getEarlySnapShotEnd() const;
224-
225213
uint64_t getMaxVisibleSeqno() const;
226214

227215
private:
@@ -275,19 +263,6 @@ class SequenceList {
275263
virtual void updateHighSeqno(std::lock_guard<std::mutex>& listWriteLg,
276264
const OrderedStoredValue& v) = 0;
277265

278-
/**
279-
* Updates the highestDedupedSeqno in the list. Since seqno is generated and
280-
* managed outside the list, the module managing it must update this after
281-
* the seqno is generated for the item already put in the list.
282-
*
283-
* @param listWriteLg Write lock of the sequenceList from getListWriteLock()
284-
* @param v Ref to orderedStoredValue
285-
*
286-
*/
287-
virtual void updateHighestDedupedSeqno(
288-
std::lock_guard<std::mutex>& listWriteLg,
289-
const OrderedStoredValue& v) = 0;
290-
291266
/**
292267
* Updates the max-visible-seqno to the seqno of the new StoredValue, only
293268
* if the new item is committed.
@@ -400,11 +375,6 @@ class SequenceList {
400375
*/
401376
virtual uint64_t getHighSeqno() const = 0;
402377

403-
/**
404-
* Returns the highest de-duplicated sequence number in the list.
405-
*/
406-
virtual uint64_t getHighestDedupedSeqno() const = 0;
407-
408378
/**
409379
* Returns the highest purged Deleted sequence number in the list.
410380
*/

engines/ep/tests/ep_testsuite.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7619,7 +7619,6 @@ static enum test_result test_mb19687_fixed(EngineIface* h) {
76197619
"vb_0:seqlist_count",
76207620
"vb_0:seqlist_deleted_count",
76217621
"vb_0:seqlist_high_seqno",
7622-
"vb_0:seqlist_highest_deduped_seqno",
76237622
"vb_0:seqlist_purged_count",
76247623
"vb_0:seqlist_range_read_begin",
76257624
"vb_0:seqlist_range_read_count",

engines/ep/tests/module_tests/ephemeral_bucket_test.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ TEST_F(EphemeralBucketStatTest, VBSeqlistStats) {
6060
<< "Expected both current and deleted documents";
6161
EXPECT_EQ("1", stats.at("vb_0:seqlist_deleted_count"));
6262
EXPECT_EQ("4", stats.at("vb_0:seqlist_high_seqno"));
63-
EXPECT_EQ("4", stats.at("vb_0:seqlist_highest_deduped_seqno"));
6463
EXPECT_EQ("0", stats.at("vb_0:seqlist_range_read_begin"));
6564
EXPECT_EQ("0", stats.at("vb_0:seqlist_range_read_end"));
6665
EXPECT_EQ("0", stats.at("vb_0:seqlist_range_read_count"));

engines/ep/tests/module_tests/ephemeral_vb_test.cc

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -781,40 +781,6 @@ TEST_F(EphTombstoneTest, DoubleDeleteTimeCorrect) {
781781
EXPECT_GE(secondDelTime, initialDelTime + timeJump);
782782
}
783783

784-
TEST_F(EphemeralVBucketTest, UpdateUpdatesHighestDedupedSeqno) {
785-
/* Add 3 items and then update all of them */
786-
const int numItems = 3;
787-
788-
auto keys = generateKeys(numItems);
789-
setMany(keys, MutationStatus::WasClean);
790-
791-
ASSERT_EQ(0, mockEpheVB->getLL()->getHighestDedupedSeqno());
792-
793-
/* Update the items */
794-
setMany(keys, MutationStatus::WasDirty);
795-
796-
EXPECT_EQ(6, mockEpheVB->getLL()->getHighestDedupedSeqno());
797-
}
798-
799-
TEST_F(EphemeralVBucketTest, AppendUpdatesHighestDedupedSeqno) {
800-
/* Add 3 items and then update all of them */
801-
const int numItems = 3;
802-
803-
auto keys = generateKeys(numItems);
804-
setMany(keys, MutationStatus::WasClean);
805-
806-
ASSERT_EQ(0, mockEpheVB->getLL()->getHighestDedupedSeqno());
807-
808-
{
809-
auto itr = mockEpheVB->getLL()->makeRangeIterator(true /*isBackfill*/);
810-
811-
/* Update the items */
812-
setMany(keys, MutationStatus::WasClean);
813-
}
814-
815-
ASSERT_EQ(6, mockEpheVB->getLL()->getHighestDedupedSeqno());
816-
}
817-
818784
// Check that tombstone purger runs fine in pause-resume mode
819785
TEST_F(EphTombstoneTest, PurgePauseResume) {
820786
// Delete the second item

0 commit comments

Comments
 (0)