Skip to content

Commit

Permalink
PSMDB-191 take into account dropped prefixes when calculating _maxPre…
Browse files Browse the repository at this point in the history
…fix (#134)
  • Loading branch information
igorsol authored and igorcanadi committed Feb 16, 2018
1 parent 997db32 commit 72d1ce2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/rocks_compaction_scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,12 @@ namespace mongo {
return _droppedPrefixes;
}

void RocksCompactionScheduler::loadDroppedPrefixes(rocksdb::Iterator* iter) {
uint32_t RocksCompactionScheduler::loadDroppedPrefixes(rocksdb::Iterator* iter) {
invariant(iter);
const uint32_t rocksdbSkippedDeletionsInitial =
(uint32_t)get_internal_delete_skipped_count();
int dropped_count = 0;
uint32_t int_prefix = 0;
for (iter->Seek(kDroppedPrefix); iter->Valid() && iter->key().starts_with(kDroppedPrefix);
iter->Next()) {
invariantRocksOK(iter->status());
Expand All @@ -360,7 +361,6 @@ namespace mongo {

// let's instruct the compaction scheduler to compact dropped prefix
++dropped_count;
uint32_t int_prefix;
bool ok = extractPrefix(prefix, &int_prefix);
invariant(ok);
{
Expand All @@ -375,6 +375,7 @@ namespace mongo {
const uint32_t skippedDroppedPrefixMarkers =
(uint32_t)get_internal_delete_skipped_count() - rocksdbSkippedDeletionsInitial;
_droppedPrefixesCount.fetch_add(skippedDroppedPrefixMarkers, std::memory_order_relaxed);
return int_prefix;
}

Status RocksCompactionScheduler::dropPrefixesAtomic(
Expand Down
2 changes: 1 addition & 1 deletion src/rocks_compaction_scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ namespace mongo {

rocksdb::CompactionFilterFactory* createCompactionFilterFactory() const;
std::unordered_set<uint32_t> getDroppedPrefixes() const;
void loadDroppedPrefixes(rocksdb::Iterator* iter);
uint32_t loadDroppedPrefixes(rocksdb::Iterator* iter);
Status dropPrefixesAtomic(const std::vector<std::string>& prefixesToDrop,
const rocksdb::WriteOptions& syncOptions,
rocksdb::WriteBatch& wb);
Expand Down
3 changes: 2 additions & 1 deletion src/rocks_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ namespace mongo {

// start compaction thread and load dropped prefixes
_compactionScheduler->start(_db.get());
_compactionScheduler->loadDroppedPrefixes(iter.get());
auto maxDroppedPrefix = _compactionScheduler->loadDroppedPrefixes(iter.get());
_maxPrefix = std::max(_maxPrefix, maxDroppedPrefix);

_durabilityManager.reset(new RocksDurabilityManager(_db.get(), _durable));

Expand Down

0 comments on commit 72d1ce2

Please sign in to comment.