Skip to content

Commit d567856

Browse files
committed
MB-31581: Fix incorrect formatting of 'vbucket-seqno' stats
As part of the Vbid refactoring (MB-30552), VBucket::getId()'s return type was changed from uint16_t to the strong type Vbid. However, EventuallyPersistentEngine::addSeqnoVbStats() was not updated to extract the raw uint16_t from the Vbid when printing. When building in Debug mode, this results in a corrupt vbid - for example see the following test failure: [ RUN ] StatTest.vbucket_seqno_stats_test ../kv_engine/engines/ep/tests/module_tests/stats_test.cc:96: Failure Value of: vals Expected: has 7 elements and there exists some permutation of elements such that: - element #0 has a key that is equal to "vb_0:uuid", and - element #1 has a first field that is equal to "vb_0:high_seqno", and has a second field that is equal to "0", and - element #2 has a first field that is equal to "vb_0:abs_high_seqno", and has a second field that is equal to "0", and - element #3 has a first field that is equal to "vb_0:last_persisted_seqno", and has a second field that is equal to "0", and - element #4 has a first field that is equal to "vb_0:purge_seqno", and has a second field that is equal to "0", and - element #5 has a first field that is equal to "vb_0:last_persisted_snap_start", and has a second field that is equal to "0", and - element #6 has a first field that is equal to "vb_0:last_persisted_snap_end", and has a second field that is equal to "0" Actual: { ("vb_0:high_seqno", "0"), ("vb_0:last_persisted_snap_start", "0"), ("vb_258146304:abs_high_seqno", "0"), ("vb_258146304:last_persisted_seqno", "0"), ("vb_258146304:last_persisted_snap_end", "0"), ("vb_258146304:purge_seqno", "0"), ("vb_258146304:uuid", "87176786588641") } [ FAILED ] StatTest.vbucket_seqno_stats_test (4 ms) Note this doesn't manifest under a release build (hence CV passing) - mostly likely because the address of the raw uint16_t is the same as the Vbid object itself; and the optimizer effectively hides the bug. Fix by adding the missing .get() call. Change-Id: I2d90ddc2855874035d7d8877a678f89dfb0a0c9d Reviewed-on: http://review.couchbase.org/100403 Reviewed-by: Chris Farman <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent df99171 commit d567856

File tree

1 file changed

+20
-13
lines changed

1 file changed

+20
-13
lines changed

engines/ep/src/ep_engine.cc

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3928,29 +3928,36 @@ void EventuallyPersistentEngine::addSeqnoVbStats(const void *cookie,
39283928
try {
39293929
char buffer[64];
39303930
failover_entry_t entry = vb->failovers->getLatestEntry();
3931-
checked_snprintf(buffer, sizeof(buffer), "vb_%d:high_seqno",
3932-
vb->getId());
3931+
checked_snprintf(
3932+
buffer, sizeof(buffer), "vb_%d:high_seqno", vb->getId().get());
39333933
add_casted_stat(buffer, relHighSeqno, add_stat, cookie);
3934-
checked_snprintf(buffer, sizeof(buffer), "vb_%d:abs_high_seqno",
3935-
vb->getId());
3934+
checked_snprintf(buffer,
3935+
sizeof(buffer),
3936+
"vb_%d:abs_high_seqno",
3937+
vb->getId().get());
39363938
add_casted_stat(buffer, vb->getHighSeqno(), add_stat, cookie);
3937-
checked_snprintf(buffer, sizeof(buffer), "vb_%d:last_persisted_seqno",
3938-
vb->getId());
3939+
checked_snprintf(buffer,
3940+
sizeof(buffer),
3941+
"vb_%d:last_persisted_seqno",
3942+
vb->getId().get());
39393943
add_casted_stat(
39403944
buffer, vb->getPublicPersistenceSeqno(), add_stat, cookie);
3941-
checked_snprintf(buffer, sizeof(buffer), "vb_%d:uuid", vb->getId());
3945+
checked_snprintf(
3946+
buffer, sizeof(buffer), "vb_%d:uuid", vb->getId().get());
39423947
add_casted_stat(buffer, entry.vb_uuid, add_stat, cookie);
3943-
checked_snprintf(buffer, sizeof(buffer), "vb_%d:purge_seqno",
3944-
vb->getId());
3948+
checked_snprintf(
3949+
buffer, sizeof(buffer), "vb_%d:purge_seqno", vb->getId().get());
39453950
add_casted_stat(buffer, vb->getPurgeSeqno(), add_stat, cookie);
39463951
const snapshot_range_t range = vb->getPersistedSnapshot();
3947-
checked_snprintf(buffer, sizeof(buffer),
3952+
checked_snprintf(buffer,
3953+
sizeof(buffer),
39483954
"vb_%d:last_persisted_snap_start",
3949-
vb->getId());
3955+
vb->getId().get());
39503956
add_casted_stat(buffer, range.start, add_stat, cookie);
3951-
checked_snprintf(buffer, sizeof(buffer),
3957+
checked_snprintf(buffer,
3958+
sizeof(buffer),
39523959
"vb_%d:last_persisted_snap_end",
3953-
vb->getId());
3960+
vb->getId().get());
39543961
add_casted_stat(buffer, range.end, add_stat, cookie);
39553962
} catch (std::exception& error) {
39563963
EP_LOG_WARN("addSeqnoVbStats: error building stats: {}", error.what());

0 commit comments

Comments
 (0)