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

A bit more debug code to catch issue with not detached BtrPageGCLock and AV in setLockAttachment() at disconnect time.

Note, it might slowdown disconnects (when there is a lot of pools and "long" locks in attachment). In any case - this is temporary code, not going to be active in public release.
Fix for "impossible" case in IndexTableScan::close() that might be a source of the issue.
This commit is contained in:
hvlad 2020-11-02 00:27:59 +02:00
parent 1a2f79876d
commit 12aa1c6197
4 changed files with 61 additions and 5 deletions

View File

@ -158,6 +158,21 @@ void Jrd::Attachment::deletePool(MemoryPool* pool)
if (att_pools.find(pool, pos))
att_pools.remove(pos);
#ifdef DEBUG_LCK_LIST
// hvlad: this could be slow, use only when absolutely necessary
for (Lock* lock = att_long_locks; lock; )
{
Lock* next = lock->lck_next;
if (BtrPageGCLock::checkPool(lock, pool))
{
gds__log("DEBUG_LCK_LIST: found not detached lock 0x%p in deleting pool 0x%p", lock, pool);
//delete lock;
lock->setLockAttachment(NULL);
}
lock = next;
}
#endif
MemoryPool::deletePool(pool);
}
}

View File

@ -243,6 +243,29 @@ public:
void enablePageGC(thread_db* tdbb);
static bool isPageGCAllowed(thread_db* tdbb, const PageNumber& page);
#ifdef DEBUG_LCK_LIST
BtrPageGCLock(thread_db* tdbb, Firebird::MemoryPool* pool)
: Lock(tdbb, PageNumber::getLockLen(), LCK_btr_dont_gc), m_pool(pool)
{
}
static bool checkPool(const Lock* lock, Firebird::MemoryPool* pool)
{
if (!pool || !lock)
return false;
const Firebird::MemoryPool* pool2 = NULL;
if (lock && (lock->lck_type == LCK_btr_dont_gc))
pool2 = reinterpret_cast<const BtrPageGCLock*>(lock)->m_pool;
return (pool == pool2);
}
private:
const Firebird::MemoryPool* m_pool;
#endif
};
// Struct used for index creation

View File

@ -1520,7 +1520,7 @@ Lock::~Lock()
if (lck_attachment || lck_next || lck_prior)
{
#ifdef DEBUG_LCK_LIST
gds__log("Lock::~Lock(): this 0x%p, attachment 0x%p, lck_type %d, lck_next 0x%p, lck_prior 0x%p",
gds__log("DEBUG_LCK_LIST: Lock::~Lock(): this 0x%p, attachment 0x%p, lck_type %d, lck_next 0x%p, lck_prior 0x%p",
this, lck_attachment ? lck_attachment->getHandle() : NULL,
(int) lck_type, lck_next, lck_prior);
#endif

View File

@ -97,16 +97,30 @@ void IndexTableScan::close(thread_db* tdbb) const
impure->irsb_nav_records_visited = NULL;
}
if (impure->irsb_nav_page)
if (impure->irsb_nav_btr_gc_lock)
{
fb_assert(impure->irsb_nav_btr_gc_lock);
#ifdef DEBUG_LCK_LIST
if (!impure->irsb_nav_page)
gds__log("DEBUG_LCK_LIST: irsb_nav_btr_gc_lock && !irsb_nav_page");
#endif
impure->irsb_nav_btr_gc_lock->enablePageGC(tdbb);
delete impure->irsb_nav_btr_gc_lock;
impure->irsb_nav_btr_gc_lock = NULL;
impure->irsb_nav_page = 0;
}
impure->irsb_nav_page = 0;
}
#ifdef DEBUG_LCK_LIST
// paranoid check
else if (impure->irsb_nav_btr_gc_lock)
{
gds__log("DEBUG_LCK_LIST: irsb_nav_btr_gc_lock && !(irsb_flags & irsb_open)");
impure->irsb_nav_btr_gc_lock->enablePageGC(tdbb);
delete impure->irsb_nav_btr_gc_lock;
impure->irsb_nav_btr_gc_lock = NULL;
impure->irsb_nav_page = 0;
}
#endif
}
bool IndexTableScan::getRecord(thread_db* tdbb) const
@ -562,7 +576,11 @@ void IndexTableScan::setPage(thread_db* tdbb, Impure* impure, win* window) const
if (!impure->irsb_nav_btr_gc_lock)
{
impure->irsb_nav_btr_gc_lock =
#ifdef DEBUG_LCK_LIST
FB_NEW_RPT(*tdbb->getDefaultPool(), 0) BtrPageGCLock(tdbb, tdbb->getDefaultPool());
#else
FB_NEW_RPT(*tdbb->getDefaultPool(), 0) BtrPageGCLock(tdbb);
#endif
}
impure->irsb_nav_btr_gc_lock->disablePageGC(tdbb, window->win_page);