|
PostgreSQL Source Code git master
|
#include <netdb.h>#include "access/xlog.h"#include "access/xlogdefs.h"#include "pgtime.h"#include "port/atomics.h"#include "replication/logicalproto.h"#include "replication/walsender.h"#include "storage/condition_variable.h"#include "storage/spin.h"#include "utils/tuplestore.h"

Go to the source code of this file.
Data Structures | |
| struct | WalRcvData |
| struct | WalRcvStreamOptions |
| struct | WalRcvExecResult |
| struct | WalReceiverFunctionsType |
Enumerations | |
| enum | WalRcvState { WALRCV_STOPPED , WALRCV_STARTING , WALRCV_CONNECTING , WALRCV_STREAMING , WALRCV_WAITING , WALRCV_RESTARTING , WALRCV_STOPPING } |
| enum | WalRcvExecStatus { WALRCV_ERROR , WALRCV_OK_COMMAND , WALRCV_OK_TUPLES , WALRCV_OK_COPY_IN , WALRCV_OK_COPY_OUT , WALRCV_OK_COPY_BOTH } |
Functions | |
| static void | walrcv_clear_result (WalRcvExecResult *walres) |
| pg_noreturn void | WalReceiverMain (const void *startup_data, size_t startup_data_len) |
| void | WalRcvForceReply (void) |
| Size | WalRcvShmemSize (void) |
| void | WalRcvShmemInit (void) |
| void | ShutdownWalRcv (void) |
| bool | WalRcvStreaming (void) |
| bool | WalRcvRunning (void) |
| WalRcvState | WalRcvGetState (void) |
| void | RequestXLogStreaming (TimeLineID tli, XLogRecPtr recptr, const char *conninfo, const char *slotname, bool create_temp_slot) |
| XLogRecPtr | GetWalRcvFlushRecPtr (XLogRecPtr *latestChunkStart, TimeLineID *receiveTLI) |
| XLogRecPtr | GetWalRcvWriteRecPtr (void) |
| int | GetReplicationApplyDelay (void) |
| int | GetReplicationTransferLatency (void) |
| #define AllowCascadeReplication | ( | ) | (EnableHotStandby && max_wal_senders > 0) |
Definition at line 40 of file walreceiver.h.
| #define MAXCONNINFO 1024 |
Definition at line 37 of file walreceiver.h.
| #define walrcv_alter_slot | ( | conn, | |
| slotname, | |||
| failover, | |||
| two_phase | |||
| ) | WalReceiverFunctions->walrcv_alter_slot(conn, slotname, failover, two_phase) |
Definition at line 462 of file walreceiver.h.
| #define walrcv_check_conninfo | ( | conninfo, | |
| must_use_password | |||
| ) | WalReceiverFunctions->walrcv_check_conninfo(conninfo, must_use_password) |
Definition at line 438 of file walreceiver.h.
| #define walrcv_connect | ( | conninfo, | |
| replication, | |||
| logical, | |||
| must_use_password, | |||
| appname, | |||
| err | |||
| ) | WalReceiverFunctions->walrcv_connect(conninfo, replication, logical, must_use_password, appname, err) |
Definition at line 436 of file walreceiver.h.
| #define walrcv_create_slot | ( | conn, | |
| slotname, | |||
| temporary, | |||
| two_phase, | |||
| failover, | |||
| snapshot_action, | |||
| lsn | |||
| ) | WalReceiverFunctions->walrcv_create_slot(conn, slotname, temporary, two_phase, failover, snapshot_action, lsn) |
Definition at line 460 of file walreceiver.h.
| #define walrcv_disconnect | ( | conn | ) | WalReceiverFunctions->walrcv_disconnect(conn) |
Definition at line 468 of file walreceiver.h.
| #define walrcv_endstreaming | ( | conn, | |
| next_tli | |||
| ) | WalReceiverFunctions->walrcv_endstreaming(conn, next_tli) |
Definition at line 454 of file walreceiver.h.
| #define walrcv_exec | ( | conn, | |
| exec, | |||
| nRetTypes, | |||
| retTypes | |||
| ) | WalReceiverFunctions->walrcv_exec(conn, exec, nRetTypes, retTypes) |
Definition at line 466 of file walreceiver.h.
| #define walrcv_get_backend_pid | ( | conn | ) | WalReceiverFunctions->walrcv_get_backend_pid(conn) |
Definition at line 464 of file walreceiver.h.
| #define walrcv_get_conninfo | ( | conn | ) | WalReceiverFunctions->walrcv_get_conninfo(conn) |
Definition at line 440 of file walreceiver.h.
| #define walrcv_get_dbname_from_conninfo | ( | conninfo | ) | WalReceiverFunctions->walrcv_get_dbname_from_conninfo(conninfo) |
Definition at line 446 of file walreceiver.h.
| #define walrcv_get_senderinfo | ( | conn, | |
| sender_host, | |||
| sender_port | |||
| ) | WalReceiverFunctions->walrcv_get_senderinfo(conn, sender_host, sender_port) |
Definition at line 442 of file walreceiver.h.
| #define walrcv_identify_system | ( | conn, | |
| primary_tli | |||
| ) | WalReceiverFunctions->walrcv_identify_system(conn, primary_tli) |
Definition at line 444 of file walreceiver.h.
| #define walrcv_readtimelinehistoryfile | ( | conn, | |
| tli, | |||
| filename, | |||
| content, | |||
| size | |||
| ) | WalReceiverFunctions->walrcv_readtimelinehistoryfile(conn, tli, filename, content, size) |
Definition at line 450 of file walreceiver.h.
| #define walrcv_receive | ( | conn, | |
| buffer, | |||
| wait_fd | |||
| ) | WalReceiverFunctions->walrcv_receive(conn, buffer, wait_fd) |
Definition at line 456 of file walreceiver.h.
| #define walrcv_send | ( | conn, | |
| buffer, | |||
| nbytes | |||
| ) | WalReceiverFunctions->walrcv_send(conn, buffer, nbytes) |
Definition at line 458 of file walreceiver.h.
| #define walrcv_server_version | ( | conn | ) | WalReceiverFunctions->walrcv_server_version(conn) |
Definition at line 448 of file walreceiver.h.
| #define walrcv_startstreaming | ( | conn, | |
| options | |||
| ) | WalReceiverFunctions->walrcv_startstreaming(conn, options) |
Definition at line 452 of file walreceiver.h.
| typedef void(* walrcv_alter_slot_fn) (WalReceiverConn *conn, const char *slotname, const bool *failover, const bool *two_phase) |
Definition at line 380 of file walreceiver.h.
Definition at line 255 of file walreceiver.h.
| typedef WalReceiverConn *(* walrcv_connect_fn) (const char *conninfo, bool replication, bool logical, bool must_use_password, const char *appname, char **err) |
Definition at line 243 of file walreceiver.h.
| typedef char *(* walrcv_create_slot_fn) (WalReceiverConn *conn, const char *slotname, bool temporary, bool two_phase, bool failover, CRSSnapshotAction snapshot_action, XLogRecPtr *lsn) |
Definition at line 366 of file walreceiver.h.
| typedef void(* walrcv_disconnect_fn) (WalReceiverConn *conn) |
Definition at line 411 of file walreceiver.h.
| typedef void(* walrcv_endstreaming_fn) (WalReceiverConn *conn, TimeLineID *next_tli) |
Definition at line 331 of file walreceiver.h.
| typedef WalRcvExecResult *(* walrcv_exec_fn) (WalReceiverConn *conn, const char *query, const int nRetTypes, const Oid *retTypes) |
Definition at line 401 of file walreceiver.h.
| typedef pid_t(* walrcv_get_backend_pid_fn) (WalReceiverConn *conn) |
Definition at line 391 of file walreceiver.h.
| typedef char *(* walrcv_get_conninfo_fn) (WalReceiverConn *conn) |
Definition at line 264 of file walreceiver.h.
Definition at line 292 of file walreceiver.h.
| typedef void(* walrcv_get_senderinfo_fn) (WalReceiverConn *conn, char **sender_host, int *sender_port) |
Definition at line 273 of file walreceiver.h.
| typedef char *(* walrcv_identify_system_fn) (WalReceiverConn *conn, TimeLineID *primary_tli) |
Definition at line 284 of file walreceiver.h.
| typedef void(* walrcv_readtimelinehistoryfile_fn) (WalReceiverConn *conn, TimeLineID tli, char **filename, char **content, int *size) |
Definition at line 308 of file walreceiver.h.
Definition at line 342 of file walreceiver.h.
Definition at line 352 of file walreceiver.h.
| typedef int(* walrcv_server_version_fn) (WalReceiverConn *conn) |
Definition at line 299 of file walreceiver.h.
| typedef bool(* walrcv_startstreaming_fn) (WalReceiverConn *conn, const WalRcvStreamOptions *options) |
Definition at line 322 of file walreceiver.h.
Definition at line 196 of file walreceiver.h.
| Enumerator | |
|---|---|
| WALRCV_ERROR | |
| WALRCV_OK_COMMAND | |
| WALRCV_OK_TUPLES | |
| WALRCV_OK_COPY_IN | |
| WALRCV_OK_COPY_OUT | |
| WALRCV_OK_COPY_BOTH | |
Definition at line 203 of file walreceiver.h.
| Enumerator | |
|---|---|
| WALRCV_STOPPED | |
| WALRCV_STARTING | |
| WALRCV_CONNECTING | |
| WALRCV_STREAMING | |
| WALRCV_WAITING | |
| WALRCV_RESTARTING | |
| WALRCV_STOPPING | |
Definition at line 45 of file walreceiver.h.
Definition at line 380 of file walreceiverfuncs.c.
References fb(), GetCurrentChunkReplayStartTime(), GetCurrentTimestamp(), GetXLogReplayRecPtr(), SpinLockAcquire, SpinLockRelease, TimestampDifferenceMilliseconds(), and WalRcv.
Referenced by ProcessWalSndrMessage().
Definition at line 410 of file walreceiverfuncs.c.
References fb(), SpinLockAcquire, SpinLockRelease, TimestampDifferenceMilliseconds(), and WalRcv.
Referenced by ProcessWalSndrMessage().
|
extern |
Definition at line 347 of file walreceiverfuncs.c.
References fb(), receiveTLI, SpinLockAcquire, SpinLockRelease, and WalRcv.
Referenced by CreateRestartPoint(), GetCurrentLSNForWaitType(), GetLatestLSN(), GetStandbyFlushRecPtr(), pg_last_wal_receive_lsn(), and WaitForWALToBecomeAvailable().
|
extern |
Definition at line 368 of file walreceiverfuncs.c.
References fb(), pg_atomic_read_u64(), and WalRcv.
Referenced by GetCurrentLSNForWaitType().
|
extern |
Definition at line 261 of file walreceiverfuncs.c.
References Assert, fb(), GetPGProcByNumber, INVALID_PROC_NUMBER, MAXCONNINFO, NAMEDATALEN, now(), PMSIGNAL_START_WALRECEIVER, SendPostmasterSignal(), SetLatch(), SpinLockAcquire, SpinLockRelease, strlcpy(), wal_segment_size, WalRcv, WALRCV_RESTARTING, WALRCV_STARTING, WALRCV_STOPPED, WALRCV_WAITING, XLogRecPtrIsValid, and XLogSegmentOffset.
Referenced by WaitForWALToBecomeAvailable().
Definition at line 193 of file walreceiverfuncs.c.
References ConditionVariableBroadcast(), ConditionVariableCancelSleep(), ConditionVariablePrepareToSleep(), ConditionVariableSleep(), fb(), kill, SpinLockAcquire, SpinLockRelease, WalRcv, WALRCV_CONNECTING, WALRCV_RESTARTING, WALRCV_STARTING, WALRCV_STOPPED, WALRCV_STOPPING, WALRCV_STREAMING, WALRCV_WAITING, and WalRcvRunning().
Referenced by XLogShutdownWalRcv().
|
inlinestatic |
Definition at line 472 of file walreceiver.h.
References fb(), FreeTupleDesc(), pfree(), and tuplestore_end().
Referenced by check_pub_dead_tuple_retention(), check_publications(), check_publications_origin_sequences(), check_publications_origin_tables(), copy_sequences(), copy_table(), fetch_relation_list(), fetch_remote_slots(), fetch_remote_table_info(), LogicalRepSyncTableStart(), ReplicationSlotDropAtPubNode(), and validate_remote_info().
Definition at line 1381 of file walreceiver.c.
References WalRcvData::force_reply, GetPGProcByNumber, INVALID_PROC_NUMBER, WalRcvData::mutex, WalRcvData::procno, SetLatch(), SpinLockAcquire, SpinLockRelease, and WalRcv.
Referenced by ApplyWalRecord(), and WaitForWALToBecomeAvailable().
|
extern |
Definition at line 124 of file walreceiverfuncs.c.
References fb(), SpinLockAcquire, SpinLockRelease, and WalRcv.
Referenced by WaitForWALToBecomeAvailable().
Definition at line 76 of file walreceiverfuncs.c.
References ConditionVariableBroadcast(), fb(), now(), SpinLockAcquire, SpinLockRelease, WalRcv, WALRCV_STARTING, WALRCV_STARTUP_TIMEOUT, and WALRCV_STOPPED.
Referenced by ShutdownWalRcv(), and StartupRequestWalReceiverRestart().
Definition at line 55 of file walreceiverfuncs.c.
References ConditionVariableInit(), INVALID_PROC_NUMBER, MemSet, WalRcvData::mutex, pg_atomic_init_u64(), WalRcvData::procno, ShmemInitStruct(), SpinLockInit, WalRcv, WALRCV_STOPPED, WalRcvShmemSize(), WalRcvData::walRcvState, WalRcvData::walRcvStoppedCV, and WalRcvData::writtenUpto.
Referenced by CreateOrAttachShmemStructs().
Definition at line 44 of file walreceiverfuncs.c.
References add_size().
Referenced by CalculateShmemSize(), and WalRcvShmemInit().
Definition at line 141 of file walreceiverfuncs.c.
References ConditionVariableBroadcast(), fb(), now(), SpinLockAcquire, SpinLockRelease, WalRcv, WALRCV_CONNECTING, WALRCV_RESTARTING, WALRCV_STARTING, WALRCV_STARTUP_TIMEOUT, WALRCV_STOPPED, and WALRCV_STREAMING.
Referenced by FinishWalRecovery(), and WaitForWALToBecomeAvailable().
|
extern |
Definition at line 153 of file walreceiver.c.
References ARCHIVE_MODE_ALWAYS, Assert, AuxiliaryProcessMainCommon(), B_WAL_RECEIVER, buf, CHECK_FOR_INTERRUPTS, close, cluster_name, ConditionVariableBroadcast(), ConfigReloadPending, DEBUG1, die, elog, ereport, err(), errcode(), errcode_for_file_access(), errdetail(), errmsg(), ERROR, FATAL, fb(), GetCurrentTimestamp(), GetSystemIdentifier(), GetXLogReplayRecPtr(), i, initStringInfo(), len, load_file(), LOG, LogstreamResult, LSN_FORMAT_ARGS, MAXCONNINFO, MAXFNAMELEN, Min, MyBackendType, MyLatch, MyProcNumber, MyProcPid, NAMEDATALEN, now(), NUM_WALRCV_WAKEUPS, on_shmem_exit(), PANIC, pfree(), pg_atomic_write_u64(), pg_memory_barrier, PGC_SIGHUP, PGINVALID_SOCKET, pgstat_report_wal(), PointerGetDatum(), pqsignal, proc_exit(), ProcessConfigFile(), procsignal_sigusr1_handler(), RecoveryInProgress(), recvFile, recvFileTLI, recvSegNo, reply_message, ResetLatch(), SIGALRM, SIGCHLD, SIGHUP, SignalHandlerForConfigReload(), SIGPIPE, SIGUSR1, SIGUSR2, snprintf, SpinLockAcquire, SpinLockRelease, strlcpy(), TIMESTAMP_INFINITY, TimestampDifferenceMilliseconds(), UINT64_FORMAT, UnBlockSig, WaitLatchOrSocket(), wakeup, wal_segment_size, WalRcv, walrcv_connect, WALRCV_CONNECTING, walrcv_create_slot, walrcv_endstreaming, walrcv_get_backend_pid, walrcv_get_conninfo, walrcv_get_senderinfo, walrcv_identify_system, walrcv_receive, WALRCV_RESTARTING, WALRCV_STARTING, walrcv_startstreaming, WALRCV_STOPPED, WALRCV_STOPPING, WALRCV_STREAMING, WALRCV_WAITING, WALRCV_WAKEUP_PING, WALRCV_WAKEUP_TERMINATE, WalRcvComputeNextWakeup(), WalRcvDie(), WalRcvFetchTimeLineHistoryFiles(), WalRcvWaitForStartPosition(), WalReceiverFunctions, WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, WL_SOCKET_READABLE, WL_TIMEOUT, wrconn, WalRcvData::writtenUpto, XLogArchiveForceDone(), XLogArchiveMode, XLogArchiveNotify(), XLogFileName(), XLogWalRcvFlush(), XLogWalRcvProcessMsg(), XLogWalRcvSendHSFeedback(), and XLogWalRcvSendReply().
|
extern |
Definition at line 91 of file walreceiver.c.
Referenced by slotsync_reread_config(), ValidateSlotSyncParams(), WalRcvComputeNextWakeup(), and XLogWalRcvSendHSFeedback().
|
extern |
Definition at line 89 of file walreceiver.c.
Referenced by adjust_xid_advance_interval(), send_feedback(), WalRcvComputeNextWakeup(), XLogWalRcvSendHSFeedback(), and XLogWalRcvSendReply().
|
extern |
Definition at line 90 of file walreceiver.c.
Referenced by logicalrep_worker_launch(), LogicalRepApplyLoop(), and WalRcvComputeNextWakeup().
|
extern |
Definition at line 34 of file walreceiverfuncs.c.
Referenced by GetReplicationApplyDelay(), GetReplicationTransferLatency(), GetWalRcvFlushRecPtr(), GetWalRcvWriteRecPtr(), pg_stat_get_wal_receiver(), ProcessWalSndrMessage(), RequestXLogStreaming(), ShutdownWalRcv(), WalRcvDie(), WalRcvForceReply(), WalRcvGetState(), WalRcvRunning(), WalRcvShmemInit(), WalRcvStreaming(), WalRcvWaitForStartPosition(), WalReceiverMain(), XLogWalRcvFlush(), and XLogWalRcvWrite().
|
extern |
Definition at line 95 of file walreceiver.c.
Referenced by _PG_init(), and WalReceiverMain().