From 2f968d649abace99aa6346e700aabab6268d12d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Gra=CC=88tzer?= Date: Tue, 25 Apr 2017 14:53:59 +0200 Subject: [PATCH 1/3] Fixed build --- arangod/Replication/InitialSyncer.cpp | 37 ++++++++++++++++----------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/arangod/Replication/InitialSyncer.cpp b/arangod/Replication/InitialSyncer.cpp index 938177157e..186a3e84ff 100644 --- a/arangod/Replication/InitialSyncer.cpp +++ b/arangod/Replication/InitialSyncer.cpp @@ -42,7 +42,7 @@ #include "RestServer/DatabaseFeature.h" #include "SimpleHttpClient/SimpleHttpClient.h" #include "SimpleHttpClient/SimpleHttpResult.h" -#include "StorageEngine/EngineSelectorFeature.h" b +#include "StorageEngine/EngineSelectorFeature.h" #include "Indexes/IndexIterator.h" #include "StorageEngine/StorageEngine.h" #include "Transaction/Helpers.h" @@ -1211,6 +1211,7 @@ int InitialSyncer::handleSyncKeysRocksDB(arangodb::LogicalCollection* col, // chunk keys + revisionId std::vector> markers; bool foundLowKey = false; + bool syncedRange = false; auto resetChunk = [&] () -> void { sendExtendBatch(); @@ -1246,6 +1247,7 @@ int InitialSyncer::handleSyncKeysRocksDB(arangodb::LogicalCollection* col, hashString = hashSlice.copyString(); localHash = 0x012345678; foundLowKey = false; + syncedRange = false; }; // set to first chunk resetChunk(); @@ -1253,7 +1255,7 @@ int InitialSyncer::handleSyncKeysRocksDB(arangodb::LogicalCollection* col, std::function parseDoc = [&] (VPackSlice doc, VPackSlice key) { - bool rangeUneqal = false; + bool rangeUneqal = true; bool nextChunk = false; int cmp1 = key.compareString(lowKey.data(), lowKey.length()); @@ -1268,7 +1270,6 @@ int InitialSyncer::handleSyncKeysRocksDB(arangodb::LogicalCollection* col, if (cmp1 == 0) { foundLowKey = true; } else if (!foundLowKey && cmp1 > 0) { - rangeUneqal = true; nextChunk = true; } @@ -1284,7 +1285,6 @@ int InitialSyncer::handleSyncKeysRocksDB(arangodb::LogicalCollection* col, nextChunk = true; } } else if (cmp2 == 0) { - rangeUneqal = true; nextChunk = true; } } else if (cmp2 > 0) { // higher than highKey @@ -1294,23 +1294,30 @@ int InitialSyncer::handleSyncKeysRocksDB(arangodb::LogicalCollection* col, nextChunk = true; } - if (rangeUneqal) { - int res = syncChunkRocksDB(&trx, keysId, currentChunkId, - lowKey, highKey, - markers, errorMsg); - if (res != TRI_ERROR_NO_ERROR) { - THROW_ARANGO_EXCEPTION(res); - } - } TRI_ASSERT(!rangeUneqal || rangeUneqal && nextChunk); // A => B - if (nextChunk && currentChunkId+1 < numChunks) { - currentChunkId++;// we are out of range, see next chunk - resetChunk(); + if (nextChunk) { + if (rangeUneqal && !syncedRange) { + syncedRange = true; + int res = syncChunkRocksDB(&trx, keysId, currentChunkId, + lowKey, highKey, + markers, errorMsg); + if (res != TRI_ERROR_NO_ERROR) { + THROW_ARANGO_EXCEPTION(res); + } + } + + if (currentChunkId+1 < numChunks) { + currentChunkId++;// we are out of range, see next chunk + resetChunk(); + } // key is higher than upper bound, recheck the current document if (cmp2 > 0) { parseDoc(doc, key); } + } else { + LOG_TOPIC(ERR, Logger::FIXME) << "Did not expect keys higher" + << "than teh highest chunk"; } }; From 26d4fd61db87aba7dfe27bdc95d8ab1bc68aba46 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Tue, 25 Apr 2017 14:56:00 +0200 Subject: [PATCH 2/3] fix compile warnings --- arangod/Replication/InitialSyncer.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/arangod/Replication/InitialSyncer.cpp b/arangod/Replication/InitialSyncer.cpp index 186a3e84ff..92456b3f09 100644 --- a/arangod/Replication/InitialSyncer.cpp +++ b/arangod/Replication/InitialSyncer.cpp @@ -1255,7 +1255,7 @@ int InitialSyncer::handleSyncKeysRocksDB(arangodb::LogicalCollection* col, std::function parseDoc = [&] (VPackSlice doc, VPackSlice key) { - bool rangeUneqal = true; + bool rangeUnequal = true; bool nextChunk = false; int cmp1 = key.compareString(lowKey.data(), lowKey.length()); @@ -1281,7 +1281,7 @@ int InitialSyncer::handleSyncKeysRocksDB(arangodb::LogicalCollection* col, markers.emplace_back(key.copyString(), TRI_ExtractRevisionId(doc)); if (cmp2 == 0) {// found highKey - rangeUneqal = std::to_string(localHash) != hashString; + rangeUnequal = std::to_string(localHash) != hashString; nextChunk = true; } } else if (cmp2 == 0) { @@ -1290,13 +1290,13 @@ int InitialSyncer::handleSyncKeysRocksDB(arangodb::LogicalCollection* col, } else if (cmp2 > 0) { // higher than highKey // current range was unequal and we did not find the // high key. Load range and skip to next - rangeUneqal = true; + rangeUnequal = true; nextChunk = true; } - TRI_ASSERT(!rangeUneqal || rangeUneqal && nextChunk); // A => B + TRI_ASSERT(!rangeUnequal || (rangeUnequal && nextChunk)); // A => B if (nextChunk) { - if (rangeUneqal && !syncedRange) { + if (rangeUnequal && !syncedRange) { syncedRange = true; int res = syncChunkRocksDB(&trx, keysId, currentChunkId, lowKey, highKey, From da5102ce6a48c217764eed4da0f4e6f8ac861346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Gra=CC=88tzer?= Date: Tue, 25 Apr 2017 15:05:18 +0200 Subject: [PATCH 3/3] fixed warning --- arangod/Replication/InitialSyncer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arangod/Replication/InitialSyncer.cpp b/arangod/Replication/InitialSyncer.cpp index 186a3e84ff..d17120e5e5 100644 --- a/arangod/Replication/InitialSyncer.cpp +++ b/arangod/Replication/InitialSyncer.cpp @@ -1294,7 +1294,7 @@ int InitialSyncer::handleSyncKeysRocksDB(arangodb::LogicalCollection* col, nextChunk = true; } - TRI_ASSERT(!rangeUneqal || rangeUneqal && nextChunk); // A => B + TRI_ASSERT(!rangeUneqal || (rangeUneqal && nextChunk)); // A => B if (nextChunk) { if (rangeUneqal && !syncedRange) { syncedRange = true;