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

Skip to content
8000

Commit 1196999

Browse files
authored
Avoid acquisition of recursive read lock on server shutdown (#14791)
* 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).
1 parent e638086 commit 1196999

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
v3.8.2 (XXXX-XX-XX)
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
* Fix active failover, so that the new host actually has working
510
foxx services. (BTS-558)
611

arangod/Replication/GlobalInitialSyncer.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,7 @@ Result GlobalInitialSyncer::updateServerInventory(VPackSlice const& leaderDataba
303303
if (!collection->system()) { // we will not drop system collections here
304304
toDrop.emplace_back(collection);
305305
}
306-
},
307-
false);
306+
});
308307

309308
for (auto const& collection : toDrop) {
310309
try {

arangod/RestServer/DatabaseFeature.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -487,14 +487,13 @@ void DatabaseFeature::stop() {
487487
#endif
488488
vocbase->stop();
489489

490-
vocbase->processCollections(
490+
vocbase->processCollectionsOnShutdown(
491491
[](LogicalCollection* collection) {
492492
// no one else must modify the collection's status while we are in
493493
// here
494494
collection->executeWhileStatusWriteLocked(
495495
[collection]() { collection->close(); });
496-
},
497-
true);
496+
});
498497

499498
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
500499
// i am here for debugging only.

arangod/VocBase/vocbase.cpp

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

1739-
void TRI_vocbase_t::processCollections(std::function<void(LogicalCollection*)> const& cb,
1740-
bool includeDeleted) {
1739+
void TRI_vocbase_t::processCollectionsOnShutdown(std::function<void(LogicalCollection*)> const& cb) {
1740+
RECURSIVE_WRITE_LOCKER(_dataSourceLock, _dataSourceLockWriteOwner);
1741+
1742+
for (auto const& it : _collections) {
1743+
cb(it.get());
1744+
}
1745+
}
1746+
1747+
void TRI_vocbase_t::processCollections(std::function<void(LogicalCollection*)> const& cb) {
17411748
RECURSIVE_READ_LOCKER(_dataSourceLock, _dataSourceLockWriteOwner);
17421749

1743-
if (includeDeleted) {
1744-
for (auto const& it : _collections) {
1745-
cb(it.get());
1746-
}
1747-
} else {
1748-
for (auto& entry : _dataSourceById) {
1749-
TRI_ASSERT(entry.second);
1750+
for (auto& entry : _dataSourceById) {
1751+
TRI_ASSERT(entry.second);
17501752

1751-
if (entry.second->category() != LogicalCollection::category()) {
1752-
continue;
1753-
}
1753+
if (entry.second->category() != LogicalCollection::category()) {
1754+
continue;
1755+
}
17541756

17551757
#ifdef ARANGODB_ENABLE_MAINTAINER_MODE
1756-
auto collection =
1757-
std::dynamic_pointer_cast<arangodb::LogicalCollection>(entry.second);
1758-
TRI_ASSERT(collection);
1758+
auto collection =
1759+
std::dynamic_pointer_cast<arangodb::LogicalCollection>(entry.second);
1760+
TRI_ASSERT(collection);
17591761
#else
1760-
auto collection =
1761-
std::static_pointer_cast<arangodb::LogicalCollection>(entry.second);
1762+
auto collection =
1763+
std::static_pointer_cast<arangodb::LogicalCollection>(entry.second);
17621764
#endif
17631765

1764-
cb(collection.get());
1765-
}
1766+
cb(collection.get());
17661767
}
17671768
}
17681769

arangod/VocBase/vocbase.h

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

255-
void processCollections(std::function<void(arangodb::LogicalCollection*)> const& cb,
256-
bool includeDeleted);
255+
void processCollectionsOnShutdown(std::function<void(arangodb::LogicalCollection*)> const& cb);
256+
257+
void processCollections(std::function<void(arangodb::LogicalCollection*)> const& cb);
257258

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

0 commit comments

Comments
 (0)
0