1
0
Fork 0

attempt to fix truncation (#7002)

This commit is contained in:
Jan 2018-10-22 16:44:21 +02:00 committed by GitHub
parent 169fb8edb7
commit 4e7f56a532
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 4 deletions

View File

@ -691,6 +691,7 @@ Result RocksDBCollection::truncate(transaction::Methods* trx,
RocksDBSettingsManager::CounterAdjustment update(seq, /*numInserts*/0,
/*numRemoves*/numDocs, /*revision*/0);
engine->settingsManager()->updateCounter(_objectId, update);
if (numDocs > 64 * 1024) {
// also compact the ranges in order to speed up all further accesses
compact();

View File

@ -282,6 +282,34 @@ class WBReader final : public rocksdb::WriteBatch::Handler {
(*it).second = keyValue;
}
}
bool truncateIndexes(uint64_t objectId) {
RocksDBEngine* engine =
static_cast<RocksDBEngine*>(EngineSelectorFeature::ENGINE);
RocksDBEngine::CollectionPair pair = engine->mapObjectToCollection(objectId);
if (pair.first == 0 || pair.second == 0) {
return false;
}
DatabaseFeature* df = DatabaseFeature::DATABASE;
TRI_vocbase_t* vb = df->useDatabase(pair.first);
if (vb == nullptr) {
return false;
}
TRI_DEFER(vb->release());
auto coll = vb->lookupCollection(pair.second);
if (coll == nullptr) {
return false;
}
for (auto const& idx : coll->getIndexes()) {
idx->afterTruncate();
}
return true;
}
RocksDBCuckooIndexEstimator<uint64_t>* findEstimator(uint64_t objectId) {
RocksDBEngine* engine =
@ -505,10 +533,11 @@ class WBReader final : public rocksdb::WriteBatch::Handler {
ops->removed = 0;
ops->added = 0;
ops->mustTruncate = true;
auto est = findEstimator(objectId);
if (est != nullptr && est->commitSeq() < currentSeqNum) {
// We track estimates for this index
est->bufferTruncate(currentSeqNum + 1);
if (!truncateIndexes(objectId)) {
// unable to truncate indexes of the collection.
// may be due to collection having been deleted etc.
LOG_TOPIC(DEBUG, Logger::ENGINES) << "unable to truncate indexes for objectId " << objectId;
}
}