From 3c4f986fc234ce95f5dbbb18e8bc3a3936670886 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Mon, 2 Jun 2014 16:24:16 +0200 Subject: [PATCH] hand over fail information for transactions --- arangod/VocBase/transaction.cpp | 9 +++++---- arangod/VocBase/transaction.h | 4 ++-- arangod/Wal/LogfileManager.cpp | 10 ++++++---- arangod/Wal/LogfileManager.h | 9 +++++---- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/arangod/VocBase/transaction.cpp b/arangod/VocBase/transaction.cpp index 06e6cead8b..91ad726f8e 100644 --- a/arangod/VocBase/transaction.cpp +++ b/arangod/VocBase/transaction.cpp @@ -576,7 +576,7 @@ TRI_transaction_t* TRI_CreateTransaction (TRI_vocbase_t* vocbase, /// @brief free a transaction container //////////////////////////////////////////////////////////////////////////////// -void TRI_FreeTransaction (TRI_transaction_t* const trx) { +void TRI_FreeTransaction (TRI_transaction_t* trx) { assert(trx != nullptr); if (trx->_status == TRI_TRANSACTION_RUNNING) { @@ -584,7 +584,8 @@ void TRI_FreeTransaction (TRI_transaction_t* const trx) { } // release the marker protector - triagens::wal::LogfileManager::instance()->unregisterMarkerProtector(trx->_id); + bool const hasFailedOperations = (trx->_hasOperations && (trx->_status == TRI_TRANSACTION_FAILED || trx->_status == TRI_TRANSACTION_ABORTED)); + triagens::wal::LogfileManager::instance()->unregisterTransaction(trx->_id, hasFailedOperations); // free all collections size_t i = trx->_collections._length; @@ -660,7 +661,7 @@ TRI_transaction_collection_t* TRI_GetCollectionTransaction (TRI_transaction_t co /// @brief add a collection to a transaction //////////////////////////////////////////////////////////////////////////////// -int TRI_AddCollectionTransaction (TRI_transaction_t* const trx, +int TRI_AddCollectionTransaction (TRI_transaction_t* trx, const TRI_voc_cid_t cid, const TRI_transaction_type_e accessType, const int nestingLevel) { @@ -926,7 +927,7 @@ int TRI_BeginTransaction (TRI_transaction_t* trx, trx->_hints = hints; // register a protector - triagens::wal::LogfileManager::instance()->registerMarkerProtector(trx->_id); + triagens::wal::LogfileManager::instance()->registerTransaction(trx->_id); } else { assert(trx->_status == TRI_TRANSACTION_RUNNING); diff --git a/arangod/VocBase/transaction.h b/arangod/VocBase/transaction.h index 03951eda19..d6d791946e 100644 --- a/arangod/VocBase/transaction.h +++ b/arangod/VocBase/transaction.h @@ -188,7 +188,7 @@ TRI_transaction_t* TRI_CreateTransaction (struct TRI_vocbase_s*, /// @brief free a transaction //////////////////////////////////////////////////////////////////////////////// -void TRI_FreeTransaction (TRI_transaction_t* const); +void TRI_FreeTransaction (TRI_transaction_t*); // ----------------------------------------------------------------------------- // --SECTION-- public functions @@ -220,7 +220,7 @@ TRI_transaction_collection_t* TRI_GetCollectionTransaction (TRI_transaction_t co /// @brief add a collection to a transaction //////////////////////////////////////////////////////////////////////////////// -int TRI_AddCollectionTransaction (TRI_transaction_t* const, +int TRI_AddCollectionTransaction (TRI_transaction_t*, const TRI_voc_cid_t, const TRI_transaction_type_e, const int); diff --git a/arangod/Wal/LogfileManager.cpp b/arangod/Wal/LogfileManager.cpp index 122248641c..c64725ba5a 100644 --- a/arangod/Wal/LogfileManager.cpp +++ b/arangod/Wal/LogfileManager.cpp @@ -327,10 +327,10 @@ void LogfileManager::stop () { // ----------------------------------------------------------------------------- //////////////////////////////////////////////////////////////////////////////// -/// @brief registers a WAL marker protector +/// @brief registers a transaction //////////////////////////////////////////////////////////////////////////////// -bool LogfileManager::registerMarkerProtector (TRI_voc_tid_t id) { +bool LogfileManager::registerTransaction (TRI_voc_tid_t id) { { WRITE_LOCKER(_logfilesLock); @@ -344,13 +344,15 @@ std::cout << "ACQUIRED PROTECTOR FOR TRANSACTION " << id << "\n"; } //////////////////////////////////////////////////////////////////////////////// -/// @brief unregisters a WAL marker protector +/// @brief unregisters a transaction //////////////////////////////////////////////////////////////////////////////// -void LogfileManager::unregisterMarkerProtector (TRI_voc_tid_t id) { +void LogfileManager::unregisterTransaction (TRI_voc_tid_t id, + bool markAsFailed) { WRITE_LOCKER(_logfilesLock); _transactions.erase(id); + // TODO: handle markAsFailed std::cout << "RELEASED PROTECTOR FOR TRANSACTION " << id << "\n"; } diff --git a/arangod/Wal/LogfileManager.h b/arangod/Wal/LogfileManager.h index b5055734cb..62b756e17d 100644 --- a/arangod/Wal/LogfileManager.h +++ b/arangod/Wal/LogfileManager.h @@ -187,16 +187,17 @@ namespace triagens { } //////////////////////////////////////////////////////////////////////////////// -/// @brief registers a WAL marker protector +/// @brief registers a transaction //////////////////////////////////////////////////////////////////////////////// - bool registerMarkerProtector (TRI_voc_tid_t); + bool registerTransaction (TRI_voc_tid_t); //////////////////////////////////////////////////////////////////////////////// -/// @brief unregisters a WAL marker protector +/// @brief unregisters a transaction //////////////////////////////////////////////////////////////////////////////// - void unregisterMarkerProtector (TRI_voc_tid_t); + void unregisterTransaction (TRI_voc_tid_t, + bool); //////////////////////////////////////////////////////////////////////////////// /// @brief whether or not it is currently allowed to create an additional