Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Backport fix for bug CORE-2993 : Fatal lock manager error "Invalid lo…
…ck id (NNN)" while working with monitoring tables on a highly loaded system
  • Loading branch information
hvlad committed May 6, 2010
1 parent 2e6a8fe commit 870cc30
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/jrd/DatabaseSnapshot.cpp
Expand Up @@ -452,6 +452,7 @@ DatabaseSnapshot::DatabaseSnapshot(thread_db* tdbb, MemoryPool& pool)

// Release our own lock
LCK_release(tdbb, dbb->dbb_monitor_lock);
dbb->dbb_ast_flags &= ~DBB_monitor_off;

{ // scope for the RAII object

Expand Down
20 changes: 17 additions & 3 deletions src/jrd/jrd.cpp
Expand Up @@ -4682,9 +4682,18 @@ bool JRD_reschedule(thread_db* tdbb, SLONG quantum, bool punt)

// Enable signal handler for the monitoring stuff

if (dbb->dbb_ast_flags & DBB_monitor_off) {
if (dbb->dbb_ast_flags & DBB_monitor_off)
{
dbb->dbb_ast_flags &= ~DBB_monitor_off;
LCK_lock(tdbb, dbb->dbb_monitor_lock, LCK_SR, LCK_WAIT);

// While waiting for return from LCK_lock call above the blocking AST (see
// DatabaseSnapshot::blockingAst) was called and set DBB_monitor_off flag
// again. But it not released lock as lck_id was unknown at that moment.
// Do it now to not block another process waiting for a monitoring lock.

if (dbb->dbb_ast_flags & DBB_monitor_off)
LCK_release(tdbb, dbb->dbb_monitor_lock);
}

tdbb->tdbb_quantum = (tdbb->tdbb_quantum <= 0) ?
Expand Down Expand Up @@ -5007,11 +5016,16 @@ static ISC_STATUS check_database(thread_db* tdbb, Attachment* attachment, ISC_ST
return error(user_status);
}

// Enable signal handler for the monitoring stuff
// Enable signal handler for the monitoring stuff.
// See also comments in JRD_reshedule.

if (dbb->dbb_ast_flags & DBB_monitor_off) {
if (dbb->dbb_ast_flags & DBB_monitor_off)
{
dbb->dbb_ast_flags &= ~DBB_monitor_off;
LCK_lock(tdbb, dbb->dbb_monitor_lock, LCK_SR, LCK_WAIT);

if (dbb->dbb_ast_flags & DBB_monitor_off)
LCK_release(tdbb, dbb->dbb_monitor_lock);
}

return FB_SUCCESS;
Expand Down

0 comments on commit 870cc30

Please sign in to comment.