Skip to content

Commit 4a5d9f4

Browse files
committed
Revert "MB-41321: 2/4 Clean-up if collection exists in old and new drop containers"
This reverts commit a3cc422. Reason for revert: Build break - merged out of order? Change-Id: Ib709a997cee0e64ff3f66eacf4e778b26b8e0cd4 Reviewed-on: http://review.couchbase.org/c/kv_engine/+/137630 Tested-by: Dave Rigby <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent a3cc422 commit 4a5d9f4

File tree

2 files changed

+19
-49
lines changed

2 files changed

+19
-49
lines changed

engines/ep/src/collections/flush.cc

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -448,44 +448,29 @@ flatbuffers::DetachedBuffer Flush::encodeOpenCollections(
448448

449449
flatbuffers::DetachedBuffer Flush::encodeDroppedCollections(
450450
std::vector<Collections::KVStore::DroppedCollection>& existingDropped) {
451-
flatbuffers::FlatBufferBuilder builder;
452-
std::vector<flatbuffers::Offset<Collections::KVStore::Dropped>> output;
453-
454-
// Add Collection's to this set only if they are in both old and new
455-
// sets of dropped collections - this ensures we generate it once into
456-
// the new output.
457-
std::unordered_set<CollectionID> skip;
458-
459451
// Iterate through the existing dropped collections and look each up in the
460452
// commit metadata. If the collection is in both lists, we will just update
461453
// the existing data (adjusting the endSeqno) and then erase the collection
462454
// from the commit meta's dropped collections.
463455
for (auto& collection : existingDropped) {
464456
if (auto itr = droppedCollections.find(collection.collectionId);
465457
itr != droppedCollections.end()) {
466-
// Collection is in both old and new 'sets' of dropped collections
467-
// we only want it in the output once - update the end-seqno here
468-
// and add to skip set
469458
collection.endSeqno = itr->second.endSeqno;
470-
skip.emplace(collection.collectionId);
459+
460+
// Now kick the collection out of collectionsMeta, its contribution
461+
// to the final output is complete
462+
droppedCollections.erase(itr);
471463
}
472-
auto newEntry = Collections::KVStore::CreateDropped(
473-
builder,
474-
collection.startSeqno,
475-
collection.endSeqno,
476-
uint32_t(collection.collectionId));
477-
output.push_back(newEntry);
478464
}
479465

480-
// Now add the newly dropped collections
481-
// Iterate through the set of collections dropped in the commit batch and
466+
flatbuffers::FlatBufferBuilder builder;
467+
std::vector<flatbuffers::Offset<Collections::KVStore::Dropped>> output;
468+
469+
// Now merge, first the newly dropped collections
470+
// Iterate through the list collections dropped in the commit batch and
482471
// and create flatbuffer versions of each one
483472
for (const auto& [cid, dropped] : droppedCollections) {
484473
(void)cid;
485-
if (skip.count(cid) > 0) {
486-
// This collection is already in output
487-
continue;
488-
}
489474
auto newEntry = Collections::KVStore::CreateDropped(
490475
builder,
491476
dropped.startSeqno,
@@ -494,6 +479,16 @@ flatbuffers::DetachedBuffer Flush::encodeDroppedCollections(
494479
output.push_back(newEntry);
495480
}
496481

482+
// and now copy across the existing dropped collections
483+
for (const auto& entry : existingDropped) {
484+
auto newEntry = Collections::KVStore::CreateDropped(
485+
builder,
486+
entry.startSeqno,
487+
entry.endSeqno,
488+
uint32_t(entry.collectionId));
489+
output.push_back(newEntry);
490+
}
491+
497492
auto vector = builder.CreateVector(output);
498493
auto final =
499494
Collections::KVStore::CreateDroppedCollections(builder, vector);

engines/ep/tests/module_tests/collections/evp_store_collections_test.cc

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2858,31 +2858,6 @@ TEST_P(CollectionsParameterizedTest, OneScopeStatsByIdParsing) {
28582858
EXPECT_EQ(cm.getUid(), result.getManifestId());
28592859
}
28602860

2861-
// Test a specific issue spotted, in the case when a collection exists
2862-
// as dropped in storage and is newly dropped - we clean-up
2863-
TEST_P(CollectionsPersistentParameterizedTest, FlushDropCreateDropCleansUp) {
2864-
CollectionsManifest cm;
2865-
cm.add(CollectionEntry::fruit); // seq:1
2866-
setCollections(cookie, std::string{cm});
2867-
flushVBucketToDiskIfPersistent(vbid, 1);
2868-
cm.remove(CollectionEntry::fruit); // seq:2
2869-
setCollections(cookie, std::string{cm});
2870-
flushVBucketToDiskIfPersistent(vbid, 1);
2871-
cm.add(CollectionEntry::fruit); // seq:3
2872-
setCollections(cookie, std::string{cm});
2873-
flushVBucketToDiskIfPersistent(vbid, 1);
2874-
cm.remove(CollectionEntry::fruit); // seq:4
2875-
setCollections(cookie, std::string{cm});
2876-
flushVBucketToDiskIfPersistent(vbid, 1);
2877-
2878-
VBucketPtr vb = store->getVBucket(vbid);
2879-
2880-
// Final flush should of removed making this invalid and we get an exception
2881-
EXPECT_THROW(vb->getManifest().lock().getStatsForFlush(
2882-
CollectionEntry::fruit, 4),
2883-
std::logic_error);
2884-
}
2885-
28862861
INSTANTIATE_TEST_SUITE_P(CollectionsExpiryLimitTests,
28872862
CollectionsExpiryLimitTest,
28882863
::testing::Bool(),

0 commit comments

Comments
 (0)