diff --git a/arangod/MMFiles/MMFilesTransactionCollection.cpp b/arangod/MMFiles/MMFilesTransactionCollection.cpp index 78d60494d1..0d184fd21f 100644 --- a/arangod/MMFiles/MMFilesTransactionCollection.cpp +++ b/arangod/MMFiles/MMFilesTransactionCollection.cpp @@ -205,10 +205,10 @@ int MMFilesTransactionCollection::use(int nestingLevel) { // use and usage-lock TRI_vocbase_col_status_e status; LOG_TRX(_transaction, nestingLevel) << "using collection " << _cid; - _collection = _transaction->_vocbase->useCollection(_cid, status); + _collection = _transaction->vocbase()->useCollection(_cid, status); } else { // use without usage-lock (lock already set externally) - _collection = _transaction->_vocbase->lookupCollection(_cid); + _collection = _transaction->vocbase()->lookupCollection(_cid); if (_collection == nullptr) { return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND; @@ -299,7 +299,7 @@ void MMFilesTransactionCollection::release() { // unuse collection, remove usage-lock LOG_TRX(_transaction, 0) << "unusing collection " << _cid; - _transaction->_vocbase->releaseCollection(_collection); + _transaction->vocbase()->releaseCollection(_collection); _collection = nullptr; } } @@ -332,7 +332,7 @@ int MMFilesTransactionCollection::doLock(AccessMode::Type type, int nestingLevel auto physical = static_cast(collection->getPhysical()); TRI_ASSERT(physical != nullptr); - double timeout = _transaction->_timeout; + double timeout = _transaction->timeout(); if (_transaction->_hints.has(transaction::Hints::Hint::TRY_LOCK)) { // give up early if we cannot acquire the lock instantly timeout = 0.00000001; diff --git a/arangod/StorageEngine/TransactionState.h b/arangod/StorageEngine/TransactionState.h index 4ad99520df..1e52e507ea 100644 --- a/arangod/StorageEngine/TransactionState.h +++ b/arangod/StorageEngine/TransactionState.h @@ -36,11 +36,11 @@ #ifdef ARANGODB_ENABLE_MAINTAINER_MODE #define LOG_TRX(trx, level) \ - LOG_TOPIC(TRACE, arangodb::Logger::FIXME) << "trx #" << trx->id() << "." << level << " (" << transaction::statusString(trx->_status) << "): " + LOG_TOPIC(TRACE, arangodb::Logger::TRANSACTIONS) << "#" << trx->id() << "." << level << " (" << transaction::statusString(trx->status()) << "): " #else -#define LOG_TRX(...) while (0) LOG_TOPIC(TRACE, arangodb::Logger::FIXME) +#define LOG_TRX(...) while (0) LOG_TOPIC(TRACE, arangodb::Logger::TRANSACTIONS) #endif @@ -69,14 +69,15 @@ class TransactionState { TRI_vocbase_t* vocbase() const { return _vocbase; } TRI_voc_tid_t id() const { return _id; } + transaction::Status status() const { return _status; } double timeout() const { return _timeout; } void timeout(double value) { if (value > 0.0) { _timeout = value; } - } + bool waitForSync() const { return _waitForSync; } void waitForSync(bool value) { _waitForSync = value; } @@ -146,17 +147,12 @@ class TransactionState { /// the transaction void clearQueryCache(); - public: - TRI_vocbase_t* _vocbase; // vocbase - protected: + TRI_vocbase_t* _vocbase; // vocbase TRI_voc_tid_t _id; // local trx id - - public: AccessMode::Type _type; // access type (read|write) transaction::Status _status; // current status - protected: SmallVector::allocator_type::arena_type _arena; // memory for collections SmallVector _collections; // list of participating collections @@ -164,7 +160,10 @@ class TransactionState { public: transaction::Hints _hints; // hints; + public: int _nestingLevel; + + protected: bool _allowImplicitCollections; bool _waitForSync; // whether or not the transaction had a synchronous op bool _beginWritten; // whether or not the begin marker was already written diff --git a/arangod/Transaction/Methods.cpp b/arangod/Transaction/Methods.cpp index b6afa44e87..f53d0313c5 100644 --- a/arangod/Transaction/Methods.cpp +++ b/arangod/Transaction/Methods.cpp @@ -187,10 +187,7 @@ bool transaction::Methods::isSingleOperationTransaction() const { /// @brief get the status of the transaction transaction::Status transaction::Methods::getStatus() const { - if (_state != nullptr) { - return _state->_status; - } - return transaction::Status::UNDEFINED; + return _state->status(); } /// @brief sort ORs for the same attribute so they are in ascending value @@ -766,7 +763,7 @@ int transaction::Methods::begin() { if (_state->isCoordinator()) { if (_nestingLevel == 0) { - _state->_status = transaction::Status::RUNNING; + _state->updateStatus(transaction::Status::RUNNING); } return TRI_ERROR_NO_ERROR; } @@ -783,7 +780,7 @@ int transaction::Methods::commit() { if (_state->isCoordinator()) { if (_nestingLevel == 0) { - _state->_status = transaction::Status::COMMITTED; + _state->updateStatus(transaction::Status::COMMITTED); } return TRI_ERROR_NO_ERROR; } @@ -800,7 +797,7 @@ int transaction::Methods::abort() { if (_state->isCoordinator()) { if (_nestingLevel == 0) { - _state->_status = transaction::Status::ABORTED; + _state->updateStatus(transaction::Status::ABORTED); } return TRI_ERROR_NO_ERROR; diff --git a/lib/Logger/LogTopic.cpp b/lib/Logger/LogTopic.cpp index 2a7ab6f925..1daee19ff7 100644 --- a/lib/Logger/LogTopic.cpp +++ b/lib/Logger/LogTopic.cpp @@ -62,6 +62,7 @@ LogTopic Logger::STARTUP("startup", LogLevel::INFO); LogTopic Logger::SUPERVISION("supervision", LogLevel::INFO); LogTopic Logger::SYSCALL("syscall", LogLevel::WARN); LogTopic Logger::THREADS("threads", LogLevel::WARN); +LogTopic Logger::TRANSACTIONS("trx", LogLevel::WARN); LogTopic Logger::V8("v8", LogLevel::WARN); #ifdef USE_ENTERPRISE @@ -121,6 +122,10 @@ LogTopic::LogTopic(std::string const& name, LogLevel level) _name(name), _level(level) { if (name != "fixme") { + // "fixme" is a remainder from ArangoDB < 3.2, when it was + // allowed to log messages without a topic. From 3.2 onwards, + // logging is always topic-based, and all previously topicless + // log invocations now use the log topic "fixme". _displayName = std::string("{") + name + "} "; } diff --git a/lib/Logger/Logger.h b/lib/Logger/Logger.h index d7f5a3c46c..0480be31a1 100644 --- a/lib/Logger/Logger.h +++ b/lib/Logger/Logger.h @@ -148,6 +148,7 @@ class Logger { static LogTopic SUPERVISION; static LogTopic SYSCALL; static LogTopic THREADS; + static LogTopic TRANSACTIONS; static LogTopic V8; public: