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

Fixed CORE-5144: Deadlock when database is encrypted or decrypted under high parallel load

This commit is contained in:
alexpeshkoff 2016-03-09 14:58:08 +00:00
parent 91c3270d37
commit 71f4da06d3
2 changed files with 16 additions and 13 deletions

View File

@ -319,7 +319,7 @@ namespace Jrd {
if (!LCK_convert(tdbb, stateLock, CRYPT_NORMAL,
(flags & CRYPT_HDR_NOWAIT) ? LCK_NO_WAIT : LCK_WAIT))
{
// Failed to take state lock - swith to slow IO mode
// Failed to take state lock - switch to slow IO mode
slowIO = LCK_read_data(tdbb, stateLock);
fb_assert(slowIO);
}

View File

@ -143,23 +143,26 @@ public:
if (counter < 0)
{
if ((counter % BIG_VALUE == 0) && (!flagWriteLock))
if (!(flagWriteLock && (thread == getThreadId())))
{
if (lockMode)
if ((counter % BIG_VALUE == 0) && (!flagWriteLock))
{
// Someone is waiting for write lock
lockCond.notifyOne();
barCond.wait(mutex);
if (lockMode)
{
// Someone is waiting for write lock
lockCond.notifyOne();
barCond.wait(mutex);
}
else
{
// Ast done
callWriteLockHandler(tdbb);
counter = 0;
}
}
else
{
// Ast done
callWriteLockHandler(tdbb);
counter = 0;
}
barCond.wait(mutex);
}
else if (!(flagWriteLock && (thread == getThreadId())))
barCond.wait(mutex);
}
++counter;
}