|
PostgreSQL Source Code git master
|
#include "postgres.h"#include <unistd.h>#include <sys/stat.h>#include "access/transam.h"#include "access/xlog_internal.h"#include "access/xlogrecovery.h"#include "common/file_utils.h"#include "common/string.h"#include "miscadmin.h"#include "pgstat.h"#include "postmaster/interrupt.h"#include "replication/logicallauncher.h"#include "replication/slotsync.h"#include "replication/slot.h"#include "replication/walsender_private.h"#include "storage/fd.h"#include "storage/ipc.h"#include "storage/proc.h"#include "storage/procarray.h"#include "utils/builtins.h"#include "utils/guc_hooks.h"#include "utils/injection_point.h"#include "utils/varlena.h"
Go to the source code of this file.
Data Structures | |
| struct | ReplicationSlotOnDisk |
| struct | SyncStandbySlotsConfigData |
| struct | SlotInvalidationCauseMap |
Macros | |
| #define | ReplicationSlotOnDiskConstantSize offsetof(ReplicationSlotOnDisk, slotdata) |
| #define | ReplicationSlotOnDiskNotChecksummedSize offsetof(ReplicationSlotOnDisk, version) |
| #define | ReplicationSlotOnDiskChecksummedSize sizeof(ReplicationSlotOnDisk) - ReplicationSlotOnDiskNotChecksummedSize |
| #define | ReplicationSlotOnDiskV2Size sizeof(ReplicationSlotOnDisk) - ReplicationSlotOnDiskConstantSize |
| #define | SLOT_MAGIC 0x1051CA1 /* format identifier */ |
| #define | SLOT_VERSION 5 /* version for new files */ |
Typedefs | |
| typedef struct ReplicationSlotOnDisk | ReplicationSlotOnDisk |
| typedef struct SlotInvalidationCauseMap | SlotInvalidationCauseMap |
Variables | |
| static const SlotInvalidationCauseMap | SlotInvalidationCauses [] |
| ReplicationSlotCtlData * | ReplicationSlotCtl = NULL |
| ReplicationSlot * | MyReplicationSlot = NULL |
| int | max_replication_slots = 10 |
| int | idle_replication_slot_timeout_secs = 0 |
| char * | synchronized_standby_slots |
| static SyncStandbySlotsConfigData * | synchronized_standby_slots_config |
| static XLogRecPtr | ss_oldest_flush_lsn = InvalidXLogRecPtr |
| #define ReplicationSlotOnDiskChecksummedSize sizeof(ReplicationSlotOnDisk) - ReplicationSlotOnDiskNotChecksummedSize |
| #define ReplicationSlotOnDiskConstantSize offsetof(ReplicationSlotOnDisk, slotdata) |
| #define ReplicationSlotOnDiskNotChecksummedSize offsetof(ReplicationSlotOnDisk, version) |
| #define ReplicationSlotOnDiskV2Size sizeof(ReplicationSlotOnDisk) - ReplicationSlotOnDiskConstantSize |
| typedef struct ReplicationSlotOnDisk ReplicationSlotOnDisk |
| typedef struct SlotInvalidationCauseMap SlotInvalidationCauseMap |
| void assign_synchronized_standby_slots | ( | const char * | newval, |
| void * | extra | ||
| ) |
Definition at line 2854 of file slot.c.
References InvalidXLogRecPtr, ss_oldest_flush_lsn, and synchronized_standby_slots_config.
|
inlinestatic |
Definition at line 1731 of file slot.c.
References ReplicationSlot::data, idle_replication_slot_timeout_secs, ReplicationSlot::inactive_since, RecoveryInProgress(), ReplicationSlotPersistentData::restart_lsn, ReplicationSlotPersistentData::synced, and XLogRecPtrIsValid.
Referenced by DetermineSlotInvalidationCause().
| bool check_synchronized_standby_slots | ( | char ** | newval, |
| void ** | extra, | ||
| GucSource | source | ||
| ) |
Definition at line 2798 of file slot.c.
References foreach_ptr, guc_malloc(), list_free(), list_length(), LOG, newval, NIL, SyncStandbySlotsConfigData::nslotnames, pfree(), pstrdup(), SyncStandbySlotsConfigData::slot_names, and validate_sync_standby_slots().
| void CheckPointReplicationSlots | ( | bool | is_shutdown | ) |
Definition at line 2126 of file slot.c.
References ReplicationSlotPersistentData::confirmed_flush, ReplicationSlot::data, DEBUG1, ReplicationSlot::dirty, elog, i, ReplicationSlot::in_use, ReplicationSlotPersistentData::invalidated, ReplicationSlot::just_dirtied, ReplicationSlot::last_saved_confirmed_flush, ReplicationSlot::last_saved_restart_lsn, LOG, LW_SHARED, LWLockAcquire(), LWLockRelease(), max_replication_slots, MAXPGPATH, ReplicationSlot::mutex, ReplicationSlotPersistentData::name, NameStr, PG_REPLSLOT_DIR, ReplicationSlotCtlData::replication_slots, ReplicationSlotCtl, ReplicationSlotsComputeRequiredLSN(), ReplicationSlotPersistentData::restart_lsn, RS_INVAL_NONE, SaveSlotToPath(), SlotIsLogical, SpinLockAcquire, SpinLockRelease, and sprintf.
Referenced by CheckPointGuts().
| void CheckSlotPermissions | ( | void | ) |
Definition at line 1555 of file slot.c.
References ereport, errcode(), errdetail(), errmsg(), ERROR, GetUserId(), and has_rolreplication().
Referenced by copy_replication_slot(), pg_create_logical_replication_slot(), pg_create_physical_replication_slot(), pg_drop_replication_slot(), pg_logical_slot_get_changes_guts(), pg_replication_slot_advance(), and pg_sync_replication_slots().
| void CheckSlotRequirements | ( | void | ) |
Definition at line 1533 of file slot.c.
References ereport, errcode(), errmsg(), ERROR, max_replication_slots, wal_level, and WAL_LEVEL_REPLICA.
Referenced by CheckLogicalDecodingRequirements(), copy_replication_slot(), pg_create_physical_replication_slot(), and pg_drop_replication_slot().
|
static |
Definition at line 2259 of file slot.c.
References ReplicationSlot::data, ReplicationSlot::dirty, END_CRIT_SECTION, ereport, errcode_for_file_access(), errmsg(), ERROR, fsync_fname(), MakePGDirectory(), MAXPGPATH, ReplicationSlotPersistentData::name, NameStr, PG_REPLSLOT_DIR, rmtree(), S_ISDIR, SaveSlotToPath(), sprintf, stat::st_mode, START_CRIT_SECTION, and stat.
Referenced by ReplicationSlotCreate().
|
static |
Definition at line 1747 of file slot.c.
References Assert(), CanInvalidateIdleSlot(), ReplicationSlot::data, ReplicationSlotPersistentData::database, ReplicationSlot::effective_catalog_xmin, ReplicationSlot::effective_xmin, idle_replication_slot_timeout_secs, ReplicationSlot::inactive_since, InvalidOid, IS_INJECTION_POINT_ATTACHED, now(), ReplicationSlotPersistentData::restart_lsn, RS_INVAL_HORIZON, RS_INVAL_IDLE_TIMEOUT, RS_INVAL_NONE, RS_INVAL_WAL_LEVEL, RS_INVAL_WAL_REMOVED, SlotIsLogical, TimestampDifferenceExceedsSeconds(), TransactionIdIsValid, TransactionIdPrecedesOrEquals(), and XLogRecPtrIsValid.
Referenced by InvalidatePossiblyObsoleteSlot().
| ReplicationSlotInvalidationCause GetSlotInvalidationCause | ( | const char * | cause_name | ) |
Definition at line 2725 of file slot.c.
References Assert(), SlotInvalidationCauseMap::cause, i, RS_INVAL_MAX_CAUSES, RS_INVAL_NONE, and SlotInvalidationCauses.
Referenced by synchronize_slots().
| const char * GetSlotInvalidationCauseName | ( | ReplicationSlotInvalidationCause | cause | ) |
Definition at line 2745 of file slot.c.
References Assert(), SlotInvalidationCauseMap::cause_name, i, RS_INVAL_MAX_CAUSES, and SlotInvalidationCauses.
Referenced by pg_get_replication_slots(), and ReplicationSlotAcquire().
| bool InvalidateObsoleteReplicationSlots | ( | uint32 | possible_causes, |
| XLogSegNo | oldestSegno, | ||
| Oid | dboid, | ||
| TransactionId | snapshotConflictHorizon | ||
| ) |
Definition at line 2066 of file slot.c.
References Assert(), i, ReplicationSlot::in_use, InvalidatePossiblyObsoleteSlot(), IsBinaryUpgrade, LW_SHARED, LWLockAcquire(), LWLockRelease(), max_replication_slots, ReplicationSlotCtlData::replication_slots, ReplicationSlotCtl, ReplicationSlotsComputeRequiredLSN(), ReplicationSlotsComputeRequiredXmin(), RS_INVAL_HORIZON, RS_INVAL_NONE, RS_INVAL_WAL_REMOVED, SlotIsLogical, TransactionIdIsValid, wal_segment_size, and XLogSegNoOffsetToRecPtr.
Referenced by CreateCheckPoint(), CreateRestartPoint(), ResolveRecoveryConflictWithSnapshot(), and xlog_redo().
|
static |
Definition at line 1838 of file slot.c.
References ReplicationSlot::active_cv, ReplicationSlot::active_pid, Assert(), B_STARTUP, ConditionVariablePrepareToSleep(), ConditionVariableSleep(), ReplicationSlot::data, DetermineSlotInvalidationCause(), GetCurrentTimestamp(), ReplicationSlot::in_use, INVALID_PROC_NUMBER, ReplicationSlotPersistentData::invalidated, InvalidXLogRecPtr, kill, ReplicationSlot::last_saved_restart_lsn, LW_SHARED, LWLockAcquire(), LWLockHeldByMe(), LWLockHeldByMeInMode(), LWLockRelease(), ReplicationSlot::mutex, MyBackendType, MyProcPid, MyReplicationSlot, ReplicationSlotPersistentData::name, now(), PROCSIG_RECOVERY_CONFLICT_LOGICALSLOT, ReplicationSlotMarkDirty(), ReplicationSlotRelease(), ReplicationSlotSave(), ReportSlotInvalidation(), ReplicationSlotPersistentData::restart_lsn, RS_INVAL_IDLE_TIMEOUT, RS_INVAL_NONE, RS_INVAL_WAL_REMOVED, SendProcSignal(), SpinLockAcquire, SpinLockRelease, and TimestampDifference().
Referenced by InvalidateObsoleteReplicationSlots().
|
static |
Definition at line 361 of file slot.c.
References CONFLICT_DETECTION_SLOT, and name.
Referenced by ReplicationSlotAcquire(), and ReplicationSlotValidateNameInternal().
| void ReplicationSlotAcquire | ( | const char * | name, |
| bool | nowait, | ||
| bool | error_if_invalid | ||
| ) |
Definition at line 626 of file slot.c.
References ReplicationSlot::active_cv, ReplicationSlot::active_pid, am_walsender, Assert(), ConditionVariableBroadcast(), ConditionVariableCancelSleep(), ConditionVariablePrepareToSleep(), ConditionVariableSleep(), ReplicationSlot::data, DEBUG1, ereport, errcode(), errdetail(), errmsg(), ERROR, GetSlotInvalidationCauseName(), ReplicationSlot::in_use, ReplicationSlotPersistentData::invalidated, IsLogicalLauncher(), IsSlotForConflictCheck(), IsUnderPostmaster, LOG, log_replication_commands, LW_SHARED, LWLockAcquire(), LWLockRelease(), ReplicationSlot::mutex, MyProcPid, MyReplicationSlot, name, ReplicationSlotPersistentData::name, NameStr, pgstat_acquire_replslot(), ReplicationSlotSetInactiveSince(), RS_INVAL_NONE, SearchNamedReplicationSlot(), SlotIsLogical, SpinLockAcquire, and SpinLockRelease.
Referenced by acquire_conflict_slot_if_exists(), binary_upgrade_logical_slot_has_caught_up(), drop_local_obsolete_slots(), pg_logical_slot_get_changes_guts(), pg_replication_slot_advance(), ReplicationSlotAlter(), ReplicationSlotDrop(), StartLogicalReplication(), StartReplication(), and synchronize_one_slot().
| void ReplicationSlotAlter | ( | const char * | name, |
| const bool * | failover, | ||
| const bool * | two_phase | ||
| ) |
Definition at line 915 of file slot.c.
References Assert(), ReplicationSlot::data, ereport, errcode(), errdetail(), errmsg(), ERROR, failover, ReplicationSlotPersistentData::failover, ReplicationSlot::mutex, MyReplicationSlot, name, ReplicationSlotPersistentData::persistency, RecoveryInProgress(), ReplicationSlotAcquire(), ReplicationSlotMarkDirty(), ReplicationSlotRelease(), ReplicationSlotSave(), RS_TEMPORARY, SlotIsPhysical, SpinLockAcquire, SpinLockRelease, ReplicationSlotPersistentData::synced, two_phase, and ReplicationSlotPersistentData::two_phase.
Referenced by AlterReplicationSlot().
| void ReplicationSlotCleanup | ( | bool | synced_only | ) |
Definition at line 853 of file slot.c.
References ReplicationSlot::active_cv, ReplicationSlot::active_pid, Assert(), ConditionVariableBroadcast(), ReplicationSlot::data, i, ReplicationSlot::in_use, LW_SHARED, LWLockAcquire(), LWLockRelease(), max_replication_slots, ReplicationSlot::mutex, MyProcPid, MyReplicationSlot, ReplicationSlotPersistentData::persistency, ReplicationSlotCtlData::replication_slots, ReplicationSlotCtl, ReplicationSlotDropPtr(), RS_TEMPORARY, SpinLockAcquire, SpinLockRelease, and ReplicationSlotPersistentData::synced.
Referenced by PostgresMain(), ReplicationSlotShmemExit(), slotsync_failure_callback(), slotsync_worker_onexit(), SyncReplicationSlots(), and WalSndErrorCleanup().
| void ReplicationSlotCreate | ( | const char * | name, |
| bool | db_specific, | ||
| ReplicationSlotPersistency | persistency, | ||
| bool | two_phase, | ||
| bool | failover, | ||
| bool | synced | ||
| ) |
Definition at line 384 of file slot.c.
References ReplicationSlot::active_cv, ReplicationSlot::active_pid, Assert(), ReplicationSlot::candidate_catalog_xmin, ReplicationSlot::candidate_restart_lsn, ReplicationSlot::candidate_restart_valid, ReplicationSlot::candidate_xmin_lsn, ConditionVariableBroadcast(), CreateSlotOnDisk(), ReplicationSlot::data, ReplicationSlotPersistentData::database, ReplicationSlot::dirty, ReplicationSlot::effective_catalog_xmin, ReplicationSlot::effective_xmin, ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errhint(), errmsg(), ERROR, failover, ReplicationSlotPersistentData::failover, i, ReplicationSlot::in_use, ReplicationSlot::inactive_since, InvalidOid, InvalidTransactionId, InvalidXLogRecPtr, IsBinaryUpgrade, IsLogicalLauncher(), IsSyncingReplicationSlots(), ReplicationSlot::just_dirtied, ReplicationSlot::last_saved_confirmed_flush, ReplicationSlot::last_saved_restart_lsn, LW_EXCLUSIVE, LW_SHARED, LWLockAcquire(), LWLockRelease(), max_replication_slots, ReplicationSlot::mutex, MyDatabaseId, MyProcPid, MyReplicationSlot, name, ReplicationSlotPersistentData::name, NameStr, namestrcpy(), ReplicationSlotPersistentData::persistency, pgstat_create_replslot(), RecoveryInProgress(), ReplicationSlotCtlData::replication_slots, ReplicationSlotCtl, ReplicationSlotValidateName(), RS_TEMPORARY, SlotIsLogical, ReplicationSlot::slotsync_skip_reason, SpinLockAcquire, SpinLockRelease, SS_SKIP_NONE, ReplicationSlotPersistentData::synced, two_phase, ReplicationSlotPersistentData::two_phase, and ReplicationSlotPersistentData::two_phase_at.
Referenced by create_logical_replication_slot(), create_physical_replication_slot(), CreateConflictDetectionSlot(), CreateReplicationSlot(), and synchronize_one_slot().
| void ReplicationSlotDrop | ( | const char * | name, |
| bool | nowait | ||
| ) |
Definition at line 892 of file slot.c.
References Assert(), ReplicationSlot::data, ereport, errcode(), errdetail(), errmsg(), ERROR, MyReplicationSlot, name, RecoveryInProgress(), ReplicationSlotAcquire(), ReplicationSlotDropAcquired(), and ReplicationSlotPersistentData::synced.
Referenced by DropReplicationSlot(), and pg_drop_replication_slot().
| void ReplicationSlotDropAcquired | ( | void | ) |
Definition at line 997 of file slot.c.
References Assert(), MyReplicationSlot, and ReplicationSlotDropPtr().
Referenced by ApplyLauncherMain(), drop_local_obsolete_slots(), ReplicationSlotDrop(), ReplicationSlotRelease(), and ReplicationSlotsDropDBSlots().
|
static |
Definition at line 1014 of file slot.c.
References ReplicationSlot::active_cv, ReplicationSlot::active_pid, ConditionVariableBroadcast(), ReplicationSlot::data, END_CRIT_SECTION, ereport, errcode_for_file_access(), errmsg(), ERROR, fsync_fname(), ReplicationSlot::in_use, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MAXPGPATH, ReplicationSlot::mutex, ReplicationSlotPersistentData::name, NameStr, ReplicationSlotPersistentData::persistency, PG_REPLSLOT_DIR, pgstat_drop_replslot(), ReplicationSlotsComputeRequiredLSN(), ReplicationSlotsComputeRequiredXmin(), rmtree(), RS_PERSISTENT, SlotIsLogical, SpinLockAcquire, SpinLockRelease, sprintf, START_CRIT_SECTION, and WARNING.
Referenced by ReplicationSlotCleanup(), and ReplicationSlotDropAcquired().
| int ReplicationSlotIndex | ( | ReplicationSlot * | slot | ) |
Definition at line 579 of file slot.c.
References Assert(), max_replication_slots, ReplicationSlotCtlData::replication_slots, and ReplicationSlotCtl.
Referenced by get_replslot_index(), pgstat_acquire_replslot(), pgstat_create_replslot(), pgstat_drop_replslot(), pgstat_report_replslot(), pgstat_report_replslotsync(), and pgstat_reset_replslot().
| void ReplicationSlotInitialize | ( | void | ) |
Definition at line 241 of file slot.c.
References before_shmem_exit(), and ReplicationSlotShmemExit().
Referenced by BaseInit().
| void ReplicationSlotMarkDirty | ( | void | ) |
Definition at line 1139 of file slot.c.
References Assert(), ReplicationSlot::dirty, ReplicationSlot::just_dirtied, ReplicationSlot::mutex, MyReplicationSlot, SpinLockAcquire, and SpinLockRelease.
Referenced by copy_replication_slot(), create_physical_replication_slot(), CreateDecodingContext(), CreateInitDecodingContext(), CreateReplicationSlot(), init_conflict_slot_xmin(), InvalidatePossiblyObsoleteSlot(), LogicalConfirmReceivedLocation(), LogicalSlotAdvanceAndCheckSnapState(), pg_logical_slot_get_changes_guts(), pg_physical_replication_slot_advance(), PhysicalConfirmReceivedLocation(), PhysicalReplicationSlotNewXmin(), ReplicationSlotAlter(), ReplicationSlotPersist(), synchronize_one_slot(), update_conflict_slot_xmin(), and update_local_synced_slot().
| bool ReplicationSlotName | ( | int | index, |
| Name | name | ||
| ) |
Definition at line 595 of file slot.c.
References ReplicationSlot::data, ReplicationSlot::in_use, LW_SHARED, LWLockAcquire(), LWLockRelease(), name, ReplicationSlotPersistentData::name, NameStr, namestrcpy(), ReplicationSlotCtlData::replication_slots, and ReplicationSlotCtl.
Referenced by pgstat_replslot_to_serialized_name_cb().
| void ReplicationSlotPersist | ( | void | ) |
Definition at line 1156 of file slot.c.
References Assert(), ReplicationSlot::data, ReplicationSlot::mutex, MyReplicationSlot, ReplicationSlotPersistentData::persistency, ReplicationSlotMarkDirty(), ReplicationSlotSave(), RS_PERSISTENT, SpinLockAcquire, and SpinLockRelease.
Referenced by copy_replication_slot(), CreateReplicationSlot(), pg_create_logical_replication_slot(), and update_and_persist_local_synced_slot().
| void ReplicationSlotRelease | ( | void | ) |
Definition at line 764 of file slot.c.
References ReplicationSlot::active_cv, ReplicationSlot::active_pid, am_walsender, Assert(), ConditionVariableBroadcast(), ReplicationSlot::data, DEBUG1, ReplicationSlot::effective_xmin, ereport, errmsg(), GetCurrentTimestamp(), InvalidTransactionId, LOG, log_replication_commands, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), ReplicationSlot::mutex, MyProc, MyReplicationSlot, ReplicationSlotPersistentData::name, NameStr, now(), ReplicationSlotPersistentData::persistency, pfree(), PGPROC::pgxactoff, ProcGlobal, pstrdup(), ReplicationSlotDropAcquired(), ReplicationSlotsComputeRequiredXmin(), ReplicationSlotSetInactiveSince(), RS_EPHEMERAL, RS_PERSISTENT, SlotIsLogical, SpinLockAcquire, SpinLockRelease, PGPROC::statusFlags, PROC_HDR::statusFlags, TransactionIdIsValid, and ReplicationSlotPersistentData::xmin.
Referenced by binary_upgrade_create_conflict_detection_slot(), binary_upgrade_logical_slot_has_caught_up(), copy_replication_slot(), CreateReplicationSlot(), InvalidatePossiblyObsoleteSlot(), pg_create_logical_replication_slot(), pg_create_physical_replication_slot(), pg_logical_slot_get_changes_guts(), pg_replication_slot_advance(), PostgresMain(), ReplicationSlotAlter(), ReplicationSlotShmemExit(), slotsync_failure_callback(), slotsync_worker_onexit(), StartLogicalReplication(), StartReplication(), synchronize_one_slot(), and WalSndErrorCleanup().
| void ReplicationSlotReserveWal | ( | void | ) |
Definition at line 1572 of file slot.c.
References Assert(), ReplicationSlot::data, GetRedoRecPtr(), GetXLogInsertRecPtr(), GetXLogReplayRecPtr(), ReplicationSlot::last_saved_restart_lsn, LogStandbySnapshot(), ReplicationSlot::mutex, MyReplicationSlot, RecoveryInProgress(), ReplicationSlotsComputeRequiredLSN(), ReplicationSlotPersistentData::restart_lsn, SlotIsLogical, SlotIsPhysical, SpinLockAcquire, SpinLockRelease, wal_segment_size, XLByteToSeg, XLogFlush(), XLogGetLastRemovedSegno(), and XLogRecPtrIsValid.
Referenced by create_physical_replication_slot(), CreateInitDecodingContext(), and CreateReplicationSlot().
| void ReplicationSlotSave | ( | void | ) |
Definition at line 1121 of file slot.c.
References Assert(), ReplicationSlot::data, ERROR, MAXPGPATH, MyReplicationSlot, ReplicationSlotPersistentData::name, NameStr, PG_REPLSLOT_DIR, SaveSlotToPath(), and sprintf.
Referenced by copy_replication_slot(), create_physical_replication_slot(), CreateDecodingContext(), CreateInitDecodingContext(), CreateReplicationSlot(), init_conflict_slot_xmin(), InvalidatePossiblyObsoleteSlot(), LogicalConfirmReceivedLocation(), ReplicationSlotAlter(), ReplicationSlotPersist(), synchronize_one_slot(), and update_local_synced_slot().
| XLogRecPtr ReplicationSlotsComputeLogicalRestartLSN | ( | void | ) |
Definition at line 1304 of file slot.c.
References ReplicationSlot::data, i, ReplicationSlot::in_use, ReplicationSlotPersistentData::invalidated, InvalidXLogRecPtr, ReplicationSlot::last_saved_restart_lsn, LW_SHARED, LWLockAcquire(), LWLockRelease(), max_replication_slots, ReplicationSlot::mutex, ReplicationSlotPersistentData::persistency, ReplicationSlotCtlData::replication_slots, ReplicationSlotCtl, ReplicationSlotPersistentData::restart_lsn, RS_INVAL_NONE, RS_PERSISTENT, SlotIsLogical, SpinLockAcquire, SpinLockRelease, and XLogRecPtrIsValid.
Referenced by CheckPointLogicalRewriteHeap(), and CheckPointSnapBuild().
| void ReplicationSlotsComputeRequiredLSN | ( | void | ) |
Definition at line 1234 of file slot.c.
References Assert(), ReplicationSlot::data, i, ReplicationSlot::in_use, ReplicationSlotPersistentData::invalidated, InvalidXLogRecPtr, ReplicationSlot::last_saved_restart_lsn, LW_SHARED, LWLockAcquire(), LWLockRelease(), max_replication_slots, ReplicationSlot::mutex, ReplicationSlotPersistentData::persistency, ReplicationSlotCtlData::replication_slots, ReplicationSlotCtl, ReplicationSlotPersistentData::restart_lsn, RS_INVAL_NONE, RS_PERSISTENT, SpinLockAcquire, SpinLockRelease, XLogRecPtrIsValid, and XLogSetReplicationSlotMinimumLSN().
Referenced by CheckPointReplicationSlots(), copy_replication_slot(), InvalidateObsoleteReplicationSlots(), LogicalConfirmReceivedLocation(), pg_replication_slot_advance(), PhysicalConfirmReceivedLocation(), ReplicationSlotDropPtr(), ReplicationSlotReserveWal(), reserve_wal_for_local_slot(), StartupReplicationSlots(), and update_local_synced_slot().
| void ReplicationSlotsComputeRequiredXmin | ( | bool | already_locked | ) |
Definition at line 1178 of file slot.c.
References Assert(), ReplicationSlot::data, ReplicationSlot::effective_catalog_xmin, ReplicationSlot::effective_xmin, i, ReplicationSlot::in_use, ReplicationSlotPersistentData::invalidated, InvalidTransactionId, LW_SHARED, LWLockAcquire(), LWLockRelease(), max_replication_slots, ReplicationSlot::mutex, ProcArraySetReplicationSlotXmin(), ReplicationSlotCtlData::replication_slots, ReplicationSlotCtl, RS_INVAL_NONE, SpinLockAcquire, SpinLockRelease, TransactionIdIsValid, and TransactionIdPrecedes().
Referenced by copy_replication_slot(), CreateInitDecodingContext(), init_conflict_slot_xmin(), InvalidateObsoleteReplicationSlots(), LogicalConfirmReceivedLocation(), pg_replication_slot_advance(), PhysicalReplicationSlotNewXmin(), ReplicationSlotDropPtr(), ReplicationSlotRelease(), StartupReplicationSlots(), synchronize_one_slot(), update_conflict_slot_xmin(), and update_local_synced_slot().
| bool ReplicationSlotsCountDBSlots | ( | Oid | dboid, |
| int * | nslots, | ||
| int * | nactive | ||
| ) |
Definition at line 1383 of file slot.c.
References ReplicationSlot::active_pid, ReplicationSlot::data, ReplicationSlotPersistentData::database, i, ReplicationSlot::in_use, LW_SHARED, LWLockAcquire(), LWLockRelease(), max_replication_slots, ReplicationSlot::mutex, ReplicationSlotCtlData::replication_slots, ReplicationSlotCtl, SlotIsLogical, SpinLockAcquire, and SpinLockRelease.
Referenced by dropdb().
| void ReplicationSlotsDropDBSlots | ( | Oid | dboid | ) |
Definition at line 1441 of file slot.c.
References ReplicationSlot::active_pid, ReplicationSlot::data, ReplicationSlotPersistentData::database, ereport, errcode(), errmsg(), ERROR, i, ReplicationSlot::in_use, LW_SHARED, LWLockAcquire(), LWLockRelease(), max_replication_slots, ReplicationSlot::mutex, MyProcPid, MyReplicationSlot, ReplicationSlotPersistentData::name, NameStr, ReplicationSlotCtlData::replication_slots, ReplicationSlotCtl, ReplicationSlotDropAcquired(), SlotIsLogical, SpinLockAcquire, and SpinLockRelease.
Referenced by dbase_redo(), and dropdb().
|
static |
Definition at line 250 of file slot.c.
References MyReplicationSlot, ReplicationSlotCleanup(), and ReplicationSlotRelease().
Referenced by ReplicationSlotInitialize().
| void ReplicationSlotsShmemInit | ( | void | ) |
Definition at line 206 of file slot.c.
References ReplicationSlot::active_cv, ConditionVariableInit(), i, ReplicationSlot::io_in_progress_lock, LWLockInitialize(), max_replication_slots, MemSet, ReplicationSlot::mutex, ReplicationSlotCtlData::replication_slots, ReplicationSlotCtl, ReplicationSlotsShmemSize(), ShmemInitStruct(), and SpinLockInit.
Referenced by CreateOrAttachShmemStructs().
| Size ReplicationSlotsShmemSize | ( | void | ) |
Definition at line 188 of file slot.c.
References add_size(), max_replication_slots, and mul_size().
Referenced by CalculateShmemSize(), and ReplicationSlotsShmemInit().
| bool ReplicationSlotValidateName | ( | const char * | name, |
| bool | allow_reserved_name, | ||
| int | elevel | ||
| ) |
Definition at line 266 of file slot.c.
References ereport, errcode(), errhint_internal(), errmsg_internal(), name, pfree(), and ReplicationSlotValidateNameInternal().
Referenced by parse_subscription_options(), ReplicationSlotCreate(), and StartupReorderBuffer().
| bool ReplicationSlotValidateNameInternal | ( | const char * | name, |
| bool | allow_reserved_name, | ||
| int * | err_code, | ||
| char ** | err_msg, | ||
| char ** | err_hint | ||
| ) |
Definition at line 311 of file slot.c.
References _, CONFLICT_DETECTION_SLOT, IsSlotForConflictCheck(), name, NAMEDATALEN, and psprintf().
Referenced by check_primary_slot_name(), ReplicationSlotValidateName(), and validate_sync_standby_slots().
|
static |
Definition at line 1649 of file slot.c.
References _, appendStringInfo(), appendStringInfoString(), StringInfoData::data, ereport, errdetail_internal(), errhint(), errmsg(), idle_replication_slot_timeout_secs, initStringInfo(), StringInfoData::len, LOG, LSN_FORMAT_ARGS, NameStr, ngettext, pfree(), pg_unreachable, RS_INVAL_HORIZON, RS_INVAL_IDLE_TIMEOUT, RS_INVAL_NONE, RS_INVAL_WAL_LEVEL, and RS_INVAL_WAL_REMOVED.
Referenced by InvalidatePossiblyObsoleteSlot().
|
static |
Definition at line 2483 of file slot.c.
References ReplicationSlot::active_pid, ReplicationSlot::candidate_catalog_xmin, ReplicationSlot::candidate_restart_lsn, ReplicationSlot::candidate_restart_valid, ReplicationSlot::candidate_xmin_lsn, ReplicationSlotPersistentData::catalog_xmin, ReplicationSlotOnDisk::checksum, CloseTransientFile(), COMP_CRC32C, ReplicationSlotPersistentData::confirmed_flush, ReplicationSlot::data, ReplicationSlotPersistentData::database, DEBUG1, ReplicationSlot::effective_catalog_xmin, ReplicationSlot::effective_xmin, elog, EnableHotStandby, END_CRIT_SECTION, EQ_CRC32C, ereport, errcode(), ERRCODE_DATA_CORRUPTED, errcode_for_file_access(), errhint(), errmsg(), FATAL, fd(), FIN_CRC32C, fsync_fname(), GetCurrentTimestamp(), i, ReplicationSlot::in_use, INIT_CRC32C, InvalidOid, InvalidTransactionId, InvalidXLogRecPtr, ReplicationSlot::last_saved_confirmed_flush, ReplicationSlot::last_saved_restart_lsn, ReplicationSlotOnDisk::length, ReplicationSlotOnDisk::magic, max_replication_slots, MAXPGPATH, name, ReplicationSlotPersistentData::name, NameStr, now(), OpenTransientFile(), PANIC, ReplicationSlotPersistentData::persistency, PG_BINARY, pg_fsync(), PG_REPLSLOT_DIR, pgstat_report_wait_end(), pgstat_report_wait_start(), read, ReplicationSlotCtlData::replication_slots, ReplicationSlotCtl, ReplicationSlotOnDiskChecksummedSize, ReplicationSlotOnDiskConstantSize, ReplicationSlotOnDiskNotChecksummedSize, ReplicationSlotOnDiskV2Size, ReplicationSlotSetInactiveSince(), ReplicationSlotPersistentData::restart_lsn, rmtree(), RS_PERSISTENT, SLOT_MAGIC, SLOT_VERSION, ReplicationSlotOnDisk::slotdata, sprintf, StandbyMode, START_CRIT_SECTION, ReplicationSlotOnDisk::version, wal_level, WAL_LEVEL_LOGICAL, WAL_LEVEL_REPLICA, WARNING, and ReplicationSlotPersistentData::xmin.
Referenced by StartupReplicationSlots().
|
static |
Definition at line 2320 of file slot.c.
References ReplicationSlotOnDisk::checksum, CloseTransientFile(), COMP_CRC32C, ReplicationSlotPersistentData::confirmed_flush, ReplicationSlot::data, ReplicationSlot::dirty, END_CRIT_SECTION, ereport, errcode_for_file_access(), errmsg(), fd(), FIN_CRC32C, fsync_fname(), INIT_CRC32C, ReplicationSlot::io_in_progress_lock, ReplicationSlot::just_dirtied, ReplicationSlot::last_saved_confirmed_flush, ReplicationSlot::last_saved_restart_lsn, ReplicationSlotOnDisk::length, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), ReplicationSlotOnDisk::magic, MAXPGPATH, ReplicationSlot::mutex, OpenTransientFile(), PG_BINARY, pg_fsync(), PG_REPLSLOT_DIR, pgstat_report_wait_end(), pgstat_report_wait_start(), ReplicationSlotOnDiskChecksummedSize, ReplicationSlotOnDiskNotChecksummedSize, ReplicationSlotOnDiskV2Size, ReplicationSlotPersistentData::restart_lsn, SLOT_MAGIC, SLOT_VERSION, ReplicationSlotOnDisk::slotdata, SpinLockAcquire, SpinLockRelease, sprintf, START_CRIT_SECTION, ReplicationSlotOnDisk::version, and write.
Referenced by CheckPointReplicationSlots(), CreateSlotOnDisk(), and ReplicationSlotSave().
| ReplicationSlot * SearchNamedReplicationSlot | ( | const char * | name, |
| bool | need_lock | ||
| ) |
Definition at line 546 of file slot.c.
References ReplicationSlot::data, i, ReplicationSlot::in_use, LW_SHARED, LWLockAcquire(), LWLockRelease(), max_replication_slots, name, ReplicationSlotPersistentData::name, NameStr, ReplicationSlotCtlData::replication_slots, and ReplicationSlotCtl.
Referenced by acquire_conflict_slot_if_exists(), get_replslot_index(), pg_ls_replslotdir(), pgstat_reset_replslot(), ReadReplicationSlot(), ReplicationSlotAcquire(), StandbySlotsHaveCaughtup(), and synchronize_one_slot().
| bool SlotExistsInSyncStandbySlots | ( | const char * | slot_name | ) |
Definition at line 2869 of file slot.c.
References i, SyncStandbySlotsConfigData::nslotnames, SyncStandbySlotsConfigData::slot_names, and synchronized_standby_slots_config.
Referenced by PhysicalWakeupLogicalWalSnd().
| bool StandbySlotsHaveCaughtup | ( | XLogRecPtr | wait_for_lsn, |
| int | elevel | ||
| ) |
Definition at line 2902 of file slot.c.
References ReplicationSlot::active_pid, Assert(), ReplicationSlot::data, ereport, errcode(), errdetail(), errhint(), errmsg(), i, ReplicationSlotPersistentData::invalidated, InvalidXLogRecPtr, LW_SHARED, LWLockAcquire(), LWLockRelease(), ReplicationSlot::mutex, name, SyncStandbySlotsConfigData::nslotnames, RecoveryInProgress(), ReplicationSlotPersistentData::restart_lsn, RS_INVAL_NONE, SearchNamedReplicationSlot(), SyncStandbySlotsConfigData::slot_names, SlotIsLogical, SpinLockAcquire, SpinLockRelease, ss_oldest_flush_lsn, synchronized_standby_slots_config, and XLogRecPtrIsValid.
Referenced by NeedToWaitForStandbys(), and WaitForStandbyConfirmation().
| void StartupReplicationSlots | ( | void | ) |
Definition at line 2198 of file slot.c.
References AllocateDir(), dirent::d_name, DEBUG1, elog, ereport, errmsg(), FreeDir(), fsync_fname(), get_dirent_type(), max_replication_slots, MAXPGPATH, PG_REPLSLOT_DIR, pg_str_endswith(), PGFILETYPE_DIR, PGFILETYPE_ERROR, ReadDir(), ReplicationSlotsComputeRequiredLSN(), ReplicationSlotsComputeRequiredXmin(), RestoreSlotFromDisk(), rmtree(), snprintf, and WARNING.
Referenced by StartupXLOG().
| StaticAssertDecl | ( | lengthof(SlotInvalidationCauses) | = =(RS_INVAL_MAX_CAUSES+1), |
| "array length mismatch" | |||
| ) |
|
static |
Definition at line 2764 of file slot.c.
References foreach_ptr, GUC_check_errcode(), GUC_check_errdetail, GUC_check_errhint, name, ReplicationSlotValidateNameInternal(), and SplitIdentifierString().
Referenced by check_synchronized_standby_slots().
| void WaitForStandbyConfirmation | ( | XLogRecPtr | wait_for_lsn | ) |
Definition at line 3050 of file slot.c.
References CHECK_FOR_INTERRUPTS, ConditionVariableCancelSleep(), ConditionVariablePrepareToSleep(), ConditionVariableTimedSleep(), ConfigReloadPending, ReplicationSlot::data, ReplicationSlotPersistentData::failover, MyReplicationSlot, PGC_SIGHUP, ProcessConfigFile(), StandbySlotsHaveCaughtup(), synchronized_standby_slots_config, WalSndCtlData::wal_confirm_rcv_cv, WalSndCtl, and WARNING.
Referenced by LogicalSlotAdvanceAndCheckSnapState(), and pg_logical_slot_get_changes_guts().
| int idle_replication_slot_timeout_secs = 0 |
Definition at line 158 of file slot.c.
Referenced by CanInvalidateIdleSlot(), DetermineSlotInvalidationCause(), and ReportSlotInvalidation().
| int max_replication_slots = 10 |
Definition at line 151 of file slot.c.
Referenced by check_new_cluster_replication_slots(), CheckPointReplicationSlots(), CheckSlotRequirements(), copy_replication_slot(), get_local_synced_slots(), InvalidateObsoleteReplicationSlots(), pg_get_replication_slots(), ReplicationSlotCleanup(), ReplicationSlotCreate(), ReplicationSlotIndex(), ReplicationSlotsComputeLogicalRestartLSN(), ReplicationSlotsComputeRequiredLSN(), ReplicationSlotsComputeRequiredXmin(), ReplicationSlotsCountDBSlots(), ReplicationSlotsDropDBSlots(), ReplicationSlotsShmemInit(), ReplicationSlotsShmemSize(), RestoreSlotFromDisk(), SearchNamedReplicationSlot(), StartupReplicationSlots(), and update_synced_slots_inactive_since().
| ReplicationSlot* MyReplicationSlot = NULL |
Definition at line 148 of file slot.c.
Referenced by ApplyLauncherMain(), binary_upgrade_logical_slot_has_caught_up(), compute_min_nonremovable_xid(), copy_replication_slot(), create_logical_replication_slot(), create_physical_replication_slot(), CreateConflictDetectionSlot(), CreateDecodingContext(), CreateInitDecodingContext(), CreateReplicationSlot(), init_conflict_slot_xmin(), InvalidatePossiblyObsoleteSlot(), LogicalConfirmReceivedLocation(), LogicalIncreaseRestartDecodingForSlot(), LogicalIncreaseXminForSlot(), logicalrep_worker_launch(), LogicalReplicationSlotHasPendingWal(), LogicalSlotAdvanceAndCheckSnapState(), NeedToWaitForStandbys(), pg_create_logical_replication_slot(), pg_create_physical_replication_slot(), pg_logical_slot_get_changes_guts(), pg_physical_replication_slot_advance(), pg_replication_slot_advance(), PhysicalConfirmReceivedLocation(), PhysicalReplicationSlotNewXmin(), PhysicalWakeupLogicalWalSnd(), PostgresMain(), ProcessStandbyHSFeedbackMessage(), ProcessStandbyReplyMessage(), ReorderBufferAllocate(), ReorderBufferFree(), ReorderBufferRestoreChanges(), ReorderBufferRestoreCleanup(), ReorderBufferSerializedPath(), ReorderBufferSerializeTXN(), ReplicationSlotAcquire(), ReplicationSlotAlter(), ReplicationSlotCleanup(), ReplicationSlotCreate(), ReplicationSlotDrop(), ReplicationSlotDropAcquired(), ReplicationSlotMarkDirty(), ReplicationSlotPersist(), ReplicationSlotRelease(), ReplicationSlotReserveWal(), ReplicationSlotSave(), ReplicationSlotsDropDBSlots(), ReplicationSlotShmemExit(), reserve_wal_for_local_slot(), slotsync_failure_callback(), slotsync_worker_onexit(), StartLogicalReplication(), StartReplication(), StartupDecodingContext(), synchronize_one_slot(), update_and_persist_local_synced_slot(), update_conflict_slot_xmin(), update_local_synced_slot(), update_slotsync_skip_stats(), WaitForStandbyConfirmation(), and WalSndErrorCleanup().
| ReplicationSlotCtlData* ReplicationSlotCtl = NULL |
Definition at line 145 of file slot.c.
Referenced by CheckPointReplicationSlots(), copy_replication_slot(), get_local_synced_slots(), InvalidateObsoleteReplicationSlots(), pg_get_replication_slots(), ReplicationSlotCleanup(), ReplicationSlotCreate(), ReplicationSlotIndex(), ReplicationSlotName(), ReplicationSlotsComputeLogicalRestartLSN(), ReplicationSlotsComputeRequiredLSN(), ReplicationSlotsComputeRequiredXmin(), ReplicationSlotsCountDBSlots(), ReplicationSlotsDropDBSlots(), ReplicationSlotsShmemInit(), RestoreSlotFromDisk(), SearchNamedReplicationSlot(), and update_synced_slots_inactive_since().
|
static |
Definition at line 113 of file slot.c.
Referenced by GetSlotInvalidationCause(), and GetSlotInvalidationCauseName().
|
static |
Definition at line 173 of file slot.c.
Referenced by assign_synchronized_standby_slots(), and StandbySlotsHaveCaughtup().
|
static |
Definition at line 167 of file slot.c.
Referenced by assign_synchronized_standby_slots(), SlotExistsInSyncStandbySlots(), StandbySlotsHaveCaughtup(), and WaitForStandbyConfirmation().