PostgreSQL Source Code git master
|
#include "postgres.h"
#include "common/hashfn.h"
#include "common/int.h"
#include "lib/ilist.h"
#include "storage/aio.h"
#include "storage/ipc.h"
#include "storage/predicate.h"
#include "storage/proc.h"
#include "utils/memutils.h"
#include "utils/resowner.h"
Go to the source code of this file.
Data Structures | |
struct | ResourceElem |
struct | ResourceOwnerData |
struct | ResourceReleaseCallbackItem |
Macros | |
#define | RESOWNER_ARRAY_SIZE 32 |
#define | RESOWNER_HASH_INIT_SIZE 64 |
#define | RESOWNER_HASH_MAX_ITEMS(capacity) Min(capacity - RESOWNER_ARRAY_SIZE, (capacity)/4 * 3) |
#define | MAX_RESOWNER_LOCKS 15 |
Typedefs | |
typedef struct ResourceElem | ResourceElem |
typedef struct ResourceReleaseCallbackItem | ResourceReleaseCallbackItem |
Variables | |
ResourceOwner | CurrentResourceOwner = NULL |
ResourceOwner | CurTransactionResourceOwner = NULL |
ResourceOwner | TopTransactionResourceOwner = NULL |
ResourceOwner | AuxProcessResourceOwner = NULL |
static ResourceReleaseCallbackItem * | ResourceRelease_callbacks = NULL |
#define MAX_RESOWNER_LOCKS 15 |
Definition at line 107 of file resowner.c.
#define RESOWNER_ARRAY_SIZE 32 |
Definition at line 73 of file resowner.c.
#define RESOWNER_HASH_INIT_SIZE 64 |
Definition at line 79 of file resowner.c.
#define RESOWNER_HASH_MAX_ITEMS | ( | capacity | ) | Min(capacity - RESOWNER_ARRAY_SIZE, (capacity)/4 * 3) |
Definition at line 91 of file resowner.c.
typedef struct ResourceElem ResourceElem |
typedef struct ResourceReleaseCallbackItem ResourceReleaseCallbackItem |
void CreateAuxProcessResourceOwner | ( | void | ) |
Definition at line 999 of file resowner.c.
References Assert(), AuxProcessResourceOwner, CurrentResourceOwner, on_shmem_exit(), ReleaseAuxProcessResourcesCallback(), and ResourceOwnerCreate().
Referenced by AuxiliaryProcessMainCommon(), InitPostgres(), and InitWalSender().
|
inlinestatic |
Definition at line 222 of file resowner.c.
References hash_combine(), hash_combine64(), murmurhash32(), murmurhash64(), and value.
Referenced by ResourceOwnerAddToHash(), and ResourceOwnerForget().
void RegisterResourceReleaseCallback | ( | ResourceReleaseCallback | callback, |
void * | arg | ||
) |
Definition at line 961 of file resowner.c.
References ResourceReleaseCallbackItem::arg, arg, ResourceReleaseCallbackItem::callback, callback(), MemoryContextAlloc(), ResourceReleaseCallbackItem::next, ResourceRelease_callbacks, and TopMemoryContext.
void ReleaseAuxProcessResources | ( | bool | isCommit | ) |
Definition at line 1019 of file resowner.c.
References AuxProcessResourceOwner, ResourceOwnerData::releasing, RESOURCE_RELEASE_AFTER_LOCKS, RESOURCE_RELEASE_BEFORE_LOCKS, RESOURCE_RELEASE_LOCKS, ResourceOwnerRelease(), and ResourceOwnerData::sorted.
Referenced by AutoVacLauncherMain(), BackgroundWriterMain(), CheckpointerMain(), InitPostgres(), perform_base_backup(), pgarch_archiveXlog(), ReleaseAuxProcessResourcesCallback(), UploadManifest(), WalSndErrorCleanup(), WalSummarizerMain(), and WalWriterMain().
|
static |
Definition at line 1044 of file resowner.c.
References ReleaseAuxProcessResources().
Referenced by CreateAuxProcessResourceOwner().
|
static |
Definition at line 269 of file resowner.c.
References a, b, ResourceElem::kind, pg_cmp_u32(), ResourceOwnerDesc::release_phase, and ResourceOwnerDesc::release_priority.
Referenced by ResourceOwnerSort().
|
static |
Definition at line 245 of file resowner.c.
References Assert(), ResourceOwnerData::capacity, ResourceOwnerData::hash, hash_resource_elem(), idx(), ResourceElem::item, ResourceElem::kind, ResourceOwnerData::nhash, and value.
Referenced by ResourceOwnerEnlarge().
ResourceOwner ResourceOwnerCreate | ( | ResourceOwner | parent, |
const char * | name | ||
) |
Definition at line 421 of file resowner.c.
References ResourceOwnerData::aio_handles, dlist_init(), ResourceOwnerData::firstchild, MemoryContextAllocZero(), name, ResourceOwnerData::name, ResourceOwnerData::nextchild, ResourceOwnerData::parent, and TopMemoryContext.
Referenced by AtStart_ResourceOwner(), AtSubStart_ResourceOwner(), CreateAuxProcessResourceOwner(), CreatePortal(), plpgsql_call_handler(), plpgsql_create_econtext(), plpgsql_inline_handler(), test_dsa_resowners(), test_resowner_forget_between_phases(), test_resowner_leak(), test_resowner_many(), test_resowner_priorities(), and test_resowner_remember_between_phases().
void ResourceOwnerDelete | ( | ResourceOwner | owner | ) |
Definition at line 871 of file resowner.c.
References Assert(), CurrentResourceOwner, ResourceOwnerData::firstchild, ResourceOwnerData::hash, MAX_RESOWNER_LOCKS, ResourceOwnerData::narr, ResourceOwnerData::nhash, ResourceOwnerData::nlocks, pfree(), ResourceOwnerDelete(), and ResourceOwnerNewParent().
Referenced by CleanupSubTransaction(), CleanupTransaction(), CommitSubTransaction(), CommitTransaction(), plpgsql_call_handler(), plpgsql_inline_handler(), PortalDrop(), PrepareTransaction(), ResourceOwnerDelete(), test_dsa_resowners(), test_resowner_leak(), test_resowner_many(), and test_resowner_priorities().
void ResourceOwnerEnlarge | ( | ResourceOwner | owner | ) |
Definition at line 452 of file resowner.c.
References ResourceOwnerData::arr, Assert(), ResourceOwnerData::capacity, elog, ERROR, ResourceOwnerData::grow_at, ResourceOwnerData::hash, i, ResourceElem::item, ResourceElem::kind, MemoryContextAllocZero(), ResourceOwnerData::narr, ResourceOwnerData::nhash, pfree(), ResourceOwnerData::releasing, ResourceOwnerAddToHash(), RESOWNER_ARRAY_SIZE, RESOWNER_HASH_INIT_SIZE, RESOWNER_HASH_MAX_ITEMS, and TopMemoryContext.
Referenced by BufferAlloc(), CachedPlanAllowsSimpleValidityCheck(), CachedPlanIsSimplyValid(), CreateWaitEventSet(), dsm_create_descriptor(), dsm_unpin_mapping(), EvictAllUnpinnedBuffers(), EvictRelUnpinnedBuffers(), EvictUnpinnedBuffer(), ExtendBufferedRelLocal(), ExtendBufferedRelShared(), FlushDatabaseBuffers(), FlushRelationBuffers(), FlushRelationsAllBuffers(), GetCachedPlan(), GetLocalVictimBuffer(), GetVictimBuffer(), IncrBufferRefCount(), IncrTupleDescRefCount(), llvm_create_context(), LocalBufferAlloc(), OpenTemporaryFile(), PathNameCreateTemporaryFile(), PathNameOpenTemporaryFile(), pg_cryptohash_create(), pg_hmac_create(), px_find_cipher(), px_find_digest(), ReadRecentBuffer(), RegisterSnapshotOnOwner(), RelationIncrementReferenceCount(), RememberManyTestResources(), SearchCatCacheInternal(), SearchCatCacheList(), SearchCatCacheMiss(), StartBufferIO(), SyncOneBuffer(), test_resowner_forget_between_phases(), test_resowner_leak(), test_resowner_priorities(), and test_resowner_remember_between_phases().
void ResourceOwnerForget | ( | ResourceOwner | owner, |
Datum | value, | ||
const ResourceOwnerDesc * | kind | ||
) |
Definition at line 564 of file resowner.c.
References ResourceOwnerData::arr, Assert(), ResourceOwnerData::capacity, DatumGetPointer(), elog, ERROR, ResourceOwnerData::hash, hash_resource_elem(), i, idx(), ResourceElem::item, ResourceElem::kind, ResourceOwnerData::name, ResourceOwnerDesc::name, ResourceOwnerData::narr, ResourceOwnerData::nhash, ResourceOwnerData::releasing, ResourceOwnerData::sorted, and value.
Referenced by ForgetManyTestResources(), ResourceOwnerForgetBuffer(), ResourceOwnerForgetBufferIO(), ResourceOwnerForgetCatCacheListRef(), ResourceOwnerForgetCatCacheRef(), ResourceOwnerForgetCryptoHash(), ResourceOwnerForgetDSM(), ResourceOwnerForgetFile(), ResourceOwnerForgetHMAC(), ResourceOwnerForgetJIT(), ResourceOwnerForgetOSSLCipher(), ResourceOwnerForgetOSSLDigest(), ResourceOwnerForgetPlanCacheRef(), ResourceOwnerForgetRelationRef(), ResourceOwnerForgetSnapshot(), ResourceOwnerForgetTupleDesc(), ResourceOwnerForgetWaitEventSet(), and test_resowner_forget_between_phases().
void ResourceOwnerForgetAioHandle | ( | ResourceOwner | owner, |
struct dlist_node * | ioh_node | ||
) |
Definition at line 1110 of file resowner.c.
References ResourceOwnerData::aio_handles, and dlist_delete_from().
Referenced by pgaio_io_reclaim(), and pgaio_io_release_resowner().
void ResourceOwnerForgetLock | ( | ResourceOwner | owner, |
LOCALLOCK * | locallock | ||
) |
Definition at line 1082 of file resowner.c.
References Assert(), elog, ERROR, i, ResourceOwnerData::locks, MAX_RESOWNER_LOCKS, ResourceOwnerData::name, and ResourceOwnerData::nlocks.
Referenced by LockReassignOwner(), LockRelease(), LockReleaseAll(), ReleaseLockIfHeld(), and RemoveLocalLock().
ResourceOwner ResourceOwnerGetParent | ( | ResourceOwner | owner | ) |
Definition at line 905 of file resowner.c.
References ResourceOwnerData::parent.
Referenced by LockReassignCurrentOwner().
void ResourceOwnerNewParent | ( | ResourceOwner | owner, |
ResourceOwner | newparent | ||
) |
Definition at line 914 of file resowner.c.
References Assert(), ResourceOwnerData::firstchild, ResourceOwnerData::nextchild, and ResourceOwnerData::parent.
Referenced by AtSubAbort_Portals(), AtSubCommit_Portals(), and ResourceOwnerDelete().
void ResourceOwnerRelease | ( | ResourceOwner | owner, |
ResourceReleasePhase | phase, | ||
bool | isCommit, | ||
bool | isTopLevel | ||
) |
Definition at line 658 of file resowner.c.
References elog, LOG, and ResourceOwnerReleaseInternal().
Referenced by AbortSubTransaction(), AbortTransaction(), CommitSubTransaction(), CommitTransaction(), PortalDrop(), PrepareTransaction(), ReleaseAuxProcessResources(), test_dsa_resowners(), test_resowner_forget_between_phases(), test_resowner_leak(), test_resowner_many(), test_resowner_priorities(), and test_resowner_remember_between_phases().
|
static |
Definition at line 348 of file resowner.c.
References ResourceOwnerData::arr, Assert(), DatumGetPointer(), ResourceOwnerDesc::DebugPrint, elog, ResourceOwnerData::hash, idx(), items, ResourceOwnerDesc::name, ResourceOwnerData::narr, ResourceOwnerData::nhash, nitems, pfree(), psprintf(), ResourceOwnerDesc::release_phase, ResourceOwnerDesc::ReleaseResource, ResourceOwnerData::releasing, ResourceOwnerData::sorted, value, and WARNING.
Referenced by ResourceOwnerReleaseInternal().
void ResourceOwnerReleaseAllOfKind | ( | ResourceOwner | owner, |
const ResourceOwnerDesc * | kind | ||
) |
Definition at line 818 of file resowner.c.
References ResourceOwnerData::arr, Assert(), ResourceOwnerData::capacity, elog, ERROR, ResourceOwnerData::hash, i, ResourceElem::item, ResourceElem::kind, ResourceOwnerDesc::name, ResourceOwnerData::narr, ResourceOwnerData::nhash, ResourceOwnerDesc::ReleaseResource, ResourceOwnerData::releasing, ResourceOwnerData::sorted, and value.
Referenced by ReleaseAllPlanCacheRefsInOwner().
|
static |
Definition at line 678 of file resowner.c.
References ResourceOwnerData::aio_handles, ResourceReleaseCallbackItem::arg, Assert(), ResourceReleaseCallbackItem::callback, CurrentResourceOwner, dlist_head_node(), dlist_is_empty(), ResourceOwnerData::firstchild, LockReassignCurrentOwner(), LockReleaseCurrentOwner(), ResourceOwnerData::locks, MAX_RESOWNER_LOCKS, next, ResourceReleaseCallbackItem::next, ResourceOwnerData::nextchild, ResourceOwnerData::nlocks, ResourceOwnerData::parent, pgaio_io_release_resowner(), ProcReleaseLocks(), ReleasePredicateLocks(), ResourceOwnerData::releasing, RESOURCE_RELEASE_AFTER_LOCKS, RESOURCE_RELEASE_BEFORE_LOCKS, RESOURCE_RELEASE_LOCKS, ResourceOwnerReleaseAll(), ResourceOwnerReleaseInternal(), ResourceOwnerSort(), ResourceRelease_callbacks, ResourceOwnerData::sorted, and TopTransactionResourceOwner.
Referenced by ResourceOwnerRelease(), and ResourceOwnerReleaseInternal().
void ResourceOwnerRemember | ( | ResourceOwner | owner, |
Datum | value, | ||
const ResourceOwnerDesc * | kind | ||
) |
Definition at line 524 of file resowner.c.
References ResourceOwnerData::arr, Assert(), elog, ERROR, idx(), ResourceElem::item, ResourceElem::kind, ResourceOwnerData::narr, ResourceOwnerDesc::release_phase, ResourceOwnerDesc::release_priority, ResourceOwnerData::releasing, RESOWNER_ARRAY_SIZE, ResourceOwnerData::sorted, and value.
Referenced by RememberManyTestResources(), ResourceOwnerRememberBuffer(), ResourceOwnerRememberBufferIO(), ResourceOwnerRememberCatCacheListRef(), ResourceOwnerRememberCatCacheRef(), ResourceOwnerRememberCryptoHash(), ResourceOwnerRememberDSM(), ResourceOwnerRememberFile(), ResourceOwnerRememberHMAC(), ResourceOwnerRememberJIT(), ResourceOwnerRememberOSSLCipher(), ResourceOwnerRememberOSSLDigest(), ResourceOwnerRememberPlanCacheRef(), ResourceOwnerRememberRelationRef(), ResourceOwnerRememberSnapshot(), ResourceOwnerRememberTupleDesc(), ResourceOwnerRememberWaitEventSet(), test_resowner_forget_between_phases(), test_resowner_leak(), test_resowner_priorities(), and test_resowner_remember_between_phases().
void ResourceOwnerRememberAioHandle | ( | ResourceOwner | owner, |
struct dlist_node * | ioh_node | ||
) |
Definition at line 1104 of file resowner.c.
References ResourceOwnerData::aio_handles, and dlist_push_tail().
Referenced by pgaio_io_resowner_register().
void ResourceOwnerRememberLock | ( | ResourceOwner | owner, |
LOCALLOCK * | locallock | ||
) |
Definition at line 1062 of file resowner.c.
References Assert(), ResourceOwnerData::locks, MAX_RESOWNER_LOCKS, and ResourceOwnerData::nlocks.
Referenced by GrantLockLocal(), and LockReassignOwner().
|
static |
Definition at line 292 of file resowner.c.
References ResourceOwnerData::arr, Assert(), ResourceOwnerData::capacity, ResourceOwnerData::hash, idx(), items, ResourceElem::kind, ResourceOwnerData::narr, ResourceOwnerData::nhash, nitems, qsort, and resource_priority_cmp().
Referenced by ResourceOwnerReleaseInternal().
StaticAssertDecl | ( | RESOWNER_HASH_MAX_ITEMS(RESOWNER_HASH_INIT_SIZE) >= | RESOWNER_ARRAY_SIZE, |
"initial hash size too small compared to array size" | |||
) |
void UnregisterResourceReleaseCallback | ( | ResourceReleaseCallback | callback, |
void * | arg | ||
) |
Definition at line 975 of file resowner.c.
References ResourceReleaseCallbackItem::arg, arg, ResourceReleaseCallbackItem::callback, callback(), ResourceReleaseCallbackItem::next, pfree(), and ResourceRelease_callbacks.
ResourceOwner AuxProcessResourceOwner = NULL |
Definition at line 176 of file resowner.c.
Referenced by AutoVacLauncherMain(), CreateAuxProcessResourceOwner(), perform_base_backup(), ReleaseAuxProcessResources(), ShutdownXLOG(), StartupXLOG(), and UploadManifest().
ResourceOwner CurrentResourceOwner = NULL |
Definition at line 173 of file resowner.c.
Referenced by _SPI_execute_plan(), apply_spooled_messages(), AssignTransactionId(), AsyncReadBuffers(), AtAbort_ResourceOwner(), AtStart_ResourceOwner(), AtSubAbort_ResourceOwner(), AtSubStart_ResourceOwner(), attach_internal(), buffer_call_start_io(), buffer_stage_common(), BufferAlloc(), CleanupSubTransaction(), CleanupTransaction(), close_lo_relation(), CommitSubTransaction(), CommitTransaction(), create_internal(), CreateAuxProcessResourceOwner(), DecrTupleDescRefCount(), dsm_create_descriptor(), dsm_unpin_mapping(), EvictAllUnpinnedBuffers(), EvictRelUnpinnedBuffers(), EvictUnpinnedBuffer(), exec_eval_simple_expr(), exec_init_tuple_store(), exec_simple_check_plan(), exec_stmt_block(), ExecAppendAsyncEventWait(), ExplainExecuteQuery(), ExtendBufferedRelLocal(), ExtendBufferedRelShared(), extendBufFile(), FlushDatabaseBuffers(), FlushRelationBuffers(), FlushRelationsAllBuffers(), get_segment_by_index(), GetCurrentFDWTuplestore(), GetLocalVictimBuffer(), GetVictimBuffer(), handle_get(), handle_get_and_error(), handle_get_release(), handle_get_twice(), IncrBufferRefCount(), IncrTupleDescRefCount(), init_execution_state(), InitPostgres(), llvm_create_context(), LocalBufferAlloc(), lock_and_open_sequence(), LockAcquireExtended(), LockReassignCurrentOwner(), LockReassignOwner(), LockRelease(), LogicalSlotAdvanceAndCheckSnapState(), make_callstmt_target(), make_new_segment(), makeBufFileCommon(), MakeTransitionCaptureState(), open_lo_relation(), OpenTemporaryFile(), PathNameCreateTemporaryFile(), PathNameOpenTemporaryFile(), perform_base_backup(), PersistHoldablePortal(), pg_cryptohash_create(), pg_hmac_create(), pg_logical_slot_get_changes_guts(), pgaio_io_resowner_register(), PinBuffer(), PinBuffer_Locked(), PinLocalBuffer(), plperl_spi_exec(), plperl_spi_exec_prepared(), plperl_spi_fetchrow(), plperl_spi_prepare(), plperl_spi_query(), plperl_spi_query_prepared(), plpgsql_estate_setup(), pltcl_func_handler(), pltcl_init_tuple_store(), pltcl_returnnext(), pltcl_SPI_execute(), pltcl_SPI_execute_plan(), pltcl_SPI_prepare(), pltcl_subtrans_abort(), pltcl_subtrans_commit(), pltcl_subtransaction(), PLy_abort_open_subtransactions(), PLy_cursor_fetch(), PLy_cursor_iternext(), PLy_cursor_plan(), PLy_cursor_query(), PLy_spi_execute_plan(), PLy_spi_execute_query(), PLy_spi_prepare(), PLy_spi_subtransaction_abort(), PLy_spi_subtransaction_commit(), PLy_subtransaction_enter(), PLy_subtransaction_exit(), PopTransaction(), PortalCleanup(), PortalRun(), PortalRunFetch(), PortalStart(), PrepareTransaction(), px_find_cipher(), px_find_digest(), read_rel_block_ll(), ReadRecentBuffer(), RegisterSnapshot(), RegisterTemporaryFile(), RelationDecrementReferenceCount(), RelationIncrementReferenceCount(), ReleaseCatCache(), ReleaseCatCacheList(), ReleaseCatCacheListWithOwner(), ReleaseCatCacheWithOwner(), ReleaseLockIfHeld(), ResourceOwnerDelete(), ResourceOwnerReleaseInternal(), SearchCatCacheInternal(), SearchCatCacheList(), SearchCatCacheMiss(), ShutdownXLOG(), SnapBuildClearExportedSnapshot(), SnapBuildExportSnapshot(), SPI_plan_get_cached_plan(), StartBufferIO(), StartupXLOG(), SyncOneBuffer(), TerminateBufferIO(), test_dsa_resowners(), test_resowner_forget_between_phases(), test_resowner_leak(), test_resowner_many(), test_resowner_priorities(), test_resowner_remember_between_phases(), tuplestore_begin_common(), tuplestore_puttuple_common(), UnpinBuffer(), UnpinLocalBuffer(), UnregisterSnapshot(), UploadManifest(), and WaitLatchOrSocket().
ResourceOwner CurTransactionResourceOwner = NULL |
Definition at line 174 of file resowner.c.
Referenced by AtStart_ResourceOwner(), AtSubStart_ResourceOwner(), CleanupSubTransaction(), CleanupTransaction(), CommitSubTransaction(), CommitTransaction(), CreatePortal(), GetCurrentFDWTuplestore(), MakeTransitionCaptureState(), PopTransaction(), and PrepareTransaction().
|
static |
Definition at line 195 of file resowner.c.
Referenced by RegisterResourceReleaseCallback(), ResourceOwnerReleaseInternal(), and UnregisterResourceReleaseCallback().
ResourceOwner TopTransactionResourceOwner = NULL |
Definition at line 175 of file resowner.c.
Referenced by AbortTransaction(), apply_spooled_messages(), AtAbort_ResourceOwner(), AtStart_ResourceOwner(), be_lo_open(), CleanupTransaction(), close_lo_relation(), closeLOfd(), CommitTransaction(), lock_and_open_sequence(), open_lo_relation(), plpgsql_create_econtext(), PortalRun(), PrepareTransaction(), and ResourceOwnerReleaseInternal().