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 1385 of file walsender.c.
References defGetBoolean(), elog, ereport, errcode(), errmsg(), ERROR, foreach_ptr, AlterReplicationSlotCmd::options, ReplicationSlotAlter(), AlterReplicationSlotCmd::slotname, and two_phase.
Referenced by exec_replication_command().
|
static |
Definition at line 1171 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 1376 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 1952 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 3477 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 713 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 3533 of file walsender.c.
References am_walsender, Assert, got_STOPPING, kill, MyProcPid, and replication_active.
Referenced by procsignal_sigusr1_handler().
|
static |
Definition at line 377 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, MemoryContextStrdup(), MyDatabaseId, RecoveryInProgress(), snprintf, StartTransactionCommand(), TTSOpsVirtual, TupleDescInitBuiltinEntry(), UINT64_FORMAT, and values.
Referenced by exec_replication_command().
|
static |
Definition at line 2869 of file walsender.c.
References WalSnd::apply, WalSnd::applyLag, Assert, WalSnd::flush, WalSnd::flushLag, i, InvalidOid, InvalidXLogRecPtr, WalSnd::kind, max_wal_senders, WalSnd::mutex, MyDatabaseId, MyProcPid, MyWalSnd, WalSnd::needreload, on_shmem_exit(), WalSnd::pid, 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 4133 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 4068 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 1021 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 1733 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 1765 of file walsender.c.
References NeedToWaitForStandbys().
Referenced by WalSndWaitForWal().
|
static |
Definition at line 3820 of file walsender.c.
References Interval::day, Interval::month, palloc(), and Interval::time.
Referenced by pg_stat_get_wal_senders().
|
static |
Definition at line 1094 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 3836 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 2330 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 2468 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 1708 of file walsender.c.
References Assert, ConditionVariableBroadcast(), ReplicationSlot::data, MyReplicationSlot, ReplicationSlotPersistentData::name, NameStr, RecoveryInProgress(), SlotExistsInSyncStandbySlots(), SlotIsPhysical, WalSndCtlData::wal_confirm_rcv_cv, and WalSndCtl.
Referenced by pg_physical_replication_slot_advance(), and PhysicalConfirmReceivedLocation().
|
static |
Definition at line 1589 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 2186 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 2548 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 2299 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 2363 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 458 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 557 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 1427 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 789 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 2517 of file walsender.c.
References epoch, EpochFromFullTransactionId, ReadNextFullTransactionId(), TransactionIdPrecedesOrEquals(), and XidFromFullTransactionId.
Referenced by ProcessStandbyHSFeedbackMessage().
|
static |
Definition at line 647 of file walsender.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, Assert, AuxProcessResourceOwner, buf, CacheMemoryContext, CreateIncrementalBackupInfo(), CurrentMemoryContext, CurrentResourceOwner, FinalizeIncrementalManifest(), HandleUploadManifestPacket(), MemoryContextDelete(), MemoryContextSetParent(), pq_beginmessage(), pq_endmessage_reuse(), pq_flush, pq_sendbyte(), pq_sendint16(), PqMsg_CopyInResponse, ReleaseAuxProcessResources(), uploaded_manifest, and uploaded_manifest_mcxt.
Referenced by exec_replication_command().
|
static |
Definition at line 2716 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 2672 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 3434 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 325 of file walsender.c.
References ConditionVariableCancelSleep(), got_SIGUSR2, got_STOPPING, IsTransactionOrTransactionBlock(), LWLockReleaseAll(), MyReplicationSlot, pgstat_report_wait_end(), proc_exit(), ReleaseAuxProcessResources(), replication_active, ReplicationSlotCleanup(), ReplicationSlotRelease(), XLogReaderState::seg, wal_segment_close(), WalSndSetState(), WALSNDSTATE_STARTUP, WALOpenSegment::ws_file, and xlogreader.
Referenced by PostgresMain().
|
static |
Definition at line 3801 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 3718 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 4007 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 4030 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 2945 of file walsender.c.
References Assert, WalSnd::mutex, MyWalSnd, WalSnd::pid, SpinLockAcquire, and SpinLockRelease.
Referenced by InitWalSenderSlot().
|
static |
Definition at line 3555 of file walsender.c.
References got_SIGUSR2, MyLatch, and SetLatch().
Referenced by WalSndSignals().
|
static |
Definition at line 2743 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 1520 of file walsender.c.
References InvalidXLogRecPtr, LogicalDecodingContext::out, pq_sendbyte(), pq_sendint64(), and resetStringInfo().
Referenced by CreateReplicationSlot(), and StartLogicalReplication().
void WalSndRqstFileReload | ( | void | ) |
Definition at line 3510 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 2961 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 3782 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 3594 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 3582 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 3563 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 1643 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 3660 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 1793 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 3744 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().
void WalSndWakeup | ( | bool | physical, |
bool | logical | ||
) |
Definition at line 3639 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 1547 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 3349 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 3039 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().
bool am_cascading_walsender = false |
Definition at line 116 of file walsender.c.
Referenced by GetStandbyFlushRecPtr(), IdentifySystem(), logical_read_xlog_page(), ProcessStandbyReplyMessage(), StartLogicalReplication(), StartReplication(), SyncRepGetStandbyPriority(), XLogSendLogical(), and XLogSendPhysical().
bool am_db_walsender = false |
Definition at line 118 of file walsender.c.
Referenced by check_db(), ClientAuthentication(), InitPostgres(), and ProcessStartupPacket().
bool am_walsender = false |
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().
bool log_replication_commands = false |
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 CheckRequiredParameterValues(), InitControlFile(), InitializeMaxBackends(), InitPostmasterChildSlots(), InitProcess(), InitWalSenderSlot(), 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().
|
static |
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(), pqGetHomeDirectory(), PQunescapeBytea(), prefix_init(), 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().
|
static |
Definition at line 182 of file walsender.c.
Referenced by ProcessRepliesIfAny(), WalSndComputeSleeptime(), WalSndDone(), WalSndKeepalive(), WalSndKeepaliveIfNecessary(), WalSndLoop(), and WalSndWaitForWal().
bool wake_wal_senders = false |
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().
|
static |
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().