1
0
Fork 0

Truncate index extimate fix (#7017)

This commit is contained in:
Simon 2018-10-23 18:06:55 +02:00 committed by Jan
parent 32ea187418
commit 3e5f90dcd3
2 changed files with 16 additions and 5 deletions

View File

@ -668,7 +668,6 @@ Result RocksDBCollection::truncate(transaction::Methods* trx,
if (!s.ok()) { if (!s.ok()) {
return rocksutils::convertStatus(s); return rocksutils::convertStatus(s);
} }
idx->afterTruncate(); // clears caches / clears links (if applicable)
} }
} }
@ -686,6 +685,14 @@ Result RocksDBCollection::truncate(transaction::Methods* trx,
return rocksutils::convertStatus(s); return rocksutils::convertStatus(s);
} }
{// only truncate indexes after a successful commit
READ_LOCKER(guard, _indexesLock);
for (std::shared_ptr<Index> const& idx : _indexes) {
idx->afterTruncate(); // clears caches / clears links (if applicable)
}
}
rocksdb::SequenceNumber seq = rocksutils::latestSequenceNumber(); rocksdb::SequenceNumber seq = rocksutils::latestSequenceNumber();
uint64_t numDocs = _numberDocuments.exchange(0); uint64_t numDocs = _numberDocuments.exchange(0);
RocksDBSettingsManager::CounterAdjustment update(seq, /*numInserts*/0, RocksDBSettingsManager::CounterAdjustment update(seq, /*numInserts*/0,

View File

@ -283,6 +283,7 @@ class WBReader final : public rocksdb::WriteBatch::Handler {
} }
} }
/// Truncate indexes of collection
bool truncateIndexes(uint64_t objectId) { bool truncateIndexes(uint64_t objectId) {
RocksDBEngine* engine = RocksDBEngine* engine =
static_cast<RocksDBEngine*>(EngineSelectorFeature::ENGINE); static_cast<RocksDBEngine*>(EngineSelectorFeature::ENGINE);
@ -299,13 +300,16 @@ class WBReader final : public rocksdb::WriteBatch::Handler {
TRI_DEFER(vb->release()); TRI_DEFER(vb->release());
auto coll = vb->lookupCollection(pair.second); auto coll = vb->lookupCollection(pair.second);
if (coll == nullptr) { if (coll == nullptr) {
return false; return false;
} }
for (auto const& idx : coll->getIndexes()) { for (auto const& idx : coll->getIndexes()) {
idx->afterTruncate(); RocksDBIndex* ridx = static_cast<RocksDBIndex*>(idx.get());
RocksDBCuckooIndexEstimator<uint64_t>* est = ridx->estimator();
if (est) {
est->bufferTruncate(currentSeqNum);
}
} }
return true; return true;
@ -537,7 +541,7 @@ class WBReader final : public rocksdb::WriteBatch::Handler {
if (!truncateIndexes(objectId)) { if (!truncateIndexes(objectId)) {
// unable to truncate indexes of the collection. // unable to truncate indexes of the collection.
// may be due to collection having been deleted etc. // may be due to collection having been deleted etc.
LOG_TOPIC(DEBUG, Logger::ENGINES) << "unable to truncate indexes for objectId " << objectId; LOG_TOPIC(WARN, Logger::ENGINES) << "unable to truncate indexes for objectId " << objectId;
} }
} }