8000 Avoid acquisition of recursive read lock on server shutdown (#14792) · arangodb/arangodb@0543b00 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0543b00

Browse files
authored
Avoid acquisition of recursive read lock on server shutdown (#14792)
1 parent 8a65d8c commit 0543b00

File tree

5 files changed

+31
-26
lines changed

5 files changed

+31
-26
lines changed

CHANGELOG

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

4+
* Avoid the acquisition of a recursive read lock on server shutdown, which
5+
could in theory lead to shutdown hangs at least if a concurrent thread is
6+
trying to modify the list of collections (very unlikely and never observed
7+
until now).
8+
49
* Fixed display of unicode characters in Windows console.
510

611
* Fixed issue BTS-531 "Error happens during EXE package installation if

arangod/Replication/GlobalInitialSyncer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -305,8 +305,7 @@ Result GlobalInitialSyncer::updateServerInventory(VPackSlice const& leaderDataba
305305
if (!collection->system()) { // we will not drop system collections here
306306
toDrop.emplace_back(collection);
307307
}
308-
},
309-
false);
308+
});
310309

311310
for (auto const& collection : toDrop) {
312311
try {

arangod/RestServer/DatabaseFeature.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,14 +484,13 @@ void DatabaseFeature::stop() {
484484
#endif
485485
vocbase->stop();
486486

487-
vocbase->processCollections(
487+
vocbase->processCollectionsOnShutdown(
488488
[](LogicalCollection* collection) {
489489
// no one else must modify the collection's status while we are in
490490
// here
491491
collection->executeWhileStatusWriteLocked(
492492
[collection]() { collection->close(); });
493-
},
494-
true);
493+
});
495494

496495
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
497496
// i am here for debugging only.

arangod/VocBase/vocbase.cpp

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,33 +1722,34 @@ std::vector<std::shared_ptr<arangodb::LogicalView>> TRI_vocbase_t::views() {
17221722
return views;
17231723
}
17241724

1725-
void TRI_vocbase_t::processCollections(std::function<void(LogicalCollection*)> const& cb,
1726-
bool includeDeleted) {
1725+
void TRI_vocbase_t::processCollectionsOnShutdown(std::function<void(LogicalCollection*)> const& cb) {
1726+
RECURSIVE_WRITE_LOCKER(_dataSourceLock, _dataSourceLockWriteOwner);
1727+
1728+
for (auto const& it : _collections) {
1729+
cb(it.get());
1730+
}
1731+
}
1732+
1733+
void TRI_vocbase_t::processCollections(std::function<void(LogicalCollection*)> const& cb) {
17271734
RECURSIVE_READ_LOCKER(_dataSourceLock, _dataSourceLockWriteOwner);
17281735

1729-
if (includeDeleted) {
1730-
for (auto const& it : _collections) {
1731-
cb(it.get());
1732-
}
1733-
} else {
1734-
for (auto& entry : _dataSourceById) {
1735-
TRI_ASSERT(entry.second);
1736+
for (auto& entry : _dataSourceById) {
1737+
TRI_ASSERT(entry.second);
17361738

1737-
if (entry.second->category() != LogicalCollection::category()) {
1738-
continue;
1739-
}
1739+
if (entry.second->category() != LogicalCollection::category()) {
1740+
continue;
1741+
}
17401742

17411743
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
1742-
auto collection =
1743-
std::dynamic_pointer_cast<arangodb::LogicalCollection>(entry.second);
1744-
TRI_ASSERT(collection);
1744+
auto collection =
1745+
std::dynamic_pointer_cast<arangodb::LogicalCollection>(entry.second);
1746+
TRI_ASSERT(collection);
17451747
#else
1746-
auto collection =
1747-
std::static_pointer_cast<arangodb::LogicalCollection>(entry.second);
1748+
auto collection =
1749+
std::static_pointer_cast<arangodb::LogicalCollection>(entry.second);
17481750
#endif
17491751

1750-
cb(collection.get());
1751-
}
1752+
cb(collection.get());
17521753
}
17531754
}
17541755

arangod/VocBase/vocbase.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,9 @@ struct TRI_vocbase_t {
286286
/// @brief returns all known collections
287287
std::vector<std::shared_ptr<arangodb::LogicalCollection>> collections(bool includeDeleted);
288288

289-
void processCollections(std::function<void(arangodb::LogicalCollection*)> const& cb,
290-
bool includeDeleted);
289+
void processCollectionsOnShutdown(std::function<void(arangodb::LogicalCollection*)> const& cb);
290+
291+
void processCollections(std::function<void(arangodb::LogicalCollection*)> const& cb);
291292

292293
/// @brief returns names of all known collections
293294
std::vector<std::string> collectionNames();

0 commit comments

Comments
 (0)
0