8000 fix potential issue during cluster index creation (#14692) · arangodb/arangodb@62872f2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 62872f2

Browse files
authored
fix potential issue during cluster index creation (#14692)
1 parent 866a723 commit 62872f2

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
devel
22
-----
33

4+
* Fix a potential multi-threading issue in index creation on coordinators,
5+
when an agency callback was triggered at the same time the method
6+
`ensureIndexCoordinatorInner` was left.
7+
48
* Added protocol specific metrics: histogram about request body size, total
59
number of HTTP/2 connections and total number of VST connections.
610

arangod/Cluster/ClusterInfo.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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
},

arangod/Cluster/ClusterInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ struct ClusterCollectionCreationInfo;
7272
// make sure a collection is still in Plan
7373
// we are only going from *assuming* that it is present
7474
// to it being changed to not present.
75-
class CollectionWatcher {
75+
class CollectionWatcher : public std::enable_shared_from_this<CollectionWatcher> {
7676
public:
7777
CollectionWatcher(CollectionWatcher const&) = delete;
7878
CollectionWatcher(AgencyCallbackRegistry* agencyCallbackRegistry, LogicalCollection const& collection);

0 commit comments

Comments
 (0)
0