1
0
Fork 0

This commit should fix cluster startup problems

This commit is contained in:
Michael Hackstein 2017-02-21 13:22:29 +01:00
parent 17effdc065
commit aacbb3e4cf
3 changed files with 15 additions and 30 deletions

View File

@ -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<MMFilesCollection*>(
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;
}
}
}

View File

@ -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<arangodb::Index> idx;
res = physical->restoreIndex(&trx, indexSlice, idx);
if (res == TRI_ERROR_NO_ERROR) {
res = physical->saveIndex(&trx, idx);
}
res = trx.finish(res);
return res;

View File

@ -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 =