diff --git a/CHANGELOG b/CHANGELOG index e4d4dc7014cb..e3fa10a81a57 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,10 @@ devel ----- +* Truncate must not trigger intermediate commits while in a streaming + transaction, because that would be against the assumption that + streaming transactions never do intermediate commits. + * Added ArangoSearch condition optimization: STARTS_WITH is merged with LEVENSHTEIN_MATCH if used in the same AND node and field name and prefix matches. diff --git a/arangod/RocksDBEngine/RocksDBCollection.cpp b/arangod/RocksDBEngine/RocksDBCollection.cpp index 1765765f0f3c..3182cc6ad55c 100644 --- a/arangod/RocksDBEngine/RocksDBCollection.cpp +++ b/arangod/RocksDBEngine/RocksDBCollection.cpp @@ -790,12 +790,16 @@ Result RocksDBCollection::truncate(transaction::Methods& trx, OperationOptions& // avoid OOM error for truncate by committing earlier uint64_t const prvICC = state->options().intermediateCommitCount; - state->options().intermediateCommitCount = std::min(prvICC, 10000); + if (!state->hasHint(transaction::Hints::Hint::GLOBAL_MANAGED)) { + state->options().intermediateCommitCount = std::min(prvICC, 10000); + } // push our current transaction on the stack state->beginQuery(true); - auto stateGuard = scopeGuard([state]() noexcept { + auto stateGuard = scopeGuard([state, prvICC]() noexcept { state->endQuery(true); + // reset to previous value after truncate is finished + state->options().intermediateCommitCount = prvICC; }); uint64_t found = 0; @@ -844,9 +848,6 @@ Result RocksDBCollection::truncate(transaction::Methods& trx, OperationOptions& trackWaitForSync(&trx, options); } - // reset to previous value after truncate is finished - state->options().intermediateCommitCount = prvICC; - #ifdef ARANGODB_ENABLE_MAINTAINER_MODE if (state->numCommits() == 0) { // check IN TRANSACTION if documents have been deleted