Skip to content

Commit d8110ee

Browse files
committed
MB-58961: Simplify cursor-registering logging logic in ActiveStream
In a couple of places we access the newly registered cursor by ensuring that the cursor cannot be removed during our access. No need of that extra logic though, all the code paths involved acquire the AS::streamLock already. Change-Id: Iefbc50b902999fd3234fe475a67f7c818f27f6ac Reviewed-on: https://review.couchbase.org/c/kv_engine/+/199153 Tested-by: Paolo Cocchi <[email protected]> Reviewed-by: Vesko Karaganev <[email protected]> Well-Formed: Restriction Checker
1 parent 1ddedbb commit d8110ee

File tree

1 file changed

+10
-26
lines changed

1 file changed

+10
-26
lines changed

engines/ep/src/dcp/active_stream.cc

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -261,26 +261,18 @@ void ActiveStream::registerCursor(CheckpointManager& chkptmgr,
261261
curChkSeqno = result.nextSeqno;
262262
cursor = result.cursor;
263263

264-
// Note: We have just registered a cursor and then unlocked the CM at
265-
// return. Might cursor-drop kick in before we even try to access the
266-
// cursor for logging here?
267-
std::optional<queue_op> op{};
268-
{
269-
const auto lockedCursor = result.cursor.lock();
270-
if (lockedCursor) {
271-
op = (*lockedCursor->getPos())->getOperation();
272-
}
273-
}
264+
const auto lockedCursor = result.cursor.lock();
265+
Expects(lockedCursor);
274266
log(spdlog::level::level_enum::info,
275-
"{} ActiveStream::registerCursor name \"{}\", wantedSeqno:{}, "
276-
"result{{tryBackfill:{}, nextSeqno:{}, op:{}}}, "
277-
"pendingBackfill:{}",
267+
"{} ActiveStream::registerCursor name \"{}\", "
268+
"lastProcessedSeqno:{}, result{{tryBackfill:{}, nextSeqno:{}, "
269+
"op:{}}}, pendingBackfill:{}",
278270
logPrefix,
279271
name_,
280272
lastProcessedSeqno,
281273
result.tryBackfill,
282274
result.nextSeqno,
283-
op ? ::to_string(*op) : "N/A",
275+
::to_string((*lockedCursor->getPos())->getOperation()),
284276
pendingBackfill);
285277
} catch (std::exception& error) {
286278
log(spdlog::level::level_enum::warn,
@@ -1777,27 +1769,19 @@ void ActiveStream::scheduleBackfill_UNLOCKED(DcpProducer& producer,
17771769
return;
17781770
}
17791771

1780-
// Note: We have just registered a cursor and then unlocked the CM at
1781-
// return. Might cursor-drop kick in before we even try to access the
1782-
// cursor for logging here?
1783-
std::optional<queue_op> op{};
1784-
{
1785-
const auto lockedCursor = registerResult.cursor.lock();
1786-
if (lockedCursor) {
1787-
op = (*lockedCursor->getPos())->getOperation();
1788-
}
1789-
}
1772+
const auto lockedCursor = registerResult.cursor.lock();
1773+
Expects(lockedCursor);
17901774
log(spdlog::level::level_enum::info,
17911775
"{} ActiveStream::scheduleBackfill_UNLOCKED register cursor with "
1792-
"name \"{}\" wantedSeqno:{}, result{{tryBackfill:{}, "
1776+
"name \"{}\" lastProcessedSeqno:{}, result{{tryBackfill:{}, "
17931777
"nextSeqno:{}}}, "
17941778
"op:{}",
17951779
logPrefix,
17961780
name_,
17971781
lastReadSeqno.load(),
17981782
registerResult.tryBackfill,
17991783
registerResult.nextSeqno,
1800-
op ? ::to_string(*op) : "N/A");
1784+
::to_string((*lockedCursor->getPos())->getOperation()));
18011785

18021786
curChkSeqno = registerResult.nextSeqno;
18031787
tryBackfill = registerResult.tryBackfill;

0 commit comments

Comments
 (0)