8000 fix potential issue during cluster index creation by jsteemann · Pull Request #14691 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

fix potential issue during cluster index creation #14691

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
v3.8.1 (XXXX-XX-XX)
-------------------

* Fix a potential multi-threading issue in index creation on coordinators, when
an agency callback was triggered at the same time the method
`ensureIndexCoordinatorInner` was left.

* Append physical compaction of log collection to every Raft log compaction
(BTS-542).

Expand Down
13 changes: 7 additions & 6 deletions arangod/Cluster/ClusterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4274,7 +4274,7 @@ Result ClusterInfo::ensureIndexCoordinatorInner(LogicalCollection const& collect
// This object watches whether the collection is still present in Plan
// It assumes that the collection *is* present and only changes state
// if the collection disappears
CollectionWatcher collectionWatcher(_agencyCallbackRegistry, collection);
auto collectionWatcher = std::make_shared<CollectionWatcher>(_agencyCallbackRegistry, collection);

if (!result.successful()) {
if (result.httpCode() == rest::ResponseCode::PRECONDITION_FAILED) {
Expand Down Expand Up @@ -4375,7 +4375,7 @@ Result ClusterInfo::ensureIndexCoordinatorInner(LogicalCollection const& collect
}
}

if (!collectionWatcher.isPresent()) {
if (!collectionWatcher->isPresent()) {
return Result(TRI_ERROR_ARANGO_INDEX_CREATION_FAILED,
"Collection " + collectionID +
" has gone from database " + databaseName +
Expand Down Expand Up @@ -4462,7 +4462,7 @@ Result ClusterInfo::ensureIndexCoordinatorInner(LogicalCollection const& collect
// when we wanted to roll back the index creation.
}

if (!collectionWatcher.isPresent()) {
if (!collectionWatcher->isPresent()) {
return Result(TRI_ERROR_ARANGO_DATA_SOURCE_NOT_FOUND,
"collection " + collectionID +
"appears to have been dropped from database " +
Expand Down Expand Up @@ -6084,9 +6084,10 @@ CollectionWatcher::CollectionWatcher(AgencyCallbackRegistry* agencyCallbackRegis

_agencyCallback = std::make_shared<AgencyCallback>(
collection.vocbase().server(), where,
[this](VPackSlice const& result) {
if (result.isNone()) {
_present.store(false);
[self = weak_from_this()](VPackSlice const& result) {
auto watcher = self.lock();
if (result.isNone() && watcher) {
watcher->_present.store(false);
}
return true;
},
Expand Down
2 changes: 1 addition & 1 deletion arangod/Cluster/ClusterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ struct ClusterCollectionCreationInfo;
// make sure a collection is still in Plan
// we are only going from *assuming* that it is present
// to it being changed to not present.
class CollectionWatcher {
class CollectionWatcher : public std::enable_shared_from_this<CollectionWatcher> {
public:
CollectionWatcher(CollectionWatcher const&) = delete;
CollectionWatcher(AgencyCallbackRegistry* agencyCallbackRegistry, LogicalCollection const& collection);
Expand Down
0