diff --git a/arangod/RocksDBEngine/RocksDBCollection.cpp b/arangod/RocksDBEngine/RocksDBCollection.cpp index d480ca16af..99518de388 100644 --- a/arangod/RocksDBEngine/RocksDBCollection.cpp +++ b/arangod/RocksDBEngine/RocksDBCollection.cpp @@ -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 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, diff --git a/arangod/RocksDBEngine/RocksDBRecoveryManager.cpp b/arangod/RocksDBEngine/RocksDBRecoveryManager.cpp index 323f96d1b8..5699f46408 100644 --- a/arangod/RocksDBEngine/RocksDBRecoveryManager.cpp +++ b/arangod/RocksDBEngine/RocksDBRecoveryManager.cpp @@ -283,6 +283,7 @@ class WBReader final : public rocksdb::WriteBatch::Handler { } } + /// Truncate indexes of collection bool truncateIndexes(uint64_t objectId) { RocksDBEngine* engine = static_cast(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(idx.get()); + RocksDBCuckooIndexEstimator* 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; } }