Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PSMDB-191 take into account dropped prefixes when calculating _maxPrefix #134

Merged
merged 1 commit into from
Feb 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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