Skip to content

Commit b973936

Browse files
committed
MB-64001: Rename Response::isMetaEvent
This function is used in one place just for stat accounting when processing the readyQueue in backfills. The function only needs to determine what events can from a backfill scan. New things like CachedValue incorrectly in the wrong part of the switch as the function wasn't so clear. Change-Id: I349147624f10bcc491a77cdfd9b9629735efce0f Reviewed-on: https://review.couchbase.org/c/kv_engine/+/235489 Reviewed-by: Trond Norbye <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent 17c6db7 commit b973936

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

engines/ep/src/dcp/active_stream.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ std::unique_ptr<DcpResponse> ActiveStream::backfillPhase(
798798
if (resp) {
799799
producer.recordBackfillManagerBytesSent(resp->getApproximateSize());
800800
bufferedBackfill.bytes.fetch_sub(resp->getApproximateSize());
801-
if (!resp->isMetaEvent() || resp->isSystemEvent()) {
801+
if (resp->isPersistedEvent()) {
802802
bufferedBackfill.items--;
803803
}
804804

engines/ep/src/dcp/response.h

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -81,44 +81,40 @@ class DcpResponse {
8181
return OptionalSeqno{/*no-seqno*/};
8282
}
8383

84-
/* Returns true if this response is a meta event (i.e. not an operation on
85-
* an actual user document.
84+
/**
85+
* Function used in backfill code to determine if the current queued item
86+
* represents a persisted item, e.g. a mutation or delete
87+
*
88+
* @return true if this event is persisted (something which has been
89+
* recombobulated from the KVStore )
8690
*/
87-
bool isMetaEvent() const {
91+
bool isPersistedEvent() const {
8892
switch (event_) {
8993
case Event::Mutation:
9094
case Event::Deletion:
9195
case Event::Expiration:
9296
case Event::Prepare:
9397
case Event::Commit:
9498
case Event::Abort:
95-
case Event::CachedValue:
96-
return false;
97-
99+
case Event::SystemEvent:
100+
return true;
98101
case Event::SetVbucket:
99102
case Event::StreamReq:
100103
case Event::StreamEnd:
101104
case Event::SnapshotMarker:
102105
case Event::AddStream:
103-
case Event::SystemEvent:
104106
case Event::SeqnoAcknowledgement:
105107
case Event::OSOSnapshot:
106108
case Event::SeqnoAdvanced:
109+
case Event::CachedValue:
107110
case Event::CacheTransferToActiveStream:
108-
return true;
111+
return false;
109112
}
110113
throw std::invalid_argument(
111-
"DcpResponse::isMetaEvent: Invalid event_ " +
114+
"DcpResponse::isPersistedEvent: Invalid event_ " +
112115
std::to_string(int(event_)));
113116
}
114117

115-
/**
116-
* Returns if the response is a system event
117-
*/
118-
bool isSystemEvent() const {
119-
return (event_ == Event::SystemEvent);
120-
}
121-
122118
virtual size_t getMessageSize() const = 0;
123119

124120
/**

engines/ep/tests/module_tests/dcp_stream_test.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,11 +768,13 @@ TEST_P(StreamTest, MB17653_ItemsRemaining) {
768768
std::unique_ptr<DcpResponse> response(
769769
stream->public_nextQueuedItem(*producer));
770770
ASSERT_NE(nullptr, response);
771-
EXPECT_TRUE(response->isMetaEvent()) << "Expected 1st item to be meta";
771+
EXPECT_FALSE(response->isPersistedEvent())
772+
<< "Expected 1st item to not be a persisted event";
772773

773774
response = stream->public_nextQueuedItem(*producer);
774775
ASSERT_NE(nullptr, response);
775-
EXPECT_FALSE(response->isMetaEvent()) << "Expected 2nd item to be non-meta";
776+
EXPECT_TRUE(response->isPersistedEvent())
777+
<< "Expected 2nd item to be from persistence";
776778

777779
response = stream->public_nextQueuedItem(*producer);
778780
EXPECT_EQ(nullptr, response) << "Expected there to not be a 3rd item.";

0 commit comments

Comments
 (0)