Skip to content

Commit acb593d

Browse files
committed
MB-56094: Add 'cursor_op' to CM cursors stats
We already dump the seqno, the 'operation' is another useful information at diagnostic. In particular in the case where cursor points to a meta-item, as consecutive meta-items share the same seqno. Output example: vb_0:persistence:cursor_op: set_vbucket_state vb_0:persistence:cursor_seqno: 1 Note: In the example above the checkpoint is like [e:1 cs:1 vbs:1), so the seqno isn't enough for knowing the precise cursor position. Change-Id: I280eb9789eb45e2ecdfb51df0fbabe75801655aa Reviewed-on: https://review.couchbase.org/c/kv_engine/+/189981 Tested-by: Paolo Cocchi <[email protected]> Reviewed-by: Dave Rigby <[email protected]>
1 parent 11eb2b1 commit acb593d

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

engines/ep/docs/stats.org

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -993,6 +993,8 @@ each stat name.
993993
| | name 'cursor_name' is pointing now |
994994
| cursor_name:cursor_seqno | The seqno at which the cursor |
995995
| | 'cursor_name' is pointing now |
996+
| cursor_name:cursor_op | The type of operation of the item pointed |
997+
| | by cursor |
996998
| cursor_name:num_visits | Number of times a batch of items have been|
997999
| | drained from a checkpoint of 'cursor_name'|
9981000
| cursor_name:num_items_for_cursor | Number of items remaining for the cursor |

engines/ep/src/checkpoint_manager.cc

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,39 +1572,49 @@ void CheckpointManager::addStats(const AddStatFn& add_stat,
15721572
add_casted_stat(buf.data(), queuedItemsMemUsage, add_stat, cookie);
15731573

15741574
for (const auto& cursor : cursors) {
1575+
const auto& name = cursor.second->getName();
1576+
15751577
checked_snprintf(buf.data(),
15761578
buf.size(),
15771579
"vb_%d:%s:cursor_checkpoint_id",
15781580
vbucketId.get(),
1579-
cursor.second->getName().c_str());
1581+
name.c_str());
15801582
add_casted_stat(buf.data(),
15811583
(*(cursor.second->getCheckpoint()))->getId(),
15821584
add_stat,
15831585
cookie);
15841586

1587+
const auto pos = cursor.second->getPos();
15851588
checked_snprintf(buf.data(),
15861589
buf.size(),
1587-
"vb_%d:%s:cursor_seqno",
1590+
"vb_%d:%s:cursor_op",
15881591
vbucketId.get(),
1589-
cursor.second->getName().c_str());
1592+
name.c_str());
15901593
add_casted_stat(buf.data(),
1591-
(*(cursor.second->getPos()))->getBySeqno(),
1594+
to_string((*pos)->getOperation()),
15921595
add_stat,
15931596
cookie);
15941597

1598+
checked_snprintf(buf.data(),
1599+
buf.size(),
1600+
"vb_%d:%s:cursor_seqno",
1601+
vbucketId.get(),
1602+
name.c_str());
1603+
add_casted_stat(buf.data(), (*pos)->getBySeqno(), add_stat, cookie);
1604+
15951605
checked_snprintf(buf.data(),
15961606
buf.size(),
15971607
"vb_%d:%s:num_visits",
15981608
vbucketId.get(),
1599-
cursor.second->getName().c_str());
1609+
name.c_str());
16001610
add_casted_stat(
16011611
buf.data(), cursor.second->getNumVisit(), add_stat, cookie);
16021612

16031613
checked_snprintf(buf.data(),
16041614
buf.size(),
16051615
"vb_%d:%s:num_items_for_cursor",
16061616
vbucketId.get(),
1607-
cursor.second->getName().c_str());
1617+
name.c_str());
16081618
add_casted_stat(buf.data(),
16091619
getNumItemsForCursor(lh, *cursor.second),
16101620
add_stat,

engines/ep/tests/ep_testsuite.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7246,6 +7246,7 @@ static enum test_result test_mb19687_fixed(EngineIface* h) {
72467246
// Add stats which are only available for persistent buckets:
72477247
std::initializer_list<std::string_view> persistence_stats = {
72487248
"vb_0:persistence:cursor_checkpoint_id",
7249+
"vb_0:persistence:cursor_op",
72497250
"vb_0:persistence:cursor_seqno",
72507251
"vb_0:persistence:num_visits",
72517252
"vb_0:persistence:num_items_for_cursor"};

0 commit comments

Comments
 (0)