PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <signal.h>
#include <unistd.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 "backup/basebackup_incremental.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/slotsync.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 "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/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 218 of file walsender.c.
#define MAX_SEND_SIZE (XLOG_BLCKSZ * 16) |
Definition at line 106 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 236 of file walsender.c.
|
static |
Definition at line 1439 of file walsender.c.
References ParseAlterReplSlotOptions(), ReplicationSlotAlter(), and AlterReplicationSlotCmd::slotname.
Referenced by exec_replication_command().
|
static |
Definition at line 1200 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 1405 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 1977 of file walsender.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, AlterReplicationSlot(), 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, uploaded_manifest, UploadManifest(), WalSndSetState(), WALSNDSTATE_STOPPING, and xlogreader.
Referenced by PostgresMain().
XLogRecPtr GetStandbyFlushRecPtr | ( | TimeLineID * | tli | ) |
Definition at line 3504 of file walsender.c.
References am_cascading_walsender, Assert, GetWalRcvFlushRecPtr(), GetXLogReplayRecPtr(), IsSyncingReplicationSlots(), and receiveTLI.
Referenced by IdentifySystem(), StartReplication(), synchronize_one_slot(), XLogSendLogical(), and XLogSendPhysical().
|
static |
Definition at line 743 of file walsender.c.
References AppendIncrementalManifestData(), Assert, buf, ereport, errcode(), errmsg(), ERROR, HOLD_CANCEL_INTERRUPTS, pq_getbyte(), pq_getmessage(), pq_getmsgstring(), PQ_LARGE_MESSAGE_LIMIT, PQ_SMALL_MESSAGE_LIMIT, pq_startmsgread(), and RESUME_CANCEL_INTERRUPTS.
Referenced by UploadManifest().
void HandleWalSndInitStopping | ( | void | ) |
Definition at line 3560 of file walsender.c.
References am_walsender, Assert, got_STOPPING, kill, MyProcPid, and replication_active.
Referenced by procsignal_sigusr1_handler().
|
static |
Definition at line 407 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 2893 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 4160 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 4095 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 1051 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 1758 of file walsender.c.
References ReplicationSlot::data, ERROR, ReplicationSlotPersistentData::failover, got_STOPPING, MyReplicationSlot, replication_active, StandbySlotsHaveCaughtup(), and WARNING.
Referenced by NeedToWaitForWal(), and WalSndWaitForWal().
|
static |
Definition at line 1790 of file walsender.c.
References NeedToWaitForStandbys().
Referenced by WalSndWaitForWal().
|
static |
Definition at line 3847 of file walsender.c.
References Interval::day, Interval::month, palloc(), and Interval::time.
Referenced by pg_stat_get_wal_senders().
|
static |
Definition at line 1414 of file walsender.c.
References defGetBoolean(), elog, ereport, errcode(), errmsg(), ERROR, foreach_ptr, and AlterReplicationSlotCmd::options.
Referenced by AlterReplicationSlot().
|
static |
Definition at line 1123 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 3863 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 2354 of file walsender.c.
References Assert, ReplicationSlot::data, InvalidXLogRecPtr, ReplicationSlot::mutex, MyReplicationSlot, PhysicalWakeupLogicalWalSnd(), ReplicationSlotMarkDirty(), ReplicationSlotsComputeRequiredLSN(), ReplicationSlotPersistentData::restart_lsn, SpinLockAcquire, and SpinLockRelease.
Referenced by ProcessStandbyReplyMessage().
|
static |
Definition at line 2492 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().
void PhysicalWakeupLogicalWalSnd | ( | void | ) |
Definition at line 1733 of file walsender.c.
References Assert, ConditionVariableBroadcast(), ReplicationSlot::data, MyReplicationSlot, ReplicationSlotPersistentData::name, NameStr, RecoveryInProgress(), SlotExistsInStandbySlotNames(), SlotIsPhysical, WalSndCtlData::wal_confirm_rcv_cv, and WalSndCtl.
Referenced by pg_physical_replication_slot_advance(), and PhysicalConfirmReceivedLocation().
|
static |
Definition at line 1614 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 2210 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 2572 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 2323 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 2387 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 490 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 589 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 1452 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 819 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 2541 of file walsender.c.
References epoch, EpochFromFullTransactionId, ReadNextFullTransactionId(), TransactionIdPrecedesOrEquals(), and XidFromFullTransactionId.
Referenced by ProcessStandbyHSFeedbackMessage().
|
static |
Definition at line 679 of file walsender.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, buf, CacheMemoryContext, CreateIncrementalBackupInfo(), CurrentMemoryContext, CurrentResourceOwner, FinalizeIncrementalManifest(), HandleUploadManifestPacket(), MemoryContextDelete(), MemoryContextSetParent(), pq_beginmessage(), pq_endmessage_reuse(), pq_flush, pq_sendbyte(), pq_sendint16(), ResourceOwnerCreate(), uploaded_manifest, uploaded_manifest_mcxt, and WalSndResourceCleanup().
Referenced by exec_replication_command().
|
static |
Definition at line 2740 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 2696 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 3461 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 327 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 3828 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 3745 of file walsender.c.
References i, INVALID_PROC_NUMBER, 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 4034 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 4057 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 2970 of file walsender.c.
References Assert, WalSnd::latch, WalSnd::mutex, MyWalSnd, WalSnd::pid, SpinLockAcquire, and SpinLockRelease.
Referenced by InitWalSenderSlot().
|
static |
Definition at line 3582 of file walsender.c.
References got_SIGUSR2, MyLatch, and SetLatch().
Referenced by WalSndSignals().
|
static |
Definition at line 2767 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 1545 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 362 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(), UploadManifest(), and WalSndErrorCleanup().
void WalSndRqstFileReload | ( | void | ) |
Definition at line 3537 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 2988 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 3809 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 3621 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_confirm_rcv_cv, WalSndCtlData::wal_flush_cv, WalSndCtlData::wal_replay_cv, WalSndCtl, WalSndCtlData::walsnds, and WalSndShmemSize().
Referenced by CreateOrAttachShmemStructs().
Size WalSndShmemSize | ( | void | ) |
Definition at line 3609 of file walsender.c.
References add_size(), max_wal_senders, mul_size(), and size.
Referenced by CalculateShmemSize(), and WalSndShmemInit().
|
static |
Definition at line 240 of file walsender.c.
Referenced by ProcessPendingWrites(), WalSndCheckTimeOut(), WalSndKeepaliveIfNecessary(), WalSndLoop(), WalSndUpdateProgress(), WalSndWaitForWal(), and WalSndWriteData().
void WalSndSignals | ( | void | ) |
Definition at line 3590 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 1668 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 3687 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_confirm_rcv_cv, WalSndCtlData::wal_flush_cv, WalSndCtlData::wal_replay_cv, WalSndCtl, and WL_POSTMASTER_DEATH.
Referenced by ProcessPendingWrites(), WalSndLoop(), and WalSndWaitForWal().
|
static |
Definition at line 1818 of file walsender.c.
References Assert, CHECK_FOR_INTERRUPTS, ConfigReloadPending, WalSnd::flush, GetCurrentTimestamp(), GetFlushRecPtr(), GetXLogReplayRecPtr(), got_STOPPING, InvalidXLogRecPtr, MyLatch, MyWalSnd, NeedToWaitForStandbys(), NeedToWaitForWal(), 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, XLogBackgroundFlush(), and XLogRecPtrIsInvalid.
Referenced by logical_read_xlog_page().
void WalSndWaitStopping | ( | void | ) |
Definition at line 3771 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 3666 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 1572 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 3376 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 3066 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(), WALReadFromBuffers(), WALReadRaiseError(), WalSndCaughtUp, WalSndSetState(), WALSNDSTATE_STOPPING, WALOpenSegment::ws_file, WALSegmentContext::ws_segsize, WALOpenSegment::ws_tli, XLByteToSeg, and xlogreader.
Referenced by StartReplication().
Definition at line 116 of file walsender.c.
Referenced by GetStandbyFlushRecPtr(), IdentifySystem(), logical_read_xlog_page(), ProcessStandbyReplyMessage(), StartLogicalReplication(), StartReplication(), SyncRepGetStandbyPriority(), XLogSendLogical(), and XLogSendPhysical().
Definition at line 118 of file walsender.c.
Referenced by check_db(), ClientAuthentication(), InitPostgres(), and ProcessStartupPacket().
Definition at line 115 of file walsender.c.
Referenced by BackendInitialize(), check_db(), ClientAuthentication(), forbidden_in_wal_sender(), HandleWalSndInitStopping(), InitPostgres(), LagTrackerWrite(), MarkPostmasterChildWalSender(), PerformAuthentication(), PostgresMain(), ProcessStartupPacket(), ReplicationSlotAcquire(), ReplicationSlotRelease(), and WalSndSetState().
|
static |
Definition at line 197 of file walsender.c.
Referenced by WalSndErrorCleanup(), WalSndLastCycleHandler(), WalSndLoop(), and XLogSendLogical().
|
static |
Definition at line 198 of file walsender.c.
Referenced by exec_replication_command(), HandleWalSndInitStopping(), NeedToWaitForStandbys(), StartLogicalReplication(), StartReplication(), WalSndErrorCleanup(), WalSndWaitForWal(), XLogSendLogical(), and XLogSendPhysical().
|
static |
Definition at line 230 of file walsender.c.
Referenced by LagTrackerRead(), and LagTrackerWrite().
|
static |
Definition at line 173 of file walsender.c.
Referenced by ProcessRepliesIfAny(), WalSndCheckTimeOut(), and WalSndKeepaliveIfNecessary().
|
static |
Definition at line 179 of file walsender.c.
Referenced by CreateReplicationSlot(), ProcessRepliesIfAny(), WalSndCheckTimeOut(), WalSndComputeSleeptime(), WalSndKeepaliveIfNecessary(), WalSndLoop(), WalSndUpdateProgress(), and WalSndWriteData().
Definition at line 125 of file walsender.c.
Referenced by exec_replication_command(), ReplicationSlotAcquire(), and ReplicationSlotRelease().
|
static |
Definition at line 208 of file walsender.c.
Referenced by StartLogicalReplication(), and XLogSendLogical().
int max_wal_senders = 10 |
Definition at line 121 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 112 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 168 of file walsender.c.
Referenced by exec_replication_command(), WalSndKeepalive(), and XLogSendPhysical().
|
static |
Definition at line 206 of file walsender.c.
Referenced by HandleWalSndInitStopping(), NeedToWaitForStandbys(), StartLogicalReplication(), StartReplication(), and WalSndErrorCleanup().
|
static |
Definition at line 169 of file walsender.c.
Referenced by exec_replication_command(), ProcessRepliesIfAny(), ProcessStandbyHSFeedbackMessage(), ProcessStandbyMessage(), and ProcessStandbyReplyMessage().
|
static |
Definition at line 156 of file walsender.c.
Referenced by logical_read_xlog_page(), StartReplication(), WalSndSegmentOpen(), and XLogSendPhysical().
Definition at line 158 of file walsender.c.
Referenced by logical_read_xlog_page(), StartReplication(), WalSndSegmentOpen(), and XLogSendPhysical().
|
static |
Definition at line 157 of file walsender.c.
Referenced by logical_read_xlog_page(), StartReplication(), WalSndSegmentOpen(), and XLogSendPhysical().
|
static |
Definition at line 159 of file walsender.c.
Referenced by logical_read_xlog_page(), StartReplication(), WalSndSegmentOpen(), and XLogSendPhysical().
|
static |
Definition at line 165 of file walsender.c.
Referenced by ProcessStandbyReplyMessage(), StartLogicalReplication(), StartReplication(), WalSndDone(), WalSndKeepalive(), WalSndWaitForWal(), XLogSendLogical(), and XLogSendPhysical().
|
static |
Definition at line 191 of file walsender.c.
Referenced by ProcessRepliesIfAny(), StartReplication(), WalSndLoop(), and WalSndWaitForWal().
|
static |
Definition at line 190 of file walsender.c.
Referenced by ProcessRepliesIfAny(), StartReplication(), WalSndLoop(), WalSndWaitForWal(), and XLogSendPhysical().
|
static |
Definition at line 170 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().
|
static |
Definition at line 147 of file walsender.c.
Referenced by exec_replication_command(), and UploadManifest().
|
static |
Definition at line 148 of file walsender.c.
Referenced by UploadManifest().
Definition at line 182 of file walsender.c.
Referenced by ProcessRepliesIfAny(), WalSndComputeSleeptime(), WalSndDone(), WalSndKeepalive(), WalSndKeepaliveIfNecessary(), WalSndLoop(), and WalSndWaitForWal().
Definition at line 130 of file walsender.c.
Referenced by WalSndWakeupProcessRequests().
int wal_sender_timeout = 60 * 1000 |
Definition at line 123 of file walsender.c.
Referenced by WalSndCheckTimeOut(), WalSndComputeSleeptime(), WalSndKeepaliveIfNecessary(), WalSndUpdateProgress(), and WalSndWriteData().
Definition at line 194 of file walsender.c.
Referenced by WalSndDone(), WalSndLoop(), WalSndWaitForWal(), XLogSendLogical(), and XLogSendPhysical().
WalSndCtlData* WalSndCtl = NULL |
Definition at line 109 of file walsender.c.
Referenced by InitWalSenderSlot(), pg_stat_get_wal_senders(), PhysicalWakeupLogicalWalSnd(), SyncRepGetCandidateStandbys(), SyncRepQueueInsert(), SyncRepReleaseWaiters(), SyncRepUpdateSyncStandbysDefined(), SyncRepWaitForLSN(), SyncRepWakeQueue(), WaitForStandbyConfirmation(), WalSndInitStopping(), WalSndRqstFileReload(), WalSndShmemInit(), WalSndUpdateProgress(), WalSndWait(), WalSndWaitStopping(), and WalSndWakeup().
|
static |
Definition at line 137 of file walsender.c.
Referenced by exec_replication_command(), StartLogicalReplication(), StartReplication(), WalSndErrorCleanup(), and XLogSendPhysical().