PostgreSQL Source Code
git master
|
#include "postgres.h"
#include "access/table.h"
#include "access/xact.h"
#include "catalog/pg_subscription_rel.h"
#include "catalog/pg_type.h"
#include "commands/copy.h"
#include "miscadmin.h"
#include "parser/parse_relation.h"
#include "pgstat.h"
#include "replication/logicallauncher.h"
#include "replication/logicalrelation.h"
#include "replication/walreceiver.h"
#include "replication/worker_internal.h"
#include "replication/slot.h"
#include "replication/origin.h"
#include "storage/ipc.h"
#include "storage/lmgr.h"
#include "utils/builtins.h"
#include "utils/lsyscache.h"
#include "utils/memutils.h"
#include "utils/snapmgr.h"
Go to the source code of this file.
Functions | |
static void | pg_attribute_noreturn () |
static bool | wait_for_relation_state_change (Oid relid, char expected_state) |
static bool | wait_for_worker_state_change (char expected_state) |
void | invalidate_syncing_table_states (Datum arg, int cacheid, uint32 hashvalue) |
static void | process_syncing_tables_for_sync (XLogRecPtr current_lsn) |
static void | process_syncing_tables_for_apply (XLogRecPtr current_lsn) |
void | process_syncing_tables (XLogRecPtr current_lsn) |
static List * | make_copy_attnamelist (LogicalRepRelMapEntry *rel) |
static int | copy_read_data (void *outbuf, int minread, int maxread) |
static void | fetch_remote_table_info (char *nspname, char *relname, LogicalRepRelation *lrel) |
static void | copy_table (Relation rel) |
void | ReplicationSlotNameForTablesync (Oid suboid, Oid relid, char *syncslotname, int szslot) |
void | ReplicationOriginNameForTablesync (Oid suboid, Oid relid, char *originname, int szorgname) |
char * | LogicalRepSyncTableStart (XLogRecPtr *origin_startpos) |
Variables | |
static bool | table_states_valid = false |
StringInfo | copybuf = NULL |
|
static |
Definition at line 619 of file tablesync.c.
References buf, CHECK_FOR_INTERRUPTS, StringInfoData::cursor, StringInfoData::data, fd(), StringInfoData::len, MyLatch, PGINVALID_SOCKET, ResetLatch(), WAIT_EVENT_LOGICAL_SYNC_DATA, WaitLatchOrSocket(), walrcv_receive, WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, WL_SOCKET_READABLE, WL_TIMEOUT, and wrconn.
Referenced by copy_table().
|
static |
Definition at line 802 of file tablesync.c.
References AccessShareLock, addRangeTableEntryForRelation(), appendStringInfo(), appendStringInfoString(), Assert, LogicalRepRelation::attnames, BeginCopyFrom(), copy_read_data(), CopyFrom(), StringInfoData::data, ereport, WalRcvExecResult::err, errmsg(), ERROR, fetch_remote_table_info(), get_namespace_name(), i, initStringInfo(), LogicalRepRelMapEntry::localrel, logicalrep_rel_close(), logicalrep_rel_open(), logicalrep_relmap_update(), make_copy_attnamelist(), make_parsestate(), makeStringInfo(), LogicalRepRelation::natts, NIL, NoLock, LogicalRepRelation::nspname, pfree(), quote_identifier(), quote_qualified_identifier(), RelationGetNamespace, RelationGetRelationName, LogicalRepRelation::relkind, LogicalRepRelation::relname, LogicalRepRelation::remoteid, WalRcvExecResult::status, walrcv_clear_result(), walrcv_exec, WALRCV_OK_COPY_OUT, and wrconn.
Referenced by LogicalRepSyncTableStart().
|
static |
Definition at line 694 of file tablesync.c.
References appendStringInfo(), Assert, LogicalRepRelation::attkeys, LogicalRepRelation::attnames, LogicalRepRelation::atttyps, bms_add_member(), StringInfoData::data, DatumGetBool, DatumGetChar, DatumGetObjectId, elog, ereport, WalRcvExecResult::err, errmsg(), ERROR, ExecClearTuple(), ExecDropSingleTupleTableSlot(), initStringInfo(), lengthof, MakeSingleTupleTableSlot(), MaxTupleAttributeNumber, LogicalRepRelation::natts, LogicalRepRelation::nspname, palloc0(), pfree(), quote_literal_cstr(), LogicalRepRelation::relkind, relname, LogicalRepRelation::relname, LogicalRepRelation::remoteid, LogicalRepRelation::replident, resetStringInfo(), slot_getattr(), WalRcvExecResult::status, TextDatumGetCString, TTSOpsMinimalTuple, WalRcvExecResult::tupledesc, WalRcvExecResult::tuplestore, tuplestore_gettupleslot(), walrcv_clear_result(), walrcv_exec, WALRCV_OK_TUPLES, walrcv_server_version, and wrconn.
Referenced by copy_table().
Definition at line 264 of file tablesync.c.
References table_states_valid.
Referenced by ApplyWorkerMain().
char* LogicalRepSyncTableStart | ( | XLogRecPtr * | origin_startpos | ) |
Definition at line 913 of file tablesync.c.
References Assert, CommandCounterIncrement(), CommitTransactionCommand(), Subscription::conninfo, copy_table(), CRS_USE_SNAPSHOT, DEBUG1, elog, ereport, WalRcvExecResult::err, errcode(), ERRCODE_DUPLICATE_OBJECT, errdetail(), errmsg(), ERROR, GetSubscriptionRelState(), GetTransactionSnapshot(), InvalidXLogRecPtr, LockRelationOid(), LSN_FORMAT_ARGS, MyLogicalRepWorker, MySubscription, NAMEDATALEN, NoLock, Subscription::oid, OidIsValid, palloc(), pgstat_report_stat(), PopActiveSnapshot(), PushActiveSnapshot(), LogicalRepWorker::relid, LogicalRepWorker::relmutex, LogicalRepWorker::relstate, LogicalRepWorker::relstate_lsn, ReplicationOriginNameForTablesync(), ReplicationSlotDropAtPubNode(), ReplicationSlotNameForTablesync(), replorigin_advance(), replorigin_by_name(), replorigin_create(), replorigin_session_get_progress(), replorigin_session_origin, replorigin_session_setup(), RowExclusiveLock, SpinLockAcquire, SpinLockRelease, StartTransactionCommand(), WalRcvExecResult::status, LogicalRepWorker::subid, table_close(), table_open(), UnlockRelationOid(), UpdateSubscriptionRelState(), wait_for_worker_state_change(), walrcv_clear_result(), walrcv_connect, walrcv_create_slot, walrcv_exec, WALRCV_OK_COMMAND, and wrconn.
Referenced by ApplyWorkerMain().
|
static |
Definition at line 599 of file tablesync.c.
References LogicalRepRelation::attnames, i, lappend(), makeString(), LogicalRepRelation::natts, NIL, and LogicalRepRelMapEntry::remoterel.
Referenced by copy_table().
|
static |
Definition at line 126 of file tablesync.c.
References CommitTransactionCommand(), ereport, errmsg(), get_rel_name(), GetXLogWriteRecPtr(), InvalidOid, IsTransactionState(), LOG, logicalrep_worker_wakeup(), MyLogicalRepWorker, MySubscription, Subscription::name, pgstat_report_stat(), proc_exit(), LogicalRepWorker::relid, StartTransactionCommand(), LogicalRepWorker::subid, and XLogFlush().
void process_syncing_tables | ( | XLogRecPtr | current_lsn | ) |
Definition at line 587 of file tablesync.c.
References am_tablesync_worker(), process_syncing_tables_for_apply(), and process_syncing_tables_for_sync().
Referenced by apply_handle_commit(), apply_handle_stream_commit(), and LogicalRepApplyLoop().
|
static |
Definition at line 355 of file tablesync.c.
References Assert, CacheMemoryContext, CommitTransactionCommand(), LogicalRepWorker::dbid, HASHCTL::entrysize, GetCurrentTimestamp(), GetSubscriptionNotReadyRelations(), HASH_BLOBS, hash_create(), hash_destroy(), HASH_ELEM, HASH_ENTER, hash_search(), IsTransactionState(), HASHCTL::keysize, lappend(), lfirst, list_free_deep(), logicalrep_sync_worker_count(), logicalrep_worker_find(), logicalrep_worker_launch(), logicalrep_worker_wakeup_ptr(), SubscriptionRelState::lsn, LW_SHARED, LWLockAcquire(), LWLockRelease(), Max, max_sync_workers_per_subscription, MemoryContextSwitchTo(), MyLogicalRepWorker, MySubscription, Subscription::name, NAMEDATALEN, NIL, now(), Subscription::oid, palloc(), pgstat_report_stat(), LogicalRepWorker::proc, SubscriptionRelState::relid, LogicalRepWorker::relmutex, LogicalRepWorker::relstate, LogicalRepWorker::relstate_lsn, ReplicationOriginNameForTablesync(), replorigin_drop_by_name(), SpinLockAcquire, SpinLockRelease, StartTransactionCommand(), SubscriptionRelState::state, LogicalRepWorker::subid, table_states_valid, TimestampDifferenceExceeds(), UpdateSubscriptionRelState(), LogicalRepWorker::userid, wait_for_relation_state_change(), and wal_retrieve_retry_interval.
Referenced by process_syncing_tables().
|
static |
Definition at line 278 of file tablesync.c.
References IsTransactionState(), MyLogicalRepWorker, NAMEDATALEN, LogicalRepWorker::relid, LogicalRepWorker::relmutex, LogicalRepWorker::relstate, LogicalRepWorker::relstate_lsn, ReplicationSlotDropAtPubNode(), ReplicationSlotNameForTablesync(), SpinLockAcquire, SpinLockRelease, StartTransactionCommand(), LogicalRepWorker::subid, UpdateSubscriptionRelState(), walrcv_endstreaming, and wrconn.
Referenced by process_syncing_tables().
Definition at line 898 of file tablesync.c.
References snprintf.
Referenced by AlterSubscription_refresh(), DropSubscription(), LogicalRepSyncTableStart(), and process_syncing_tables_for_apply().
Definition at line 885 of file tablesync.c.
References GetSystemIdentifier(), snprintf, and UINT64_FORMAT.
Referenced by AlterSubscription_refresh(), DropSubscription(), LogicalRepSyncTableStart(), process_syncing_tables_for_sync(), and ReportSlotConnectionError().
Definition at line 167 of file tablesync.c.
References CHECK_FOR_INTERRUPTS, GetSubscriptionRelState(), InvalidateCatalogSnapshot(), logicalrep_worker_find(), LW_SHARED, LWLockAcquire(), LWLockRelease(), MyLatch, MyLogicalRepWorker, ResetLatch(), LogicalRepWorker::subid, WAIT_EVENT_LOGICAL_SYNC_STATE_CHANGE, WaitLatch(), WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, and WL_TIMEOUT.
Referenced by process_syncing_tables_for_apply().
|
static |
Definition at line 215 of file tablesync.c.
References CHECK_FOR_INTERRUPTS, InvalidOid, logicalrep_worker_find(), logicalrep_worker_wakeup_ptr(), LW_SHARED, LWLockAcquire(), LWLockRelease(), MyLatch, MyLogicalRepWorker, LogicalRepWorker::proc, LogicalRepWorker::relstate, ResetLatch(), LogicalRepWorker::subid, WAIT_EVENT_LOGICAL_SYNC_STATE_CHANGE, WaitLatch(), WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, and WL_TIMEOUT.
Referenced by LogicalRepSyncTableStart().
StringInfo copybuf = NULL |
Definition at line 120 of file tablesync.c.
Referenced by CopyStreamReceive(), dumpTableData_copy(), HandleCopyStream(), ReceiveCopyData(), and StreamLogicalLog().
Definition at line 118 of file tablesync.c.
Referenced by invalidate_syncing_table_states(), and process_syncing_tables_for_apply().