MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / MonitoringSnapshot

Method MonitoringSnapshot

src/jrd/Monitoring.cpp:444–692  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

442
443
444MonitoringSnapshot::MonitoringSnapshot(thread_db* tdbb, MemoryPool& pool)
445 : SnapshotData(pool)
446{
447 PAG_header(tdbb, true);
448
449 const auto dbb = tdbb->getDatabase();
450 const auto attachment = tdbb->getAttachment();
451
452 const auto selfAttId = attachment->att_attachment_id;
453
454 // Initialize record buffers
455 const auto dbb_buffer = allocBuffer(tdbb, pool, rel_mon_database);
456 const auto att_buffer = allocBuffer(tdbb, pool, rel_mon_attachments);
457 const auto tra_buffer = allocBuffer(tdbb, pool, rel_mon_transactions);
458 const auto cmp_stmt_buffer = dbb->getEncodedOdsVersion() >= ODS_13_1 ?
459 allocBuffer(tdbb, pool, rel_mon_compiled_statements) :
460 nullptr;
461 const auto stmt_buffer = allocBuffer(tdbb, pool, rel_mon_statements);
462 const auto call_buffer = allocBuffer(tdbb, pool, rel_mon_calls);
463 const auto io_stat_buffer = allocBuffer(tdbb, pool, rel_mon_io_stats);
464 const auto rec_stat_buffer = allocBuffer(tdbb, pool, rel_mon_rec_stats);
465 const auto ctx_var_buffer = allocBuffer(tdbb, pool, rel_mon_ctx_vars);
466 const auto mem_usage_buffer = allocBuffer(tdbb, pool, rel_mon_mem_usage);
467 const auto tab_stat_buffer = allocBuffer(tdbb, pool, rel_mon_tab_stats);
468
469 // Increment the global monitor generation
470
471 const auto generation = dbb->newMonitorGeneration();
472
473 // Dump state of our own attachment
474
475 Monitoring::dumpAttachment(tdbb, attachment, generation);
476
477 // Enumerate active sessions and ensure they have dumped their state.
478 // Check that by comparing the session generation with the current one.
479
480 const auto locksmith = attachment->locksmith(tdbb, MONITOR_ANY_ATTACHMENT);
481 const auto userName = attachment->getEffectiveUserName();
482 const auto userNamePtr = locksmith ? nullptr : userName.c_str();
483
484 Lock temp_lock(tdbb, sizeof(AttNumber), LCK_monitor), *lock = &temp_lock;
485 MonitoringData::SessionList sessions(pool);
486
487 do
488 {
489 ThreadStatusGuard tempStatus(tdbb);
490
491 { // scope for the guard
492
493 MonitoringData::Guard guard(dbb->dbb_monitoring_data);
494 dbb->dbb_monitoring_data->enumerate(userNamePtr, generation, sessions);
495 }
496
497 if (!sessions.hasData())
498 break;
499
500 const auto attId = sessions.pop();
501 fb_assert(attId != selfAttId);

Callers

nothing calls this directly

Calls 15

PAG_headerFunction · 0.85
LCK_lockFunction · 0.85
LCK_releaseFunction · 0.85
ERR_puntFunction · 0.85
EVL_fieldFunction · 0.85
getDatabaseMethod · 0.80
getEncodedOdsVersionMethod · 0.80
getTempRecordMethod · 0.80
nullifyMethod · 0.80
isBlobMethod · 0.80
getAttachmentMethod · 0.45
newMonitorGenerationMethod · 0.45

Tested by

no test coverage detected