From 13949c0550020df3f8168ee4e6a95f22975d7341 Mon Sep 17 00:00:00 2001 From: dimitr Date: Tue, 12 Nov 2013 16:52:32 +0000 Subject: [PATCH] Fixed the status vector being left dirty after the non-critical lock manager error. This resolves CORE-4265: Unexpected lock conflict error may be raised while connecting to a heavily loaded database. --- src/jrd/GlobalRWLock.cpp | 9 ++++++++- src/jrd/pcmet.epp | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/jrd/GlobalRWLock.cpp b/src/jrd/GlobalRWLock.cpp index 79735da1a7..22313384f3 100644 --- a/src/jrd/GlobalRWLock.cpp +++ b/src/jrd/GlobalRWLock.cpp @@ -148,12 +148,15 @@ bool GlobalRWLock::lockWrite(thread_db* tdbb, SSHORT wait) ++pendingLock; } - COS_TRACE(("(%p)->lockWrite LCK_lock readers(%d), blocking(%d), pendingWriters(%d), currentWriter(%d), lck_physical(%d), pendingLock(%d)", this, readers, blocking, pendingWriters, currentWriter, cachedLock->lck_physical, pendingLock)); if (!LCK_lock(tdbb, cachedLock, LCK_write, wait)) { + ISC_STATUS* const status = tdbb->tdbb_status_vector; + if ((wait == LCK_NO_WAIT) || ((wait < 0) && (status[1] == isc_lock_timeout))) + fb_utils::init_status(status); + Attachment::CheckoutLockGuard counterGuard(att, counterMutex, FB_FUNCTION, true); --pendingLock; @@ -266,6 +269,10 @@ bool GlobalRWLock::lockRead(thread_db* tdbb, SSHORT wait, const bool queueJump) if (!LCK_lock(tdbb, cachedLock, LCK_read, wait)) { + ISC_STATUS* const status = tdbb->tdbb_status_vector; + if ((wait == LCK_NO_WAIT) || ((wait < 0) && (status[1] == isc_lock_timeout))) + fb_utils::init_status(status); + Attachment::CheckoutLockGuard counterGuard(att, counterMutex, FB_FUNCTION, true); --pendingLock; return false; diff --git a/src/jrd/pcmet.epp b/src/jrd/pcmet.epp index 6601161497..491987a61c 100644 --- a/src/jrd/pcmet.epp +++ b/src/jrd/pcmet.epp @@ -265,7 +265,12 @@ void PCMET_lookup_index(thread_db* tdbb, jrd_rel* relation, index_desc* idx) // if we can't get the lock, no big deal: just give up on caching the index info if (!LCK_lock(tdbb, index_block->idb_lock, LCK_SR, LCK_NO_WAIT)) + { + // clear lock error from status vector + fb_utils::init_status(tdbb->tdbb_status_vector); + return; + } // whether the index block already existed or was just created, // fill in the cached information about the index