Skip to content

Commit

Permalink
MB-31581: Fix incorrect formatting of 'vbucket-seqno' stats
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
daverigby committed Oct 9, 2018
1 parent df99171 commit d567856
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions engines/ep/src/ep_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3928,29 +3928,36 @@ void EventuallyPersistentEngine::addSeqnoVbStats(const void *cookie,
try {
char buffer[64];
failover_entry_t entry = vb->failovers->getLatestEntry();
checked_snprintf(buffer, sizeof(buffer), "vb_%d:high_seqno",
vb->getId());
checked_snprintf(
buffer, sizeof(buffer), "vb_%d:high_seqno", vb->getId().get());
add_casted_stat(buffer, relHighSeqno, add_stat, cookie);
checked_snprintf(buffer, sizeof(buffer), "vb_%d:abs_high_seqno",
vb->getId());
checked_snprintf(buffer,
sizeof(buffer),
"vb_%d:abs_high_seqno",
vb->getId().get());
add_casted_stat(buffer, vb->getHighSeqno(), add_stat, cookie);
checked_snprintf(buffer, sizeof(buffer), "vb_%d:last_persisted_seqno",
vb->getId());
checked_snprintf(buffer,
sizeof(buffer),
"vb_%d:last_persisted_seqno",
vb->getId().get());
add_casted_stat(
buffer, vb->getPublicPersistenceSeqno(), add_stat, cookie);
checked_snprintf(buffer, sizeof(buffer), "vb_%d:uuid", vb->getId());
checked_snprintf(
buffer, sizeof(buffer), "vb_%d:uuid", vb->getId().get());
add_casted_stat(buffer, entry.vb_uuid, add_stat, cookie);
checked_snprintf(buffer, sizeof(buffer), "vb_%d:purge_seqno",
vb->getId());
checked_snprintf(
buffer, sizeof(buffer), "vb_%d:purge_seqno", vb->getId().get());
add_casted_stat(buffer, vb->getPurgeSeqno(), add_stat, cookie);
const snapshot_range_t range = vb->getPersistedSnapshot();
checked_snprintf(buffer, sizeof(buffer),
checked_snprintf(buffer,
sizeof(buffer),
"vb_%d:last_persisted_snap_start",
vb->getId());
vb->getId().get());
add_casted_stat(buffer, range.start, add_stat, cookie);
checked_snprintf(buffer, sizeof(buffer),
checked_snprintf(buffer,
sizeof(buffer),
"vb_%d:last_persisted_snap_end",
vb->getId());
vb->getId().get());
add_casted_stat(buffer, range.end, add_stat, cookie);
} catch (std::exception& error) {
EP_LOG_WARN("addSeqnoVbStats: error building stats: {}", error.what());
Expand Down

0 comments on commit d567856

Please sign in to comment.