diff --git a/arangod/VocBase/transaction.cpp b/arangod/VocBase/transaction.cpp index 39b12cd427..8ec81ff89d 100644 --- a/arangod/VocBase/transaction.cpp +++ b/arangod/VocBase/transaction.cpp @@ -1151,20 +1151,25 @@ int TRI_AddOperationTransaction(TRI_transaction_t* trx, trx, document->_info.id(), TRI_TRANSACTION_WRITE); if (trxCollection->_operations == nullptr) { trxCollection->_operations = new std::vector; - trxCollection->_operations->reserve(4); + trxCollection->_operations->reserve(16); trx->_hasOperations = true; } else { - // reserve space for one more element - trxCollection->_operations->reserve(trxCollection->_operations->size() + 1); + // reserve space for one more element so the push_back below does not fail + size_t oldSize = trxCollection->_operations->size(); + if (oldSize + 1 >= trxCollection->_operations->capacity()) { + // double the size + trxCollection->_operations->reserve((oldSize + 1) * 2); + } + } + + TRI_IF_FAILURE("TransactionOperationPushBack") { + // test what happens if reserve above failed + THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG); } arangodb::wal::DocumentOperation* copy = operation.swap(); - TRI_IF_FAILURE("TransactionOperationPushBack") { - // test what happens if push_back fails - THROW_ARANGO_EXCEPTION(TRI_ERROR_DEBUG); - } - + // should not fail because we reserved enough room above trxCollection->_operations->push_back(copy); copy->handle(); } diff --git a/js/server/tests/shell/shell-transactions-noncluster.js b/js/server/tests/shell/shell-transactions-noncluster.js index 97bdfda0ab..d229f466ae 100644 --- a/js/server/tests/shell/shell-transactions-noncluster.js +++ b/js/server/tests/shell/shell-transactions-noncluster.js @@ -4153,7 +4153,6 @@ function transactionServerFailuresSuite () { "TransactionOperationNoSlot", "TransactionOperationNoSlotExcept", "TransactionOperationAfterAdjust", - "TransactionOperationPushBack", "TransactionOperationAtEnd" ]; failures.forEach (function (f) { @@ -4189,7 +4188,6 @@ function transactionServerFailuresSuite () { "TransactionOperationNoSlot", "TransactionOperationNoSlotExcept", "TransactionOperationAfterAdjust", - "TransactionOperationPushBack", "TransactionOperationAtEnd" ]; failures.forEach (function (f) { @@ -4332,7 +4330,6 @@ function transactionServerFailuresSuite () { "TransactionOperationNoSlot", "TransactionOperationNoSlotExcept", "TransactionOperationAfterAdjust", - "TransactionOperationPushBack", "TransactionOperationAtEnd" ]; failures.forEach (function (f) { @@ -4423,7 +4420,6 @@ function transactionServerFailuresSuite () { "TransactionOperationNoSlot", "TransactionOperationNoSlotExcept", "TransactionOperationAfterAdjust", - "TransactionOperationPushBack", "TransactionOperationAtEnd" ]; failures.forEach (function (f) {