Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 46c01ce

Browse files
committed
Fix waiting for plan version for 3.11.
1 parent 06972e3 commit 46c01ce

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

‎arangod/RestHandler/RestIndexHandler.cpp

+27-11
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "Containers/FlatHashSet.h"
3232
#include "Futures/Utilities.h"
3333
#include "Logger/LogMacros.h"
34+
#include "Logger/LogTopic.h"
3435
#include "Network/Methods.h"
3536
#include "Network/NetworkFeature.h"
3637
#include "RestServer/VocbaseContext.h"
@@ -217,24 +218,39 @@ RestStatus RestIndexHandler::getIndexes() {
217218

218219
// first fetch list of planned indexes. this includes all indexes,
219220
// even the in-progress indexes
220-
std::string ap = absl::StrCat("Plan/Collections/", _vocbase.name(), "/",
221-
coll->planId().id(), "/indexes");
221+
std::string const ap = absl::StrCat("Plan/Collections/", _vocbase.name(),
222+
"/", coll->planId().id(), "/indexes");
222223
auto& ac = _vocbase.server().getFeature<ClusterFeature>().agencyCache();
223224
// we need to wait for the latest commit index here, because otherwise
224225
// we may not see all indexes that were declared ready by the
225226
// supervision.
226227
ac.waitForLatestCommitIndex().get();
227228

228-
auto [plannedIndexes, idx] = ac.get(ap);
229+
auto [plannedIndexes, idx1] = ac.get(ap);
230+
auto [planVersion, idx2] = ac.get("Plan/Version");
229231

230-
// Let's wait until the ClusterInfo has processed at least this
231-
// Raft index. This means that if an index is no longer `isBuilding`
232-
// in the agency Plan, then ClusterInfo should know it.
233-
_vocbase.server()
234-
.getFeature<ClusterFeature>()
235-
.clusterInfo()
236-
.waitForPlan(idx)
237-
.wait();
232+
uint64_t planVersionInt = 0;
233+
try {
234+
if (planVersion->slice().isNumber()) {
235+
planVersionInt = planVersion->slice().getNumber<uint64_t>();
236+
}
237+
} catch (std::exception const&) {
238+
}
239+
240+
if (planVersionInt > 0) {
241+
// Let's wait until the ClusterInfo has processed at least this
242+
// Raft index. This means that if an index is no longer `isBuilding`
243+
// in the agency Plan, then ClusterInfo should know it.
244+
_vocbase.server()
245+
.getFeature<ClusterFeature>()
246+
.clusterInfo()
247+
.waitForPlanVersion(planVersionInt)
248+
.wait();
249+
} else {
250+
LOG_TOPIC("12536", WARN, Logger::CLUSTER)
251+
<< "Expected numberin /arango/Plan/Version, instead found: "
252+
<< planVersion->slice().toJson();
253+
}
238254

239255
// now fetch list of ready indexes
240256
VPackBuilder indexes;

0 commit comments

Comments
 (0)