diff --git a/arangod/Replication/InitialSyncer.cpp b/arangod/Replication/InitialSyncer.cpp index 356c9171b1..451b37b813 100644 --- a/arangod/Replication/InitialSyncer.cpp +++ b/arangod/Replication/InitialSyncer.cpp @@ -33,7 +33,10 @@ #include "RestServer/DatabaseFeature.h" #include "SimpleHttpClient/SimpleHttpClient.h" #include "SimpleHttpClient/SimpleHttpResult.h" +#include "StorageEngine/EngineSelectorFeature.h" +#include "StorageEngine/StorageEngine.h" #include "Utils/CollectionGuard.h" +#include "MMFiles/MMFilesCollection.h" #include "MMFiles/MMFilesDatafileHelper.h" #include "MMFiles/MMFilesIndexElement.h" #include "MMFiles/MMFilesPrimaryIndex.h" @@ -1073,13 +1076,13 @@ int InitialSyncer::handleSyncKeys(arangodb::LogicalCollection* col, // We do not take responsibility for the index. // The LogicalCollection is protected by trx. // Neither it nor it's indexes can be invalidated - auto idx = trx.documentCollection()->primaryIndex(); - markers.reserve(idx->size()); + + markers.reserve(trx.documentCollection()->numberDocuments()); uint64_t iterations = 0; ManagedDocumentResult mmdr; - trx.invokeOnAllElements(trx.name(), [this, &trx, &mmdr, &markers, &iterations, &idx](DocumentIdentifierToken const& token) { - if (idx->collection()->readDocument(&trx, token, mmdr)) { + trx.invokeOnAllElements(trx.name(), [this, &trx, &mmdr, &markers, &iterations](DocumentIdentifierToken const& token) { + if (trx.documentCollection()->readDocument(&trx, token, mmdr)) { markers.emplace_back(mmdr.vpack()); if (++iterations % 10000 == 0) { @@ -1286,7 +1289,11 @@ int InitialSyncer::handleSyncKeys(arangodb::LogicalCollection* col, // We do not take responsibility for the index. // The LogicalCollection is protected by trx. // Neither it nor it's indexes can be invalidated - auto idx = trx.documentCollection()->primaryIndex(); + + // TODO Move to MMFiles + auto physical = static_cast( + trx.documentCollection()->getPhysical()); + auto idx = physical->primaryIndex(); size_t const currentChunkId = i; progress = "processing keys chunk " + std::to_string(currentChunkId) + @@ -1886,16 +1893,6 @@ int InitialSyncer::handleCollection(VPackSlice const& parameters, errorMsg = "could not create index: " + std::string(TRI_errno_string(res)); break; - } else { - TRI_ASSERT(idx != nullptr); - - res = physical->saveIndex(&trx, idx); - - if (res != TRI_ERROR_NO_ERROR) { - errorMsg = "could not save index: " + - std::string(TRI_errno_string(res)); - break; - } } } diff --git a/arangod/Replication/Syncer.cpp b/arangod/Replication/Syncer.cpp index 47bb40d10c..95b9c8a4f6 100644 --- a/arangod/Replication/Syncer.cpp +++ b/arangod/Replication/Syncer.cpp @@ -29,6 +29,8 @@ #include "SimpleHttpClient/GeneralClientConnection.h" #include "SimpleHttpClient/SimpleHttpClient.h" #include "SimpleHttpClient/SimpleHttpResult.h" +#include "StorageEngine/EngineSelectorFeature.h" +#include "StorageEngine/StorageEngine.h" #include "StorageEngine/TransactionState.h" #include "Utils/CollectionGuard.h" #include "Utils/OperationOptions.h" @@ -565,11 +567,6 @@ int Syncer::createIndex(VPackSlice const& slice) { TRI_ASSERT(physical != nullptr); std::shared_ptr idx; res = physical->restoreIndex(&trx, indexSlice, idx); - - if (res == TRI_ERROR_NO_ERROR) { - res = physical->saveIndex(&trx, idx); - } - res = trx.finish(res); return res; diff --git a/arangod/RestHandler/RestReplicationHandler.cpp b/arangod/RestHandler/RestReplicationHandler.cpp index 51b6b43abf..f212326f52 100644 --- a/arangod/RestHandler/RestReplicationHandler.cpp +++ b/arangod/RestHandler/RestReplicationHandler.cpp @@ -1779,17 +1779,8 @@ int RestReplicationHandler::processRestoreIndexes(VPackSlice const& collection, errorMsg = "could not create index: " + std::string(TRI_errno_string(res)); break; - } else { - TRI_ASSERT(idx != nullptr); - - res = physical->saveIndex(&trx, idx); - - if (res != TRI_ERROR_NO_ERROR) { - errorMsg = - "could not save index: " + std::string(TRI_errno_string(res)); - break; - } } + TRI_ASSERT(idx != nullptr); } } catch (arangodb::basics::Exception const& ex) { errorMsg =