1
0
Fork 0

protect some properties

This commit is contained in:
jsteemann 2017-02-15 11:14:56 +01:00
parent b4027dc02c
commit c69eb0a7d5
5 changed files with 22 additions and 20 deletions

View File

@ -205,10 +205,10 @@ int MMFilesTransactionCollection::use(int nestingLevel) {
// use and usage-lock // use and usage-lock
TRI_vocbase_col_status_e status; TRI_vocbase_col_status_e status;
LOG_TRX(_transaction, nestingLevel) << "using collection " << _cid; LOG_TRX(_transaction, nestingLevel) << "using collection " << _cid;
_collection = _transaction->_vocbase->useCollection(_cid, status); _collection = _transaction->vocbase()->useCollection(_cid, status);
} else { } else {
// use without usage-lock (lock already set externally) // use without usage-lock (lock already set externally)
_collection = _transaction->_vocbase->lookupCollection(_cid); _collection = _transaction->vocbase()->lookupCollection(_cid);
if (_collection == nullptr) { if (_collection == nullptr) {
return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND; return TRI_ERROR_ARANGO_COLLECTION_NOT_FOUND;
@ -299,7 +299,7 @@ void MMFilesTransactionCollection::release() {
// unuse collection, remove usage-lock // unuse collection, remove usage-lock
LOG_TRX(_transaction, 0) << "unusing collection " << _cid; LOG_TRX(_transaction, 0) << "unusing collection " << _cid;
_transaction->_vocbase->releaseCollection(_collection); _transaction->vocbase()->releaseCollection(_collection);
_collection = nullptr; _collection = nullptr;
} }
} }
@ -332,7 +332,7 @@ int MMFilesTransactionCollection::doLock(AccessMode::Type type, int nestingLevel
auto physical = static_cast<MMFilesCollection*>(collection->getPhysical()); auto physical = static_cast<MMFilesCollection*>(collection->getPhysical());
TRI_ASSERT(physical != nullptr); TRI_ASSERT(physical != nullptr);
double timeout = _transaction->_timeout; double timeout = _transaction->timeout();
if (_transaction->_hints.has(transaction::Hints::Hint::TRY_LOCK)) { if (_transaction->_hints.has(transaction::Hints::Hint::TRY_LOCK)) {
// give up early if we cannot acquire the lock instantly // give up early if we cannot acquire the lock instantly
timeout = 0.00000001; timeout = 0.00000001;

View File

@ -36,11 +36,11 @@
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE #ifdef ARANGODB_ENABLE_MAINTAINER_MODE
#define LOG_TRX(trx, level) \ #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 #else
#define LOG_TRX(...) while (0) LOG_TOPIC(TRACE, arangodb::Logger::FIXME) #define LOG_TRX(...) while (0) LOG_TOPIC(TRACE, arangodb::Logger::TRANSACTIONS)
#endif #endif
@ -69,14 +69,15 @@ class TransactionState {
TRI_vocbase_t* vocbase() const { return _vocbase; } TRI_vocbase_t* vocbase() const { return _vocbase; }
TRI_voc_tid_t id() const { return _id; } TRI_voc_tid_t id() const { return _id; }
transaction::Status status() const { return _status; }
double timeout() const { return _timeout; } double timeout() const { return _timeout; }
void timeout(double value) { void timeout(double value) {
if (value > 0.0) { if (value > 0.0) {
_timeout = value; _timeout = value;
} }
} }
bool waitForSync() const { return _waitForSync; } bool waitForSync() const { return _waitForSync; }
void waitForSync(bool value) { _waitForSync = value; } void waitForSync(bool value) { _waitForSync = value; }
@ -146,17 +147,12 @@ class TransactionState {
/// the transaction /// the transaction
void clearQueryCache(); void clearQueryCache();
public:
TRI_vocbase_t* _vocbase; // vocbase
protected: protected:
TRI_vocbase_t* _vocbase; // vocbase
TRI_voc_tid_t _id; // local trx id TRI_voc_tid_t _id; // local trx id
public:
AccessMode::Type _type; // access type (read|write) AccessMode::Type _type; // access type (read|write)
transaction::Status _status; // current status transaction::Status _status; // current status
protected:
SmallVector<TransactionCollection*>::allocator_type::arena_type _arena; // memory for collections SmallVector<TransactionCollection*>::allocator_type::arena_type _arena; // memory for collections
SmallVector<TransactionCollection*> _collections; // list of participating collections SmallVector<TransactionCollection*> _collections; // list of participating collections
@ -164,7 +160,10 @@ class TransactionState {
public: public:
transaction::Hints _hints; // hints; transaction::Hints _hints; // hints;
public:
int _nestingLevel; int _nestingLevel;
protected:
bool _allowImplicitCollections; bool _allowImplicitCollections;
bool _waitForSync; // whether or not the transaction had a synchronous op bool _waitForSync; // whether or not the transaction had a synchronous op
bool _beginWritten; // whether or not the begin marker was already written bool _beginWritten; // whether or not the begin marker was already written

View File

@ -187,10 +187,7 @@ bool transaction::Methods::isSingleOperationTransaction() const {
/// @brief get the status of the transaction /// @brief get the status of the transaction
transaction::Status transaction::Methods::getStatus() const { transaction::Status transaction::Methods::getStatus() const {
if (_state != nullptr) { return _state->status();
return _state->_status;
}
return transaction::Status::UNDEFINED;
} }
/// @brief sort ORs for the same attribute so they are in ascending value /// @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 (_state->isCoordinator()) {
if (_nestingLevel == 0) { if (_nestingLevel == 0) {
_state->_status = transaction::Status::RUNNING; _state->updateStatus(transaction::Status::RUNNING);
} }
return TRI_ERROR_NO_ERROR; return TRI_ERROR_NO_ERROR;
} }
@ -783,7 +780,7 @@ int transaction::Methods::commit() {
if (_state->isCoordinator()) { if (_state->isCoordinator()) {
if (_nestingLevel == 0) { if (_nestingLevel == 0) {
_state->_status = transaction::Status::COMMITTED; _state->updateStatus(transaction::Status::COMMITTED);
} }
return TRI_ERROR_NO_ERROR; return TRI_ERROR_NO_ERROR;
} }
@ -800,7 +797,7 @@ int transaction::Methods::abort() {
if (_state->isCoordinator()) { if (_state->isCoordinator()) {
if (_nestingLevel == 0) { if (_nestingLevel == 0) {
_state->_status = transaction::Status::ABORTED; _state->updateStatus(transaction::Status::ABORTED);
} }
return TRI_ERROR_NO_ERROR; return TRI_ERROR_NO_ERROR;

View File

@ -62,6 +62,7 @@ LogTopic Logger::STARTUP("startup", LogLevel::INFO);
LogTopic Logger::SUPERVISION("supervision", LogLevel::INFO); LogTopic Logger::SUPERVISION("supervision", LogLevel::INFO);
LogTopic Logger::SYSCALL("syscall", LogLevel::WARN); LogTopic Logger::SYSCALL("syscall", LogLevel::WARN);
LogTopic Logger::THREADS("threads", LogLevel::WARN); LogTopic Logger::THREADS("threads", LogLevel::WARN);
LogTopic Logger::TRANSACTIONS("trx", LogLevel::WARN);
LogTopic Logger::V8("v8", LogLevel::WARN); LogTopic Logger::V8("v8", LogLevel::WARN);
#ifdef USE_ENTERPRISE #ifdef USE_ENTERPRISE
@ -121,6 +122,10 @@ LogTopic::LogTopic(std::string const& name, LogLevel level)
_name(name), _name(name),
_level(level) { _level(level) {
if (name != "fixme") { 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 + "} "; _displayName = std::string("{") + name + "} ";
} }

View File

@ -148,6 +148,7 @@ class Logger {
static LogTopic SUPERVISION; static LogTopic SUPERVISION;
static LogTopic SYSCALL; static LogTopic SYSCALL;
static LogTopic THREADS; static LogTopic THREADS;
static LogTopic TRANSACTIONS;
static LogTopic V8; static LogTopic V8;
public: public: