Skip to content

Commit e2564a0

Browse files
jimwwalkerdaverigby
authored andcommitted
MB-16181: Adjust seqno range test in isLogicallyDeleted
A create collection system event was incorrectly flagged as logically deleted because the seqno range check incorrectly used 'less-or-equal'. Change-Id: I358ce13608edf1ea933bfb5d3e27d2027b39346e Reviewed-on: http://review.couchbase.org/c/kv_engine/+/133729 Tested-by: Build Bot <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent 62b1dfd commit e2564a0

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

engines/ep/src/collections/vbucket_manifest.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ bool Manifest::isLogicallyDeleted(const container::const_iterator entry,
542542

543543
// seqno >= 0 (so temp items etc... are ok) AND the seqno is below the
544544
// collection start (start is set on creation and moves with flush)
545-
return seqno >= 0 && seqno <= entry->second.getStartSeqno();
545+
return seqno >= 0 && seqno < entry->second.getStartSeqno();
546546
}
547547

548548
void Manifest::processExpiryTime(const container::const_iterator entry,

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,17 @@ TEST_F(VBucketManifestTest, check_applyChanges) {
796796
EXPECT_EQ(2, manifest.getActiveManifest().size());
797797
}
798798

799+
TEST_F(VBucketManifestTest, isLogicallyDeleted) {
800+
// This test creates the vegetable collection at seqno 1, it is not
801+
// logically deleted
802+
EXPECT_TRUE(manifest.update(cm));
803+
auto item = SystemEventFactory::makeCollectionEvent(
804+
CollectionEntry::vegetable, {}, {});
805+
auto sno = manifest.getActiveVB().getHighSeqno();
806+
EXPECT_FALSE(
807+
manifest.active.lock().isLogicallyDeleted(item->getKey(), sno));
808+
}
809+
799810
class VBucketManifestCachingReadHandle : public VBucketManifestTest {};
800811

801812
TEST_F(VBucketManifestCachingReadHandle, basic) {
@@ -843,5 +854,6 @@ TEST_F(VBucketManifestCachingReadHandle, deleted_default) {
843854
EXPECT_TRUE(manifest.update(cm.remove(CollectionEntry::defaultC)));
844855
StoredDocKey key{"fruit:v1", CollectionEntry::defaultC};
845856
auto rh = manifest.active.lock(key);
846-
EXPECT_TRUE(rh.isLogicallyDeleted(0));
857+
// Real items begin at seqno 1
858+
EXPECT_TRUE(rh.isLogicallyDeleted(1 /*seqno*/));
847859
}

0 commit comments

Comments
 (0)