PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <signal.h>
#include <unistd.h>
#include "access/printtup.h"
#include "access/timeline.h"
#include "access/transam.h"
#include "access/xact.h"
#include "access/xlog_internal.h"
#include "access/xlogreader.h"
#include "access/xlogrecovery.h"
#include "access/xlogutils.h"
#include "backup/basebackup.h"
#include "catalog/pg_authid.h"
#include "catalog/pg_type.h"
#include "commands/dbcommands.h"
#include "commands/defrem.h"
#include "funcapi.h"
#include "libpq/libpq.h"
#include "libpq/pqformat.h"
#include "miscadmin.h"
#include "nodes/replnodes.h"
#include "pgstat.h"
#include "postmaster/interrupt.h"
#include "replication/decode.h"
#include "replication/logical.h"
#include "replication/slot.h"
#include "replication/snapbuild.h"
#include "replication/syncrep.h"
#include "replication/walreceiver.h"
#include "replication/walsender.h"
#include "replication/walsender_private.h"
#include "storage/condition_variable.h"
#include "storage/fd.h"
#include "storage/ipc.h"
#include "storage/pmsignal.h"
#include "storage/proc.h"
#include "storage/procarray.h"
#include "tcop/dest.h"
#include "tcop/tcopprot.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/guc.h"
#include "utils/memutils.h"
#include "utils/pg_lsn.h"
#include "utils/portal.h"
#include "utils/ps_status.h"
#include "utils/timeout.h"
#include "utils/timestamp.h"
Go to the source code of this file.
Data Structures | |
struct | WalTimeSample |
struct | LagTracker |
Macros | |
#define | MAX_SEND_SIZE (XLOG_BLCKSZ * 16) |
#define | LAG_TRACKER_BUFFER_SIZE 8192 |
#define | READ_REPLICATION_SLOT_COLS 3 |
#define | WALSND_LOGICAL_LAG_TRACK_INTERVAL_MS 1000 |
#define | PG_STAT_GET_WAL_SENDERS_COLS 12 |
Typedefs | |
typedef void(* | WalSndSendDataCallback) (void) |
#define LAG_TRACKER_BUFFER_SIZE 8192 |
Definition at line 208 of file walsender.c.
#define MAX_SEND_SIZE (XLOG_BLCKSZ * 16) |
Definition at line 107 of file walsender.c.
#define PG_STAT_GET_WAL_SENDERS_COLS 12 |
#define READ_REPLICATION_SLOT_COLS 3 |
#define WALSND_LOGICAL_LAG_TRACK_INTERVAL_MS 1000 |
typedef void(* WalSndSendDataCallback) (void) |
Definition at line 226 of file walsender.c.
|
static |
Definition at line 1041 of file walsender.c.
References Assert(), begin_tup_output_tupdesc(), CheckLogicalDecodingRequirements(), ReplicationSlotPersistentData::confirmed_flush, CreateDestReceiver(), CreateInitDecodingContext(), CreateTemplateTupleDesc(), CRS_EXPORT_SNAPSHOT, CRS_USE_SNAPSHOT, CStringGetTextDatum, ReplicationSlot::data, DecodingContextFindStartpoint(), generate_unaccent_rules::dest, DestRemoteSimple, do_tup_output(), end_tup_output(), ereport, errmsg(), ERROR, FirstSnapshotSet, FreeDecodingContext(), InvalidXLogRecPtr, IsSubTransaction(), IsTransactionBlock(), CreateReplicationSlotCmd::kind, last_reply_timestamp, logical_read_xlog_page(), LSN_FORMAT_ARGS, MAXFNAMELEN, MyProc, MyReplicationSlot, ReplicationSlotPersistentData::name, NameStr, NIL, parseCreateReplSlotOptions(), CreateReplicationSlotCmd::plugin, REPLICATION_KIND_LOGICAL, REPLICATION_KIND_PHYSICAL, ReplicationSlotCreate(), ReplicationSlotMarkDirty(), ReplicationSlotPersist(), ReplicationSlotRelease(), ReplicationSlotReserveWal(), ReplicationSlotSave(), RestoreTransactionSnapshot(), RS_EPHEMERAL, RS_PERSISTENT, RS_TEMPORARY, CreateReplicationSlotCmd::slotname, SnapBuildExportSnapshot(), SnapBuildInitialSnapshot(), LogicalDecodingContext::snapshot_builder, snprintf, CreateReplicationSlotCmd::temporary, TTSOpsVirtual, TupleDescInitBuiltinEntry(), two_phase, values, wal_segment_close(), WalSndPrepareWrite(), WalSndSegmentOpen(), WalSndUpdateProgress(), WalSndWriteData(), XACT_REPEATABLE_READ, XactIsoLevel, XactReadOnly, and XL_ROUTINE.
Referenced by exec_replication_command(), main(), and StartLogStreamer().
|
static |
Definition at line 1244 of file walsender.c.
References ReplicationSlotDrop(), DropReplicationSlotCmd::slotname, and DropReplicationSlotCmd::wait.
Referenced by exec_replication_command(), and main().
bool exec_replication_command | ( | const char * | cmd_string | ) |
Definition at line 1672 of file walsender.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert(), CHECK_FOR_INTERRUPTS, CommitTransactionCommand(), CreateDestReceiver(), CreateReplicationSlot(), CurrentMemoryContext, DEBUG1, debug_query_string, generate_unaccent_rules::dest, DestRemoteSimple, DropReplicationSlot(), elog(), EndReplicationCommand(), ereport, errcode(), errmsg(), errmsg_internal(), ERROR, GetPGVariable(), got_STOPPING, IdentifySystem(), initStringInfo(), InvalidOid, IsAbortedTransactionBlockState(), StartReplicationCmd::kind, LOG, log_replication_commands, MemoryContextDelete(), MemoryContextSwitchTo(), MyDatabaseId, MyWalSnd, VariableShowStmt::name, output_message, pgstat_report_activity(), PreventInTransactionBlock(), ReadReplicationSlot(), REPLICATION_KIND_PHYSICAL, replication_parse_result, replication_scanner_finish(), replication_scanner_init(), replication_scanner_is_replication_command(), replication_yyparse(), reply_message, SendBaseBackup(), SendTimeLineHistory(), set_ps_display(), SnapBuildClearExportedSnapshot(), StartLogicalReplication(), StartReplication(), StartTransactionCommand(), WalSnd::state, STATE_RUNNING, tmpbuf, Node::type, ReadReplicationSlotCmd::type, WalSndSetState(), WALSNDSTATE_STOPPING, and xlogreader.
Referenced by PostgresMain().
|
static |
Definition at line 3170 of file walsender.c.
References GetWalRcvFlushRecPtr(), GetXLogReplayRecPtr(), and receiveTLI.
Referenced by IdentifySystem(), StartReplication(), XLogSendLogical(), and XLogSendPhysical().
void HandleWalSndInitStopping | ( | void | ) |
Definition at line 3224 of file walsender.c.
References am_walsender, Assert(), got_STOPPING, kill, MyProcPid, and replication_active.
Referenced by procsignal_sigusr1_handler().
|
static |
Definition at line 395 of file walsender.c.
References am_cascading_walsender, begin_tup_output_tupdesc(), CommitTransactionCommand(), CreateDestReceiver(), CreateTemplateTupleDesc(), CStringGetTextDatum, cur, CurrentMemoryContext, dbname, generate_unaccent_rules::dest, DestRemoteSimple, do_tup_output(), end_tup_output(), get_database_name(), GetFlushRecPtr(), GetStandbyFlushRecPtr(), GetSystemIdentifier(), Int64GetDatum(), InvalidOid, LSN_FORMAT_ARGS, MAXFNAMELEN, MemoryContextSwitchTo(), MyDatabaseId, RecoveryInProgress(), snprintf, StartTransactionCommand(), TTSOpsVirtual, TupleDescInitBuiltinEntry(), UINT64_FORMAT, and values.
Referenced by exec_replication_command().
|
static |
Definition at line 2572 of file walsender.c.
References WalSnd::apply, WalSnd::applyLag, Assert(), WalSnd::flush, WalSnd::flushLag, i, InvalidOid, InvalidXLogRecPtr, WalSnd::kind, WalSnd::latch, max_wal_senders, WalSnd::mutex, MyDatabaseId, MyProc, MyProcPid, MyWalSnd, WalSnd::needreload, on_shmem_exit(), WalSnd::pid, PGPROC::procLatch, REPLICATION_KIND_LOGICAL, REPLICATION_KIND_PHYSICAL, WalSnd::replyTime, WalSnd::sentPtr, SpinLockAcquire, SpinLockRelease, WalSnd::state, WalSnd::sync_standby_priority, WalSndCtl, WalSndKill(), WalSndCtlData::walsnds, WALSNDSTATE_STARTUP, WalSnd::write, and WalSnd::writeLag.
|
static |
Definition at line 3821 of file walsender.c.
References Assert(), LagTracker::buffer, lag_tracker, LAG_TRACKER_BUFFER_SIZE, LagTracker::last_read, WalTimeSample::lsn, next, now(), LagTracker::read_heads, WalTimeSample::time, and LagTracker::write_head.
Referenced by ProcessStandbyReplyMessage().
|
static |
Definition at line 3756 of file walsender.c.
References am_walsender, LagTracker::buffer, i, lag_tracker, LAG_TRACKER_BUFFER_SIZE, LagTracker::last_lsn, WalTimeSample::lsn, NUM_SYNC_REP_WAIT_MODE, LagTracker::read_heads, WalTimeSample::time, and LagTracker::write_head.
Referenced by WalSndUpdateProgress(), and XLogSendPhysical().
|
static |
Definition at line 902 of file walsender.c.
References am_cascading_walsender, CheckXLogRemoved(), GetWALInsertionTimeLine(), GetXLogReplayRecPtr(), RecoveryInProgress(), sendTimeLine, sendTimeLineIsHistoric, sendTimeLineNextTLI, sendTimeLineValidUpto, WALRead(), WALReadRaiseError(), WalSndWaitForWal(), XLByteToSeg, and XLogReadDetermineTimeline().
Referenced by CreateReplicationSlot(), and StartLogicalReplication().
|
static |
Definition at line 3508 of file walsender.c.
References Interval::day, Interval::month, palloc(), and Interval::time.
Referenced by pg_stat_get_wal_senders().
|
static |
Definition at line 974 of file walsender.c.
References generate_unaccent_rules::action, CRS_EXPORT_SNAPSHOT, CRS_NOEXPORT_SNAPSHOT, CRS_USE_SNAPSHOT, defGetBoolean(), defGetString(), DefElem::defname, elog(), ereport, errcode(), errmsg(), ERROR, CreateReplicationSlotCmd::kind, lfirst, CreateReplicationSlotCmd::options, REPLICATION_KIND_LOGICAL, REPLICATION_KIND_PHYSICAL, and two_phase.
Referenced by CreateReplicationSlot().
Datum pg_stat_get_wal_senders | ( | PG_FUNCTION_ARGS | ) |
Definition at line 3524 of file walsender.c.
References WalSnd::apply, WalSnd::applyLag, CStringGetTextDatum, WalSnd::flush, WalSnd::flushLag, GetUserId(), has_privs_of_role(), i, InitMaterializedSRF(), Int32GetDatum(), IntervalPGetDatum(), j, LSNGetDatum(), max_wal_senders, MemSet, WalSnd::mutex, offset_to_interval(), PG_STAT_GET_WAL_SENDERS_COLS, WalSnd::pid, WalSnd::replyTime, WalSnd::sentPtr, ReturnSetInfo::setDesc, ReturnSetInfo::setResult, SpinLockAcquire, SpinLockRelease, WalSnd::state, SYNC_REP_PRIORITY, WalSnd::sync_standby_priority, SyncRepConfigData::syncrep_method, SyncRepConfig, SyncRepGetCandidateStandbys(), TimestampTzGetDatum(), tuplestore_putvalues(), values, WalSndCtl, WalSndGetStateString(), WalSndCtlData::walsnds, WalSnd::write, write, WalSnd::writeLag, and XLogRecPtrIsInvalid.
|
static |
Definition at line 2034 of file walsender.c.
References Assert(), ReplicationSlot::data, InvalidXLogRecPtr, ReplicationSlot::mutex, MyReplicationSlot, ReplicationSlotMarkDirty(), ReplicationSlotsComputeRequiredLSN(), ReplicationSlotPersistentData::restart_lsn, SpinLockAcquire, and SpinLockRelease.
Referenced by ProcessStandbyReplyMessage().
|
static |
Definition at line 2171 of file walsender.c.
References ReplicationSlotPersistentData::catalog_xmin, ReplicationSlot::data, ReplicationSlot::effective_catalog_xmin, ReplicationSlot::effective_xmin, InvalidTransactionId, ReplicationSlot::mutex, MyProc, MyReplicationSlot, ReplicationSlotMarkDirty(), ReplicationSlotsComputeRequiredXmin(), SpinLockAcquire, SpinLockRelease, TransactionIdIsNormal, TransactionIdPrecedes(), ReplicationSlotPersistentData::xmin, and PGPROC::xmin.
Referenced by ProcessStandbyHSFeedbackMessage().
|
static |
Definition at line 1416 of file walsender.c.
References CHECK_FOR_INTERRUPTS, ConfigReloadPending, GetCurrentTimestamp(), MyLatch, PGC_SIGHUP, pq_flush_if_writable, pq_is_send_pending, ProcessConfigFile(), ProcessRepliesIfAny(), ResetLatch(), SetLatch(), SyncRepInitConfig(), WalSndCheckTimeOut(), WalSndComputeSleeptime(), WalSndKeepaliveIfNecessary(), WalSndShutdown(), WalSndWait(), WL_SOCKET_READABLE, and WL_SOCKET_WRITEABLE.
Referenced by WalSndUpdateProgress(), and WalSndWriteData().
|
static |
Definition at line 1890 of file walsender.c.
References Assert(), COMMERROR, ereport, errcode(), errmsg(), FATAL, GetCurrentTimestamp(), last_processing, last_reply_timestamp, pq_endmsgread(), pq_getbyte_if_available(), pq_getmessage(), PQ_LARGE_MESSAGE_LIMIT, pq_putmessage_noblock, PQ_SMALL_MESSAGE_LIMIT, pq_startmsgread(), PqMsg_CopyData, PqMsg_CopyDone, PqMsg_Terminate, proc_exit(), ProcessStandbyMessage(), reply_message, resetStringInfo(), streamingDoneReceiving, streamingDoneSending, and waiting_for_ping_response.
Referenced by ProcessPendingWrites(), WalSndLoop(), and WalSndWaitForWal().
|
static |
Definition at line 2251 of file walsender.c.
References DEBUG2, elog(), InvalidTransactionId, message_level_is_interesting(), WalSnd::mutex, MyProc, MyReplicationSlot, MyWalSnd, pfree(), PhysicalReplicationSlotNewXmin(), pq_getmsgint(), pq_getmsgint64(), pstrdup(), reply_message, WalSnd::replyTime, SpinLockAcquire, SpinLockRelease, timestamptz_to_str(), TransactionIdInRecentPast(), TransactionIdIsNormal, TransactionIdPrecedes(), and PGPROC::xmin.
Referenced by ProcessStandbyMessage().
|
static |
Definition at line 2003 of file walsender.c.
References COMMERROR, ereport, errcode(), errmsg(), pq_getmsgbyte(), proc_exit(), ProcessStandbyHSFeedbackMessage(), ProcessStandbyReplyMessage(), and reply_message.
Referenced by ProcessRepliesIfAny().
|
static |
Definition at line 2066 of file walsender.c.
References am_cascading_walsender, WalSnd::apply, WalSnd::applyLag, DEBUG2, elog(), WalSnd::flush, WalSnd::flushLag, GetCurrentTimestamp(), InvalidXLogRecPtr, LagTrackerRead(), LogicalConfirmReceivedLocation(), LSN_FORMAT_ARGS, message_level_is_interesting(), WalSnd::mutex, MyReplicationSlot, MyWalSnd, now(), pfree(), PhysicalConfirmReceivedLocation(), pq_getmsgbyte(), pq_getmsgint64(), pstrdup(), reply_message, WalSnd::replyTime, sentPtr, SlotIsLogical, SpinLockAcquire, SpinLockRelease, SYNC_REP_WAIT_APPLY, SYNC_REP_WAIT_FLUSH, SYNC_REP_WAIT_WRITE, SyncRepReleaseWaiters(), timestamptz_to_str(), WalSndKeepalive(), WalSnd::write, and WalSnd::writeLag.
Referenced by ProcessStandbyMessage().
|
static |
Definition at line 478 of file walsender.c.
References Assert(), begin_tup_output_tupdesc(), CreateDestReceiver(), CreateTemplateTupleDesc(), CStringGetTextDatum, ReplicationSlot::data, ReplicationSlotPersistentData::database, generate_unaccent_rules::dest, DestRemoteSimple, do_tup_output(), end_tup_output(), ereport, errcode(), errmsg(), ERROR, GetWALInsertionTimeLine(), GetXLogReplayRecPtr(), i, ReplicationSlot::in_use, Int64GetDatum(), LSN_FORMAT_ARGS, LW_SHARED, LWLockAcquire(), LWLockRelease(), ReplicationSlot::mutex, NIL, OidIsValid, READ_REPLICATION_SLOT_COLS, readTimeLineHistory(), RecoveryInProgress(), ReplicationSlotPersistentData::restart_lsn, SearchNamedReplicationSlot(), ReadReplicationSlotCmd::slotname, snprintf, SpinLockAcquire, SpinLockRelease, tliOfPointInHistory(), TTSOpsVirtual, TupleDescInitBuiltinEntry(), values, and XLogRecPtrIsInvalid.
Referenced by exec_replication_command().
|
static |
Definition at line 577 of file walsender.c.
References buf, CloseTransientFile(), CMD_SELECT, CreateDestReceiver(), CreateTemplateTupleDesc(), PGAlignedBlock::data, generate_unaccent_rules::dest, DestRemoteSimple, ereport, errcode(), ERRCODE_DATA_CORRUPTED, errcode_for_file_access(), errmsg(), ERROR, fd(), len, MAXFNAMELEN, MAXPGPATH, OpenTransientFile(), PG_BINARY, pgstat_report_wait_end(), pgstat_report_wait_start(), pq_beginmessage(), pq_endmessage(), pq_sendbytes(), pq_sendint16(), pq_sendint32(), PqMsg_DataRow, read, TimeLineHistoryCmd::timeline, TLHistoryFileName(), TLHistoryFilePath(), and TupleDescInitBuiltinEntry().
Referenced by exec_replication_command().
|
static |
Definition at line 1254 of file walsender.c.
References am_cascading_walsender, Assert(), buf, CheckLogicalDecodingRequirements(), ReplicationSlotPersistentData::confirmed_flush, CreateDecodingContext(), ReplicationSlot::data, DestRemote, EndCommand(), ereport, errmsg(), FreeDecodingContext(), got_STOPPING, LOG, logical_decoding_ctx, logical_read_xlog_page(), WalSnd::mutex, MyReplicationSlot, MyWalSnd, StartReplicationCmd::options, pq_beginmessage(), pq_endmessage(), pq_flush, pq_sendbyte(), pq_sendint16(), PqMsg_CopyBothResponse, proc_exit(), LogicalDecodingContext::reader, RecoveryInProgress(), replication_active, ReplicationSlotAcquire(), ReplicationSlotRelease(), ReplicationSlotPersistentData::restart_lsn, sentPtr, WalSnd::sentPtr, SetQueryCompletion(), StartReplicationCmd::slotname, SpinLockAcquire, SpinLockRelease, StartReplicationCmd::startpoint, SyncRepInitConfig(), wal_segment_close(), WalSndLoop(), WalSndPrepareWrite(), WalSndSegmentOpen(), WalSndSetState(), WALSNDSTATE_CATCHUP, WALSNDSTATE_STARTUP, WalSndUpdateProgress(), WalSndWriteData(), XL_ROUTINE, XLogBeginRead(), xlogreader, and XLogSendLogical().
Referenced by exec_replication_command().
|
static |
Definition at line 670 of file walsender.c.
References am_cascading_walsender, Assert(), begin_tup_output_tupdesc(), buf, CreateDestReceiver(), CreateTemplateTupleDesc(), CStringGetTextDatum, generate_unaccent_rules::dest, DestRemoteSimple, do_tup_output(), end_tup_output(), EndReplicationCommand(), ereport, errcode(), errdetail(), errmsg(), ERROR, GetFlushRecPtr(), GetStandbyFlushRecPtr(), got_STOPPING, Int64GetDatum(), InvalidXLogRecPtr, list_free_deep(), LSN_FORMAT_ARGS, WalSnd::mutex, MyReplicationSlot, MyWalSnd, pq_beginmessage(), pq_endmessage(), pq_flush, pq_sendbyte(), pq_sendint16(), PqMsg_CopyBothResponse, proc_exit(), readTimeLineHistory(), RecoveryInProgress(), replication_active, ReplicationSlotAcquire(), ReplicationSlotRelease(), sendTimeLine, sendTimeLineIsHistoric, sendTimeLineNextTLI, sendTimeLineValidUpto, sentPtr, WalSnd::sentPtr, SlotIsLogical, StartReplicationCmd::slotname, snprintf, SpinLockAcquire, SpinLockRelease, StartReplicationCmd::startpoint, streamingDoneReceiving, streamingDoneSending, SyncRepInitConfig(), StartReplicationCmd::timeline, tliSwitchPoint(), TTSOpsVirtual, TupleDescInitBuiltinEntry(), values, wal_segment_close(), wal_segment_size, WalSndLoop(), WalSndSegmentOpen(), WalSndSetState(), WALSNDSTATE_CATCHUP, WALSNDSTATE_STARTUP, XL_ROUTINE, xlogreader, XLogReaderAllocate(), XLogRecPtrIsInvalid, and XLogSendPhysical().
Referenced by exec_replication_command().
|
static |
Definition at line 2220 of file walsender.c.
References epoch, EpochFromFullTransactionId, ReadNextFullTransactionId(), TransactionIdPrecedesOrEquals(), and XidFromFullTransactionId.
Referenced by ProcessStandbyHSFeedbackMessage().
|
static |
Definition at line 2419 of file walsender.c.
References COMMERROR, ereport, errmsg(), last_processing, last_reply_timestamp, TimestampTzPlusMilliseconds, wal_sender_timeout, and WalSndShutdown().
Referenced by ProcessPendingWrites(), WalSndLoop(), and WalSndWaitForWal().
|
static |
Definition at line 2375 of file walsender.c.
References last_reply_timestamp, now(), TimestampDifferenceMilliseconds(), TimestampTzPlusMilliseconds, waiting_for_ping_response, and wal_sender_timeout.
Referenced by ProcessPendingWrites(), WalSndLoop(), and WalSndWaitForWal().
|
static |
Definition at line 3130 of file walsender.c.
References DestRemote, EndCommand(), WalSnd::flush, InvalidXLogRecPtr, MyWalSnd, pq_flush, pq_is_send_pending, proc_exit(), sentPtr, SetQueryCompletion(), waiting_for_ping_response, WalSndCaughtUp, WalSndKeepalive(), WalSnd::write, and XLogRecPtrIsInvalid.
Referenced by WalSndLoop().
void WalSndErrorCleanup | ( | void | ) |
Definition at line 315 of file walsender.c.
References ConditionVariableCancelSleep(), got_SIGUSR2, got_STOPPING, IsTransactionOrTransactionBlock(), LWLockReleaseAll(), MyReplicationSlot, pgstat_report_wait_end(), proc_exit(), replication_active, ReplicationSlotCleanup(), ReplicationSlotRelease(), XLogReaderState::seg, wal_segment_close(), WalSndResourceCleanup(), WalSndSetState(), WALSNDSTATE_STARTUP, WALOpenSegment::ws_file, and xlogreader.
Referenced by PostgresMain().
|
static |
Definition at line 3489 of file walsender.c.
References WALSNDSTATE_BACKUP, WALSNDSTATE_CATCHUP, WALSNDSTATE_STARTUP, WALSNDSTATE_STOPPING, and WALSNDSTATE_STREAMING.
Referenced by pg_stat_get_wal_senders().
void WalSndInitStopping | ( | void | ) |
Definition at line 3406 of file walsender.c.
References i, InvalidBackendId, max_wal_senders, WalSnd::mutex, WalSnd::pid, PROCSIG_WALSND_INIT_STOPPING, SendProcSignal(), SpinLockAcquire, SpinLockRelease, WalSndCtl, and WalSndCtlData::walsnds.
Referenced by ShutdownXLOG().
|
static |
Definition at line 3695 of file walsender.c.
References StringInfoData::data, DEBUG2, elog(), GetCurrentTimestamp(), StringInfoData::len, output_message, pq_putmessage_noblock, pq_sendbyte(), pq_sendint64(), resetStringInfo(), sentPtr, waiting_for_ping_response, and XLogRecPtrIsInvalid.
Referenced by ProcessStandbyReplyMessage(), WalSndDone(), WalSndKeepaliveIfNecessary(), WalSndUpdateProgress(), and WalSndWaitForWal().
|
static |
Definition at line 3718 of file walsender.c.
References InvalidXLogRecPtr, last_processing, last_reply_timestamp, pq_flush_if_writable, TimestampTzPlusMilliseconds, waiting_for_ping_response, wal_sender_timeout, WalSndKeepalive(), and WalSndShutdown().
Referenced by ProcessPendingWrites(), WalSndLoop(), and WalSndWaitForWal().
|
static |
Definition at line 2649 of file walsender.c.
References Assert(), WalSnd::latch, WalSnd::mutex, MyWalSnd, WalSnd::pid, SpinLockAcquire, and SpinLockRelease.
Referenced by InitWalSenderSlot().
|
static |
Definition at line 3246 of file walsender.c.
References got_SIGUSR2, MyLatch, and SetLatch().
Referenced by WalSndSignals().
|
static |
Definition at line 2446 of file walsender.c.
References application_name, CHECK_FOR_INTERRUPTS, ConfigReloadPending, DEBUG1, ereport, errmsg_internal(), GetCurrentTimestamp(), got_SIGUSR2, last_reply_timestamp, MyLatch, MyWalSnd, PGC_SIGHUP, pq_flush_if_writable, pq_is_send_pending, ProcessConfigFile(), ProcessRepliesIfAny(), ResetLatch(), WalSnd::state, streamingDoneReceiving, streamingDoneSending, SyncRepInitConfig(), waiting_for_ping_response, WalSndCaughtUp, WalSndCheckTimeOut(), WalSndComputeSleeptime(), WalSndDone(), WalSndKeepaliveIfNecessary(), WalSndSetState(), WalSndShutdown(), WALSNDSTATE_CATCHUP, WALSNDSTATE_STREAMING, WalSndWait(), WL_SOCKET_READABLE, WL_SOCKET_WRITEABLE, and XLogSendLogical().
Referenced by StartLogicalReplication(), and StartReplication().
|
static |
Definition at line 1347 of file walsender.c.
References InvalidXLogRecPtr, LogicalDecodingContext::out, pq_sendbyte(), pq_sendint64(), and resetStringInfo().
Referenced by CreateReplicationSlot(), and StartLogicalReplication().
void WalSndResourceCleanup | ( | bool | isCommit | ) |
Definition at line 350 of file walsender.c.
References CurrentResourceOwner, RESOURCE_RELEASE_AFTER_LOCKS, RESOURCE_RELEASE_BEFORE_LOCKS, RESOURCE_RELEASE_LOCKS, ResourceOwnerDelete(), and ResourceOwnerRelease().
Referenced by perform_base_backup(), and WalSndErrorCleanup().
void WalSndRqstFileReload | ( | void | ) |
Definition at line 3201 of file walsender.c.
References i, max_wal_senders, WalSnd::mutex, WalSnd::needreload, WalSnd::pid, SpinLockAcquire, SpinLockRelease, WalSndCtl, and WalSndCtlData::walsnds.
Referenced by KeepFileRestoredFromArchive().
|
static |
Definition at line 2667 of file walsender.c.
References BasicOpenFile(), ereport, errcode_for_file_access(), errmsg(), ERROR, MAXFNAMELEN, MAXPGPATH, PG_BINARY, sendTimeLine, sendTimeLineIsHistoric, sendTimeLineNextTLI, sendTimeLineValidUpto, wal_segment_size, XLByteToSeg, XLogFileName(), and XLogFilePath().
Referenced by CreateReplicationSlot(), StartLogicalReplication(), and StartReplication().
void WalSndSetState | ( | WalSndState | state | ) |
Definition at line 3470 of file walsender.c.
References am_walsender, Assert(), WalSnd::mutex, MyWalSnd, SpinLockAcquire, SpinLockRelease, and WalSnd::state.
Referenced by exec_replication_command(), SendBaseBackup(), StartLogicalReplication(), StartReplication(), WalSndErrorCleanup(), WalSndLoop(), and XLogSendPhysical().
void WalSndShmemInit | ( | void | ) |
Definition at line 3289 of file walsender.c.
References ConditionVariableInit(), dlist_init(), i, max_wal_senders, MemSet, WalSnd::mutex, NUM_SYNC_REP_WAIT_MODE, ShmemInitStruct(), SpinLockInit, WalSndCtlData::SyncRepQueue, WalSndCtlData::wal_flush_cv, WalSndCtlData::wal_replay_cv, WalSndCtl, WalSndCtlData::walsnds, and WalSndShmemSize().
Referenced by CreateSharedMemoryAndSemaphores().
Size WalSndShmemSize | ( | void | ) |
Definition at line 3277 of file walsender.c.
References add_size(), max_wal_senders, and mul_size().
Referenced by CalculateShmemSize(), and WalSndShmemInit().
|
static |
Definition at line 230 of file walsender.c.
Referenced by ProcessPendingWrites(), WalSndCheckTimeOut(), WalSndKeepaliveIfNecessary(), WalSndLoop(), WalSndUpdateProgress(), WalSndWaitForWal(), and WalSndWriteData().
void WalSndSignals | ( | void | ) |
Definition at line 3258 of file walsender.c.
References die, InitializeTimeouts(), pqsignal(), procsignal_sigusr1_handler(), SIG_DFL, SIG_IGN, SIGCHLD, SIGHUP, SignalHandlerForConfigReload(), SIGPIPE, SIGUSR1, SIGUSR2, StatementCancelHandler(), and WalSndLastCycleHandler().
Referenced by PostgresMain().
|
static |
Definition at line 1470 of file walsender.c.
References LogicalDecodingContext::end_xact, GetCurrentTimestamp(), LagTrackerWrite(), last_reply_timestamp, now(), pq_flush_if_writable, pq_is_send_pending, ProcessPendingWrites(), SyncRepRequested, TimestampDifferenceExceeds(), TimestampTzPlusMilliseconds, wal_sender_timeout, WALSND_LOGICAL_LAG_TRACK_INTERVAL_MS, WalSndCtl, WalSndKeepalive(), and WalSndShutdown().
Referenced by CreateReplicationSlot(), and StartLogicalReplication().
Definition at line 3354 of file walsender.c.
References ConditionVariableCancelSleep(), ConditionVariablePrepareToSleep(), WaitEvent::events, FeBeWaitSet, FeBeWaitSetSocketPos, WalSnd::kind, ModifyWaitEvent(), MyWalSnd, proc_exit(), REPLICATION_KIND_LOGICAL, REPLICATION_KIND_PHYSICAL, WaitEventSetWait(), WalSndCtlData::wal_flush_cv, WalSndCtlData::wal_replay_cv, WalSndCtl, and WL_POSTMASTER_DEATH.
Referenced by ProcessPendingWrites(), WalSndLoop(), and WalSndWaitForWal().
|
static |
Definition at line 1538 of file walsender.c.
References CHECK_FOR_INTERRUPTS, ConfigReloadPending, WalSnd::flush, GetCurrentTimestamp(), GetFlushRecPtr(), GetXLogReplayRecPtr(), got_STOPPING, InvalidXLogRecPtr, MyLatch, MyWalSnd, PGC_SIGHUP, pq_flush_if_writable, pq_is_send_pending, ProcessConfigFile(), ProcessRepliesIfAny(), RecoveryInProgress(), ResetLatch(), sentPtr, SetLatch(), streamingDoneReceiving, streamingDoneSending, SyncRepInitConfig(), waiting_for_ping_response, WalSndCaughtUp, WalSndCheckTimeOut(), WalSndComputeSleeptime(), WalSndKeepalive(), WalSndKeepaliveIfNecessary(), WalSndShutdown(), WalSndWait(), WL_SOCKET_READABLE, WL_SOCKET_WRITEABLE, WalSnd::write, and XLogBackgroundFlush().
Referenced by logical_read_xlog_page().
void WalSndWaitStopping | ( | void | ) |
Definition at line 3432 of file walsender.c.
References i, max_wal_senders, WalSnd::mutex, pg_usleep(), WalSnd::pid, SpinLockAcquire, SpinLockRelease, WalSnd::state, WalSndCtl, WalSndCtlData::walsnds, and WALSNDSTATE_STOPPING.
Referenced by ShutdownXLOG().
Definition at line 3333 of file walsender.c.
References ConditionVariableBroadcast(), WalSndCtlData::wal_flush_cv, WalSndCtlData::wal_replay_cv, and WalSndCtl.
Referenced by ApplyWalRecord(), KeepFileRestoredFromArchive(), StartupXLOG(), WalSndWakeupProcessRequests(), and XLogWalRcvFlush().
|
static |
Definition at line 1374 of file walsender.c.
References CHECK_FOR_INTERRUPTS, StringInfoData::data, GetCurrentTimestamp(), last_reply_timestamp, StringInfoData::len, now(), LogicalDecodingContext::out, pq_flush_if_writable, pq_is_send_pending, pq_putmessage_noblock, pq_sendint64(), ProcessPendingWrites(), resetStringInfo(), TimestampTzPlusMilliseconds, tmpbuf, wal_sender_timeout, and WalSndShutdown().
Referenced by CreateReplicationSlot(), and StartLogicalReplication().
|
static |
Definition at line 3045 of file walsender.c.
References am_cascading_walsender, elog(), XLogReaderState::EndRecPtr, ERROR, GetFlushRecPtr(), GetStandbyFlushRecPtr(), got_SIGUSR2, got_STOPPING, InvalidXLogRecPtr, logical_decoding_ctx, LogicalDecodingProcessRecord(), WalSnd::mutex, MyWalSnd, LogicalDecodingContext::reader, sentPtr, WalSnd::sentPtr, SpinLockAcquire, SpinLockRelease, WalSndCaughtUp, and XLogReadRecord().
Referenced by StartLogicalReplication(), and WalSndLoop().
|
static |
Definition at line 2745 of file walsender.c.
References am_cascading_walsender, Assert(), CheckXLogRemoved(), StringInfoData::data, DEBUG1, elog(), enlargeStringInfo(), GetCurrentTimestamp(), GetFlushRecPtr(), GetStandbyFlushRecPtr(), GetWALInsertionTimeLine(), got_STOPPING, LagTrackerWrite(), StringInfoData::len, list_free_deep(), LSN_FORMAT_ARGS, MAX_SEND_SIZE, WalSnd::mutex, MyWalSnd, WalSnd::needreload, output_message, pq_putmessage_noblock, pq_sendbyte(), pq_sendint64(), readTimeLineHistory(), RecoveryInProgress(), resetStringInfo(), XLogReaderState::seg, XLogReaderState::segcxt, sendTimeLine, sendTimeLineIsHistoric, sendTimeLineNextTLI, sendTimeLineValidUpto, sentPtr, WalSnd::sentPtr, set_ps_display(), snprintf, SpinLockAcquire, SpinLockRelease, streamingDoneSending, tliSwitchPoint(), tmpbuf, update_process_title, wal_segment_close(), WALRead(), WALReadRaiseError(), WalSndCaughtUp, WalSndSetState(), WALSNDSTATE_STOPPING, WALOpenSegment::ws_file, WALSegmentContext::ws_segsize, WALOpenSegment::ws_tli, XLByteToSeg, and xlogreader.
Referenced by StartReplication().
Definition at line 117 of file walsender.c.
Referenced by IdentifySystem(), logical_read_xlog_page(), ProcessStandbyReplyMessage(), StartLogicalReplication(), StartReplication(), SyncRepGetStandbyPriority(), XLogSendLogical(), and XLogSendPhysical().
Definition at line 119 of file walsender.c.
Referenced by check_db(), ClientAuthentication(), InitPostgres(), and ProcessStartupPacket().
Definition at line 116 of file walsender.c.
Referenced by BackendInitialize(), check_db(), ClientAuthentication(), forbidden_in_wal_sender(), HandleWalSndInitStopping(), InitPostgres(), InitProcess(), LagTrackerWrite(), MarkPostmasterChildWalSender(), PerformAuthentication(), PostgresMain(), ProcessStartupPacket(), and WalSndSetState().
|
static |
Definition at line 187 of file walsender.c.
Referenced by WalSndErrorCleanup(), WalSndLastCycleHandler(), WalSndLoop(), and XLogSendLogical().
|
static |
Definition at line 188 of file walsender.c.
Referenced by exec_replication_command(), HandleWalSndInitStopping(), StartLogicalReplication(), StartReplication(), WalSndErrorCleanup(), WalSndWaitForWal(), XLogSendLogical(), and XLogSendPhysical().
|
static |
Definition at line 220 of file walsender.c.
Referenced by LagTrackerRead(), and LagTrackerWrite().
|
static |
Definition at line 163 of file walsender.c.
Referenced by ProcessRepliesIfAny(), WalSndCheckTimeOut(), and WalSndKeepaliveIfNecessary().
|
static |
Definition at line 169 of file walsender.c.
Referenced by CreateReplicationSlot(), ProcessRepliesIfAny(), WalSndCheckTimeOut(), WalSndComputeSleeptime(), WalSndKeepaliveIfNecessary(), WalSndLoop(), WalSndUpdateProgress(), and WalSndWriteData().
Definition at line 126 of file walsender.c.
Referenced by exec_replication_command().
|
static |
Definition at line 198 of file walsender.c.
Referenced by StartLogicalReplication(), and XLogSendLogical().
int max_wal_senders = 10 |
Definition at line 122 of file walsender.c.
Referenced by check_autovacuum_max_workers(), check_max_connections(), check_max_worker_processes(), CheckRequiredParameterValues(), InitControlFile(), InitializeMaxBackends(), InitProcess(), InitWalSenderSlot(), MaxLivePostmasterChildren(), pg_stat_get_wal_senders(), PostmasterMain(), SyncRepGetCandidateStandbys(), WalSndInitStopping(), WalSndRqstFileReload(), WalSndShmemInit(), WalSndShmemSize(), WalSndWaitStopping(), WalSndWakeupProcessRequests(), and XLogReportParameters().
WalSnd* MyWalSnd = NULL |
Definition at line 113 of file walsender.c.
Referenced by exec_replication_command(), InitWalSenderSlot(), ProcessStandbyHSFeedbackMessage(), ProcessStandbyReplyMessage(), StartLogicalReplication(), StartReplication(), SyncRepGetCandidateStandbys(), SyncRepInitConfig(), SyncRepReleaseWaiters(), WalSndDone(), WalSndKill(), WalSndLoop(), WalSndSetState(), WalSndWait(), WalSndWaitForWal(), XLogSendLogical(), and XLogSendPhysical().
|
static |
Definition at line 158 of file walsender.c.
Referenced by exec_replication_command(), WalSndKeepalive(), and XLogSendPhysical().
|
static |
Definition at line 196 of file walsender.c.
Referenced by HandleWalSndInitStopping(), StartLogicalReplication(), StartReplication(), and WalSndErrorCleanup().
|
static |
Definition at line 159 of file walsender.c.
Referenced by exec_replication_command(), ProcessRepliesIfAny(), ProcessStandbyHSFeedbackMessage(), ProcessStandbyMessage(), and ProcessStandbyReplyMessage().
|
static |
Definition at line 146 of file walsender.c.
Referenced by logical_read_xlog_page(), StartReplication(), WalSndSegmentOpen(), and XLogSendPhysical().
Definition at line 148 of file walsender.c.
Referenced by logical_read_xlog_page(), StartReplication(), WalSndSegmentOpen(), and XLogSendPhysical().
|
static |
Definition at line 147 of file walsender.c.
Referenced by logical_read_xlog_page(), StartReplication(), WalSndSegmentOpen(), and XLogSendPhysical().
|
static |
Definition at line 149 of file walsender.c.
Referenced by logical_read_xlog_page(), StartReplication(), WalSndSegmentOpen(), and XLogSendPhysical().
|
static |
Definition at line 155 of file walsender.c.
Referenced by ProcessStandbyReplyMessage(), StartLogicalReplication(), StartReplication(), WalSndDone(), WalSndKeepalive(), WalSndWaitForWal(), XLogSendLogical(), and XLogSendPhysical().
|
static |
Definition at line 181 of file walsender.c.
Referenced by ProcessRepliesIfAny(), StartReplication(), WalSndLoop(), and WalSndWaitForWal().
|
static |
Definition at line 180 of file walsender.c.
Referenced by ProcessRepliesIfAny(), StartReplication(), WalSndLoop(), WalSndWaitForWal(), and XLogSendPhysical().
|
static |
Definition at line 160 of file walsender.c.
Referenced by copy_crlf(), describeOneTableDetails(), exec_replication_command(), GetVisibilityMapPins(), mdc_finish(), multirange_recv(), parse_literal_data(), parse_symenc_sesskey(), PQunescapeBytea(), pullf_read_max(), scanGetCandidate(), shm_mq_sendv(), tsvectorin(), WalSndWriteData(), and XLogSendPhysical().
Definition at line 172 of file walsender.c.
Referenced by ProcessRepliesIfAny(), WalSndComputeSleeptime(), WalSndDone(), WalSndKeepalive(), WalSndKeepaliveIfNecessary(), WalSndLoop(), and WalSndWaitForWal().
Definition at line 131 of file walsender.c.
Referenced by WalSndWakeupProcessRequests().
int wal_sender_timeout = 60 * 1000 |
Definition at line 124 of file walsender.c.
Referenced by WalSndCheckTimeOut(), WalSndComputeSleeptime(), WalSndKeepaliveIfNecessary(), WalSndUpdateProgress(), and WalSndWriteData().
Definition at line 184 of file walsender.c.
Referenced by WalSndDone(), WalSndLoop(), WalSndWaitForWal(), XLogSendLogical(), and XLogSendPhysical().
WalSndCtlData* WalSndCtl = NULL |
Definition at line 110 of file walsender.c.
Referenced by InitWalSenderSlot(), pg_stat_get_wal_senders(), SyncRepGetCandidateStandbys(), SyncRepQueueInsert(), SyncRepReleaseWaiters(), SyncRepUpdateSyncStandbysDefined(), SyncRepWaitForLSN(), SyncRepWakeQueue(), WalSndInitStopping(), WalSndRqstFileReload(), WalSndShmemInit(), WalSndUpdateProgress(), WalSndWait(), WalSndWaitStopping(), and WalSndWakeup().
|
static |
Definition at line 138 of file walsender.c.
Referenced by exec_replication_command(), StartLogicalReplication(), StartReplication(), WalSndErrorCleanup(), and XLogSendPhysical().