@@ -4336,7 +4336,7 @@ Result ClusterInfo::ensureIndexCoordinatorInner(LogicalCollection const& collect
43364336 // This object watches whether the collection is still present in Plan
43374337 // It assumes that the collection *is* present and only changes state
43384338 // if the collection disappears
4339- CollectionWatcher collectionWatcher (_agencyCallbackRegistry, collection);
4339+ auto collectionWatcher = std::make_shared<CollectionWatcher> (_agencyCallbackRegistry, collection);
43404340
43414341 if (!result.successful ()) {
43424342 if (result.httpCode () == rest::ResponseCode::PRECONDITION_FAILED) {
@@ -4437,7 +4437,7 @@ Result ClusterInfo::ensureIndexCoordinatorInner(LogicalCollection const& collect
44374437 }
44384438 }
44394439
4440- if (!collectionWatcher. isPresent ()) {
4440+ if (!collectionWatcher-> isPresent ()) {
44414441 return Result (TRI_ERROR_ARANGO_INDEX_CREATION_FAILED,
44424442 " Collection " + collectionID +
44434443 " has gone from database " + databaseName +
@@ -4524,7 +4524,7 @@ Result ClusterInfo::ensureIndexCoordinatorInner(LogicalCollection const& collect
45244524 // when we wanted to roll back the index creation.
45254525 }
45264526
4527- if (!collectionWatcher. isPresent ()) {
4527+ if (!collectionWatcher-> isPresent ()) {
45284528 return Result (TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND,
45294529 " collection " + collectionID +
45304530 " appears to have been dropped from database " +
@@ -6164,9 +6164,10 @@ CollectionWatcher::CollectionWatcher(AgencyCallbackRegistry* agencyCallbackRegis
61646164
61656165 _agencyCallback = std::make_shared<AgencyCallback>(
61666166 collection.vocbase ().server (), where,
6167- [this ](VPackSlice const & result) {
6168- if (result.isNone ()) {
6169- _present.store (false );
6167+ [self = weak_from_this ()](VPackSlice const & result) {
6168+ auto watcher = self.lock ();
6169+ if (result.isNone () && watcher) {
6170+ watcher->_present .store (false );
61706171 }
61716172 return true ;
61726173 },
0 commit comments