Skip to content

Commit

Permalink
Merge fixes/NFSE-4123
Browse files Browse the repository at this point in the history
  • Loading branch information
David Boles committed Apr 20, 2020
2 parents 5f13543 + fba1e36 commit 6ed3cfe
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 59 deletions.
2 changes: 0 additions & 2 deletions src/mongo/db/storage/hse/src/hse.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions src/mongo/db/storage/hse/src/hse_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
2 changes: 0 additions & 2 deletions src/mongo/db/storage/hse/src/hse_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 3 additions & 15 deletions src/mongo/db/storage/hse/src/hse_kvscursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

//
Expand All @@ -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),
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -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)};
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 2 additions & 5 deletions src/mongo/db/storage/hse/src/hse_kvscursor.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,15 @@ 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:
KvsCursor(KVSHandle kvs,
KVDBData& prefix,
bool forward,
ClientTxn* lnkd_txn,
const struct CompParms& compparms,
bool enableRa = false);
const struct CompParms& compparms);

virtual ~KvsCursor();

Expand Down Expand Up @@ -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;
Expand Down
7 changes: 1 addition & 6 deletions src/mongo/db/storage/hse/src/hse_record_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2026,19 +2026,14 @@ 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;

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 =
Expand Down
4 changes: 0 additions & 4 deletions src/mongo/db/storage/hse/src/hse_record_store.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -700,9 +699,6 @@ class KVDBOplogStoreCursor : public KVDBCappedRecordStoreCursor {

RecordId _readUntilForOplog;
shared_ptr<KVDBOplogBlockManager> _opBlkMgr{};

// Heuristic oplog read rate that determines whether read ahead is needed.
const int64_t READ_AHEAD_THRESHOLD{100};
};

class KVDBCappedVisibilityManager {
Expand Down
5 changes: 2 additions & 3 deletions src/mongo/db/storage/hse/src/hse_recovery_unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
3 changes: 1 addition & 2 deletions src/mongo/db/storage/hse/src/hse_recovery_unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/storage/hse/src/hse_stats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ KVDBStatAppBytes _hseAppBytesReadCounter{"hseAppBytesRead"};
KVDBStatAppBytes _hseAppBytesWrittenCounter{"hseAppBytesWritten"};

// Rate stats
KVDBStatRate _hseOplogCursorReadRate{"hseOplogCursorRead", true};
KVDBStatRate _hseOplogCursorReadRate{"hseOplogCursorRead"};

// End Stats declarations

Expand Down
2 changes: 1 addition & 1 deletion src/mongo/db/storage/hse/src/hse_stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
17 changes: 3 additions & 14 deletions src/mongo/db/storage/hse/src/hse_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,16 @@ 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++) {
hse_params_create(&_params[i]);
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());
Expand All @@ -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() {
Expand Down

0 comments on commit 6ed3cfe

Please sign in to comment.