Skip to content

Commit 6bcf6a9

Browse files
committed
MB-57609: Do not increment numGetFailure for document not found
The kv_ep_data_read_failed stat is used by ns_server to detect sustained disk errors and fail over the node. Do not increment the stat when the document does not exist. Change-Id: I7847528106a42dfcc6255e7d943e68a2131b6653 Reviewed-on: https://review.couchbase.org/c/kv_engine/+/193173 Tested-by: Build Bot <[email protected]> Reviewed-by: Jim Walker <[email protected]> Reviewed-by: Paolo Cocchi <[email protected]> Reviewed-by: James H <[email protected]> Well-Formed: Restriction Checker
1 parent e347d67 commit 6bcf6a9

File tree

5 files changed

+19
-8
lines changed

5 files changed

+19
-8
lines changed

engines/ep/src/kvstore/couch-kvstore/couch-kvstore.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,9 @@ GetValue CouchKVStore::getWithHeader(DbHolder& db,
639639
}
640640
}
641641

642-
if(errCode != COUCHSTORE_SUCCESS) {
642+
// MB-57609: Only report actual get errors, no_such_key should not count
643+
if (errCode != COUCHSTORE_SUCCESS &&
644+
errCode != COUCHSTORE_ERROR_DOC_NOT_FOUND) {
643645
++st.numGetFailure;
644646
}
645647

engines/ep/src/kvstore/magma-kvstore/magma-kvstore.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -954,9 +954,6 @@ GetValue MagmaKVStore::getWithHeader(const DiskDocKey& key,
954954
}
955955

956956
if (!found) {
957-
// Whilst this isn't strictly a failure if we're running full eviction
958-
// it could be considered one for value eviction.
959-
st.numGetFailure++;
960957
return GetValue{nullptr, cb::engine_errc::no_such_key};
961958
}
962959

engines/ep/src/kvstore/rocksdb-kvstore/rocksdb-kvstore.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,9 @@ GetValue RocksDBKVStore::getWithHeader(const DiskDocKey& key,
697697
rocksdb::Status s = rdb->Get(
698698
rocksdb::ReadOptions(), vbh->defaultCFH.get(), keySlice, &value);
699699
if (!s.ok()) {
700-
st.numGetFailure++;
700+
if (!s.IsNotFound()) {
701+
st.numGetFailure++;
702+
}
701703
return GetValue{nullptr, cb::engine_errc::no_such_key};
702704
}
703705

engines/ep/tests/module_tests/couch-kvstore_test.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,11 @@ TEST_F(CouchKVStoreErrorInjectionTest, get_docinfo_by_id) {
830830
gv = kvstore->get(DiskDocKey{*items.front()}, Vbid(0));
831831
}
832832
EXPECT_EQ(cb::engine_errc::temporary_failure, gv.getStatus());
833+
834+
/* Check we incremented the read failures */
835+
size_t getFailures = 0;
836+
kvstore->getStat("failure_get", getFailures);
837+
EXPECT_EQ(1, getFailures);
833838
}
834839

835840
/**
@@ -881,6 +886,11 @@ TEST_F(CouchKVStoreErrorInjectionTest, getMulti_docinfos_by_id) {
881886
}
882887
EXPECT_EQ(cb::engine_errc::temporary_failure,
883888
itms[DiskDocKey{*items.at(0)}].value.getStatus());
889+
890+
/* Check we incremented the read failures */
891+
size_t getFailures = 0;
892+
kvstore->getStat("failure_get", getFailures);
893+
EXPECT_EQ(1, getFailures);
884894
}
885895

886896
/**

engines/ep/tests/module_tests/kvstore_test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,14 +365,14 @@ TEST_P(KVStoreParamTest, GetModes) {
365365
EXPECT_FALSE(gv.item->getValue());
366366
}
367367

368-
// A doc not found should equal a get failure for a get call (used for some
369-
// stats, fetching docs to expire, and rollback)
368+
// A doc not found should not equal a get failure for a get call (used for
369+
// failover by ns_server).
370370
TEST_P(KVStoreParamTest, GetMissNumGetFailure) {
371371
GetValue gv = kvstore->get(DiskDocKey{makeStoredDocKey("key")}, Vbid(0));
372372
EXPECT_EQ(cb::engine_errc::no_such_key, gv.getStatus());
373373

374374
auto stats = kvstore->getKVStoreStat();
375-
EXPECT_EQ(1, stats.numGetFailure);
375+
EXPECT_EQ(0, stats.numGetFailure);
376376
EXPECT_EQ(0, kvstore->getKVStoreStat().io_bg_fetch_docs_read);
377377
EXPECT_EQ(0, kvstore->getKVStoreStat().io_bgfetch_doc_bytes);
378378
}

0 commit comments

Comments
 (0)