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

Rework fix for bug CORE-5436 : [FB3 SC] Server hangs (under load test)

This commit is contained in:
hvlad 2018-06-21 00:40:34 +03:00
parent 0a2082628f
commit f8370c2bc8

View File

@ -268,8 +268,11 @@ int CCH_down_grade_dbb(void* ast_object)
SyncLockGuard bcbSync(&bcb->bcb_syncObject, SYNC_EXCLUSIVE, "CCH_down_grade_dbb");
bcb->bcb_flags &= ~BCB_exclusive;
if (bcb->bcb_count)
bool done = (bcb->bcb_count == 0);
while (!done)
{
done = true;
const bcb_repeat* const head = bcb->bcb_rpt;
const bcb_repeat* tail = bcb->bcb_rpt;
fb_assert(tail); // once I've got here with NULL. AP.
for (const bcb_repeat* const end = tail + bcb->bcb_count; tail < end; ++tail)
@ -277,8 +280,23 @@ int CCH_down_grade_dbb(void* ast_object)
BufferDesc* bdb = tail->bcb_bdb;
// Acquire EX latch to avoid races with LCK_release (called by CCH_release)
// or LCK_lock (by lock_buffer) in main thread. See CORE-5436
SyncLockGuard guard(&bdb->bdb_syncPage, SYNC_EXCLUSIVE, FB_FUNCTION);
// or LCK_lock (by lock_buffer) in main thread. Take extra care to avoid
// deadlock with CCH_handoff. See CORE-5436.
Sync sync(&bdb->bdb_syncPage, FB_FUNCTION);
while (!sync.lockConditional(SYNC_EXCLUSIVE))
{
SyncUnlockGuard bcbUnlock(bcbSync);
Thread::sleep(1);
}
if (head != bcb->bcb_rpt)
{
// expand_buffers or CCH_fini was called, consider to start all over again
done = (bcb->bcb_count == 0);
break;
}
PAGE_LOCK_ASSERT(tdbb, bcb, bdb->bdb_lock);
}