PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <signal.h>
#include <unistd.h>
#include "access/parallel.h"
#include "commands/async.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "port/pg_bitutils.h"
#include "replication/logicalworker.h"
#include "replication/walsender.h"
#include "storage/condition_variable.h"
#include "storage/ipc.h"
#include "storage/latch.h"
#include "storage/shmem.h"
#include "storage/sinval.h"
#include "storage/smgr.h"
#include "tcop/tcopprot.h"
#include "utils/memutils.h"
Go to the source code of this file.
Data Structures | |
struct | ProcSignalSlot |
struct | ProcSignalHeader |
Macros | |
#define | NumProcSignalSlots (MaxBackends + NUM_AUXILIARY_PROCS) |
#define | BARRIER_SHOULD_CHECK(flags, type) (((flags) & (((uint32) 1) << (uint32) (type))) != 0) |
#define | BARRIER_CLEAR_BIT(flags, type) ((flags) &= ~(((uint32) 1) << (uint32) (type))) |
Functions | |
static bool | CheckProcSignal (ProcSignalReason reason) |
static void | CleanupProcSignalState (int status, Datum arg) |
static void | ResetProcSignalBarrierBits (uint32 flags) |
Size | ProcSignalShmemSize (void) |
void | ProcSignalShmemInit (void) |
void | ProcSignalInit (bool cancel_key_valid, int32 cancel_key) |
int | SendProcSignal (pid_t pid, ProcSignalReason reason, ProcNumber procNumber) |
uint64 | EmitProcSignalBarrier (ProcSignalBarrierType type) |
void | WaitForProcSignalBarrier (uint64 generation) |
static void | HandleProcSignalBarrierInterrupt (void) |
void | ProcessProcSignalBarrier (void) |
void | procsignal_sigusr1_handler (SIGNAL_ARGS) |
void | SendCancelRequest (int backendPID, int32 cancelAuthCode) |
Variables | |
NON_EXEC_STATIC ProcSignalHeader * | ProcSignal = NULL |
static ProcSignalSlot * | MyProcSignalSlot = NULL |
Definition at line 101 of file procsignal.c.
Definition at line 97 of file procsignal.c.
#define NumProcSignalSlots (MaxBackends + NUM_AUXILIARY_PROCS) |
Definition at line 94 of file procsignal.c.
|
static |
Definition at line 646 of file procsignal.c.
References MyProcSignalSlot, and ProcSignalSlot::pss_signalFlags.
Referenced by procsignal_sigusr1_handler().
|
static |
Definition at line 225 of file procsignal.c.
References Assert, ConditionVariableBroadcast(), elog, LOG, MyProcPid, MyProcSignalSlot, pg_atomic_read_u32(), pg_atomic_write_u32(), pg_atomic_write_u64(), PG_UINT64_MAX, ProcSignal, ProcSignalHeader::psh_slot, ProcSignalSlot::pss_barrierCV, ProcSignalSlot::pss_barrierGeneration, ProcSignalSlot::pss_cancel_key, ProcSignalSlot::pss_cancel_key_valid, ProcSignalSlot::pss_mutex, ProcSignalSlot::pss_pid, SpinLockAcquire, and SpinLockRelease.
Referenced by ProcSignalInit().
uint64 EmitProcSignalBarrier | ( | ProcSignalBarrierType | type | ) |
Definition at line 353 of file procsignal.c.
References i, kill, NumProcSignalSlots, pg_atomic_add_fetch_u64(), pg_atomic_fetch_or_u32(), pg_atomic_read_u32(), PROCSIG_BARRIER, ProcSignal, ProcSignalHeader::psh_barrierGeneration, ProcSignalHeader::psh_slot, ProcSignalSlot::pss_barrierCheckMask, ProcSignalSlot::pss_mutex, ProcSignalSlot::pss_pid, ProcSignalSlot::pss_signalFlags, SIGUSR1, SpinLockAcquire, SpinLockRelease, and type.
Referenced by dbase_redo(), dropdb(), DropTableSpace(), movedb(), and tblspc_redo().
|
static |
Definition at line 480 of file procsignal.c.
References InterruptPending, and ProcSignalBarrierPending.
Referenced by procsignal_sigusr1_handler().
void ProcessProcSignalBarrier | ( | void | ) |
Definition at line 496 of file procsignal.c.
References Assert, BARRIER_CLEAR_BIT, ConditionVariableBroadcast(), MyProcSignalSlot, pg_atomic_exchange_u32(), pg_atomic_read_u64(), pg_atomic_write_u64(), PG_CATCH, PG_END_TRY, PG_RE_THROW, pg_rightmost_one_pos32(), PG_TRY, ProcessBarrierSmgrRelease(), ProcSignal, PROCSIGNAL_BARRIER_SMGRRELEASE, ProcSignalBarrierPending, ProcSignalHeader::psh_barrierGeneration, ProcSignalSlot::pss_barrierCheckMask, ProcSignalSlot::pss_barrierCV, ProcSignalSlot::pss_barrierGeneration, ResetProcSignalBarrierBits(), success, and type.
Referenced by BufferSync(), CheckpointWriteDelay(), HandleAutoVacLauncherInterrupts(), HandleCheckpointerInterrupts(), HandleMainLoopInterrupts(), HandlePgArchInterrupts(), HandleStartupProcInterrupts(), HandleWalSummarizerInterrupts(), and ProcessInterrupts().
void procsignal_sigusr1_handler | ( | SIGNAL_ARGS | ) |
Definition at line 671 of file procsignal.c.
References CheckProcSignal(), HandleCatchupInterrupt(), HandleLogMemoryContextInterrupt(), HandleNotifyInterrupt(), HandleParallelApplyMessageInterrupt(), HandleParallelMessageInterrupt(), HandleProcSignalBarrierInterrupt(), HandleRecoveryConflictInterrupt(), HandleWalSndInitStopping(), MyLatch, PROCSIG_BARRIER, PROCSIG_CATCHUP_INTERRUPT, PROCSIG_LOG_MEMORY_CONTEXT, PROCSIG_NOTIFY_INTERRUPT, PROCSIG_PARALLEL_APPLY_MESSAGE, PROCSIG_PARALLEL_MESSAGE, PROCSIG_RECOVERY_CONFLICT_BUFFERPIN, PROCSIG_RECOVERY_CONFLICT_DATABASE, PROCSIG_RECOVERY_CONFLICT_LOCK, PROCSIG_RECOVERY_CONFLICT_LOGICALSLOT, PROCSIG_RECOVERY_CONFLICT_SNAPSHOT, PROCSIG_RECOVERY_CONFLICT_STARTUP_DEADLOCK, PROCSIG_RECOVERY_CONFLICT_TABLESPACE, PROCSIG_WALSND_INIT_STOPPING, and SetLatch().
Referenced by autoprewarm_main(), AutoVacWorkerMain(), BackgroundWorkerMain(), BackgroundWriterMain(), CheckpointerMain(), PgArchiverMain(), PostgresMain(), ReplSlotSyncWorkerMain(), StartupProcessMain(), WalReceiverMain(), WalSndSignals(), WalSummarizerMain(), and WalWriterMain().
Definition at line 166 of file procsignal.c.
References CleanupProcSignalState(), elog, ERROR, LOG, MemSet, MyProcNumber, MyProcPid, MyProcSignalSlot, NUM_PROCSIGNALS, NumProcSignalSlots, on_shmem_exit(), pg_atomic_read_u32(), pg_atomic_read_u64(), pg_atomic_write_u32(), pg_atomic_write_u64(), ProcSignal, ProcSignalHeader::psh_barrierGeneration, ProcSignalHeader::psh_slot, ProcSignalSlot::pss_barrierCheckMask, ProcSignalSlot::pss_barrierGeneration, ProcSignalSlot::pss_cancel_key, ProcSignalSlot::pss_cancel_key_valid, ProcSignalSlot::pss_mutex, ProcSignalSlot::pss_pid, ProcSignalSlot::pss_signalFlags, SpinLockAcquire, and SpinLockRelease.
Referenced by AuxiliaryProcessMainCommon(), and InitPostgres().
void ProcSignalShmemInit | ( | void | ) |
Definition at line 130 of file procsignal.c.
References ConditionVariableInit(), i, MemSet, NumProcSignalSlots, pg_atomic_init_u32(), pg_atomic_init_u64(), PG_UINT64_MAX, ProcSignal, ProcSignalShmemSize(), ProcSignalHeader::psh_barrierGeneration, ProcSignalHeader::psh_slot, ProcSignalSlot::pss_barrierCheckMask, ProcSignalSlot::pss_barrierCV, ProcSignalSlot::pss_barrierGeneration, ProcSignalSlot::pss_cancel_key, ProcSignalSlot::pss_cancel_key_valid, ProcSignalSlot::pss_mutex, ProcSignalSlot::pss_pid, ProcSignalSlot::pss_signalFlags, ShmemInitStruct(), size, and SpinLockInit.
Referenced by CreateOrAttachShmemStructs().
Size ProcSignalShmemSize | ( | void | ) |
Definition at line 116 of file procsignal.c.
References add_size(), mul_size(), NumProcSignalSlots, and size.
Referenced by CalculateShmemSize(), and ProcSignalShmemInit().
|
static |
Definition at line 633 of file procsignal.c.
References InterruptPending, MyProcSignalSlot, pg_atomic_fetch_or_u32(), ProcSignalBarrierPending, and ProcSignalSlot::pss_barrierCheckMask.
Referenced by ProcessProcSignalBarrier().
void SendCancelRequest | ( | int | backendPID, |
int32 | cancelAuthCode | ||
) |
Definition at line 726 of file procsignal.c.
References Assert, DEBUG2, ereport, errmsg(), errmsg_internal(), i, kill, LOG, NumProcSignalSlots, pg_atomic_read_u32(), ProcSignal, ProcSignalHeader::psh_slot, ProcSignalSlot::pss_cancel_key, ProcSignalSlot::pss_cancel_key_valid, ProcSignalSlot::pss_mutex, ProcSignalSlot::pss_pid, SpinLockAcquire, and SpinLockRelease.
Referenced by ProcessStartupPacket().
int SendProcSignal | ( | pid_t | pid, |
ProcSignalReason | reason, | ||
ProcNumber | procNumber | ||
) |
Definition at line 281 of file procsignal.c.
References Assert, i, INVALID_PROC_NUMBER, kill, NumProcSignalSlots, pg_atomic_read_u32(), ProcSignal, ProcSignalHeader::psh_slot, ProcSignalSlot::pss_mutex, ProcSignalSlot::pss_pid, ProcSignalSlot::pss_signalFlags, SIGUSR1, SpinLockAcquire, and SpinLockRelease.
Referenced by CancelDBBackends(), InvalidatePossiblyObsoleteSlot(), mq_putmessage(), pa_shutdown(), ParallelWorkerShutdown(), pg_log_backend_memory_contexts(), SICleanupQueue(), SignalBackends(), SignalVirtualTransaction(), and WalSndInitStopping().
void WaitForProcSignalBarrier | ( | uint64 | generation | ) |
Definition at line 421 of file procsignal.c.
References Assert, ConditionVariableCancelSleep(), ConditionVariableTimedSleep(), DEBUG1, elog, ereport, errmsg(), i, LOG, NumProcSignalSlots, pg_atomic_read_u32(), pg_atomic_read_u64(), pg_memory_barrier, ProcSignal, ProcSignalHeader::psh_barrierGeneration, ProcSignalHeader::psh_slot, ProcSignalSlot::pss_barrierCV, ProcSignalSlot::pss_barrierGeneration, ProcSignalSlot::pss_pid, and UINT64_FORMAT.
Referenced by dbase_redo(), dropdb(), DropTableSpace(), movedb(), and tblspc_redo().
|
static |
Definition at line 105 of file procsignal.c.
Referenced by CheckProcSignal(), CleanupProcSignalState(), ProcessProcSignalBarrier(), ProcSignalInit(), and ResetProcSignalBarrierBits().
NON_EXEC_STATIC ProcSignalHeader* ProcSignal = NULL |
Definition at line 104 of file procsignal.c.
Referenced by CleanupProcSignalState(), EmitProcSignalBarrier(), ProcessProcSignalBarrier(), ProcSignalInit(), ProcSignalShmemInit(), SendCancelRequest(), SendProcSignal(), and WaitForProcSignalBarrier().