Skip to content

Commit 802eba7

Browse files
paolococchidaverigby
authored andcommitted
MB-38444: Remove the SequenceList::rangeRead API
Not used in production. Change-Id: Id7343040d72f77ea6b75711aff0830c99f9eb0ae Reviewed-on: http://review.couchbase.org/c/kv_engine/+/144255 Well-Formed: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent e462ee0 commit 802eba7

File tree

7 files changed

+4
-369
lines changed

7 files changed

+4
-369
lines changed

engines/ep/src/ephemeral_vb.cc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -316,15 +316,11 @@ std::unique_ptr<DCPBackfillIface> EphemeralVBucket::createDCPBackfill(
316316
evb, stream, startSeqno, endSeqno);
317317
}
318318

319-
std::tuple<ENGINE_ERROR_CODE, std::vector<UniqueItemPtr>, seqno_t>
320-
EphemeralVBucket::inMemoryBackfill(uint64_t start, uint64_t end) {
321-
return seqList->rangeRead(start, end);
322-
}
323-
324319
boost::optional<SequenceList::RangeIterator>
325320
EphemeralVBucket::makeRangeIterator(bool isBackfill) {
326321
return seqList->makeRangeIterator(isBackfill);
327322
}
323+
328324
bool EphemeralVBucket::isKeyLogicallyDeleted(const DocKey& key,
329325
int64_t bySeqno) {
330326
auto cid = key.getCollectionID();

engines/ep/src/ephemeral_vb.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -128,25 +128,6 @@ class EphemeralVBucket : public VBucket {
128128
uint64_t startSeqno,
129129
uint64_t endSeqno) override;
130130

131-
/**
132-
* Reads backfill items from in memory ordered data structure.
133-
*
134-
* Because the backfill may have to be extended to ensure consistency (e.g.,
135-
* an item in the range has been updated and the new version is
136-
* outside of the original range would result in a missing item), the
137-
* end of the range may be at a higher seqno than was requested; this new
138-
* end value is returned.
139-
*
140-
* @param startSeqno requested start sequence number of the backfill
141-
* @param endSeqno requested end sequence number of the backfill
142-
*
143-
* @return ENGINE_SUCCESS, items in the snapshot, adjusted endSeqno
144-
* ENGINE_ENOMEM on no memory to copy items
145-
* ENGINE_ERANGE on incorrect start and end
146-
*/
147-
std::tuple<ENGINE_ERROR_CODE, std::vector<UniqueItemPtr>, seqno_t>
148-
inMemoryBackfill(uint64_t start, uint64_t end);
149-
150131
/**
151132
* Creates a range iterator for the underlying SequenceList 'optionally'.
152133
* Under scenarios like where we want to limit the number of range iterators

engines/ep/src/linked_list.cc

Lines changed: 0 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -89,107 +89,6 @@ SequenceList::UpdateStatus BasicLinkedList::updateListElem(
8989
return UpdateStatus::Success;
9090
}
9191

92-
std::tuple<ENGINE_ERROR_CODE, std::vector<UniqueItemPtr>, seqno_t>
93-
BasicLinkedList::rangeRead(seqno_t start, seqno_t end) {
94-
if ((start > end) || (start <= 0)) {
95-
EP_LOG_WARN(
96-
"BasicLinkedList::rangeRead(): ({}) ERANGE: start {} > end {}",
97-
vbid,
98-
start,
99-
end);
100-
return std::make_tuple(ENGINE_ERANGE, std::vector<UniqueItemPtr>(), 0);
101-
}
102-
103-
RangeGuard range;
104-
105-
{
106-
std::lock_guard<std::mutex> listWriteLg(getListWriteLock());
107-
108-
if (start > highSeqno) {
109-
EP_LOG_WARN(
110-
"BasicLinkedList::rangeRead(): "
111-
"({}) ERANGE: start {} > highSeqno {}",
112-
vbid,
113-
start,
114-
static_cast<seqno_t>(highSeqno));
115-
/* If the request is for an invalid range, return before iterating
116-
through the list */
117-
return std::make_tuple(
118-
ENGINE_ERANGE, std::vector<UniqueItemPtr>(), 0);
119-
}
120-
121-
/* Mark the initial read range */
122-
end = std::min(end, static_cast<seqno_t>(highSeqno));
123-
end = std::max(end, static_cast<seqno_t>(highestDedupedSeqno));
124-
125-
// the range lock will be released when the RangeGuard is destroyed.
126-
range = tryLockSeqnoRangeShared(1, end);
127-
if (!range) {
128-
return std::make_tuple(
129-
ENGINE_TMPFAIL, std::vector<UniqueItemPtr>(), 0);
130-
}
131-
}
132-
133-
/* Read items in the range */
134-
std::vector<UniqueItemPtr> items;
135-
136-
for (const auto& osv : seqList) {
137-
int64_t currSeqno(osv.getBySeqno());
138-
139-
if (currSeqno > end || currSeqno < 0) {
140-
/* We have read all the items in the requested range, or the osv
141-
* does not yet have a valid seqno; either way we are done */
142-
break;
143-
}
144-
145-
if (currSeqno < start) {
146-
/* skip this item */
147-
continue;
148-
}
149-
150-
if (currSeqno > 1) {
151-
// strictly monotonically update the range lock
152-
range.updateRangeStart(currSeqno);
153-
/* [EPHE TODO] MB-37710: Will updating the range start every time
154-
* have a negative performance impact? */
155-
}
156-
157-
/* Check if this OSV has been made stale and has been superseded by a
158-
* newer version. If it has, and the replacement is /also/ in the range
159-
* we are reading, we should skip this item to avoid duplicates */
160-
StoredValue* replacement;
161-
{
162-
std::lock_guard<std::mutex> writeGuard(getListWriteLock());
163-
replacement = osv.getReplacementIfStale(writeGuard);
164-
}
165-
166-
if (replacement &&
167-
replacement->toOrderedStoredValue()->getBySeqno() <= end) {
168-
continue;
169-
}
170-
171-
try {
172-
items.push_back(UniqueItemPtr(osv.toItem(vbid)));
173-
} catch (const std::bad_alloc&) {
174-
/* [EPHE TODO]: Do we handle backfill in a better way ?
175-
Perhaps do backfilling partially (that is
176-
backfill ==> stream; backfill ==> stream ..so on )?
177-
*/
178-
EP_LOG_WARN(
179-
"BasicLinkedList::rangeRead(): "
180-
"({}) ENOMEM while trying to copy "
181-
"item with seqno {} before streaming it",
182-
vbid,
183-
currSeqno);
184-
return std::make_tuple(
185-
ENGINE_ENOMEM, std::vector<UniqueItemPtr>(), 0);
186-
}
187-
}
188-
189-
/* Return all the range read items */
190-
return std::make_tuple(ENGINE_SUCCESS, std::move(items), end);
191-
}
192-
19392
void BasicLinkedList::updateHighSeqno(std::lock_guard<std::mutex>& listWriteLg,
19493
const OrderedStoredValue& v) {
19594
if (v.getBySeqno() < 1) {

engines/ep/src/linked_list.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,6 @@ class BasicLinkedList : public SequenceList {
9696
std::lock_guard<std::mutex>& writeLock,
9797
OrderedStoredValue& v) override;
9898

99-
std::tuple<ENGINE_ERROR_CODE, std::vector<UniqueItemPtr>, seqno_t>
100-
rangeRead(seqno_t start, seqno_t end) override;
101-
10299
void updateHighSeqno(std::lock_guard<std::mutex>& listWriteLg,
103100
const OrderedStoredValue& v) override;
104101

engines/ep/src/seqlist.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -264,27 +264,6 @@ class SequenceList {
264264
std::lock_guard<std::mutex>& writeLock,
265265
OrderedStoredValue& v) = 0;
266266

267-
/**
268-
* Provides point-in-time snapshots which can be used for incremental
269-
* replication.
270-
*
271-
* Copies the StoredValues as a vector of ref counterd items starting from
272-
* 'start + 1' seqno into 'items' as a snapshot.
273-
*
274-
* Since we use monotonically increasing point-in-time snapshots we cannot
275-
* guarantee that the snapshot ends at the requested end seqno. Due to
276-
* dedups we may have to send till a higher seqno in the snapshot.
277-
*
278-
* @param start requested start seqno
279-
* @param end requested end seqno
280-
*
281-
* @return ENGINE_SUCCESS, items in the snapshot and adjusted endSeqNo
282-
* ENGINE_ENOMEM on no memory to copy items
283-
* ENGINE_ERANGE on incorrect start and end
284-
*/
285-
virtual std::tuple<ENGINE_ERROR_CODE, std::vector<UniqueItemPtr>, seqno_t>
286-
rangeRead(seqno_t start, seqno_t end) = 0;
287-
288267
/**
289268
* Updates the highSeqno in the list. Since seqno is generated and managed
290269
* outside the list, the module managing it must update this after the seqno

engines/ep/tests/module_tests/basic_ll_test.cc

Lines changed: 0 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -270,98 +270,6 @@ TEST_F(BasicLinkedListTest, SetItems) {
270270
EXPECT_EQ(expectedSeqno, basicLL->getAllSeqnoForVerification());
271271
}
272272

273-
TEST_F(BasicLinkedListTest, TestRangeRead) {
274-
const int numItems = 3;
275-
276-
/* Add 3 new items */
277-
addNewItemsToList(1, std::string("key"), numItems);
278-
279-
/* Now do a range read */
280-
ENGINE_ERROR_CODE status;
281-
std::vector<UniqueItemPtr> items;
282-
seqno_t endSeqno;
283-
std::tie(status, items, endSeqno) = basicLL->rangeRead(1, numItems);
284-
285-
EXPECT_EQ(ENGINE_SUCCESS, status);
286-
EXPECT_EQ(numItems, items.size());
287-
EXPECT_EQ(numItems, items.back()->getBySeqno());
288-
EXPECT_EQ(numItems, endSeqno);
289-
}
290-
291-
TEST_F(BasicLinkedListTest, TestRangeReadTillInf) {
292-
const int numItems = 3;
293-
294-
/* Add 3 new items */
295-
addNewItemsToList(1, std::string("key"), numItems);
296-
297-
/* Now do a range read */
298-
ENGINE_ERROR_CODE status;
299-
std::vector<UniqueItemPtr> items;
300-
seqno_t endSeqno;
301-
std::tie(status, items, endSeqno) =
302-
basicLL->rangeRead(1, std::numeric_limits<seqno_t>::max());
303-
304-
EXPECT_EQ(ENGINE_SUCCESS, status);
305-
EXPECT_EQ(numItems, items.size());
306-
EXPECT_EQ(numItems, items.back()->getBySeqno());
307-
EXPECT_EQ(numItems, endSeqno);
308-
}
309-
310-
TEST_F(BasicLinkedListTest, TestRangeReadFromMid) {
311-
const int numItems = 3;
312-
313-
/* Add 3 new items */
314-
addNewItemsToList(1, std::string("key"), numItems);
315-
316-
/* Now do a range read */
317-
ENGINE_ERROR_CODE status;
318-
std::vector<UniqueItemPtr> items;
319-
seqno_t endSeqno;
320-
std::tie(status, items, endSeqno) = basicLL->rangeRead(2, numItems);
321-
322-
EXPECT_EQ(ENGINE_SUCCESS, status);
323-
EXPECT_EQ(numItems - 1, items.size());
324-
EXPECT_EQ(numItems, items.back()->getBySeqno());
325-
EXPECT_EQ(numItems, endSeqno);
326-
}
327-
328-
TEST_F(BasicLinkedListTest, TestRangeReadStopBeforeEnd) {
329-
const int numItems = 3;
330-
331-
/* Add 3 new items */
332-
addNewItemsToList(1, std::string("key"), numItems);
333-
334-
/* Now request for a range read of just 2 items */
335-
ENGINE_ERROR_CODE status;
336-
std::vector<UniqueItemPtr> items;
337-
seqno_t endSeqno;
338-
std::tie(status, items, endSeqno) = basicLL->rangeRead(1, numItems - 1);
339-
340-
EXPECT_EQ(ENGINE_SUCCESS, status);
341-
EXPECT_EQ(numItems - 1, items.size());
342-
EXPECT_EQ(numItems - 1, items.back()->getBySeqno());
343-
EXPECT_EQ(numItems - 1, endSeqno);
344-
}
345-
346-
TEST_F(BasicLinkedListTest, TestRangeReadNegatives) {
347-
const int numItems = 3;
348-
349-
/* Add 3 new items */
350-
addNewItemsToList(1, std::string("key"), numItems);
351-
352-
ENGINE_ERROR_CODE status;
353-
std::vector<UniqueItemPtr> items;
354-
355-
/* Now do a range read with start > end */
356-
std::tie(status, items, std::ignore) = basicLL->rangeRead(2, 1);
357-
EXPECT_EQ(ENGINE_ERANGE, status);
358-
359-
/* Now do a range read with start > highSeqno */
360-
std::tie(status, items, std::ignore) =
361-
basicLL->rangeRead(numItems + 1, numItems + 2);
362-
EXPECT_EQ(ENGINE_ERANGE, status);
363-
}
364-
365273
TEST_F(BasicLinkedListTest, UpdateFirstElem) {
366274
const int numItems = 3;
367275
const std::string keyPrefix("key");
@@ -886,28 +794,6 @@ TEST_F(BasicLinkedListTest,
886794
EXPECT_FALSE(guard2);
887795
}
888796

889-
TEST_F(BasicLinkedListTest, RangeReadStopsOnInvalidSeqno) {
890-
/* MB-24376: rangeRead has to stop if it encounters an OSV with a seqno of
891-
* -1; this item is definitely past the end of the rangeRead, and has not
892-
* yet had its seqno updated in queueDirty */
893-
const int numItems = 2;
894-
const std::string keyPrefix("key");
895-
896-
/* Add 2 new items */
897-
addNewItemsToList(1, keyPrefix, numItems);
898-
899-
/* Add a key that does not yet have a vaild seqno (say -1) */
900-
addItemWithoutSeqno("key3");
901-
902-
EXPECT_EQ(-1, basicLL->getSeqList().back().getBySeqno());
903-
904-
auto res = basicLL->rangeRead(1, std::numeric_limits<seqno_t>::max());
905-
906-
EXPECT_EQ(ENGINE_SUCCESS, std::get<0>(res));
907-
EXPECT_EQ(numItems, std::get<1>(res).size());
908-
EXPECT_EQ(numItems, std::get<2>(res));
909-
}
910-
911797
/* 'EphemeralVBucket' (class that has the list) never calls the purge of last
912798
element, but the list must support generic purge (that is purge until any
913799
element). */

0 commit comments

Comments
 (0)