Skip to content

Commit f32bc81

Browse files
committed
Fixed endless wait in Coordinator during CreateCollection
for cases where Agency may remove the collection from Plan.
1 parent d2dcac3 commit f32bc81

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

arangod/Cluster/ClusterCollectionMethods.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,31 @@ Result impl(ClusterInfo& ci, ArangodServer& server,
368368

369369
// Now "busy-loop"
370370
while (!server.isStopping()) {
371+
372+
// Between the starting of collection creation process and its
373+
// completion, if the agency supervision momentarily marks the
374+
// coordinator as BAD (maybe because it is unreachable due to n/w
375+
// issues), the agency supervision will delete the collection name(s)
376+
// from Plan/Collections/<database>. When the coordinator comes back,
377+
// it will continue waiting endlessly for the collection(s) that will
378+
// never be created.
379+
//
380+
// Check if the collection name(s) is still present in Plan, report error
381+
// otherwise.
382+
//
383+
{
384+
auto& agencyCache = server.getFeature<ClusterFeature>().agencyCache();
385+
auto baseCollectionPath = std::string("Plan/Collections/") + std::string(databaseName) + "/";
386+
auto [query, index] = agencyCache.get(baseCollectionPath);
387+
auto slice = query->slice();
388+
for (const auto& coll : colls) {
389+
const auto& collId = coll.getCID();
390+
if (!slice.hasKey(collId)) {
391+
callbackInfos->addReport(collId, Result(TRI_ERROR_CLUSTER_COULD_NOT_CREATE_COLLECTION));
392+
}
393+
}
394+
}
395+
371396
auto maybeFinalResult = callbackInfos->getResultIfAllReported();
372397
if (maybeFinalResult.has_value()) {
373398
// We have a final result. we are complete

0 commit comments

Comments
 (0)