From 0d38d2c287d9297f5b95c8f75af4374e84ee1938 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Mon, 27 Mar 2017 11:30:30 +0200 Subject: [PATCH] finalize insert() --- arangod/RocksDBEngine/RocksDBCollection.cpp | 24 +++++++++++++++---- .../RocksDBTransactionCollection.cpp | 4 ---- .../RocksDBTransactionCollection.h | 2 -- arangod/Transaction/Methods.cpp | 1 - 4 files changed, 20 insertions(+), 11 deletions(-) diff --git a/arangod/RocksDBEngine/RocksDBCollection.cpp b/arangod/RocksDBEngine/RocksDBCollection.cpp index 1be1dacb5e..01f0650ff1 100644 --- a/arangod/RocksDBEngine/RocksDBCollection.cpp +++ b/arangod/RocksDBEngine/RocksDBCollection.cpp @@ -34,6 +34,7 @@ #include "RocksDBEngine/RocksDBPrimaryMockIndex.h" #include "StorageEngine/EngineSelectorFeature.h" #include "StorageEngine/StorageEngine.h" +#include "StorageEngine/TransactionState.h" #include "Transaction/Helpers.h" #include "Utils/OperationOptions.h" #include "VocBase/LogicalCollection.h" @@ -389,7 +390,8 @@ int RocksDBCollection::insert(arangodb::transaction::Methods* trx, // } // store the tick that was used for writing the document -// resultMarkerTick = operation.tick(); + // note that we don't need it for this engine + resultMarkerTick = 0; } return res; } @@ -571,11 +573,25 @@ int RocksDBCollection::insertDocument(arangodb::transaction::Methods* trx, } } - // TODO: handle waitForSync here? - if (result != TRI_ERROR_NO_ERROR) { + if (result != TRI_ERROR_NO_ERROR) { + rocksdb::WriteOptions writeOptions; + + if (_logicalCollection->waitForSync()) { + waitForSync = true; + } + + if (waitForSync) { + trx->state()->waitForSync(true); + + // handle waitForSync for single operations here + if (trx->state()->isSingleOperation()) { + writeOptions.sync = true; + } + } + StorageEngine* engine = EngineSelectorFeature::ENGINE; rocksdb::TransactionDB* db = static_cast(engine)->db(); - db->Write(rocksdb::WriteOptions(), &writeBatch); + db->Write(writeOptions, &writeBatch); } return result; diff --git a/arangod/RocksDBEngine/RocksDBTransactionCollection.cpp b/arangod/RocksDBEngine/RocksDBTransactionCollection.cpp index 5980a2891c..04ee463332 100644 --- a/arangod/RocksDBEngine/RocksDBTransactionCollection.cpp +++ b/arangod/RocksDBEngine/RocksDBTransactionCollection.cpp @@ -38,7 +38,6 @@ RocksDBTransactionCollection::RocksDBTransactionCollection(TransactionState* trx TRI_voc_cid_t cid, AccessMode::Type accessType) : TransactionCollection(trx, cid), - _waitForSync(false), _accessType(accessType), _numOperations(0) {} @@ -137,9 +136,6 @@ int RocksDBTransactionCollection::use(int nestingLevel) { !LogicalCollection::IsSystemName(_collection->name())) { return TRI_ERROR_ARANGO_READ_ONLY; } - - // store the waitForSync property - _waitForSync = _collection->waitForSync(); } return TRI_ERROR_NO_ERROR; diff --git a/arangod/RocksDBEngine/RocksDBTransactionCollection.h b/arangod/RocksDBEngine/RocksDBTransactionCollection.h index 4c32ed71c4..610cdcb0d6 100644 --- a/arangod/RocksDBEngine/RocksDBTransactionCollection.h +++ b/arangod/RocksDBEngine/RocksDBTransactionCollection.h @@ -70,8 +70,6 @@ class RocksDBTransactionCollection final : public TransactionCollection { void release() override; private: - bool _waitForSync; // whether or not the collection has waitForSync - AccessMode::Type _accessType; // access type (read|write) uint64_t _numOperations; }; diff --git a/arangod/Transaction/Methods.cpp b/arangod/Transaction/Methods.cpp index 7c75c30c22..de4f3673eb 100644 --- a/arangod/Transaction/Methods.cpp +++ b/arangod/Transaction/Methods.cpp @@ -2578,7 +2578,6 @@ arangodb::LogicalCollection* transaction::Methods::documentCollection( TRI_ASSERT(trxCollection != nullptr); TRI_ASSERT(_state->status() == transaction::Status::RUNNING); - LOG_TOPIC(ERR, Logger::FIXME) << "accessing collection " << trxCollection->id() << ": " << trxCollection; TRI_ASSERT(trxCollection->collection() != nullptr); return trxCollection->collection();