|
PostgreSQL Source Code git master
|
#include "postgres.h"#include "access/table.h"#include "access/xact.h"#include "catalog/indexing.h"#include "catalog/pg_subscription_rel.h"#include "catalog/pg_type.h"#include "commands/copy.h"#include "miscadmin.h"#include "nodes/makefuncs.h"#include "parser/parse_relation.h"#include "pgstat.h"#include "replication/logicallauncher.h"#include "replication/logicalrelation.h"#include "replication/logicalworker.h"#include "replication/origin.h"#include "replication/slot.h"#include "replication/walreceiver.h"#include "replication/worker_internal.h"#include "storage/ipc.h"#include "storage/lmgr.h"#include "utils/acl.h"#include "utils/array.h"#include "utils/builtins.h"#include "utils/lsyscache.h"#include "utils/rls.h"#include "utils/snapmgr.h"#include "utils/syscache.h"#include "utils/usercontext.h"
Go to the source code of this file.
Functions | |
| static bool | wait_for_table_state_change (Oid relid, char expected_state) |
| static bool | wait_for_worker_state_change (char expected_state) |
| void | ProcessSyncingTablesForSync (XLogRecPtr current_lsn) |
| void | ProcessSyncingTablesForApply (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, List **qual, bool *gencol_published) |
| static void | copy_table (Relation rel) |
| void | ReplicationSlotNameForTablesync (Oid suboid, Oid relid, char *syncslotname, Size szslot) |
| static char * | LogicalRepSyncTableStart (XLogRecPtr *origin_startpos) |
| static void | start_table_sync (XLogRecPtr *origin_startpos, char **slotname) |
| static void | run_tablesync_worker () |
| void | TableSyncWorkerMain (Datum main_arg) |
| bool | AllTablesyncsReady (void) |
| bool | HasSubscriptionTablesCached (void) |
| void | UpdateTwoPhaseState (Oid suboid, char new_state) |
Variables | |
| List * | table_states_not_ready = NIL |
| static StringInfo | copybuf = NULL |
| bool AllTablesyncsReady | ( | void | ) |
Definition at line 1600 of file tablesync.c.
References CommitTransactionCommand(), FetchRelationStates(), NIL, pgstat_report_stat(), and table_states_not_ready.
Referenced by pa_can_start(), ProcessSyncingTablesForApply(), run_apply_worker(), and wait_for_local_flush().
|
static |
Definition at line 646 of file tablesync.c.
References buf, CHECK_FOR_INTERRUPTS, copybuf, StringInfoData::cursor, StringInfoData::data, fd(), StringInfoData::len, len, LogRepWorkerWalRcvConn, MyLatch, PGINVALID_SOCKET, ResetLatch(), WaitLatchOrSocket(), walrcv_receive, WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, WL_SOCKET_READABLE, and WL_TIMEOUT.
Referenced by copy_table().
|
static |
Definition at line 1043 of file tablesync.c.
References AccessShareLock, addRangeTableEntryForRelation(), appendStringInfo(), appendStringInfoChar(), appendStringInfoString(), Assert(), LogicalRepRelation::attnames, BeginCopyFrom(), Subscription::binary, copy_read_data(), copybuf, CopyFrom(), StringInfoData::data, ereport, WalRcvExecResult::err, errcode(), errmsg(), ERROR, fetch_remote_table_info(), for_each_from, get_namespace_name(), i, initStringInfo(), lfirst, linitial, list_free_deep(), list_make1, LogicalRepRelMapEntry::localrel, logicalrep_rel_close(), logicalrep_rel_open(), logicalrep_relmap_update(), LogRepWorkerWalRcvConn, make_copy_attnamelist(), make_parsestate(), makeDefElem(), makeString(), makeStringInfo(), MySubscription, LogicalRepRelation::natts, NIL, NoLock, LogicalRepRelation::nspname, pfree(), quote_identifier(), quote_qualified_identifier(), RelationGetNamespace, RelationGetRelationName, LogicalRepRelation::relkind, LogicalRepRelation::relname, LogicalRepRelation::remoteid, WalRcvExecResult::status, strVal, walrcv_clear_result(), walrcv_exec, WALRCV_OK_COPY_OUT, and walrcv_server_version.
Referenced by LogicalRepSyncTableStart().
|
static |
Definition at line 725 of file tablesync.c.
References appendStringInfo(), appendStringInfoString(), ARR_DATA_PTR, ARR_DIMS, Assert(), LogicalRepRelation::attkeys, LogicalRepRelation::attnames, attnum, LogicalRepRelation::atttyps, bms_add_member(), bms_is_member(), StringInfoData::data, DatumGetArrayTypeP, DatumGetBool(), DatumGetChar(), DatumGetInt16(), DatumGetObjectId(), destroyStringInfo(), elog, ereport, WalRcvExecResult::err, errcode(), errmsg(), ERROR, ExecClearTuple(), ExecDropSingleTupleTableSlot(), GetPublicationsStr(), initStringInfo(), lappend(), lengthof, list_free_deep(), LogRepWorkerWalRcvConn, MakeSingleTupleTableSlot(), makeString(), makeStringInfo(), MaxTupleAttributeNumber, MySubscription, LogicalRepRelation::natts, NIL, LogicalRepRelation::nspname, palloc0(), pfree(), Subscription::publications, quote_literal_cstr(), LogicalRepRelation::relkind, relname, LogicalRepRelation::relname, LogicalRepRelation::remoteid, LogicalRepRelation::replident, resetStringInfo(), server_version, slot_getattr(), WalRcvExecResult::status, TextDatumGetCString, TTSOpsMinimalTuple, WalRcvExecResult::tupledesc, WalRcvExecResult::tuplestore, tuplestore_gettupleslot(), tuplestore_tuple_count(), walrcv_clear_result(), walrcv_exec, WALRCV_OK_TUPLES, and walrcv_server_version.
Referenced by copy_table().
| bool HasSubscriptionTablesCached | ( | void | ) |
Definition at line 1630 of file tablesync.c.
References CommitTransactionCommand(), FetchRelationStates(), and pgstat_report_stat().
Referenced by wait_for_local_flush().
|
static |
Definition at line 1219 of file tablesync.c.
References ACL_INSERT, aclcheck_error(), ACLCHECK_OK, Assert(), check_enable_rls(), CommandCounterIncrement(), CommitTransactionCommand(), Subscription::conninfo, copy_table(), CRS_USE_SNAPSHOT, DEBUG1, elog, ereport, WalRcvExecResult::err, err(), errcode(), ERRCODE_DUPLICATE_OBJECT, errmsg(), ERROR, Subscription::failover, FinishSyncWorker(), get_relkind_objtype(), GetSubscriptionRelState(), GetTransactionSnapshot(), GetUserId(), GetUserNameFromId(), InvalidOid, InvalidXLogRecPtr, LockRelationOid(), LogRepWorkerWalRcvConn, LSN_FORMAT_ARGS, MyLogicalRepWorker, MySubscription, Subscription::name, NAMEDATALEN, NoLock, Subscription::oid, OidIsValid, Subscription::ownersuperuser, palloc(), Subscription::passwordrequired, pg_class_aclcheck(), pgstat_report_stat(), PopActiveSnapshot(), PushActiveSnapshot(), RelationData::rd_rel, RelationGetRelationName, RelationGetRelid, LogicalRepWorker::relid, LogicalRepWorker::relmutex, LogicalRepWorker::relstate, LogicalRepWorker::relstate_lsn, ReplicationOriginNameForLogicalRep(), ReplicationSlotDropAtPubNode(), ReplicationSlotNameForTablesync(), replorigin_advance(), replorigin_by_name(), replorigin_create(), replorigin_session_get_progress(), replorigin_session_origin, replorigin_session_setup(), RestoreUserContext(), RLS_ENABLED, RowExclusiveLock, Subscription::runasowner, SpinLockAcquire, SpinLockRelease, StartTransactionCommand(), WalRcvExecResult::status, LogicalRepWorker::subid, SwitchToUntrustedUser(), table_close(), table_open(), UnlockRelationOid(), UpdateSubscriptionRelState(), wait_for_worker_state_change(), walrcv_clear_result(), walrcv_connect, walrcv_create_slot, walrcv_exec, and WALRCV_OK_COMMAND.
Referenced by start_table_sync().
|
static |
Definition at line 626 of file tablesync.c.
References LogicalRepRelation::attnames, i, lappend(), makeString(), LogicalRepRelation::natts, NIL, and LogicalRepRelMapEntry::remoterel.
Referenced by copy_table().
| void ProcessSyncingTablesForApply | ( | XLogRecPtr | current_lsn | ) |
Definition at line 368 of file tablesync.c.
References AccessShareLock, AllTablesyncsReady(), ApplyLauncherForgetWorkerStartTime(), Assert(), CommandCounterIncrement(), CommitTransactionCommand(), ctl, ereport, errmsg(), FetchRelationStates(), get_rel_relkind(), HASH_BLOBS, hash_create(), hash_destroy(), HASH_ELEM, HASH_ENTER, hash_search(), IsTransactionState(), last_start_times, launch_sync_worker(), lfirst, LockSharedObject(), LOG, logicalrep_sync_worker_count(), logicalrep_worker_find(), logicalrep_worker_wakeup_ptr(), SubscriptionRelState::lsn, LW_SHARED, LWLockAcquire(), LWLockRelease(), Max, MyLogicalRepWorker, MySubscription, Subscription::name, NAMEDATALEN, NIL, NoLock, Subscription::oid, pgstat_report_stat(), LogicalRepWorker::proc, proc_exit(), SubscriptionRelState::relid, LogicalRepWorker::relmutex, LogicalRepWorker::relstate, LogicalRepWorker::relstate_lsn, ReplicationOriginNameForLogicalRep(), replorigin_drop_by_name(), RowExclusiveLock, SpinLockAcquire, SpinLockRelease, StartTransactionCommand(), SubscriptionRelState::state, LogicalRepWorker::subid, table_close(), table_open(), table_states_not_ready, Subscription::twophasestate, UpdateSubscriptionRelState(), wait_for_table_state_change(), and WORKERTYPE_TABLESYNC.
Referenced by ProcessSyncingRelations().
| void ProcessSyncingTablesForSync | ( | XLogRecPtr | current_lsn | ) |
Definition at line 244 of file tablesync.c.
References CommitTransactionCommand(), FinishSyncWorker(), InvalidRepOriginId, InvalidXLogRecPtr, IsTransactionState(), LogRepWorkerWalRcvConn, MyLogicalRepWorker, NAMEDATALEN, pgstat_report_stat(), LogicalRepWorker::relid, LogicalRepWorker::relmutex, LogicalRepWorker::relstate, LogicalRepWorker::relstate_lsn, ReplicationOriginNameForLogicalRep(), ReplicationSlotDropAtPubNode(), ReplicationSlotNameForTablesync(), replorigin_drop_by_name(), replorigin_session_origin, replorigin_session_origin_lsn, replorigin_session_origin_timestamp, replorigin_session_reset(), SpinLockAcquire, SpinLockRelease, StartTransactionCommand(), LogicalRepWorker::subid, UpdateSubscriptionRelState(), and walrcv_endstreaming.
Referenced by ProcessSyncingRelations().
Definition at line 1203 of file tablesync.c.
References GetSystemIdentifier(), snprintf, and UINT64_FORMAT.
Referenced by AlterSubscription_refresh(), DropSubscription(), LogicalRepSyncTableStart(), ProcessSyncingTablesForSync(), and ReportSlotConnectionError().
|
static |
Definition at line 1554 of file tablesync.c.
References InvalidXLogRecPtr, LogRepWorkerWalRcvConn, MyLogicalRepWorker, MySubscription, NAMEDATALEN, Subscription::oid, options, LogicalRepWorker::relid, ReplicationOriginNameForLogicalRep(), set_apply_error_context_origin(), set_stream_options(), start_apply(), start_table_sync(), and walrcv_startstreaming.
Referenced by TableSyncWorkerMain().
|
static |
Definition at line 1511 of file tablesync.c.
References AbortOutOfAnyTransaction(), am_tablesync_worker(), ApplyContext, Assert(), Subscription::disableonerr, DisableSubscriptionAndExit(), LogicalRepSyncTableStart(), MemoryContextStrdup(), MySubscription, Subscription::oid, pfree(), PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, pgstat_report_subscription_error(), and WORKERTYPE_TABLESYNC.
Referenced by run_tablesync_worker().
| void TableSyncWorkerMain | ( | Datum | main_arg | ) |
Definition at line 1580 of file tablesync.c.
References DatumGetInt32(), FinishSyncWorker(), run_tablesync_worker(), and SetupApplyOrSyncWorker().
| void UpdateTwoPhaseState | ( | Oid | suboid, |
| char | new_state | ||
| ) |
Definition at line 1651 of file tablesync.c.
References Assert(), CatalogTupleUpdate(), CharGetDatum(), elog, ERROR, heap_freetuple(), heap_modify_tuple(), HeapTupleIsValid, ObjectIdGetDatum(), RelationGetDescr, RowExclusiveLock, SearchSysCacheCopy1, HeapTupleData::t_self, table_close(), table_open(), and values.
Referenced by CreateSubscription(), and run_apply_worker().
|
static |
Definition at line 140 of file tablesync.c.
References CHECK_FOR_INTERRUPTS, GetSubscriptionRelState(), InvalidateCatalogSnapshot(), logicalrep_worker_find(), LW_SHARED, LWLockAcquire(), LWLockRelease(), MyLatch, MyLogicalRepWorker, ResetLatch(), LogicalRepWorker::subid, WaitLatch(), WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, WL_TIMEOUT, and WORKERTYPE_TABLESYNC.
Referenced by ProcessSyncingTablesForApply().
|
static |
Definition at line 189 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, WaitLatch(), WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, WL_TIMEOUT, and WORKERTYPE_APPLY.
Referenced by LogicalRepSyncTableStart().
|
static |
Definition at line 127 of file tablesync.c.
Referenced by copy_read_data(), copy_table(), CopyStreamReceive(), dumpTableData_copy(), GetCopyDataByte(), GetCopyDataEnd(), GetCopyDataString(), GetCopyDataUInt64(), HandleCopyStream(), ProcessKeepaliveMsg(), ProcessWALDataMsg(), ReceiveArchiveStreamChunk(), ReceiveBackupManifestChunk(), ReceiveBackupManifestInMemoryChunk(), ReceiveCopyData(), ReceiveTarCopyChunk(), ReportCopyDataParseError(), and StreamLogicalLog().
Definition at line 125 of file tablesync.c.
Referenced by AllTablesyncsReady(), FetchRelationStates(), and ProcessSyncingTablesForApply().