mirror of https://gitee.com/bigwinds/arangodb
Truncate index extimate fix (#7017)
This commit is contained in:
parent
32ea187418
commit
3e5f90dcd3
|
@ -668,7 +668,6 @@ Result RocksDBCollection::truncate(transaction::Methods* trx,
|
|||
if (!s.ok()) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
{// 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();
|
||||
uint64_t numDocs = _numberDocuments.exchange(0);
|
||||
RocksDBSettingsManager::CounterAdjustment update(seq, /*numInserts*/0,
|
||||
|
|
|
@ -283,6 +283,7 @@ class WBReader final : public rocksdb::WriteBatch::Handler {
|
|||
}
|
||||
}
|
||||
|
||||
/// Truncate indexes of collection
|
||||
bool truncateIndexes(uint64_t objectId) {
|
||||
RocksDBEngine* engine =
|
||||
static_cast<RocksDBEngine*>(EngineSelectorFeature::ENGINE);
|
||||
|
@ -299,13 +300,16 @@ class WBReader final : public rocksdb::WriteBatch::Handler {
|
|||
TRI_DEFER(vb->release());
|
||||
|
||||
auto coll = vb->lookupCollection(pair.second);
|
||||
|
||||
if (coll == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
|
@ -537,7 +541,7 @@ class WBReader final : public rocksdb::WriteBatch::Handler {
|
|||
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;
|
||||
LOG_TOPIC(WARN, Logger::ENGINES) << "unable to truncate indexes for objectId " << objectId;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue