8000 Avoid acquisition of recursive read lock on server shutdown by jsteemann · Pull Request #14792 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Avoid acquisition of recursive read lock on server shutdown #14792

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 1 commit into from
Sep 17, 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
5 changes: 5 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
devel
-----

* Avoid the acquisition of a recursive read lock on server shutdown, which
could in theory lead to shutdown hangs at least if a concurrent thread is
trying to modify the list of collections (very unlikely and never observed
until now).

* Fixed display of unicode characters in Windows console.

* Fixed issue BTS-531 "Error happens during EXE package installation if
Expand Down
3 changes: 1 addition & 2 deletions arangod/Replication/GlobalInitialSyncer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,7 @@ Result GlobalInitialSyncer::updateServerInventory(VPackSlice const& leaderDataba
if (!collection->system()) { // we will not drop system collections here
toDrop.emplace_back(collection);
}
},
false);
});

for (auto const& collection : toDrop) {
try {
Expand Down
5 changes: 2 additions & 3 deletions arangod/RestServer/DatabaseFeature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,14 +484,13 @@ void DatabaseFeature::stop() {
#endif
vocbase->stop();

vocbase->processCollections(
vocbase->processCollectionsOnShutdown(
[](LogicalCollection* collection) {
// no one else must modify the collection's status while we are in
// here
collection->executeWhileStatusWriteLocked(
[collection]() { collection->close(); });
},
true);
});

#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
// i am here for debugging only.
Expand Down
39 changes: 20 additions & 19 deletions arangod/VocBase/vocbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1722,33 +1722,34 @@ std::vector<std::shared_ptr<arangodb::LogicalView>> TRI_vocbase_t::views() {
return views;
}

void TRI_vocbase_t::processCollections(std::function<void(LogicalCollection*)> const& cb,
bool includeDeleted) {
void TRI_vocbase_t::processCollectionsOnShutdown(std::function<void(LogicalCollection*)> const& cb) {
RECURSIVE_WRITE_LOCKER(_dataSourceLock, _dataSourceLockWriteOwner);

for (auto const& it : _collections) {
cb(it.get());
}
}

void TRI_vocbase_t::processCollections(std::function<void(LogicalCollection*)> const& cb) {
RECURSIVE_READ_LOCKER(_dataSourceLock, _dataSourceLockWriteOwner);

if (includeDeleted) {
for (auto const& it : _collections) {
cb(it.get());
}
} else {
for (auto& entry : _dataSourceById) {
TRI_ASSERT(entry.second);
for (auto& entry : _dataSourceById) {
TRI_ASSERT(entry.second);

if (entry.second->category() != LogicalCollection::category()) {
continue;
}
if (entry.second->category() != LogicalCollection::category()) {
continue;
}

#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
auto collection =
std::dynamic_pointer_cast<arangodb::LogicalCollection>(entry.second);
TRI_ASSERT(collection);
auto collection =
std::dynamic_pointer_cast<arangodb::LogicalCollection>(entry.second);
TRI_ASSERT(collection);
#else
auto collection =
std::static_pointer_cast<arangodb::LogicalCollection>(entry.second);
auto collection =
std::static_pointer_cast<arangodb::LogicalCollection>(entry.second);
#endif

cb(collection.get());
}
cb(collection.get());
}
}

Expand Down
5 changes: 3 additions & 2 deletions arangod/VocBase/vocbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,9 @@ struct TRI_vocbase_t {
/// @brief returns all known collections
std::vector<std::shared_ptr<arangodb::LogicalCollection>> collections(bool includeDeleted);

void processCollections(std::function<void(arangodb::LogicalCollection*)> const& cb,
bool includeDeleted);
void processCollectionsOnShutdown(std::function<void(arangodb::LogicalCollection*)> const& cb);

void processCollections(std::function<void(arangodb::LogicalCollection*)> const& cb);

/// @brief returns names of all known collections
std::vector<std::string> collectionNames();
Expand Down
0