From fba1e36ddaac99440c439f6b18ec8d4744de63ab Mon Sep 17 00:00:00 2001 From: David Boles Date: Sun, 19 Apr 2020 23:03:00 -0500 Subject: [PATCH] Merge updates/NFSE-4116 (cherry picked from commit bad3d541dd7b4ae96f8e1bdc219a6ff7dcf78607) --- src/mongo/db/storage/hse/src/hse.h | 2 -- src/mongo/db/storage/hse/src/hse_impl.cpp | 4 ---- src/mongo/db/storage/hse/src/hse_impl.h | 2 -- src/mongo/db/storage/hse/src/hse_kvscursor.cpp | 18 +++--------------- src/mongo/db/storage/hse/src/hse_kvscursor.h | 7 ++----- .../db/storage/hse/src/hse_record_store.cpp | 7 +------ .../db/storage/hse/src/hse_record_store.h | 4 ---- .../db/storage/hse/src/hse_recovery_unit.cpp | 5 ++--- .../db/storage/hse/src/hse_recovery_unit.h | 3 +-- src/mongo/db/storage/hse/src/hse_stats.cpp | 2 +- src/mongo/db/storage/hse/src/hse_stats.h | 2 +- src/mongo/db/storage/hse/src/hse_test.cpp | 17 +++-------------- 12 files changed, 14 insertions(+), 59 deletions(-) diff --git a/src/mongo/db/storage/hse/src/hse.h b/src/mongo/db/storage/hse/src/hse.h index 5690c525df5a0..7ed32764eee94 100644 --- a/src/mongo/db/storage/hse/src/hse.h +++ b/src/mongo/db/storage/hse/src/hse.h @@ -344,8 +344,6 @@ class KVDB { virtual struct hse_kvdb* kvdb_handle() = 0; - virtual Status kvdb_kvs_count(unsigned int* count) = 0; - virtual Status kvdb_get_names(unsigned int* count, char*** kvs_list) = 0; virtual Status kvdb_free_names(char** kvsv) = 0; diff --git a/src/mongo/db/storage/hse/src/hse_impl.cpp b/src/mongo/db/storage/hse/src/hse_impl.cpp index d1b10727c0f2a..f162bb006c966 100644 --- a/src/mongo/db/storage/hse/src/hse_impl.cpp +++ b/src/mongo/db/storage/hse/src/hse_impl.cpp @@ -104,10 +104,6 @@ Status KVDBImpl::kvdb_kvs_close(KVSHandle handle) { return Status(::hse_kvdb_kvs_close(kvsH)); } -Status KVDBImpl::kvdb_kvs_count(unsigned int* count) { - return Status(::hse_kvdb_kvs_count(_handle, count)); -} - Status KVDBImpl::kvdb_get_names(unsigned int* count, char*** kvs_list) { return Status(::hse_kvdb_get_names(_handle, count, kvs_list)); } diff --git a/src/mongo/db/storage/hse/src/hse_impl.h b/src/mongo/db/storage/hse/src/hse_impl.h index 102ab411dd37a..aae5b160d0296 100644 --- a/src/mongo/db/storage/hse/src/hse_impl.h +++ b/src/mongo/db/storage/hse/src/hse_impl.h @@ -62,8 +62,6 @@ class KVDBImpl : public KVDB { return _handle; } - virtual Status kvdb_kvs_count(unsigned int* count); - virtual Status kvdb_get_names(unsigned int* count, char*** kvs_list); virtual Status kvdb_free_names(char** kvsv); diff --git a/src/mongo/db/storage/hse/src/hse_kvscursor.cpp b/src/mongo/db/storage/hse/src/hse_kvscursor.cpp index 13bd7543bfcd2..8afa2419d2586 100644 --- a/src/mongo/db/storage/hse/src/hse_kvscursor.cpp +++ b/src/mongo/db/storage/hse/src/hse_kvscursor.cpp @@ -70,9 +70,8 @@ KvsCursor* create_cursor(KVSHandle kvs, KVDBData& prefix, bool forward, const struct CompParms& compparms, - ClientTxn* lnkd_txn, - bool enableRa) { - return new KvsCursor(kvs, prefix, forward, lnkd_txn, compparms, enableRa); + ClientTxn* lnkd_txn) { + return new KvsCursor(kvs, prefix, forward, lnkd_txn, compparms); } // @@ -82,12 +81,10 @@ KvsCursor::KvsCursor(KVSHandle handle, KVDBData& prefix, bool forward, ClientTxn* lnkd_txn, - const struct CompParms& compparms, - bool enableRa) + const struct CompParms& compparms) : _kvs((struct hse_kvs*)handle), _pfx(prefix), _forward(forward), - _enableRa{enableRa}, _lnkd_txn(lnkd_txn), _cursor(0), _start(0), @@ -123,10 +120,6 @@ KvsCursor::KvsCursor(KVSHandle handle, opspec.kop_flags |= HSE_KVDB_KOP_FLAG_REVERSE; } - if (_enableRa) { - opspec.kop_flags |= HSE_KVDB_KOP_FLAG_CURSOR_RA; - } - while (true) { if (retries < FIB_LEN) { sleepTime = RETRY_FIB_SEQ_EAGAIN[retries % FIB_LEN]; @@ -202,10 +195,6 @@ Status KvsCursor::update(ClientTxn* lnkd_txn) { opspec.kop_flags |= HSE_KVDB_KOP_FLAG_REVERSE; } - if (_enableRa) { - opspec.kop_flags |= HSE_KVDB_KOP_FLAG_CURSOR_RA; - } - _hseKvsCursorCreateCounter.add(); auto lt = _hseKvsCursorCreateLatency.begin(); st = Status{::hse_kvs_cursor_create(_kvs, &opspec, _pfx.data(), _pfx.len(), &_cursor)}; @@ -290,7 +279,6 @@ Status KvsCursor::read(KVDBData& key, KVDBData& val, bool& eof) { } int KvsCursor::_read_kvs() { - int ret = 0; Status st{}; int retries = 0; unsigned long long sleepTime = 0; diff --git a/src/mongo/db/storage/hse/src/hse_kvscursor.h b/src/mongo/db/storage/hse/src/hse_kvscursor.h index ea2232b1aebe0..db619cc43ae17 100644 --- a/src/mongo/db/storage/hse/src/hse_kvscursor.h +++ b/src/mongo/db/storage/hse/src/hse_kvscursor.h @@ -61,8 +61,7 @@ KvsCursor* create_cursor(KVSHandle kvs, KVDBData& prefix, bool forward, const struct CompParms& compparms, - ClientTxn* lnkd_txn = 0, - bool enableRa = false); + ClientTxn* lnkd_txn = 0); class KvsCursor { public: @@ -70,8 +69,7 @@ class KvsCursor { KVDBData& prefix, bool forward, ClientTxn* lnkd_txn, - const struct CompParms& compparms, - bool enableRa = false); + const struct CompParms& compparms); virtual ~KvsCursor(); @@ -101,7 +99,6 @@ class KvsCursor { struct hse_kvs* _kvs; // not owned KVDBData _pfx; bool _forward{true}; - bool _enableRa{false}; ClientTxn* _lnkd_txn; // not owned std::mutex _mutex; bool _is_ready; diff --git a/src/mongo/db/storage/hse/src/hse_record_store.cpp b/src/mongo/db/storage/hse/src/hse_record_store.cpp index a3e915b499efb..27e8a6cc1f1cc 100644 --- a/src/mongo/db/storage/hse/src/hse_record_store.cpp +++ b/src/mongo/db/storage/hse/src/hse_record_store.cpp @@ -2026,10 +2026,6 @@ void KVDBOplogStoreCursor::_reallySeek(const RecordId& id) { _needSeek = false; } -bool KVDBOplogStoreCursor::_needReadAhead() { - return (_hseOplogCursorReadRate.getRate() > READ_AHEAD_THRESHOLD); -} - KvsCursor* KVDBOplogStoreCursor::_getMCursor() { KVDBRecoveryUnit* ru = KVDBRecoveryUnit::getKVDBRecoveryUnit(_opctx); hse::Status st; @@ -2037,8 +2033,7 @@ KvsCursor* KVDBOplogStoreCursor::_getMCursor() { if (!_cursorValid) { KVDBData compatKey{(uint8_t*)&_prefixValBE, sizeof(_prefixValBE)}; _updateReadUntil(); - st = ru->beginOplogScan( - _colKvs, compatKey, _forward, &_mCursor, this->_compparms, _needReadAhead()); + st = ru->beginOplogScan(_colKvs, compatKey, _forward, &_mCursor, this->_compparms); invariantHseSt(st); _cursorValid = true; _needSeek = diff --git a/src/mongo/db/storage/hse/src/hse_record_store.h b/src/mongo/db/storage/hse/src/hse_record_store.h index e0ab8c87637c5..0b6884dc4e8a2 100644 --- a/src/mongo/db/storage/hse/src/hse_record_store.h +++ b/src/mongo/db/storage/hse/src/hse_record_store.h @@ -688,7 +688,6 @@ class KVDBOplogStoreCursor : public KVDBCappedRecordStoreCursor { // virtual hse::Status _currCursorRead( KVDBRecoveryUnit* ru, KvsCursor* cursor, KVDBData& elKey, KVDBData& elVal, bool& eof); - inline bool _needReadAhead(); // virtual bool _currIsHidden(const RecordId& loc); @@ -700,9 +699,6 @@ class KVDBOplogStoreCursor : public KVDBCappedRecordStoreCursor { RecordId _readUntilForOplog; shared_ptr _opBlkMgr{}; - - // Heuristic oplog read rate that determines whether read ahead is needed. - const int64_t READ_AHEAD_THRESHOLD{100}; }; class KVDBCappedVisibilityManager { diff --git a/src/mongo/db/storage/hse/src/hse_recovery_unit.cpp b/src/mongo/db/storage/hse/src/hse_recovery_unit.cpp index 35e0f6d8e2163..7479a4915d4bc 100644 --- a/src/mongo/db/storage/hse/src/hse_recovery_unit.cpp +++ b/src/mongo/db/storage/hse/src/hse_recovery_unit.cpp @@ -341,12 +341,11 @@ hse::Status KVDBRecoveryUnit::beginOplogScan(const KVSHandle& h, KVDBData pfx, bool forward, KvsCursor** cursor, - const struct CompParms& compparm, - bool readAhead) { + const struct CompParms& compparm) { KvsCursor* lcursor = 0; try { - lcursor = create_cursor(h, pfx, forward, compparm, _txn, readAhead); + lcursor = create_cursor(h, pfx, forward, compparm, _txn); } catch (...) { return hse::Status(ENOMEM); } diff --git a/src/mongo/db/storage/hse/src/hse_recovery_unit.h b/src/mongo/db/storage/hse/src/hse_recovery_unit.h index fe6f4554d2652..98cf543554026 100644 --- a/src/mongo/db/storage/hse/src/hse_recovery_unit.h +++ b/src/mongo/db/storage/hse/src/hse_recovery_unit.h @@ -165,8 +165,7 @@ class KVDBRecoveryUnit : public RecoveryUnit { KVDBData prefix, bool forward, KvsCursor** cursor, - const struct hse::CompParms& compparm, - bool readAhead = false); + const struct hse::CompParms& compparm); hse::Status oplogCursorUpdate(KvsCursor* cursor); hse::Status oplogCursorSeek(KvsCursor* cursor, const KVDBData& key, diff --git a/src/mongo/db/storage/hse/src/hse_stats.cpp b/src/mongo/db/storage/hse/src/hse_stats.cpp index 61be440a30a6e..3368a573f248e 100644 --- a/src/mongo/db/storage/hse/src/hse_stats.cpp +++ b/src/mongo/db/storage/hse/src/hse_stats.cpp @@ -336,7 +336,7 @@ KVDBStatAppBytes _hseAppBytesReadCounter{"hseAppBytesRead"}; KVDBStatAppBytes _hseAppBytesWrittenCounter{"hseAppBytesWritten"}; // Rate stats -KVDBStatRate _hseOplogCursorReadRate{"hseOplogCursorRead", true}; +KVDBStatRate _hseOplogCursorReadRate{"hseOplogCursorRead"}; // End Stats declarations diff --git a/src/mongo/db/storage/hse/src/hse_stats.h b/src/mongo/db/storage/hse/src/hse_stats.h index be854924ebf08..6cfacbe7f415b 100644 --- a/src/mongo/db/storage/hse/src/hse_stats.h +++ b/src/mongo/db/storage/hse/src/hse_stats.h @@ -153,7 +153,7 @@ class KVDBStatAppBytes final : public KVDBStat { class KVDBStatRate final : public KVDBStat { public: - KVDBStatRate(const string name, bool enableOverride); + KVDBStatRate(const string name, bool enableOverride = false); static void init(); virtual void appendTo(BSONObjBuilder& bob) const override; void update(uint64_t incr = 1); diff --git a/src/mongo/db/storage/hse/src/hse_test.cpp b/src/mongo/db/storage/hse/src/hse_test.cpp index 912759118e896..2141efc7c018d 100644 --- a/src/mongo/db/storage/hse/src/hse_test.cpp +++ b/src/mongo/db/storage/hse/src/hse_test.cpp @@ -222,13 +222,7 @@ namespace mongo { class KVDBREGTEST : public unittest::Test { protected: void setUp() { - unsigned kvsCnt = 0; - hse::Status st = _db.kvdb_kvs_count(&kvsCnt); - ASSERT_EQUALS(0, st.getErrno()); - - ASSERT_EQ((unsigned int)0, kvsCnt); - - // ASSERT_EQ(0, _db._testGetMaxIdx()); + // ASSERT_EQ(0, _db._testGetMaxIdx()); // Create all the kvses for (unsigned int i = 0; i < TEST_KVS_CNT; i++) { @@ -236,7 +230,8 @@ class KVDBREGTEST : public unittest::Test { ASSERT_FALSE(nullptr == _params[i]); string paramName = string("kvs.pfx_len"); - st = _db.kvdb_params_set(_params[i], paramName, std::to_string(hse::DEFAULT_PFX_LEN)); + hse::Status st = + _db.kvdb_params_set(_params[i], paramName, std::to_string(hse::DEFAULT_PFX_LEN)); ASSERT_EQUALS(0, st.getErrno()); st = _db.kvdb_kvs_make(_kvsNames[i], _params[i]); ASSERT_EQUALS(0, st.getErrno()); @@ -245,12 +240,6 @@ class KVDBREGTEST : public unittest::Test { hse_params_destroy(_params[i]); } - - - st = _db.kvdb_kvs_count(&kvsCnt); - ASSERT_EQUALS(0, st.getErrno()); - - ASSERT_EQ(TEST_KVS_CNT, kvsCnt); } void tearDown() {