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

Skip to content

fix potential issue during cluster index creation #14690

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 2 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 59ff6eec69302024789cbff6ffa3ab280bdc3989
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
v3.7.15 (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.

* When creating Pregel memory-mapped files, create them with O_TMPFILE attribute
on Linux so that files are guaranteed to vanish even if a process dies.

Expand Down
6 changes: 3 additions & 3 deletions arangod/Cluster/ClusterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4008,7 +4008,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() == (int)arangodb::rest::ResponseCode::PRECONDITION_FAILED) {
Expand Down Expand Up @@ -4111,7 +4111,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 @@ -4198,7 +4198,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
15 changes: 9 additions & 6 deletions arangod/Cluster/ClusterInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,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 All @@ -76,24 +76,27 @@ class CollectionWatcher {

_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;
},
true, false);

_agencyCallbackRegistry->registerCallback(_agencyCallback);
}

~CollectionWatcher();

bool isPresent() {
// Make sure we did not miss a callback
_agencyCallback->refetchAndUpdate(true, false);
return _present.load();
};
}

private:
private:
AgencyCallbackRegistry *_agencyCallbackRegistry;
std::shared_ptr<AgencyCallback> _agencyCallback;

Expand Down
0