PostgreSQL Source Code git master
|
#include "access/xlogdefs.h"
#include "catalog/pg_subscription.h"
#include "datatype/timestamp.h"
#include "miscadmin.h"
#include "replication/logicalrelation.h"
#include "replication/walreceiver.h"
#include "storage/buffile.h"
#include "storage/fileset.h"
#include "storage/lock.h"
#include "storage/shm_mq.h"
#include "storage/shm_toc.h"
#include "storage/spin.h"
Go to the source code of this file.
Data Structures | |
struct | LogicalRepWorker |
struct | ParallelApplyWorkerShared |
struct | ParallelApplyWorkerInfo |
Macros | |
#define | isParallelApplyWorker(worker) |
#define | isTablesyncWorker(worker) |
Typedefs | |
typedef enum LogicalRepWorkerType | LogicalRepWorkerType |
typedef struct LogicalRepWorker | LogicalRepWorker |
typedef enum ParallelTransState | ParallelTransState |
typedef enum PartialFileSetState | PartialFileSetState |
typedef struct ParallelApplyWorkerShared | ParallelApplyWorkerShared |
typedef struct ParallelApplyWorkerInfo | ParallelApplyWorkerInfo |
Enumerations | |
enum | LogicalRepWorkerType { WORKERTYPE_UNKNOWN = 0 , WORKERTYPE_TABLESYNC , WORKERTYPE_APPLY , WORKERTYPE_PARALLEL_APPLY } |
enum | ParallelTransState { PARALLEL_TRANS_UNKNOWN , PARALLEL_TRANS_STARTED , PARALLEL_TRANS_FINISHED } |
enum | PartialFileSetState { FS_EMPTY , FS_SERIALIZE_IN_PROGRESS , FS_SERIALIZE_DONE , FS_READY } |
#define isParallelApplyWorker | ( | worker | ) |
Definition at line 329 of file worker_internal.h.
#define isTablesyncWorker | ( | worker | ) |
Definition at line 331 of file worker_internal.h.
typedef struct LogicalRepWorker LogicalRepWorker |
typedef enum LogicalRepWorkerType LogicalRepWorkerType |
typedef struct ParallelApplyWorkerInfo ParallelApplyWorkerInfo |
typedef struct ParallelApplyWorkerShared ParallelApplyWorkerShared |
typedef enum ParallelTransState ParallelTransState |
typedef enum PartialFileSetState PartialFileSetState |
enum LogicalRepWorkerType |
Enumerator | |
---|---|
WORKERTYPE_UNKNOWN | |
WORKERTYPE_TABLESYNC | |
WORKERTYPE_APPLY | |
WORKERTYPE_PARALLEL_APPLY |
Definition at line 29 of file worker_internal.h.
enum ParallelTransState |
Enumerator | |
---|---|
PARALLEL_TRANS_UNKNOWN | |
PARALLEL_TRANS_STARTED | |
PARALLEL_TRANS_FINISHED |
Definition at line 103 of file worker_internal.h.
enum PartialFileSetState |
Enumerator | |
---|---|
FS_EMPTY | |
FS_SERIALIZE_IN_PROGRESS | |
FS_SERIALIZE_DONE | |
FS_READY |
Definition at line 126 of file worker_internal.h.
bool AllTablesyncsReady | ( | void | ) |
Definition at line 1739 of file tablesync.c.
References CommitTransactionCommand(), FetchTableStates(), NIL, pgstat_report_stat(), and table_states_not_ready.
Referenced by pa_can_start(), process_syncing_tables_for_apply(), and run_apply_worker().
|
inlinestatic |
Definition at line 341 of file worker_internal.h.
References Assert, LogicalRepWorker::in_use, MyLogicalRepWorker, LogicalRepWorker::type, and WORKERTYPE_APPLY.
Referenced by apply_worker_exit(), DisableSubscriptionAndExit(), InitializeLogRepWorker(), logicalrep_worker_detach(), maybe_reread_subscription(), pa_can_start(), pa_set_fileset_state(), pa_xact_finish(), and SetupApplyOrSyncWorker().
|
inlinestatic |
Definition at line 348 of file worker_internal.h.
References Assert, LogicalRepWorker::in_use, isParallelApplyWorker, and MyLogicalRepWorker.
Referenced by apply_spooled_messages(), apply_worker_exit(), clear_subscription_skip_lsn(), get_transaction_apply_action(), IsLogicalParallelApplyWorker(), maybe_reread_subscription(), pa_decr_and_wait_stream_block(), pa_free_worker(), pa_get_fileset_state(), and store_flush_position().
|
inlinestatic |
Definition at line 335 of file worker_internal.h.
References isTablesyncWorker, and MyLogicalRepWorker.
Referenced by apply_handle_begin_prepare(), apply_handle_origin(), apply_handle_stream_prepare(), DisableSubscriptionAndExit(), InitializeLogRepWorker(), SetupApplyOrSyncWorker(), start_apply(), and start_table_sync().
void apply_dispatch | ( | StringInfo | s | ) |
Definition at line 3364 of file worker.c.
References generate_unaccent_rules::action, apply_error_callback_arg, apply_handle_begin(), apply_handle_begin_prepare(), apply_handle_commit(), apply_handle_commit_prepared(), apply_handle_delete(), apply_handle_insert(), apply_handle_origin(), apply_handle_prepare(), apply_handle_relation(), apply_handle_rollback_prepared(), apply_handle_stream_abort(), apply_handle_stream_commit(), apply_handle_stream_prepare(), apply_handle_stream_start(), apply_handle_stream_stop(), apply_handle_truncate(), apply_handle_type(), apply_handle_update(), ApplyErrorCallbackArg::command, ereport, errcode(), errmsg(), ERROR, LOGICAL_REP_MSG_BEGIN, LOGICAL_REP_MSG_BEGIN_PREPARE, LOGICAL_REP_MSG_COMMIT, LOGICAL_REP_MSG_COMMIT_PREPARED, LOGICAL_REP_MSG_DELETE, LOGICAL_REP_MSG_INSERT, LOGICAL_REP_MSG_MESSAGE, LOGICAL_REP_MSG_ORIGIN, LOGICAL_REP_MSG_PREPARE, LOGICAL_REP_MSG_RELATION, LOGICAL_REP_MSG_ROLLBACK_PREPARED, LOGICAL_REP_MSG_STREAM_ABORT, LOGICAL_REP_MSG_STREAM_COMMIT, LOGICAL_REP_MSG_STREAM_PREPARE, LOGICAL_REP_MSG_STREAM_START, LOGICAL_REP_MSG_STREAM_STOP, LOGICAL_REP_MSG_TRUNCATE, LOGICAL_REP_MSG_TYPE, LOGICAL_REP_MSG_UPDATE, and pq_getmsgbyte().
Referenced by apply_spooled_messages(), LogicalParallelApplyLoop(), and LogicalRepApplyLoop().
void apply_error_callback | ( | void * | arg | ) |
Definition at line 4995 of file worker.c.
References apply_error_callback_arg, Assert, LogicalRepRelation::attnames, ApplyErrorCallbackArg::command, errcontext, ERROR, ApplyErrorCallbackArg::finish_lsn, geterrlevel(), logicalrep_message_type(), LSN_FORMAT_ARGS, LogicalRepRelation::nspname, ApplyErrorCallbackArg::origin_name, ApplyErrorCallbackArg::rel, LogicalRepRelation::relname, ApplyErrorCallbackArg::remote_attnum, ApplyErrorCallbackArg::remote_xid, LogicalRepRelMapEntry::remoterel, replorigin_reset(), TransactionIdIsValid, and XLogRecPtrIsInvalid.
Referenced by LogicalParallelApplyLoop(), and LogicalRepApplyLoop().
void apply_spooled_messages | ( | FileSet * | stream_fileset, |
TransactionId | xid, | ||
XLogRecPtr | lsn | ||
) |
Definition at line 2022 of file worker.c.
References am_parallel_apply_worker(), apply_dispatch(), ApplyMessageContext, begin_replication_step(), BufFileOpenFileSet(), BufFileReadExact(), BufFileReadMaybeEOF(), BufFileTell(), changes_filename(), CHECK_FOR_INTERRUPTS, CurrentResourceOwner, DEBUG1, elog, end_replication_step(), ensure_last_message(), ERROR, in_remote_transaction, initReadOnlyStringInfo(), len, MAXPGPATH, maybe_start_skipping_changes(), MemoryContextReset(), MemoryContextSwitchTo(), MyLogicalRepWorker, palloc(), pgstat_report_activity(), remote_final_lsn, repalloc(), s2, STATE_RUNNING, stream_close_file(), stream_fd, LogicalRepWorker::subid, TopTransactionContext, and TopTransactionResourceOwner.
Referenced by apply_handle_stream_commit(), apply_handle_stream_prepare(), and pa_process_spooled_messages_if_required().
void DisableSubscriptionAndExit | ( | void | ) |
Definition at line 4807 of file worker.c.
References AbortOutOfAnyTransaction(), am_leader_apply_worker(), am_tablesync_worker(), ApplyLauncherForgetWorkerStartTime(), CommitTransactionCommand(), DisableSubscription(), EmitErrorReport(), ereport, errmsg(), FlushErrorState(), HOLD_INTERRUPTS, LOG, MyLogicalRepWorker, MySubscription, Subscription::name, Subscription::oid, pgstat_report_subscription_error(), proc_exit(), RESUME_INTERRUPTS, StartTransactionCommand(), and LogicalRepWorker::subid.
Referenced by start_apply(), and start_table_sync().
void InitializeLogRepWorker | ( | void | ) |
Definition at line 4639 of file worker.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, am_leader_apply_worker(), am_tablesync_worker(), apply_worker_exit(), ApplyContext, ApplyLauncherForgetWorkerStartTime(), BackgroundWorkerInitializeConnectionByOid(), CacheRegisterSyscacheCallback(), CommitTransactionCommand(), LogicalRepWorker::dbid, Subscription::enabled, ereport, errmsg(), get_rel_name(), GetSubscription(), LOG, MemoryContextSwitchTo(), MyLogicalRepWorker, MySubscription, MySubscriptionValid, Subscription::name, PGC_BACKEND, PGC_S_OVERRIDE, PGC_SUSET, proc_exit(), LogicalRepWorker::relid, SetConfigOption(), StartTransactionCommand(), LogicalRepWorker::subid, subscription_change_cb(), Subscription::synccommit, TopMemoryContext, and LogicalRepWorker::userid.
Referenced by ParallelApplyWorkerMain(), and SetupApplyOrSyncWorker().
Definition at line 281 of file tablesync.c.
References SYNC_TABLE_STATE_NEEDS_REBUILD, and table_states_validity.
Referenced by ParallelApplyWorkerMain(), and SetupApplyOrSyncWorker().
void logicalrep_pa_worker_stop | ( | ParallelApplyWorkerInfo * | winfo | ) |
Definition at line 630 of file launcher.c.
References Assert, ParallelApplyWorkerInfo::error_mq_handle, LogicalRepWorker::generation, isParallelApplyWorker, ParallelApplyWorkerShared::logicalrep_worker_generation, ParallelApplyWorkerShared::logicalrep_worker_slot_no, logicalrep_worker_stop_internal(), LogicalRepCtx, LW_SHARED, LWLockAcquire(), LWLockRelease(), max_logical_replication_workers, ParallelApplyWorkerShared::mutex, LogicalRepWorker::proc, ParallelApplyWorkerInfo::shared, shm_mq_detach(), SpinLockAcquire, SpinLockRelease, and LogicalRepCtxStruct::workers.
Referenced by pa_free_worker().
int logicalrep_sync_worker_count | ( | Oid | subid | ) |
Definition at line 845 of file launcher.c.
References Assert, i, isTablesyncWorker, LogicalRepCtx, LWLockHeldByMe(), max_logical_replication_workers, res, LogicalRepWorker::subid, and LogicalRepCtxStruct::workers.
Referenced by logicalrep_worker_launch(), and process_syncing_tables_for_apply().
void logicalrep_worker_attach | ( | int | slot | ) |
Definition at line 704 of file launcher.c.
References Assert, before_shmem_exit(), ereport, errcode(), errmsg(), ERROR, LogicalRepWorker::in_use, logicalrep_worker_onexit(), LogicalRepCtx, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), max_logical_replication_workers, MyLogicalRepWorker, MyProc, LogicalRepWorker::proc, and LogicalRepCtxStruct::workers.
Referenced by ParallelApplyWorkerMain(), and SetupApplyOrSyncWorker().
LogicalRepWorker * logicalrep_worker_find | ( | Oid | subid, |
Oid | relid, | ||
bool | only_running | ||
) |
Definition at line 234 of file launcher.c.
References Assert, i, LogicalRepWorker::in_use, isParallelApplyWorker, LogicalRepCtx, LWLockHeldByMe(), max_logical_replication_workers, LogicalRepWorker::proc, LogicalRepWorker::relid, res, LogicalRepWorker::subid, and LogicalRepCtxStruct::workers.
Referenced by ApplyLauncherMain(), logicalrep_worker_stop(), logicalrep_worker_wakeup(), process_syncing_tables_for_apply(), wait_for_relation_state_change(), and wait_for_worker_state_change().
bool logicalrep_worker_launch | ( | LogicalRepWorkerType | wtype, |
Oid | dbid, | ||
Oid | subid, | ||
const char * | subname, | ||
Oid | userid, | ||
Oid | relid, | ||
dsm_handle | subworker_dsm | ||
) |
Definition at line 297 of file launcher.c.
References Assert, BackgroundWorker::bgw_extra, BackgroundWorker::bgw_flags, BackgroundWorker::bgw_function_name, BackgroundWorker::bgw_library_name, BackgroundWorker::bgw_main_arg, BGW_MAXLEN, BackgroundWorker::bgw_name, BGW_NEVER_RESTART, BackgroundWorker::bgw_notify_pid, BackgroundWorker::bgw_restart_time, BackgroundWorker::bgw_start_time, BackgroundWorker::bgw_type, BGWORKER_BACKEND_DATABASE_CONNECTION, BGWORKER_SHMEM_ACCESS, BgWorkerStart_RecoveryFinished, LogicalRepWorker::dbid, DEBUG1, DSM_HANDLE_INVALID, elog, ereport, errcode(), errhint(), errmsg(), errmsg_internal(), ERROR, LogicalRepWorker::generation, GetCurrentTimestamp(), i, LogicalRepWorker::in_use, Int32GetDatum(), InvalidPid, InvalidXLogRecPtr, LogicalRepWorker::last_lsn, LogicalRepWorker::last_recv_time, LogicalRepWorker::last_send_time, LogicalRepWorker::launch_time, LogicalRepWorker::leader_pid, logicalrep_pa_worker_count(), logicalrep_sync_worker_count(), logicalrep_worker_cleanup(), LogicalRepCtx, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), max_logical_replication_workers, max_parallel_apply_workers_per_subscription, max_replication_slots, max_sync_workers_per_subscription, MAXPGPATH, MyProcPid, now(), OidIsValid, LogicalRepWorker::parallel_apply, LogicalRepWorker::proc, RegisterDynamicBackgroundWorker(), LogicalRepWorker::relid, LogicalRepWorker::relstate, LogicalRepWorker::relstate_lsn, LogicalRepWorker::reply_lsn, LogicalRepWorker::reply_time, snprintf, LogicalRepWorker::stream_fileset, LogicalRepWorker::subid, subname, TIMESTAMP_NOBEGIN, TimestampDifferenceExceeds(), LogicalRepWorker::type, LogicalRepWorker::userid, WaitForReplicationWorkerAttach(), wal_receiver_timeout, WARNING, LogicalRepCtxStruct::workers, WORKERTYPE_APPLY, WORKERTYPE_PARALLEL_APPLY, WORKERTYPE_TABLESYNC, and WORKERTYPE_UNKNOWN.
Referenced by ApplyLauncherMain(), pa_launch_parallel_worker(), and process_syncing_tables_for_apply().
Definition at line 606 of file launcher.c.
References Assert, isParallelApplyWorker, logicalrep_worker_find(), logicalrep_worker_stop_internal(), LW_SHARED, LWLockAcquire(), and LWLockRelease().
Referenced by AlterSubscription_refresh(), and DropSubscription().
Definition at line 673 of file launcher.c.
References logicalrep_worker_find(), logicalrep_worker_wakeup_ptr(), LW_SHARED, LWLockAcquire(), and LWLockRelease().
Referenced by apply_handle_stream_start(), and pg_attribute_noreturn().
void logicalrep_worker_wakeup_ptr | ( | LogicalRepWorker * | worker | ) |
Definition at line 693 of file launcher.c.
References Assert, LWLockHeldByMe(), LogicalRepWorker::proc, PGPROC::procLatch, and SetLatch().
Referenced by AtEOXact_LogicalRepWorkers(), logicalrep_worker_wakeup(), process_syncing_tables_for_apply(), and wait_for_worker_state_change().
Definition at line 266 of file launcher.c.
References Assert, i, LogicalRepWorker::in_use, lappend(), LogicalRepCtx, LW_SHARED, LWLockAcquire(), LWLockHeldByMe(), LWLockRelease(), max_logical_replication_workers, NIL, LogicalRepWorker::proc, res, LogicalRepWorker::subid, and LogicalRepCtxStruct::workers.
Referenced by AlterSubscription(), AtEOXact_LogicalRepWorkers(), DropSubscription(), and logicalrep_worker_detach().
void maybe_reread_subscription | ( | void | ) |
Definition at line 3957 of file worker.c.
References am_leader_apply_worker(), am_parallel_apply_worker(), apply_worker_exit(), ApplyContext, ApplyLauncherForgetWorkerStartTime(), Assert, Subscription::binary, CommitTransactionCommand(), Subscription::conninfo, Subscription::dbid, elog, equal(), ereport, errmsg(), ERROR, FreeSubscription(), GetSubscription(), IsTransactionState(), LOG, MemoryContextSwitchTo(), MyLogicalRepWorker, MySubscription, MySubscriptionValid, Subscription::name, newsub(), Subscription::origin, Subscription::owner, Subscription::ownersuperuser, Subscription::passwordrequired, PGC_BACKEND, PGC_S_OVERRIDE, proc_exit(), Subscription::publications, SetConfigOption(), Subscription::slotname, StartTransactionCommand(), Subscription::stream, LogicalRepWorker::subid, Subscription::synccommit, and Subscription::twophasestate.
Referenced by apply_handle_commit_internal(), begin_replication_step(), LogicalRepApplyLoop(), and pa_can_start().
void pa_allocate_worker | ( | TransactionId | xid | ) |
Definition at line 470 of file applyparallelworker.c.
References ApplyContext, ctl, elog, ERROR, HASH_BLOBS, HASH_CONTEXT, hash_create(), HASH_ELEM, HASH_ENTER, hash_search(), ParallelApplyWorkerInfo::in_use, MemSet, ParallelApplyWorkerShared::mutex, pa_can_start(), pa_launch_parallel_worker(), PARALLEL_TRANS_UNKNOWN, ParallelApplyTxnHash, ParallelApplyWorkerInfo::serialize_changes, ParallelApplyWorkerInfo::shared, SpinLockAcquire, SpinLockRelease, ParallelApplyWorkerEntry::winfo, ParallelApplyWorkerShared::xact_state, and ParallelApplyWorkerShared::xid.
Referenced by apply_handle_stream_start().
void pa_decr_and_wait_stream_block | ( | void | ) |
Definition at line 1591 of file applyparallelworker.c.
References AccessShareLock, am_parallel_apply_worker(), Assert, elog, ERROR, MyParallelShared, pa_has_spooled_message_pending(), pa_lock_stream(), pa_unlock_stream(), ParallelApplyWorkerShared::pending_stream_count, pg_atomic_read_u32(), pg_atomic_sub_fetch_u32(), and ParallelApplyWorkerShared::xid.
Referenced by apply_handle_stream_abort(), and apply_handle_stream_stop().
void pa_detach_all_error_mq | ( | void | ) |
Definition at line 622 of file applyparallelworker.c.
References ParallelApplyWorkerInfo::error_mq_handle, lfirst, ParallelApplyWorkerPool, and shm_mq_detach().
Referenced by logicalrep_worker_detach().
ParallelApplyWorkerInfo * pa_find_worker | ( | TransactionId | xid | ) |
Definition at line 518 of file applyparallelworker.c.
References Assert, HASH_FIND, hash_search(), ParallelApplyWorkerInfo::in_use, ParallelApplyTxnHash, stream_apply_worker, TransactionIdIsValid, and ParallelApplyWorkerEntry::winfo.
Referenced by get_transaction_apply_action().
void pa_lock_stream | ( | TransactionId | xid, |
LOCKMODE | lockmode | ||
) |
Definition at line 1540 of file applyparallelworker.c.
References LockApplyTransactionForSession(), MyLogicalRepWorker, PARALLEL_APPLY_LOCK_STREAM, and LogicalRepWorker::subid.
Referenced by apply_handle_stream_abort(), apply_handle_stream_stop(), pa_decr_and_wait_stream_block(), pa_process_spooled_messages_if_required(), and pa_switch_to_partial_serialize().
void pa_lock_transaction | ( | TransactionId | xid, |
LOCKMODE | lockmode | ||
) |
Definition at line 1573 of file applyparallelworker.c.
References LockApplyTransactionForSession(), MyLogicalRepWorker, PARALLEL_APPLY_LOCK_XACT, and LogicalRepWorker::subid.
Referenced by apply_handle_stream_start(), and pa_wait_for_xact_finish().
void pa_reset_subtrans | ( | void | ) |
Definition at line 1402 of file applyparallelworker.c.
References NIL, and subxactlist.
Referenced by apply_handle_stream_commit(), apply_handle_stream_prepare(), and pa_stream_abort().
bool pa_send_data | ( | ParallelApplyWorkerInfo * | winfo, |
Size | nbytes, | ||
const void * | data | ||
) |
Definition at line 1146 of file applyparallelworker.c.
References Assert, CHECK_FOR_INTERRUPTS, data, DEBUG_LOGICAL_REP_STREAMING_IMMEDIATE, debug_logical_replication_streaming, ereport, errcode(), errmsg(), ERROR, GetCurrentTimestamp(), IsTransactionState(), ParallelApplyWorkerInfo::mq_handle, MyLatch, ResetLatch(), ParallelApplyWorkerInfo::serialize_changes, SHM_MQ_DETACHED, shm_mq_send(), SHM_MQ_SUCCESS, SHM_MQ_WOULD_BLOCK, SHM_SEND_RETRY_INTERVAL_MS, SHM_SEND_TIMEOUT_MS, TimestampDifferenceExceeds(), unlikely, WaitLatch(), WL_EXIT_ON_PM_DEATH, WL_LATCH_SET, and WL_TIMEOUT.
Referenced by apply_handle_stream_abort(), apply_handle_stream_commit(), apply_handle_stream_prepare(), apply_handle_stream_start(), apply_handle_stream_stop(), and handle_streamed_transaction().
void pa_set_fileset_state | ( | ParallelApplyWorkerShared * | wshared, |
PartialFileSetState | fileset_state | ||
) |
Definition at line 1498 of file applyparallelworker.c.
References am_leader_apply_worker(), Assert, ParallelApplyWorkerShared::fileset, ParallelApplyWorkerShared::fileset_state, FS_SERIALIZE_DONE, ParallelApplyWorkerShared::mutex, MyLogicalRepWorker, SpinLockAcquire, SpinLockRelease, and LogicalRepWorker::stream_fileset.
Referenced by apply_handle_stream_abort(), apply_handle_stream_commit(), apply_handle_stream_prepare(), pa_process_spooled_messages_if_required(), and pa_switch_to_partial_serialize().
void pa_set_stream_apply_worker | ( | ParallelApplyWorkerInfo * | winfo | ) |
Definition at line 1334 of file applyparallelworker.c.
References stream_apply_worker.
Referenced by apply_handle_stream_start(), and apply_handle_stream_stop().
void pa_set_xact_state | ( | ParallelApplyWorkerShared * | wshared, |
ParallelTransState | xact_state | ||
) |
Definition at line 1307 of file applyparallelworker.c.
References ParallelApplyWorkerShared::mutex, SpinLockAcquire, SpinLockRelease, and ParallelApplyWorkerShared::xact_state.
Referenced by apply_handle_stream_commit(), apply_handle_stream_prepare(), apply_handle_stream_start(), and pa_stream_abort().
void pa_start_subtrans | ( | TransactionId | current_xid, |
TransactionId | top_xid | ||
) |
Definition at line 1362 of file applyparallelworker.c.
References BeginTransactionBlock(), CommitTransactionCommand(), DEBUG1, DefineSavepoint(), elog, IsTransactionBlock(), IsTransactionState(), lappend_xid(), list_member_xid(), MemoryContextSwitchTo(), MySubscription, NAMEDATALEN, Subscription::oid, pa_savepoint_name(), StartTransactionCommand(), subxactlist, and TopTransactionContext.
Referenced by handle_streamed_transaction().
void pa_stream_abort | ( | LogicalRepStreamAbortData * | abort_data | ) |
Definition at line 1416 of file applyparallelworker.c.
References LogicalRepStreamAbortData::abort_lsn, LogicalRepStreamAbortData::abort_time, AbortCurrentTransaction(), AccessExclusiveLock, CommitTransactionCommand(), DEBUG1, elog, EndTransactionBlock(), i, IsTransactionBlock(), lfirst_xid, list_length(), list_nth_cell(), list_truncate(), MyParallelShared, MySubscription, NAMEDATALEN, Subscription::oid, pa_reset_subtrans(), pa_savepoint_name(), pa_set_xact_state(), pa_unlock_transaction(), PARALLEL_TRANS_FINISHED, pgstat_report_activity(), replorigin_session_origin_lsn, replorigin_session_origin_timestamp, RollbackToSavepoint(), STATE_IDLE, subxactlist, LogicalRepStreamAbortData::subxid, and LogicalRepStreamAbortData::xid.
Referenced by apply_handle_stream_abort().
void pa_switch_to_partial_serialize | ( | ParallelApplyWorkerInfo * | winfo, |
bool | stream_locked | ||
) |
Definition at line 1211 of file applyparallelworker.c.
References AccessExclusiveLock, ereport, errmsg(), FS_SERIALIZE_IN_PROGRESS, LOG, pa_lock_stream(), pa_set_fileset_state(), ParallelApplyWorkerInfo::serialize_changes, ParallelApplyWorkerInfo::shared, stream_start_internal(), and ParallelApplyWorkerShared::xid.
Referenced by apply_handle_stream_abort(), apply_handle_stream_commit(), apply_handle_stream_prepare(), apply_handle_stream_start(), apply_handle_stream_stop(), and handle_streamed_transaction().
void pa_unlock_stream | ( | TransactionId | xid, |
LOCKMODE | lockmode | ||
) |
Definition at line 1547 of file applyparallelworker.c.
References MyLogicalRepWorker, PARALLEL_APPLY_LOCK_STREAM, LogicalRepWorker::subid, and UnlockApplyTransactionForSession().
Referenced by apply_handle_stream_abort(), apply_handle_stream_start(), pa_decr_and_wait_stream_block(), pa_process_spooled_messages_if_required(), and pa_xact_finish().
void pa_unlock_transaction | ( | TransactionId | xid, |
LOCKMODE | lockmode | ||
) |
Definition at line 1580 of file applyparallelworker.c.
References MyLogicalRepWorker, PARALLEL_APPLY_LOCK_XACT, LogicalRepWorker::subid, and UnlockApplyTransactionForSession().
Referenced by apply_handle_stream_commit(), apply_handle_stream_prepare(), pa_stream_abort(), and pa_wait_for_xact_finish().
void pa_xact_finish | ( | ParallelApplyWorkerInfo * | winfo, |
XLogRecPtr | remote_lsn | ||
) |
Definition at line 1618 of file applyparallelworker.c.
References AccessExclusiveLock, am_leader_apply_worker(), Assert, ParallelApplyWorkerShared::last_commit_end, pa_free_worker(), pa_unlock_stream(), pa_wait_for_xact_finish(), ParallelApplyWorkerInfo::shared, store_flush_position(), ParallelApplyWorkerShared::xid, and XLogRecPtrIsInvalid.
Referenced by apply_handle_stream_abort(), apply_handle_stream_commit(), and apply_handle_stream_prepare().
void process_syncing_tables | ( | XLogRecPtr | current_lsn | ) |
Definition at line 667 of file tablesync.c.
References elog, ERROR, MyLogicalRepWorker, process_syncing_tables_for_apply(), process_syncing_tables_for_sync(), LogicalRepWorker::type, WORKERTYPE_APPLY, WORKERTYPE_PARALLEL_APPLY, WORKERTYPE_TABLESYNC, and WORKERTYPE_UNKNOWN.
Referenced by apply_handle_commit(), apply_handle_commit_prepared(), apply_handle_prepare(), apply_handle_rollback_prepared(), apply_handle_stream_commit(), apply_handle_stream_prepare(), and LogicalRepApplyLoop().
void ReplicationOriginNameForLogicalRep | ( | Oid | suboid, |
Oid | relid, | ||
char * | originname, | ||
Size | szoriginname | ||
) |
Definition at line 426 of file worker.c.
References OidIsValid, and snprintf.
Referenced by AlterSubscription(), AlterSubscription_refresh(), binary_upgrade_replorigin_advance(), CreateSubscription(), DropSubscription(), LogicalRepSyncTableStart(), ParallelApplyWorkerMain(), process_syncing_tables_for_apply(), process_syncing_tables_for_sync(), run_apply_worker(), and run_tablesync_worker().
void set_apply_error_context_origin | ( | char * | originname | ) |
Definition at line 5148 of file worker.c.
References apply_error_callback_arg, ApplyContext, MemoryContextStrdup(), and ApplyErrorCallbackArg::origin_name.
Referenced by ParallelApplyWorkerMain(), run_apply_worker(), and run_tablesync_worker().
void set_stream_options | ( | WalRcvStreamOptions * | options, |
char * | slotname, | ||
XLogRecPtr * | origin_startpos | ||
) |
Definition at line 4433 of file worker.c.
References Subscription::binary, LOGICALREP_PROTO_STREAM_PARALLEL_VERSION_NUM, LOGICALREP_PROTO_STREAM_VERSION_NUM, LOGICALREP_PROTO_TWOPHASE_VERSION_NUM, LOGICALREP_PROTO_VERSION_NUM, LogRepWorkerWalRcvConn, MyLogicalRepWorker, MySubscription, Subscription::origin, LogicalRepWorker::parallel_apply, pstrdup(), Subscription::publications, server_version, Subscription::stream, and walrcv_server_version.
Referenced by run_apply_worker(), and run_tablesync_worker().
void SetupApplyOrSyncWorker | ( | int | worker_slot | ) |
Definition at line 4733 of file worker.c.
References am_leader_apply_worker(), am_tablesync_worker(), Assert, BackgroundWorkerUnblockSignals(), before_shmem_exit(), CacheRegisterSyscacheCallback(), Subscription::conninfo, DEBUG1, die, elog, GetCurrentTimestamp(), InitializeLogRepWorker(), invalidate_syncing_table_states(), LogicalRepWorker::last_recv_time, LogicalRepWorker::last_send_time, load_file(), logicalrep_worker_attach(), MyLogicalRepWorker, MySubscription, pqsignal(), replorigin_reset(), LogicalRepWorker::reply_time, SIGHUP, and SignalHandlerForConfigReload().
Referenced by ApplyWorkerMain(), and TablesyncWorkerMain().
void start_apply | ( | XLogRecPtr | origin_startpos | ) |
Definition at line 4502 of file worker.c.
References AbortOutOfAnyTransaction(), am_tablesync_worker(), Subscription::disableonerr, DisableSubscriptionAndExit(), LogicalRepApplyLoop(), MySubscription, Subscription::oid, PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, and pgstat_report_subscription_error().
Referenced by run_apply_worker(), and run_tablesync_worker().
void store_flush_position | ( | XLogRecPtr | remote_lsn, |
XLogRecPtr | local_lsn | ||
) |
Definition at line 3528 of file worker.c.
References am_parallel_apply_worker(), ApplyContext, ApplyMessageContext, dlist_push_tail(), FlushPosition::local_end, lsn_mapping, MemoryContextSwitchTo(), FlushPosition::node, palloc(), and FlushPosition::remote_end.
Referenced by apply_handle_commit_internal(), apply_handle_commit_prepared(), apply_handle_prepare(), apply_handle_rollback_prepared(), apply_handle_stream_prepare(), and pa_xact_finish().
void stream_cleanup_files | ( | Oid | subid, |
TransactionId | xid | ||
) |
Definition at line 4300 of file worker.c.
References BufFileDeleteFileSet(), changes_filename(), MAXPGPATH, MyLogicalRepWorker, LogicalRepWorker::stream_fileset, and subxact_filename().
Referenced by apply_handle_stream_commit(), apply_handle_stream_prepare(), pa_free_worker_info(), and stream_abort_internal().
void stream_start_internal | ( | TransactionId | xid, |
bool | first_segment | ||
) |
Definition at line 1450 of file worker.c.
References ApplyContext, begin_replication_step(), end_replication_step(), FileSetInit(), MemoryContextSwitchTo(), MyLogicalRepWorker, palloc(), LogicalRepWorker::stream_fileset, stream_open_file(), LogicalRepWorker::subid, and subxact_info_read().
Referenced by apply_handle_stream_start(), pa_switch_to_partial_serialize(), and stream_open_and_write_change().
void stream_stop_internal | ( | TransactionId | xid | ) |
Definition at line 1624 of file worker.c.
References Assert, CommitTransactionCommand(), IsTransactionState(), LogicalStreamingContext, MemoryContextReset(), MyLogicalRepWorker, stream_close_file(), LogicalRepWorker::subid, and subxact_info_write().
Referenced by apply_handle_stream_stop(), and stream_open_and_write_change().
void UpdateTwoPhaseState | ( | Oid | suboid, |
char | new_state | ||
) |
Definition at line 1764 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().
|
extern |
Definition at line 289 of file worker.c.
Referenced by HandleParallelApplyMessage(), and LogicalRepApplyLoop().
|
extern |
Definition at line 292 of file worker.c.
Referenced by InitializeLogRepWorker(), LogicalParallelApplyLoop(), LogicalRepApplyLoop(), maybe_reread_subscription(), pa_allocate_worker(), pa_launch_parallel_worker(), send_feedback(), set_apply_error_context_origin(), start_table_sync(), store_flush_position(), and stream_start_internal().
|
extern |
Definition at line 291 of file worker.c.
Referenced by apply_spooled_messages(), begin_replication_step(), LogicalParallelApplyLoop(), LogicalRepApplyLoop(), and store_flush_position().
|
extern |
Definition at line 304 of file worker.c.
Referenced by apply_handle_begin(), apply_handle_begin_prepare(), apply_handle_commit_internal(), apply_handle_commit_prepared(), apply_handle_origin(), apply_handle_prepare(), apply_handle_rollback_prepared(), apply_handle_stream_prepare(), apply_spooled_messages(), LogicalRepApplyLoop(), and maybe_start_skipping_changes().
|
extern |
Definition at line 319 of file worker.c.
Referenced by ApplyWorkerMain(), logicalrep_worker_onexit(), and ParallelApplyWorkerMain().
|
extern |
Definition at line 297 of file worker.c.
Referenced by copy_read_data(), copy_table(), fetch_remote_table_info(), logicalrep_worker_onexit(), LogicalRepApplyLoop(), LogicalRepSyncTableStart(), process_syncing_tables_for_sync(), run_apply_worker(), run_tablesync_worker(), send_feedback(), and set_stream_options().
|
extern |
Definition at line 54 of file launcher.c.
Referenced by am_leader_apply_worker(), am_parallel_apply_worker(), am_tablesync_worker(), apply_handle_stream_abort(), apply_handle_stream_commit(), apply_handle_stream_prepare(), apply_handle_stream_start(), apply_spooled_messages(), apply_worker_exit(), DisableSubscriptionAndExit(), ensure_last_message(), InitializeLogRepWorker(), IsLogicalWorker(), logicalrep_worker_attach(), logicalrep_worker_detach(), logicalrep_worker_onexit(), LogicalRepSyncTableStart(), maybe_reread_subscription(), pa_can_start(), pa_free_worker_info(), pa_launch_parallel_worker(), pa_lock_stream(), pa_lock_transaction(), pa_set_fileset_state(), pa_shutdown(), pa_unlock_stream(), pa_unlock_transaction(), ParallelApplyWorkerMain(), pg_attribute_noreturn(), process_syncing_tables(), process_syncing_tables_for_apply(), process_syncing_tables_for_sync(), run_tablesync_worker(), set_stream_options(), SetupApplyOrSyncWorker(), should_apply_changes_for_rel(), stream_abort_internal(), stream_cleanup_files(), stream_open_file(), stream_start_internal(), stream_stop_internal(), subxact_info_read(), subxact_info_write(), UpdateWorkerStats(), wait_for_relation_state_change(), and wait_for_worker_state_change().
|
extern |
Definition at line 239 of file applyparallelworker.c.
Referenced by apply_handle_stream_commit(), apply_handle_stream_prepare(), apply_handle_stream_start(), pa_decr_and_wait_stream_block(), pa_get_fileset_state(), pa_process_spooled_messages_if_required(), pa_stream_abort(), and ParallelApplyWorkerMain().
|
extern |
Definition at line 299 of file worker.c.
Referenced by apply_handle_commit_prepared(), apply_handle_delete(), apply_handle_insert(), apply_handle_prepare_internal(), apply_handle_rollback_prepared(), apply_handle_truncate(), apply_handle_update(), clear_subscription_skip_lsn(), copy_table(), DisableSubscriptionAndExit(), fetch_remote_table_info(), FetchTableStates(), InitializeLogRepWorker(), logicalrep_rel_open(), LogicalRepSyncTableStart(), maybe_reread_subscription(), maybe_start_skipping_changes(), pa_can_start(), pa_launch_parallel_worker(), pa_start_subtrans(), pa_stream_abort(), ParallelApplyWorkerMain(), pg_attribute_noreturn(), process_syncing_tables_for_apply(), ProcessParallelApplyInterrupts(), ReportApplyConflict(), run_apply_worker(), run_tablesync_worker(), set_stream_options(), SetupApplyOrSyncWorker(), should_apply_changes_for_rel(), start_apply(), and start_table_sync().