8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-22 22:43:03 +01:00

Backported fix for #7199: Various errors (strange messages in firebird.log, segfaults) with high rate of attach/detach database operations

This commit is contained in:
AlexPeshkoff 2022-06-07 10:20:02 +03:00
parent b4d218e5a7
commit f86f4edb52
2 changed files with 19 additions and 7 deletions

View File

@ -493,6 +493,15 @@ namespace Jrd
// Database::GlobalObjectHolder class implementation
int Database::GlobalObjectHolder::release() const
{
// Release should be executed under g_mutex protection
// in order to modify reference counter & hash table atomically
MutexLockGuard guard(g_mutex, FB_FUNCTION);
return RefCounted::release();
}
Database::GlobalObjectHolder* Database::GlobalObjectHolder::init(const string& id,
const PathName& filename,
RefPtr<const Config> config)
@ -512,17 +521,18 @@ namespace Jrd
Database::GlobalObjectHolder::~GlobalObjectHolder()
{
// here we cleanup what should not be globally protected
if (m_replMgr)
m_replMgr->shutdown();
MutexLockGuard guard(g_mutex, FB_FUNCTION);
// dtor is executed under g_mutex protection
Database::GlobalObjectHolder::DbId* entry = g_hashTable->lookup(m_id);
if (!g_hashTable->remove(m_id))
fb_assert(false);
// these objects should be deleted under g_mutex protection
{ // scope
// here we cleanup what should not be globally protected
MutexUnlockGuard guard(g_mutex, FB_FUNCTION);
if (m_replMgr)
m_replMgr->shutdown();
}
m_lockMgr = nullptr;
m_eventMgr = nullptr;
m_replMgr = nullptr;

View File

@ -305,6 +305,8 @@ class Database : public pool_alloc<type_dbb>
const Firebird::PathName& filename,
Firebird::RefPtr<const Firebird::Config> config);
int release() const override;
~GlobalObjectHolder();
LockManager* getLockManager();