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

Skip to content

fix 8000 potential issue during cluster index creation #14692

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 5 commits into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
fix potential issue during cluster index creation
* 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.
  • Loading branch information
jsteemann committed Aug 24, 2021
commit 15b00bc26fd86a7dc388a62e84c819436fe331a2
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
devel
-----

* 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.

* Add pseudo log topic "all" to set the log levels for all log topics at
once. For example, this can be used when starting a server with trace or
debug logging enabled for all log topics, e.g.
Expand Down
11 changes: 6 additions & 5 deletions arangod/Cluster/ClusterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4336,7 +4336,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 @@ -4437,7 +4437,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 @@ -4524,7 +4524,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 @@ -6164,8 +6164,9 @@ CollectionWatcher::CollectionWatcher(AgencyCallbackRegistry* agencyCallbackRegis

_agencyCallback = std::make_shared<AgencyCallback>(
collection.vocbase().server(), where,
[this](VPackSlice const& result) {
if (result.isNone()) {
[self = weak_from_this()](VPackSlice const& result) {
auto watcher = self.lock();
if (result.isNone() && 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 @@ -72,7 +72,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