Skip to content

Commit

Permalink
Merge pull request mongodb-partners#80 from denis-protivenskii/psmdb-…
Browse files Browse the repository at this point in the history
…164-32

PSMDB-164 Ignore missing ident in dropIdent
  • Loading branch information
igorsol committed Aug 22, 2017
2 parents b482f54 + 46d52c7 commit d103d3d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/rocks_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,20 @@ namespace mongo {

// cannot be rolled back
Status RocksEngine::dropIdent(OperationContext* opCtx, StringData ident) {
auto identPrefix = _tryGetIdentPrefix(ident);
// happens rarely when dropped prefix markers are persisted but metadata changes
// are lost due to system crash on standalone with default acknowledgement behavior
if (identPrefix.empty()) {
log() << "Cannot find ident " << ident << " to drop, ignoring";
return Status::OK();
}

rocksdb::WriteBatch wb;
wb.Delete(kMetadataPrefix + ident.toString());

// calculate which prefixes we need to drop
std::vector<std::string> prefixesToDrop;
prefixesToDrop.push_back(_getIdentPrefix(ident));
prefixesToDrop.push_back(identPrefix);
if (_oplogIdent == ident.toString()) {
// if we're dropping oplog, we also need to drop keys from RocksOplogKeyTracker (they
// are stored at prefix+1)
Expand Down Expand Up @@ -502,6 +510,13 @@ namespace mongo {
return encodePrefix(prefixIter->second);
}

std::string RocksEngine::_tryGetIdentPrefix(StringData ident) {
stdx::lock_guard<stdx::mutex> lk(_identPrefixMapMutex);
auto prefixIter = _identPrefixMap.find(ident);
const bool prefixFound = (prefixIter != _identPrefixMap.end());
return prefixFound ? encodePrefix(prefixIter->second) : std::string();
}

rocksdb::Options RocksEngine::_options() const {
// default options
rocksdb::Options options;
Expand Down
1 change: 1 addition & 0 deletions src/rocks_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ namespace mongo {
private:
Status _createIdentPrefix(StringData ident);
std::string _getIdentPrefix(StringData ident);
std::string _tryGetIdentPrefix(StringData ident);

rocksdb::Options _options() const;

Expand Down

0 comments on commit d103d3d

Please sign in to comment.