@@ -677,7 +677,7 @@ TEST_P(EPBucketFullEvictionTest, ExpiryFindNonResidentItem) {
677677}
678678
679679void EPBucketFullEvictionTest::compactionFindsNonResidentItem (
680- bool dropCollection) {
680+ bool dropCollection, bool switchToReplica ) {
681681 EXPECT_EQ (cb::engine_errc::success,
682682 store->setVBucketState (vbid, vbucket_state_active, {}));
683683
@@ -723,34 +723,56 @@ void EPBucketFullEvictionTest::compactionFindsNonResidentItem(
723723 // We should have queued a BGFetch for the item
724724 EXPECT_EQ (1 , vb->getNumItems ());
725725 ASSERT_TRUE (vb->hasPendingBGFetchItems ());
726+
727+ auto highSeqno = vb->getHighSeqno ();
728+ if (switchToReplica) {
729+ EXPECT_EQ (cb::engine_errc::success,
730+ store->setVBucketState (vbid, vbucket_state_replica, {}));
731+ }
732+
726733 runBGFetcherTask ();
727- EXPECT_FALSE (vb->hasPendingBGFetchItems ());
728734
729- // We should have expired the item
730- EXPECT_EQ (expectedExpiredItems, vb->numExpiredItems );
735+ if (!switchToReplica) {
736+ EXPECT_FALSE ( vb->hasPendingBGFetchItems () );
731737
732- // But it still exists on disk until we flush
733- EXPECT_EQ (1 , vb->getNumItems () );
738+ // We should have expired the item
739+ EXPECT_EQ (expectedExpiredItems , vb->numExpiredItems );
734740
735- auto expectedItems = 0 ;
736- if (isRocksDB () || dropCollection) {
737- // RocksDB doesn't know if we insert or update so item counts are not
738- // correct.
739- // Or if we drop the collection, no expiry. Item count won't be updated
740- // until collections are purged, so 1 is correct.
741- expectedItems = 1 ;
741+ // But it still exists on disk until we flush
742+ EXPECT_EQ (1 , vb->getNumItems ());
743+
744+ auto expectedItems = 0 ;
745+ if (isRocksDB () || dropCollection) {
746+ // RocksDB doesn't know if we insert or update so item counts are
747+ // not correct. Or if we drop the collection, no expiry. Item count
748+ // won't be updated until collections are purged, so 1 is correct.
749+ expectedItems = 1 ;
750+ if (dropCollection) {
751+ EXPECT_EQ (highSeqno, vb->getHighSeqno ());
752+ }
753+ } else {
754+ EXPECT_LT (highSeqno, vb->getHighSeqno ());
755+ flushVBucketToDiskIfPersistent (vbid, 1 );
756+ }
757+ EXPECT_EQ (expectedItems, vb->getNumItems ());
742758 } else {
743- flushVBucketToDiskIfPersistent (vbid, 1 );
759+ EXPECT_EQ (0 , vb->numExpiredItems );
760+ EXPECT_EQ (highSeqno, vb->getHighSeqno ());
744761 }
745- EXPECT_EQ (expectedItems, vb->getNumItems ());
746762}
747763
748764TEST_P (EPBucketFullEvictionTest, CompactionFindsNonResidentItem) {
749- compactionFindsNonResidentItem (false );
765+ compactionFindsNonResidentItem (false , false );
750766}
751767
752768TEST_P (EPBucketFullEvictionTest, MB_42295_dropCollectionBeforeExpiry) {
753- compactionFindsNonResidentItem (true );
769+ compactionFindsNonResidentItem (true , false );
770+ }
771+
772+ TEST_P (EPBucketFullEvictionTest, MB_48841_switchToReplica) {
773+ // Test will switch from active to replica, bgfetch runs whilst replica and
774+ // all pending expiries must not take affect.
775+ compactionFindsNonResidentItem (false , true );
754776}
755777
756778/* *
0 commit comments