mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 23:23:04 +01:00
Better (methinks) synchronization for the monitoring stuff. Being field tested.
This commit is contained in:
parent
51d1cd35d3
commit
d4492eea92
@ -434,7 +434,7 @@ void Jrd::Attachment::initLocks(thread_db* tdbb)
|
|||||||
Lock(tdbb, sizeof(SLONG), LCK_monitor, this, blockingAstMonitor);
|
Lock(tdbb, sizeof(SLONG), LCK_monitor, this, blockingAstMonitor);
|
||||||
att_monitor_lock = lock;
|
att_monitor_lock = lock;
|
||||||
lock->lck_key.lck_long = att_attachment_id;
|
lock->lck_key.lck_long = att_attachment_id;
|
||||||
LCK_lock(tdbb, lock, LCK_SR, LCK_WAIT);
|
LCK_lock(tdbb, lock, LCK_EX, LCK_WAIT);
|
||||||
|
|
||||||
// Unless we're a system attachment, allocate the cancellation lock
|
// Unless we're a system attachment, allocate the cancellation lock
|
||||||
|
|
||||||
@ -644,6 +644,8 @@ int Jrd::Attachment::blockingAstMonitor(void* ast_object)
|
|||||||
|
|
||||||
AsyncContextHolder tdbb(dbb, FB_FUNCTION, attachment->att_monitor_lock);
|
AsyncContextHolder tdbb(dbb, FB_FUNCTION, attachment->att_monitor_lock);
|
||||||
|
|
||||||
|
if (!(attachment->att_flags & ATT_monitor_done))
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Monitoring::dumpAttachment(tdbb, attachment, true);
|
Monitoring::dumpAttachment(tdbb, attachment, true);
|
||||||
@ -653,8 +655,9 @@ int Jrd::Attachment::blockingAstMonitor(void* ast_object)
|
|||||||
iscLogException("Cannot dump the monitoring data", ex);
|
iscLogException("Cannot dump the monitoring data", ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
LCK_release(tdbb, attachment->att_monitor_lock);
|
LCK_downgrade(tdbb, attachment->att_monitor_lock);
|
||||||
attachment->att_flags |= ATT_monitor_off;
|
attachment->att_flags |= ATT_monitor_done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (const Exception&)
|
catch (const Exception&)
|
||||||
{} // no-op
|
{} // no-op
|
||||||
|
@ -478,8 +478,8 @@ const ULONG ATT_manual_lock = 0x00800L; // Was locked manually
|
|||||||
const ULONG ATT_async_manual_lock = 0x01000L; // Async mutex was locked manually
|
const ULONG ATT_async_manual_lock = 0x01000L; // Async mutex was locked manually
|
||||||
const ULONG ATT_purge_started = 0x02000L; // Purge already started - avoid 2 purges at once
|
const ULONG ATT_purge_started = 0x02000L; // Purge already started - avoid 2 purges at once
|
||||||
const ULONG ATT_system = 0x04000L; // Special system attachment
|
const ULONG ATT_system = 0x04000L; // Special system attachment
|
||||||
const ULONG ATT_creator = 0x08000L; // This attachment created the DB.
|
const ULONG ATT_creator = 0x08000L; // This attachment created the DB
|
||||||
const ULONG ATT_monitor_off = 0x10000L; // Monitoring lock is released
|
const ULONG ATT_monitor_done = 0x10000L; // Monitoring data is refreshed
|
||||||
|
|
||||||
const ULONG ATT_NO_CLEANUP = (ATT_no_cleanup | ATT_notify_gc);
|
const ULONG ATT_NO_CLEANUP = (ATT_no_cleanup | ATT_notify_gc);
|
||||||
|
|
||||||
|
@ -351,15 +351,16 @@ MonitoringSnapshot::MonitoringSnapshot(thread_db* tdbb, MemoryPool& pool)
|
|||||||
RecordBuffer* const ctx_var_buffer = allocBuffer(tdbb, pool, rel_mon_ctx_vars);
|
RecordBuffer* const ctx_var_buffer = allocBuffer(tdbb, pool, rel_mon_ctx_vars);
|
||||||
RecordBuffer* const mem_usage_buffer = allocBuffer(tdbb, pool, rel_mon_mem_usage);
|
RecordBuffer* const mem_usage_buffer = allocBuffer(tdbb, pool, rel_mon_mem_usage);
|
||||||
|
|
||||||
// Release our own lock
|
// Dump our own data and downgrade the lock, if required
|
||||||
|
|
||||||
LCK_release(tdbb, attachment->att_monitor_lock);
|
|
||||||
attachment->att_flags &= ~ATT_monitor_off;
|
|
||||||
|
|
||||||
// Dump our own data
|
|
||||||
|
|
||||||
Monitoring::dumpAttachment(tdbb, attachment, false);
|
Monitoring::dumpAttachment(tdbb, attachment, false);
|
||||||
|
|
||||||
|
if (!(attachment->att_flags & ATT_monitor_done))
|
||||||
|
{
|
||||||
|
LCK_convert(tdbb, attachment->att_monitor_lock, LCK_SR, LCK_NO_WAIT);
|
||||||
|
attachment->att_flags |= ATT_monitor_done;
|
||||||
|
}
|
||||||
|
|
||||||
// Enumerate active sessions
|
// Enumerate active sessions
|
||||||
|
|
||||||
MonitoringData::SessionList sessions(pool);
|
MonitoringData::SessionList sessions(pool);
|
||||||
@ -384,7 +385,7 @@ MonitoringSnapshot::MonitoringSnapshot(thread_db* tdbb, MemoryPool& pool)
|
|||||||
{
|
{
|
||||||
lock->lck_key.lck_long = *iter;
|
lock->lck_key.lck_long = *iter;
|
||||||
|
|
||||||
if (LCK_lock(tdbb, lock, LCK_EX, LCK_WAIT))
|
if (LCK_lock(tdbb, lock, LCK_SR, LCK_WAIT))
|
||||||
LCK_release(tdbb, lock);
|
LCK_release(tdbb, lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -419,10 +420,6 @@ MonitoringSnapshot::MonitoringSnapshot(thread_db* tdbb, MemoryPool& pool)
|
|||||||
dbb->dbb_monitoring_data->read(self_att_id, temp_space);
|
dbb->dbb_monitoring_data->read(self_att_id, temp_space);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark our attachment as requesting a new lock
|
|
||||||
|
|
||||||
attachment->att_flags |= ATT_monitor_off;
|
|
||||||
|
|
||||||
string databaseName(dbb->dbb_database_name.c_str());
|
string databaseName(dbb->dbb_database_name.c_str());
|
||||||
ISC_systemToUtf8(databaseName);
|
ISC_systemToUtf8(databaseName);
|
||||||
|
|
||||||
@ -1148,11 +1145,11 @@ void Monitoring::checkState(thread_db* tdbb)
|
|||||||
|
|
||||||
Jrd::Attachment* const attachment = tdbb->getAttachment();
|
Jrd::Attachment* const attachment = tdbb->getAttachment();
|
||||||
|
|
||||||
if (attachment->att_flags & ATT_monitor_off)
|
if (attachment->att_flags & ATT_monitor_done)
|
||||||
{
|
{
|
||||||
// Enable signal handler for the monitoring stuff
|
// Enable signal handler for the monitoring stuff
|
||||||
attachment->att_flags &= ~ATT_monitor_off;
|
attachment->att_flags &= ~ATT_monitor_done;
|
||||||
LCK_lock(tdbb, attachment->att_monitor_lock, LCK_SR, LCK_WAIT);
|
LCK_convert(tdbb, attachment->att_monitor_lock, LCK_EX, LCK_WAIT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user