mirror of https://gitee.com/bigwinds/arangodb
fix assertion failure with _numLogData (#6633)
This commit is contained in:
parent
25f5c841b9
commit
4b2a6d430b
|
@ -729,7 +729,7 @@ Result RocksDBCollection::truncate(transaction::Methods* trx,
|
||||||
TRI_ASSERT(key.isString());
|
TRI_ASSERT(key.isString());
|
||||||
TRI_ASSERT(rid != 0);
|
TRI_ASSERT(rid != 0);
|
||||||
|
|
||||||
RocksDBSavePoint guard(mthds, trx->isSingleOperationTransaction());
|
RocksDBSavePoint guard(trx, TRI_VOC_DOCUMENT_OPERATION_REMOVE);
|
||||||
|
|
||||||
state->prepareOperation(_logicalCollection.id(),
|
state->prepareOperation(_logicalCollection.id(),
|
||||||
rid, // actual revision ID!!
|
rid, // actual revision ID!!
|
||||||
|
@ -895,10 +895,9 @@ Result RocksDBCollection::insert(arangodb::transaction::Methods* trx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto state = RocksDBTransactionState::toState(trx);
|
RocksDBSavePoint guard(trx, TRI_VOC_DOCUMENT_OPERATION_INSERT);
|
||||||
auto mthds = RocksDBTransactionState::toMethods(trx);
|
|
||||||
RocksDBSavePoint guard(mthds, trx->isSingleOperationTransaction());
|
|
||||||
|
|
||||||
|
auto state = RocksDBTransactionState::toState(trx);
|
||||||
state->prepareOperation(
|
state->prepareOperation(
|
||||||
_logicalCollection.id(), revisionId, TRI_VOC_DOCUMENT_OPERATION_INSERT
|
_logicalCollection.id(), revisionId, TRI_VOC_DOCUMENT_OPERATION_INSERT
|
||||||
);
|
);
|
||||||
|
@ -1008,8 +1007,7 @@ Result RocksDBCollection::update(arangodb::transaction::Methods* trx,
|
||||||
VPackSlice const newDoc(builder->slice());
|
VPackSlice const newDoc(builder->slice());
|
||||||
|
|
||||||
auto state = RocksDBTransactionState::toState(trx);
|
auto state = RocksDBTransactionState::toState(trx);
|
||||||
RocksDBSavePoint guard(RocksDBTransactionState::toMethods(trx),
|
RocksDBSavePoint guard(trx, TRI_VOC_DOCUMENT_OPERATION_UPDATE);
|
||||||
trx->isSingleOperationTransaction());
|
|
||||||
|
|
||||||
// add possible log statement under guard
|
// add possible log statement under guard
|
||||||
state->prepareOperation(
|
state->prepareOperation(
|
||||||
|
@ -1117,8 +1115,7 @@ Result RocksDBCollection::replace(transaction::Methods* trx,
|
||||||
VPackSlice const newDoc(builder->slice());
|
VPackSlice const newDoc(builder->slice());
|
||||||
|
|
||||||
auto state = RocksDBTransactionState::toState(trx);
|
auto state = RocksDBTransactionState::toState(trx);
|
||||||
RocksDBSavePoint guard(RocksDBTransactionState::toMethods(trx),
|
RocksDBSavePoint guard(trx, TRI_VOC_DOCUMENT_OPERATION_REPLACE);
|
||||||
trx->isSingleOperationTransaction());
|
|
||||||
|
|
||||||
// add possible log statement under guard
|
// add possible log statement under guard
|
||||||
state->prepareOperation(
|
state->prepareOperation(
|
||||||
|
@ -1200,8 +1197,7 @@ Result RocksDBCollection::remove(arangodb::transaction::Methods* trx,
|
||||||
}
|
}
|
||||||
|
|
||||||
auto state = RocksDBTransactionState::toState(trx);
|
auto state = RocksDBTransactionState::toState(trx);
|
||||||
RocksDBSavePoint guard(RocksDBTransactionState::toMethods(trx),
|
RocksDBSavePoint guard(trx, TRI_VOC_DOCUMENT_OPERATION_REMOVE);
|
||||||
trx->isSingleOperationTransaction());
|
|
||||||
|
|
||||||
// add possible log statement under guard
|
// add possible log statement under guard
|
||||||
state->prepareOperation(
|
state->prepareOperation(
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include "Logger/Logger.h"
|
#include "Logger/Logger.h"
|
||||||
#include "RocksDBEngine/RocksDBCommon.h"
|
#include "RocksDBEngine/RocksDBCommon.h"
|
||||||
#include "RocksDBEngine/RocksDBTransactionState.h"
|
#include "RocksDBEngine/RocksDBTransactionState.h"
|
||||||
|
#include "Transaction/Methods.h"
|
||||||
|
|
||||||
#include <rocksdb/db.h>
|
#include <rocksdb/db.h>
|
||||||
#include <rocksdb/options.h>
|
#include <rocksdb/options.h>
|
||||||
|
@ -37,12 +38,15 @@ using namespace arangodb;
|
||||||
// ================= RocksDBSavePoint ==================
|
// ================= RocksDBSavePoint ==================
|
||||||
|
|
||||||
RocksDBSavePoint::RocksDBSavePoint(
|
RocksDBSavePoint::RocksDBSavePoint(
|
||||||
RocksDBMethods* trx, bool handled)
|
transaction::Methods* trx, TRI_voc_document_operation_e operationType)
|
||||||
: _trx(trx), _handled(handled) {
|
: _trx(trx),
|
||||||
|
_operationType(operationType),
|
||||||
|
_handled(_trx->isSingleOperationTransaction()) {
|
||||||
TRI_ASSERT(trx != nullptr);
|
TRI_ASSERT(trx != nullptr);
|
||||||
if (!_handled) {
|
if (!_handled) {
|
||||||
|
auto mthds = RocksDBTransactionState::toMethods(_trx);
|
||||||
// only create a savepoint when necessary
|
// only create a savepoint when necessary
|
||||||
_trx->SetSavePoint();
|
mthds->SetSavePoint();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +75,8 @@ void RocksDBSavePoint::finish(bool hasPerformedIntermediateCommit) {
|
||||||
// leave the savepoint alone, because it belonged to another
|
// leave the savepoint alone, because it belonged to another
|
||||||
// transaction, and the current transaction will not have any
|
// transaction, and the current transaction will not have any
|
||||||
// savepoint
|
// savepoint
|
||||||
_trx->PopSavePoint();
|
auto mthds = RocksDBTransactionState::toMethods(_trx);
|
||||||
|
mthds->PopSavePoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
// this will prevent the rollback call in the destructor
|
// this will prevent the rollback call in the destructor
|
||||||
|
@ -80,7 +85,12 @@ void RocksDBSavePoint::finish(bool hasPerformedIntermediateCommit) {
|
||||||
|
|
||||||
void RocksDBSavePoint::rollback() {
|
void RocksDBSavePoint::rollback() {
|
||||||
TRI_ASSERT(!_handled);
|
TRI_ASSERT(!_handled);
|
||||||
_trx->RollbackToSavePoint();
|
auto mthds = RocksDBTransactionState::toMethods(_trx);
|
||||||
|
mthds->RollbackToSavePoint();
|
||||||
|
|
||||||
|
auto state = RocksDBTransactionState::toState(_trx);
|
||||||
|
state->rollbackOperation(_operationType);
|
||||||
|
|
||||||
_handled = true; // in order to not roll back again by accident
|
_handled = true; // in order to not roll back again by accident
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,9 @@ struct ReadOptions;
|
||||||
} // namespace rocksdb
|
} // namespace rocksdb
|
||||||
|
|
||||||
namespace arangodb {
|
namespace arangodb {
|
||||||
|
namespace transaction {
|
||||||
|
class Methods;
|
||||||
|
}
|
||||||
|
|
||||||
class RocksDBKey;
|
class RocksDBKey;
|
||||||
class RocksDBMethods;
|
class RocksDBMethods;
|
||||||
|
@ -45,7 +48,7 @@ class RocksDBTransactionState;
|
||||||
|
|
||||||
class RocksDBSavePoint {
|
class RocksDBSavePoint {
|
||||||
public:
|
public:
|
||||||
RocksDBSavePoint(RocksDBMethods* trx, bool handled);
|
RocksDBSavePoint(transaction::Methods* trx, TRI_voc_document_operation_e operationType);
|
||||||
~RocksDBSavePoint();
|
~RocksDBSavePoint();
|
||||||
|
|
||||||
/// @brief acknowledges the current savepoint, so there
|
/// @brief acknowledges the current savepoint, so there
|
||||||
|
@ -58,7 +61,8 @@ class RocksDBSavePoint {
|
||||||
void rollback();
|
void rollback();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RocksDBMethods* _trx;
|
transaction::Methods* _trx;
|
||||||
|
TRI_voc_document_operation_e const _operationType;
|
||||||
bool _handled;
|
bool _handled;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -475,6 +475,32 @@ void RocksDBTransactionState::prepareOperation(TRI_voc_cid_t cid, TRI_voc_rid_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief undo the effects of the previous prepareOperation call
|
||||||
|
void RocksDBTransactionState::rollbackOperation(TRI_voc_document_operation_e operationType) {
|
||||||
|
bool singleOp = hasHint(transaction::Hints::Hint::SINGLE_OPERATION);
|
||||||
|
if (singleOp) {
|
||||||
|
switch (operationType) {
|
||||||
|
case TRI_VOC_DOCUMENT_OPERATION_INSERT:
|
||||||
|
case TRI_VOC_DOCUMENT_OPERATION_UPDATE:
|
||||||
|
case TRI_VOC_DOCUMENT_OPERATION_REPLACE:
|
||||||
|
case TRI_VOC_DOCUMENT_OPERATION_REMOVE:
|
||||||
|
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
||||||
|
--_numLogdata;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
default: {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (operationType == TRI_VOC_DOCUMENT_OPERATION_REMOVE) {
|
||||||
|
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
|
||||||
|
--_numLogdata;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief add an operation for a transaction collection
|
/// @brief add an operation for a transaction collection
|
||||||
Result RocksDBTransactionState::addOperation(
|
Result RocksDBTransactionState::addOperation(
|
||||||
TRI_voc_cid_t cid, TRI_voc_rid_t revisionId,
|
TRI_voc_cid_t cid, TRI_voc_rid_t revisionId,
|
||||||
|
|
|
@ -108,6 +108,9 @@ class RocksDBTransactionState final : public TransactionState {
|
||||||
void prepareOperation(TRI_voc_cid_t cid, TRI_voc_rid_t rid,
|
void prepareOperation(TRI_voc_cid_t cid, TRI_voc_rid_t rid,
|
||||||
TRI_voc_document_operation_e operationType);
|
TRI_voc_document_operation_e operationType);
|
||||||
|
|
||||||
|
/// @brief undo the effects of the previous prepareOperation call
|
||||||
|
void rollbackOperation(TRI_voc_document_operation_e operationType);
|
||||||
|
|
||||||
/// @brief add an operation for a transaction collection
|
/// @brief add an operation for a transaction collection
|
||||||
/// sets hasPerformedIntermediateCommit to true if an intermediate commit was performed
|
/// sets hasPerformedIntermediateCommit to true if an intermediate commit was performed
|
||||||
Result addOperation(TRI_voc_cid_t collectionId,
|
Result addOperation(TRI_voc_cid_t collectionId,
|
||||||
|
|
Loading…
Reference in New Issue