#include "postgres.h"
#include <unistd.h>
#include "access/xact.h"
#include "lib/dshash.h"
#include "pgstat.h"
#include "storage/fd.h"
#include "storage/ipc.h"
#include "storage/lwlock.h"
#include "utils/guc_hooks.h"
#include "utils/memutils.h"
#include "utils/pgstat_internal.h"
#include "utils/timestamp.h"
#include "lib/simplehash.h"
Go to the source code of this file.
Definition at line 2067 of file pgstat.c.
References force_stats_snapshot_clear, newval, and pgstat_fetch_consistency.
Definition at line 821 of file pgstat.c.
References PgStat_HashKey::dboid, PgStatShared_HashEntry::key, and MyDatabaseId.
Referenced by pgstat_reset_counters().
Definition at line 560 of file pgstat.c.
References Assert(), PgStat_ShmemControl::is_shutdown, pgstat_report_stat(), pgstat_write_statsfile(), pgStatLocal, and PgStat_LocalState::shmem.
Referenced by CheckpointerMain(), and InitPostgres().
Definition at line 1118 of file pgstat.c.
References PgStat_KindInfo::accessed_across_databases, Assert(), PgStatShared_HashEntry::body, PgStat_Snapshot::context, PgStat_SnapshotEntry::data, PgStat_HashKey::dboid, PgStatShared_HashEntry::dropped, PgStat_LocalState::dsa, dsa_get_address(), dshash_seq_init(), dshash_seq_next(), dshash_seq_term(), PgStat_KindInfo::fixed_amount, GetCurrentTimestamp(), InvalidOid, PgStatShared_HashEntry::key, PgStat_HashKey::kind, PgStatShared_Common::lock, LW_SHARED, LWLockAcquire(), LWLockRelease(), MemoryContextAlloc(), PgStat_Snapshot::mode, MyDatabaseId, pg_atomic_read_u32(), pgstat_build_snapshot_fixed(), pgstat_fetch_consistency, PGSTAT_FETCH_CONSISTENCY_SNAPSHOT, pgstat_get_entry_data(), pgstat_get_entry_len(), pgstat_get_kind_info(), PgStat_Kind, PGSTAT_KIND_MAX, PGSTAT_KIND_MIN, pgstat_prep_snapshot(), pgStatLocal, PgStatShared_HashEntry::refcount, PgStat_LocalState::shared_hash, PgStat_LocalState::snapshot, PgStat_KindInfo::snapshot_cb, PgStat_Snapshot::snapshot_timestamp, and PgStat_Snapshot::stats.
Referenced by pgstat_fetch_entry(), and pgstat_snapshot_fixed().
Definition at line 1208 of file pgstat.c.
References Assert(), PgStat_Snapshot::custom_valid, PgStat_KindInfo::fixed_amount, PgStat_Snapshot::fixed_valid, idx(), pgstat_fetch_consistency, PGSTAT_FETCH_CONSISTENCY_CACHE, PGSTAT_FETCH_CONSISTENCY_NONE, pgstat_get_kind_info(), pgstat_is_kind_builtin(), PGSTAT_KIND_CUSTOM_MIN, pgStatLocal, PgStat_LocalState::snapshot, and PgStat_KindInfo::snapshot_cb.
Referenced by pgstat_build_snapshot(), pgstat_snapshot_fixed(), and pgstat_write_statsfile().
Definition at line 900 of file pgstat.c.
References PgStat_Snapshot::context, PgStat_Snapshot::custom_valid, PgStat_Snapshot::fixed_valid, force_stats_snapshot_clear, MemoryContextDelete(), PgStat_Snapshot::mode, pgstat_assert_is_up, pgstat_clear_backend_activity_snapshot(), PGSTAT_FETCH_CONSISTENCY_NONE, pgStatLocal, PgStat_LocalState::snapshot, and PgStat_Snapshot::stats.
Referenced by AtEOXact_PgStat(), pg_stat_clear_snapshot(), pgstat_get_stat_snapshot_timestamp(), pgstat_prep_snapshot(), pgstat_snapshot_fixed(), and PostPrepare_PgStat().
Definition at line 1314 of file pgstat.c.
References Assert(), PgStat_KindInfo::delete_pending_cb, dlist_delete(), PgStatShared_HashEntry::key, PgStat_HashKey::kind, PgStat_EntryRef::pending, PgStat_EntryRef::pending_node, pfree(), pgstat_get_kind_info(), PgStat_Kind, and PgStat_EntryRef::shared_entry.
Referenced by pgstat_flush_pending_entries(), and pgstat_release_entry_ref().
Definition at line 517 of file pgstat.c.
References DEBUG2, elog, ereport, errcode_for_file_access(), errmsg(), errmsg_internal(), LOG, pgstat_reset_after_failure(), and PGSTAT_STAT_PERMANENT_FILENAME.
Referenced by StartupXLOG().
Definition at line 932 of file pgstat.c.
References Assert(), PgStat_Snapshot::context, PgStat_SnapshotEntry::data, PgStatShared_HashEntry::dropped, PgStat_KindInfo::fixed_amount, IsPostmasterEnvironment, IsUnderPostmaster, sort-test::key, MemoryContextAlloc(), PgStat_Snapshot::mode, palloc(), pgstat_build_snapshot(), pgstat_fetch_consistency, PGSTAT_FETCH_CONSISTENCY_CACHE, PGSTAT_FETCH_CONSISTENCY_NONE, PGSTAT_FETCH_CONSISTENCY_SNAPSHOT, pgstat_get_entry_data(), pgstat_get_entry_ref(), pgstat_get_kind_info(), pgstat_lock_entry_shared(), pgstat_prep_snapshot(), pgstat_unlock_entry(), pgStatLocal, PgStat_KindInfo::shared_data_len, PgStat_EntryRef::shared_entry, PgStat_EntryRef::shared_stats, PgStat_LocalState::snapshot, and PgStat_Snapshot::stats.
Referenced by pgstat_fetch_replslot(), pgstat_fetch_stat_backend(), pgstat_fetch_stat_dbentry(), pgstat_fetch_stat_funcentry(), pgstat_fetch_stat_injentry(), pgstat_fetch_stat_subscription(), and pgstat_fetch_stat_tabentry_ext().
Definition at line 1301 of file pgstat.c.
References PgStat_EntryRef::pending, and pgstat_get_entry_ref().
Referenced by find_funcstat_entry(), and find_tabstat_entry().
Definition at line 1337 of file pgstat.c.
References Assert(), cur, dlist_container, dlist_has_next(), dlist_head_node(), dlist_is_empty(), dlist_next_node(), PgStat_KindInfo::fixed_amount, PgStat_KindInfo::flush_pending_cb, PgStatShared_HashEntry::key, sort-test::key, next, pgstat_delete_pending_entry(), pgstat_get_kind_info(), PgStat_Kind, pgStatPending, and PgStat_EntryRef::shared_entry.
Referenced by pgstat_report_stat().
Definition at line 812 of file pgstat.c.
References pgStatForceNextFlush.
Referenced by pg_stat_force_next_flush().
Definition at line 1399 of file pgstat.c.
References ereport, errcode(), errmsg(), ERROR, idx(), name, pg_strcasecmp(), PgStat_Kind, pgstat_kind_builtin_infos, PGSTAT_KIND_BUILTIN_MAX, PGSTAT_KIND_BUILTIN_MIN, pgstat_kind_custom_infos, PGSTAT_KIND_CUSTOM_MAX, PGSTAT_KIND_CUSTOM_MIN, and PGSTAT_KIND_INVALID.
Referenced by pg_stat_have_stats().
Definition at line 1433 of file pgstat.c.
References idx(), pgstat_is_kind_builtin(), pgstat_is_kind_custom(), pgstat_kind_builtin_infos, pgstat_kind_custom_infos, and PGSTAT_KIND_CUSTOM_MIN.
Referenced by pgstat_build_snapshot(), pgstat_build_snapshot_fixed(), pgstat_create_transactional(), pgstat_delete_pending_entry(), pgstat_drop_entry_internal(), pgstat_fetch_entry(), pgstat_flush_pending_entries(), pgstat_free_entry(), pgstat_get_custom_shmem_data(), pgstat_get_custom_snapshot_data(), pgstat_get_entry_count(), pgstat_get_entry_data(), pgstat_get_entry_len(), pgstat_have_entry(), pgstat_init_entry(), pgstat_init_snapshot_fixed(), pgstat_initialize(), pgstat_prep_pending_entry(), pgstat_read_statsfile(), pgstat_report_stat(), pgstat_reset(), pgstat_reset_after_failure(), pgstat_reset_entry(), pgstat_reset_of_kind(), pgstat_snapshot_fixed(), pgstat_write_statsfile(), shared_stat_reset_contents(), StatsShmemInit(), and StatsShmemSize().
Definition at line 1025 of file pgstat.c.
References force_stats_snapshot_clear, PgStat_Snapshot::mode, pgstat_clear_snapshot(), PGSTAT_FETCH_CONSISTENCY_SNAPSHOT, pgStatLocal, PgStat_LocalState::snapshot, and PgStat_Snapshot::snapshot_timestamp.
Referenced by pg_stat_get_snapshot_timestamp().
Definition at line 1042 of file pgstat.c.
References pgstat_get_entry_ref(), and pgstat_get_kind_info().
Referenced by pg_stat_have_stats().
Definition at line 1078 of file pgstat.c.
References PgStat_Snapshot::custom_data, PgStat_KindInfo::fixed_amount, MemoryContextAlloc(), pgstat_get_kind_info(), PgStat_Kind, PGSTAT_KIND_CUSTOM_MAX, PGSTAT_KIND_CUSTOM_MIN, pgStatLocal, PgStat_KindInfo::shared_data_len, PgStat_LocalState::snapshot, and TopMemoryContext.
Referenced by pgstat_initialize().
Definition at line 639 of file pgstat.c.
References Assert(), before_shmem_exit(), PgStat_KindInfo::init_backend_cb, pgstat_attach_shmem(), pgstat_get_kind_info(), pgstat_init_snapshot_fixed(), PgStat_Kind, PGSTAT_KIND_MAX, PGSTAT_KIND_MIN, and pgstat_shutdown_hook().
Referenced by BaseInit().
Definition at line 1427 of file pgstat.c.
References pgstat_is_kind_builtin(), and pgstat_is_kind_custom().
Referenced by pgstat_read_statsfile(), pgstat_snapshot_fixed(), and pgstat_write_statsfile().
Definition at line 1263 of file pgstat.c.
References ALLOCSET_SMALL_SIZES, AllocSetContextCreate, Assert(), dlist_push_tail(), MemoryContextAllocZero(), PgStat_EntryRef::pending, PgStat_EntryRef::pending_node, PgStat_KindInfo::pending_size, pgstat_get_entry_ref(), pgstat_get_kind_info(), pgStatPending, pgStatPendingContext, TopMemoryContext, and unlikely.
Referenced by pgstat_create_inj(), pgstat_init_function_usage(), pgstat_prep_database_pending(), pgstat_prep_relation_pending(), pgstat_report_inj(), pgstat_report_subscription_conflict(), and pgstat_report_subscription_error().
Definition at line 1097 of file pgstat.c.
References ALLOCSET_SMALL_SIZES, AllocSetContextCreate, PgStat_Snapshot::context, force_stats_snapshot_clear, pgstat_clear_snapshot(), pgstat_fetch_consistency, PGSTAT_FETCH_CONSISTENCY_NONE, PGSTAT_SNAPSHOT_HASH_SIZE, pgStatLocal, PgStat_LocalState::snapshot, PgStat_Snapshot::stats, and TopMemoryContext.
Referenced by pgstat_build_snapshot(), and pgstat_fetch_entry().
Definition at line 1754 of file pgstat.c.
References AllocateFile(), Assert(), CHECK_FOR_INTERRUPTS, PgStat_ShmemControl::custom_data, DEBUG2, dshash_find_or_insert(), dshash_release_lock(), elog, ereport, errcode_for_file_access(), errmsg(), ERROR, error(), PgStat_KindInfo::fixed_amount, FreeFile(), PgStat_KindInfo::from_serialized_name, idx(), IsPostmasterEnvironment, IsUnderPostmaster, sort-test::key, LOG, name, NameStr, PG_BINARY_R, PGSTAT_FILE_ENTRY_END, PGSTAT_FILE_ENTRY_FIXED, PGSTAT_FILE_ENTRY_HASH, PGSTAT_FILE_ENTRY_NAME, PGSTAT_FILE_FORMAT_ID, pgstat_get_entry_data(), pgstat_get_entry_len(), pgstat_get_kind_info(), pgstat_init_entry(), pgstat_is_kind_builtin(), pgstat_is_kind_valid(), PgStat_Kind, PGSTAT_KIND_CUSTOM_MIN, pgstat_reset_after_failure(), PGSTAT_STAT_PERMANENT_FILENAME, pgStatLocal, read_chunk(), read_chunk_s, PgStat_KindInfo::shared_ctl_off, PgStat_KindInfo::shared_data_len, PgStat_KindInfo::shared_data_off, PgStat_LocalState::shared_hash, PgStat_LocalState::shmem, and WARNING.
Referenced by pgstat_restore_stats().
Definition at line 1461 of file pgstat.c.
References ereport, errdetail(), errhint(), errmsg(), ERROR, PgStat_KindInfo::fixed_amount, idx(), LOG, MemoryContextAllocZero(), name, PgStat_KindInfo::name, pg_strcasecmp(), pgstat_is_kind_custom(), PgStat_Kind, pgstat_kind_custom_infos, PGSTAT_KIND_CUSTOM_MAX, PGSTAT_KIND_CUSTOM_MIN, PGSTAT_KIND_CUSTOM_SIZE, process_shared_preload_libraries_in_progress, PgStat_KindInfo::shared_size, TopMemoryContext, and PgStat_KindInfo::track_entry_count.
Referenced by pgstat_register_inj(), and pgstat_register_inj_fixed().
Definition at line 692 of file pgstat.c.
References Assert(), dlist_is_empty(), PgStat_KindInfo::flush_static_cb, GetCurrentTimestamp(), GetCurrentTransactionStopTimestamp(), PgStat_ShmemControl::is_shutdown, IsTransactionOrTransactionBlock(), now(), pgstat_assert_is_up, pgstat_flush_pending_entries(), pgstat_get_kind_info(), PGSTAT_IDLE_INTERVAL, PgStat_Kind, PGSTAT_KIND_MAX, PGSTAT_KIND_MIN, PGSTAT_MAX_INTERVAL, PGSTAT_MIN_INTERVAL, pgstat_report_fixed, pgstat_update_dbstats(), pgStatForceNextFlush, pgStatLocal, pgStatPending, PgStat_LocalState::shmem, and TimestampDifferenceExceeds().
Referenced by AllTablesyncsReady(), apply_handle_commit_internal(), apply_handle_commit_prepared(), apply_handle_prepare(), apply_handle_rollback_prepared(), apply_handle_stream_prepare(), finish_sync_worker(), HasSubscriptionRelationsCached(), LogicalRepApplyLoop(), LogicalRepSyncTableStart(), pgstat_before_server_shutdown(), pgstat_shutdown_hook(), PostgresMain(), process_syncing_tables_for_apply(), process_syncing_tables_for_sync(), ProcessInterrupts(), standby_redo(), and worker_spi_main().
Definition at line 852 of file pgstat.c.
References PgStat_KindInfo::accessed_across_databases, Assert(), GetCurrentTimestamp(), pgstat_get_kind_info(), pgstat_reset_database_timestamp(), and pgstat_reset_entry().
Referenced by pg_stat_reset_backend_stats(), pg_stat_reset_single_function_counters(), pg_stat_reset_single_table_counters(), pg_stat_reset_subscription_stats(), pgstat_create_transactional(), and pgstat_reset_replslot().
Definition at line 2044 of file pgstat.c.
References PgStat_KindInfo::fixed_amount, GetCurrentTimestamp(), pgstat_drop_all_entries(), pgstat_get_kind_info(), PgStat_Kind, PGSTAT_KIND_MAX, PGSTAT_KIND_MIN, and PgStat_KindInfo::reset_all_cb.
Referenced by pgstat_discard_stats(), and pgstat_read_statsfile().
Definition at line 833 of file pgstat.c.
References GetCurrentTimestamp(), match_db_entries(), MyDatabaseId, ObjectIdGetDatum(), and pgstat_reset_matching_entries().
Referenced by pg_stat_reset().
Definition at line 874 of file pgstat.c.
References PgStat_KindInfo::fixed_amount, GetCurrentTimestamp(), pgstat_get_kind_info(), pgstat_reset_entries_of_kind(), and PgStat_KindInfo::reset_all_cb.
Referenced by pg_stat_reset_replication_slot(), pg_stat_reset_shared(), pg_stat_reset_slru(), and pg_stat_reset_subscription_stats().
Definition at line 505 of file pgstat.c.
References pgstat_read_statsfile().
Referenced by StartupXLOG().
Definition at line 601 of file pgstat.c.
References Assert(), dlist_init(), dlist_is_empty(), InvalidOid, IsPostmasterEnvironment, IsUnderPostmaster, MyDatabaseId, MyProcNumber, OidIsValid, pgstat_detach_shmem(), pgstat_drop_entry(), PGSTAT_KIND_BACKEND, pgstat_report_disconnect(), pgstat_report_stat(), pgstat_request_entry_refs_gc(), and pgStatPending.
Referenced by pgstat_initialize().
Definition at line 1058 of file pgstat.c.
References Assert(), PgStat_Snapshot::custom_valid, PgStat_Snapshot::fixed_valid, force_stats_snapshot_clear, pgstat_build_snapshot(), pgstat_build_snapshot_fixed(), pgstat_clear_snapshot(), pgstat_fetch_consistency, PGSTAT_FETCH_CONSISTENCY_SNAPSHOT, pgstat_get_kind_info(), pgstat_is_kind_builtin(), pgstat_is_kind_custom(), pgstat_is_kind_valid(), PGSTAT_KIND_CUSTOM_MIN, pgStatLocal, and PgStat_LocalState::snapshot.
Referenced by injection_points_stats_fixed(), pgstat_fetch_slru(), pgstat_fetch_stat_archiver(), pgstat_fetch_stat_bgwriter(), pgstat_fetch_stat_checkpointer(), pgstat_fetch_stat_io(), and pgstat_fetch_stat_wal().
Definition at line 1570 of file pgstat.c.
References AllocateFile(), Assert(), B_CHECKPOINTER, CHECK_FOR_INTERRUPTS, PgStat_Snapshot::custom_data, DEBUG2, PgStat_LocalState::dsa, dsa_get_address(), dshash_seq_init(), dshash_seq_next(), dshash_seq_term(), durable_rename(), elog, ereport, errcode_for_file_access(), errmsg(), PgStat_KindInfo::fixed_amount, FreeFile(), IsUnderPostmaster, LOG, MyBackendType, name, pg_atomic_read_u32(), PG_BINARY_W, pgstat_assert_is_up, pgstat_build_snapshot_fixed(), pgstat_fetch_consistency, PGSTAT_FETCH_CONSISTENCY_NONE, PGSTAT_FILE_ENTRY_END, PGSTAT_FILE_ENTRY_FIXED, PGSTAT_FILE_ENTRY_HASH, PGSTAT_FILE_ENTRY_NAME, PGSTAT_FILE_FORMAT_ID, pgstat_get_entry_data(), pgstat_get_entry_len(), pgstat_get_kind_info(), pgstat_is_kind_builtin(), pgstat_is_kind_valid(), PgStat_Kind, PGSTAT_KIND_CUSTOM_MIN, PGSTAT_KIND_MAX, PGSTAT_KIND_MIN, PGSTAT_STAT_PERMANENT_FILENAME, PGSTAT_STAT_PERMANENT_TMPFILE, pgStatLocal, ps, PgStat_KindInfo::shared_data_len, PgStat_LocalState::shared_hash, PgStat_LocalState::snapshot, PgStat_KindInfo::snapshot_ctl_off, PgStat_KindInfo::to_serialized_name, WARNING, write_chunk(), write_chunk_s, and PgStat_KindInfo::write_to_file.
Referenced by pgstat_before_server_shutdown().
Definition at line 1740 of file pgstat.c.
References len.
Referenced by pgstat_read_statsfile().
Definition at line 1553 of file pgstat.c.
References len.
Referenced by pgstat_write_statsfile().
Definition at line 255 of file pgstat.c.
Referenced by assign_stats_fetch_consistency(), pgstat_clear_snapshot(), pgstat_get_stat_snapshot_timestamp(), pgstat_prep_snapshot(), and pgstat_snapshot_fixed().
Definition at line 204 of file pgstat.c.
Referenced by assign_stats_fetch_consistency(), pgstat_build_snapshot(), pgstat_build_snapshot_fixed(), pgstat_fetch_entry(), pgstat_prep_snapshot(), pgstat_snapshot_fixed(), and pgstat_write_statsfile().
Definition at line 281 of file pgstat.c.
Referenced by pgstat_get_kind_from_str(), and pgstat_get_kind_info().
Definition at line 492 of file pgstat.c.
Referenced by pgstat_get_kind_from_str(), pgstat_get_kind_info(), and pgstat_register_kind().
Definition at line 218 of file pgstat.c.
Referenced by AdvanceXLInsertBuffer(), get_slru_entry(), pgstat_count_backend_io_op(), pgstat_count_backend_io_op_time(), pgstat_count_io_op(), pgstat_report_stat(), and XLogInsertRecord().
Definition at line 203 of file pgstat.c.
Referenced by autovac_init(), AutoVacuumingActive(), pgstat_init_relation(), pgstat_report_analyze(), pgstat_report_checksum_failures_in_db(), pgstat_report_deadlock(), pgstat_report_recovery_conflict(), pgstat_report_tempfile(), and pgstat_report_vacuum().
Definition at line 249 of file pgstat.c.
Referenced by pgstat_force_next_flush(), and pgstat_report_stat().
Definition at line 212 of file pgstat.c.
Referenced by pgstat_acquire_entry_ref(), pgstat_archiver_reset_all_cb(), pgstat_archiver_snapshot_cb(), pgstat_attach_shmem(), pgstat_before_server_shutdown(), pgstat_bgwriter_reset_all_cb(), pgstat_bgwriter_snapshot_cb(), pgstat_build_snapshot(), pgstat_build_snapshot_fixed(), pgstat_checkpointer_reset_all_cb(), pgstat_checkpointer_snapshot_cb(), pgstat_clear_snapshot(), pgstat_detach_shmem(), pgstat_drop_database_and_contents(), pgstat_drop_entry(), pgstat_drop_entry_internal(), pgstat_drop_matching_entries(), pgstat_fetch_entry(), pgstat_fetch_slru(), pgstat_fetch_stat_archiver(), pgstat_fetch_stat_bgwriter(), pgstat_fetch_stat_checkpointer(), pgstat_fetch_stat_io(), pgstat_fetch_stat_wal(), pgstat_free_entry(), pgstat_gc_entry_refs(), pgstat_get_custom_shmem_data(), pgstat_get_custom_snapshot_data(), pgstat_get_entry_count(), pgstat_get_entry_ref(), pgstat_get_stat_snapshot_timestamp(), pgstat_init_entry(), pgstat_init_snapshot_fixed(), pgstat_io_flush_cb(), pgstat_io_reset_all_cb(), pgstat_io_snapshot_cb(), pgstat_need_entry_refs_gc(), pgstat_prep_snapshot(), pgstat_read_statsfile(), pgstat_reinit_entry(), pgstat_release_entry_ref(), pgstat_report_archiver(), pgstat_report_bgwriter(), pgstat_report_checkpointer(), pgstat_report_stat(), pgstat_request_entry_refs_gc(), pgstat_reset_matching_entries(), pgstat_reset_slru_counter_internal(), pgstat_setup_shared_refs(), pgstat_slru_flush_cb(), pgstat_slru_snapshot_cb(), pgstat_snapshot_fixed(), pgstat_wal_flush_cb(), pgstat_wal_reset_all_cb(), pgstat_wal_snapshot_cb(), pgstat_write_statsfile(), and StatsShmemInit().
Definition at line 242 of file pgstat.c.
Referenced by pgstat_flush_pending_entries(), pgstat_prep_pending_entry(), pgstat_report_stat(), and pgstat_shutdown_hook().
Definition at line 234 of file pgstat.c.
Referenced by pgstat_prep_pending_entry().