mirror of https://gitee.com/bigwinds/arangodb
notify collections about transaction status changes
This commit is contained in:
parent
ccc7c3665b
commit
28e0f8bd09
|
@ -96,7 +96,6 @@ namespace triagens {
|
|||
|
||||
TRI_ASSERT_DEBUG(_vocbase != 0);
|
||||
|
||||
// normally this will return TRI_ERROR_NO_ERROR
|
||||
this->setupTransaction();
|
||||
}
|
||||
|
||||
|
@ -236,16 +235,6 @@ namespace triagens {
|
|||
return res;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief dump the transaction
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/*
|
||||
void dump () {
|
||||
if (_trx != 0) {
|
||||
TRI_DumpTransaction(_trx);
|
||||
}
|
||||
}
|
||||
*/
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -1035,7 +1035,6 @@ static int UpdateDocument (TRI_document_collection_t* document,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -1234,6 +1233,42 @@ static void DebugHeaderDocumentCollection (TRI_document_collection_t* collection
|
|||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief notify a collection about transaction begin/commit/abort
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static int NotifyTransaction (TRI_primary_collection_t* primary,
|
||||
TRI_transaction_status_e status) {
|
||||
TRI_document_collection_t* document;
|
||||
size_t i, n;
|
||||
|
||||
document = (TRI_document_collection_t*) primary;
|
||||
|
||||
n = document->_allIndexes._length;
|
||||
|
||||
for (i = 0; i < n ; ++i) {
|
||||
TRI_index_t* idx = TRI_AtVectorPointer(&document->_allIndexes, i);
|
||||
|
||||
if (status == TRI_TRANSACTION_RUNNING) {
|
||||
if (idx->beginTransaction != NULL) {
|
||||
idx->beginTransaction(idx, primary);
|
||||
}
|
||||
}
|
||||
else if (status == TRI_TRANSACTION_ABORTED) {
|
||||
if (idx->abortTransaction != NULL) {
|
||||
idx->abortTransaction(idx, primary);
|
||||
}
|
||||
}
|
||||
else if (status == TRI_TRANSACTION_COMMITTED) {
|
||||
if (idx->commitTransaction != NULL) {
|
||||
idx->commitTransaction(idx, primary);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief insert a shaped-json document into the collection
|
||||
/// note: key might be NULL. in this case, a key is auto-generated
|
||||
|
@ -2058,18 +2093,21 @@ static bool InitDocumentCollection (TRI_document_collection_t* collection,
|
|||
TRI_InitCondition(&collection->_journalsCondition);
|
||||
|
||||
// setup methods
|
||||
collection->base.beginRead = BeginRead;
|
||||
collection->base.endRead = EndRead;
|
||||
collection->base.beginRead = BeginRead;
|
||||
collection->base.endRead = EndRead;
|
||||
|
||||
collection->base.beginWrite = BeginWrite;
|
||||
collection->base.endWrite = EndWrite;
|
||||
collection->base.beginWrite = BeginWrite;
|
||||
collection->base.endWrite = EndWrite;
|
||||
|
||||
collection->base.insert = InsertShapedJson;
|
||||
collection->base.read = ReadShapedJson;
|
||||
collection->base.update = UpdateShapedJson;
|
||||
collection->base.destroy = DeleteShapedJson;
|
||||
collection->base.notifyTransaction = NotifyTransaction;
|
||||
|
||||
collection->cleanupIndexes = CleanupIndexes;
|
||||
// crud methods
|
||||
collection->base.insert = InsertShapedJson;
|
||||
collection->base.read = ReadShapedJson;
|
||||
collection->base.update = UpdateShapedJson;
|
||||
collection->base.destroy = DeleteShapedJson;
|
||||
|
||||
collection->cleanupIndexes = CleanupIndexes;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -293,6 +293,8 @@ typedef struct TRI_primary_collection_s {
|
|||
int (*beginWrite) (struct TRI_primary_collection_s*);
|
||||
int (*endWrite) (struct TRI_primary_collection_s*);
|
||||
|
||||
int (*notifyTransaction) (struct TRI_primary_collection_s*, TRI_transaction_status_e);
|
||||
|
||||
int (*insert) (struct TRI_doc_operation_context_s*, const TRI_voc_key_t, TRI_doc_mptr_t*, TRI_df_marker_type_e, TRI_shaped_json_t const*, void const*, const bool, const bool);
|
||||
|
||||
int (*read) (struct TRI_doc_operation_context_s*, const TRI_voc_key_t, TRI_doc_mptr_t*, const bool);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -34,7 +34,6 @@
|
|||
#include "BasicsC/hashes.h"
|
||||
#include "BasicsC/locks.h"
|
||||
#include "BasicsC/vector.h"
|
||||
#include "BasicsC/voc-errors.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -103,36 +102,10 @@ TRI_transaction_status_e;
|
|||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief an entry in the transactions list
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if 0
|
||||
typedef struct TRI_transaction_list_entry_s {
|
||||
TRI_transaction_local_id_t _id;
|
||||
TRI_transaction_status_e _status;
|
||||
}
|
||||
TRI_transaction_list_entry_t;
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief transaction list typedef
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if 0
|
||||
typedef struct TRI_transaction_list_s {
|
||||
TRI_vector_t _vector; // vector containing trx_list_entry_t
|
||||
size_t _numRunning; // number of currently running trx
|
||||
size_t _numAborted; // number of already aborted trx
|
||||
}
|
||||
TRI_transaction_list_t;
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
// --SECTION-- TRANSACTION CONTEXT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
@ -166,19 +139,6 @@ typedef struct TRI_transaction_context_s {
|
|||
}
|
||||
TRI_transaction_context_t;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief global instance of a collection in the transaction system
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if 0
|
||||
typedef struct TRI_transaction_collection_global_s {
|
||||
TRI_transaction_cid_t _cid; // collection id
|
||||
TRI_transaction_list_t _writeTransactions; // list of write-transactions currently going on for the collection
|
||||
TRI_mutex_t _writeLock; // write lock for the collection, used to serialize writes on the same collection
|
||||
}
|
||||
TRI_transaction_collection_global_t;
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -225,14 +185,6 @@ void TRI_FreeTransactionContext (TRI_transaction_context_t* const);
|
|||
void TRI_RemoveCollectionTransactionContext (TRI_transaction_context_t* const,
|
||||
const TRI_transaction_cid_t);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief dump transaction context data
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#if 0
|
||||
void TRI_DumpTransactionContext (TRI_transaction_context_t* const);
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
@ -256,16 +208,9 @@ void TRI_DumpTransactionContext (TRI_transaction_context_t* const);
|
|||
|
||||
typedef struct TRI_transaction_collection_s {
|
||||
TRI_transaction_cid_t _cid; // collection id
|
||||
TRI_transaction_type_e _type; // access type (read|write)
|
||||
TRI_transaction_type_e _accessType; // access type (read|write)
|
||||
int _nestingLevel; // the transaction level that added this collection
|
||||
#if 0
|
||||
TRI_transaction_list_t _writeTransactions; // private copy of other write transactions at transaction start
|
||||
#endif
|
||||
struct TRI_vocbase_col_s* _collection; // vocbase collection pointer
|
||||
#if 0
|
||||
TRI_transaction_collection_global_t* _globalInstance; // pointer to the global instance of the collection in the trx system
|
||||
bool _globalLock; // global collection lock flag (used for write transactions)
|
||||
#endif
|
||||
bool _locked; // collection lock flag
|
||||
}
|
||||
TRI_transaction_collection_t;
|
||||
|
@ -295,7 +240,6 @@ typedef struct TRI_transaction_s {
|
|||
TRI_transaction_context_t* _context; // global context object
|
||||
// TODO: fix
|
||||
uint64_t _id;
|
||||
//TRI_transaction_id_t _id; // id of transaction
|
||||
TRI_transaction_type_e _type; // access type (read|write)
|
||||
TRI_transaction_status_e _status; // current status
|
||||
TRI_vector_pointer_t _collections; // list of participating collections
|
||||
|
@ -342,22 +286,6 @@ void TRI_FreeTransaction (TRI_transaction_t* const);
|
|||
/// @{
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return whether the transaction consists only of a single operation
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_IsSingleOperationTransaction (const TRI_transaction_t* const);
|
||||
*/
|
||||
|
||||
/*
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief return whether the transaction spans multiple write collections
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool TRI_IsMultiCollectionWriteTransaction (const TRI_transaction_t* const);
|
||||
*/
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief dump information about a transaction
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue