@@ -2751,10 +2751,11 @@ Result ClusterInfo::ensureIndexCoordinatorInner( // create index
2751
2751
}
2752
2752
2753
2753
// will contain the error number and message
2754
- auto dbServerResult = std::make_shared<std:: atomic<int >> (-1 );
2754
+ std::atomic<int > dbServerResult (-1 );
2755
2755
std::shared_ptr<std::string> errMsg = std::make_shared<std::string>();
2756
2756
2757
- std::function<bool (VPackSlice const & result)> dbServerChanged = [=](VPackSlice const & result) {
2757
+ std::function<bool (VPackSlice const & result)> dbServerChanged = [=, &dbServerResult](
2758
+ VPackSlice const & result) {
2758
2759
if (!result.isObject () || result.length () != numberOfShards) {
2759
2760
return true ;
2760
2761
}
@@ -2786,7 +2787,7 @@ Result ClusterInfo::ensureIndexCoordinatorInner( // create index
2786
2787
// error otherwise
2787
2788
int errNum = arangodb::basics::VelocyPackHelper::readNumericValue<int >(
2788
2789
v, StaticStrings::ErrorNum, TRI_ERROR_ARANGO_INDEX_CREATION_FAILED);
2789
- dbServerResult-> store (errNum, std::memory_order_release);
2790
+ dbServerResult. store (errNum, std::memory_order_release);
2790
2791
return true ;
2791
2792
}
2792
2793
@@ -2797,7 +2798,7 @@ Result ClusterInfo::ensureIndexCoordinatorInner( // create index
2797
2798
}
2798
2799
2799
2800
if (found == (size_t )numberOfShards) {
2800
- dbServerResult-> store (setErrormsg (TRI_ERROR_NO_ERROR, *errMsg), std::memory_order_release);
2801
+ dbServerResult. store (setErrormsg (TRI_ERROR_NO_ERROR, *errMsg), std::memory_order_release);
2801
2802
}
2802
2803
2803
2804
return true ;
@@ -2828,12 +2829,12 @@ Result ClusterInfo::ensureIndexCoordinatorInner( // create index
2828
2829
// by a mutex. We use the mutex of the condition variable in the
2829
2830
// AgencyCallback for this.
2830
2831
std::string where = " Current/Collections/" + databaseName + " /" + collectionID;
2831
-
2832
2832
auto agencyCallback =
2833
2833
std::make_shared<AgencyCallback>(ac, where, dbServerChanged, true , false );
2834
2834
_agencyCallbackRegistry->registerCallback (agencyCallback);
2835
2835
auto cbGuard = scopeGuard (
2836
2836
[&] { _agencyCallbackRegistry->unregisterCallback (agencyCallback); });
2837
+
2837
2838
AgencyOperation newValue (planIndexesKey, AgencyValueOperationType::PUSH,
2838
2839
newIndexBuilder.slice ());
2839
2840
AgencyOperation incrementVersion (" Plan/Version" , AgencySimpleOperationType::INCREMENT_OP);
@@ -2878,7 +2879,40 @@ Result ClusterInfo::ensureIndexCoordinatorInner( // create index
2878
2879
2879
2880
{
2880
2881
while (!application_features::ApplicationServer::isStopping ()) {
2881
- int tmpRes = dbServerResult->load (std::memory_order_acquire);
2882
+ int tmpRes = dbServerResult.load (std::memory_order_acquire);
2883
+
10000
td>2884
+ if (tmpRes < 0 ) {
2885
+ // index has not shown up in Current yet, follow up check to
2886
+ // ensure it is still in plan (not dropped between iterations)
2887
+
2888
+ AgencyCommResult result = _agency.sendTransactionWithFailover (
2889
+ AgencyReadTransaction (AgencyCommManager::path (planIndexesKey)));
2890
+
2891
+ if (result.successful ()) {
2892
+ auto indexes = result.slice ()[0 ].get (
2893
+ std::vector<std::string>{AgencyCommManager::path (), " Plan" ,
2894
+ " Collections" , databaseName,
2895
+ collectionID, " indexes" });
2896
+
2897
+ bool found = false ;
2898
+ if (indexes.isArray ()) {
2899
+ for (auto const & v : VPackArrayIterator (indexes)) {
2900
+ VPackSlice const k = v.get (StaticStrings::IndexId);
2901
+ if (k.isString () && k.isEqualString (idString)) {
2902
+ // index is still here
2903
+ found = true ;
2904
+ break ;
2905
+ }
2906
+ }
2907
+ }
2908
+
2909
+ if (!found) {
2910
+ return Result (TRI_ERROR_ARANGO_INDEX_CREATION_FAILED,
2911
+ " index was dropped during creation" );
2912
+ }
2913
+ }
2914
+ }
2915
+
2882
2916
if (tmpRes == 0 ) {
2883
2917
// Finally, in case all is good, remove the `isBuilding` flag
2884
2918
// check that the index has appeared. Note that we have to have
0 commit comments