diff --git a/src/jrd/DatabaseSnapshot.cpp b/src/jrd/DatabaseSnapshot.cpp index 2a1ba67e73..e58c413a34 100644 --- a/src/jrd/DatabaseSnapshot.cpp +++ b/src/jrd/DatabaseSnapshot.cpp @@ -403,19 +403,27 @@ int DatabaseSnapshot::blockingAst(void* ast_object) if (!(dbb->dbb_ast_flags & DBB_monitor_off)) { // Write the data to the shared memory - try + if (!(dbb->dbb_flags & DBB_not_in_use)) { - dumpData(tdbb, true); - } - catch (const Exception& ex) - { - ISC_STATUS_ARRAY status; - ex.stuff_exception(status); - gds__log_status("Cannot dump the monitoring data", status); + try + { + dumpData(tdbb, true); + } + catch (const Exception& ex) + { + ISC_STATUS_ARRAY status; + ex.stuff_exception(status); + gds__log_status("Cannot dump the monitoring data", status); + } } - // Release the lock and mark dbb as requesting a new one - LCK_release(tdbb, lock); + // Release the lock, if feasible + if (!(dbb->dbb_flags & DBB_monitor_locking)) + { + LCK_release(tdbb, lock); + } + + // Mark dbb as requesting a new lock dbb->dbb_ast_flags |= DBB_monitor_off; } diff --git a/src/jrd/jrd.cpp b/src/jrd/jrd.cpp index 5556eb4a79..cef274a2a0 100644 --- a/src/jrd/jrd.cpp +++ b/src/jrd/jrd.cpp @@ -4692,7 +4692,9 @@ bool JRD_reschedule(thread_db* tdbb, SLONG quantum, bool punt) if (dbb->dbb_ast_flags & DBB_monitor_off) { dbb->dbb_ast_flags &= ~DBB_monitor_off; + dbb->dbb_flags |= DBB_monitor_locking; LCK_lock(tdbb, dbb->dbb_monitor_lock, LCK_SR, LCK_WAIT); + dbb->dbb_flags &= ~DBB_monitor_locking; // While waiting for return from LCK_lock call above the blocking AST (see // DatabaseSnapshot::blockingAst) was called and set DBB_monitor_off flag @@ -5029,7 +5031,9 @@ static ISC_STATUS check_database(thread_db* tdbb, Attachment* attachment, ISC_ST if (dbb->dbb_ast_flags & DBB_monitor_off) { dbb->dbb_ast_flags &= ~DBB_monitor_off; + dbb->dbb_flags |= DBB_monitor_locking; LCK_lock(tdbb, dbb->dbb_monitor_lock, LCK_SR, LCK_WAIT); + dbb->dbb_flags &= ~DBB_monitor_locking; if (dbb->dbb_ast_flags & DBB_monitor_off) LCK_release(tdbb, dbb->dbb_monitor_lock); diff --git a/src/jrd/jrd.h b/src/jrd/jrd.h index bc82ada784..8811d4b044 100644 --- a/src/jrd/jrd.h +++ b/src/jrd/jrd.h @@ -389,6 +389,8 @@ const ULONG DBB_gc_background = 0x1000000L; // background garbage collection by #if (defined DEV_BUILD && !defined MULTI_THREAD) const ULONG DBB_exec_statement = 0x2000000L; // execute statement runs against database #endif +const ULONG DBB_monitor_locking = 0x4000000L; // monitoring lock is being acquired + // // dbb_ast_flags //