Skip to content

Commit 19fa708

Browse files
committed
MB-56094: Add 'cursor_distance' to CM cursors stats
Another useful information at diagnostic, distance from checkpoint begin. Example, in a state like: [e:1 cs:1 vbs:1 vbs:1) ^ It would be: vb_0:persistence:cursor_distance: 3 vb_0:persistence:cursor_op: set_vbucket_state vb_0:persistence:cursor_seqno: 1 Note: We can have multiple consecutive set_vbucket_state items that share the same seqno. A cursor placed at the first vbs would report distance:2. Change-Id: If969c62132ccd1731d0d4abaacf005d3dbb93792 Reviewed-on: https://review.couchbase.org/c/kv_engine/+/189985 Reviewed-by: Dave Rigby <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent acb593d commit 19fa708

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

engines/ep/docs/stats.org

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -991,6 +991,8 @@ each stat name.
991991

992992
| cursor_name:cursor_checkpoint_id | Checkpoint ID at which the cursor is |
993993
| | name 'cursor_name' is pointing now |
994+
| cursor_name:cursor_distance | The distance of cursor from checkpoint |
995+
| | begin |
994996
| cursor_name:cursor_seqno | The seqno at which the cursor |
995997
| | 'cursor_name' is pointing now |
996998
| cursor_name:cursor_op | The type of operation of the item pointed |

engines/ep/src/checkpoint_manager.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,6 +1585,14 @@ void CheckpointManager::addStats(const AddStatFn& add_stat,
15851585
cookie);
15861586

15871587
const auto pos = cursor.second->getPos();
1588+
checked_snprintf(buf.data(),
1589+
buf.size(),
1590+
"vb_%d:%s:cursor_distance",
1591+
vbucketId.get(),
1592+
name.c_str());
1593+
add_casted_stat(
1594+
buf.data(), cursor.second->getDistance(), add_stat, cookie);
1595+
15881596
checked_snprintf(buf.data(),
15891597
buf.size(),
15901598
"vb_%d:%s:cursor_op",

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_distance",
72497250
"vb_0:persistence:cursor_op",
72507251
"vb_0:persistence:cursor_seqno",
72517252
"vb_0:persistence:num_visits",

0 commit comments

Comments
 (0)