|
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) |
| #define | isSequenceSyncWorker(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_SEQUENCESYNC , 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 362 of file worker_internal.h.
| #define isSequenceSyncWorker | ( | worker | ) |
Definition at line 366 of file worker_internal.h.
| #define isTableSyncWorker | ( | worker | ) |
Definition at line 364 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_SEQUENCESYNC | |
| 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 120 of file worker_internal.h.
| enum PartialFileSetState |
| Enumerator | |
|---|---|
| FS_EMPTY | |
| FS_SERIALIZE_IN_PROGRESS | |
| FS_SERIALIZE_DONE | |
| FS_READY | |
Definition at line 143 of file worker_internal.h.
| 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().
|
inlinestatic |
Definition at line 382 of file worker_internal.h.
References Assert(), LogicalRepWorker::in_use, MyLogicalRepWorker, LogicalRepWorker::type, and WORKERTYPE_APPLY.
Referenced by apply_worker_exit(), can_advance_nonremovable_xid(), DisableSubscriptionAndExit(), FindDeletedTupleInLocalRel(), InitializeLogRepWorker(), logicalrep_worker_detach(), maybe_reread_subscription(), pa_can_start(), pa_set_fileset_state(), pa_xact_finish(), and SetupApplyOrSyncWorker().
|
inlinestatic |
Definition at line 389 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 376 of file worker_internal.h.
References isSequenceSyncWorker, and MyLogicalRepWorker.
Referenced by FinishSyncWorker(), InitializeLogRepWorker(), SetupApplyOrSyncWorker(), and start_sequence_sync().
|
inlinestatic |
Definition at line 370 of file worker_internal.h.
References isTableSyncWorker, and MyLogicalRepWorker.
Referenced by apply_handle_begin_prepare(), apply_handle_origin(), apply_handle_stream_prepare(), FinishSyncWorker(), InitializeLogRepWorker(), SetupApplyOrSyncWorker(), and start_table_sync().
| void apply_dispatch | ( | StringInfo | s | ) |
Definition at line 3775 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 6159 of file worker.c.
References apply_error_callback_arg, Assert(), LogicalRepRelation::attnames, ApplyErrorCallbackArg::command, errcontext, ApplyErrorCallbackArg::finish_lsn, logicalrep_message_type(), LSN_FORMAT_ARGS, LogicalRepRelation::nspname, ApplyErrorCallbackArg::origin_name, ApplyErrorCallbackArg::rel, LogicalRepRelation::relname, ApplyErrorCallbackArg::remote_attnum, ApplyErrorCallbackArg::remote_xid, LogicalRepRelMapEntry::remoterel, TransactionIdIsValid, and XLogRecPtrIsValid.
Referenced by LogicalParallelApplyLoop(), and LogicalRepApplyLoop().
| void apply_spooled_messages | ( | FileSet * | stream_fileset, |
| TransactionId | xid, | ||
| XLogRecPtr | lsn | ||
| ) |
Definition at line 2260 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 5943 of file worker.c.
References AbortOutOfAnyTransaction(), am_leader_apply_worker(), ApplyLauncherForgetWorkerStartTime(), CheckSubDeadTupleRetention(), CommitTransactionCommand(), DisableSubscription(), EmitErrorReport(), ereport, errmsg(), FlushErrorState(), GetTransactionSnapshot(), HOLD_INTERRUPTS, LOG, MyLogicalRepWorker, MySubscription, Subscription::name, Subscription::oid, pgstat_report_subscription_error(), PopActiveSnapshot(), proc_exit(), PushActiveSnapshot(), RESUME_INTERRUPTS, Subscription::retaindeadtuples, Subscription::retentionactive, StartTransactionCommand(), LogicalRepWorker::subid, LogicalRepWorker::type, and WARNING.
Referenced by start_apply(), start_sequence_sync(), and start_table_sync().
| void FetchRelationStates | ( | bool * | has_pending_subtables, |
| bool * | has_pending_sequences, | ||
| bool * | started_tx | ||
| ) |
Definition at line 202 of file syncutils.c.
References CacheMemoryContext, foreach_ptr, get_rel_relkind(), GetSubscriptionRelations(), HasSubscriptionTables(), IsTransactionState(), lappend(), list_free_deep(), MemoryContextSwitchTo(), MySubscription, NIL, Subscription::oid, palloc(), relation_states_validity, StartTransactionCommand(), SYNC_RELATIONS_STATE_REBUILD_STARTED, SYNC_RELATIONS_STATE_VALID, and table_states_not_ready.
Referenced by AllTablesyncsReady(), HasSubscriptionTablesCached(), ProcessSequencesForSync(), and ProcessSyncingTablesForApply().
| pg_noreturn void FinishSyncWorker | ( | void | ) |
Definition at line 50 of file syncutils.c.
References am_sequencesync_worker(), am_tablesync_worker(), Assert(), CommitTransactionCommand(), ereport, errmsg(), get_rel_name(), GetXLogWriteRecPtr(), InvalidOid, IsTransactionState(), LOG, logicalrep_reset_seqsync_start_time(), logicalrep_worker_wakeup(), MyLogicalRepWorker, MySubscription, Subscription::name, pgstat_report_stat(), proc_exit(), LogicalRepWorker::relid, StartTransactionCommand(), LogicalRepWorker::subid, WORKERTYPE_APPLY, and XLogFlush().
Referenced by LogicalRepSyncTableStart(), ProcessSyncingTablesForSync(), SequenceSyncWorkerMain(), and TableSyncWorkerMain().
| bool HasSubscriptionTablesCached | ( | void | ) |
Definition at line 1630 of file tablesync.c.
References CommitTransactionCommand(), FetchRelationStates(), and pgstat_report_stat().
Referenced by wait_for_local_flush().
| void InitializeLogRepWorker | ( | void | ) |
Definition at line 5737 of file worker.c.
References AccessShareLock, ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, am_leader_apply_worker(), am_sequencesync_worker(), am_tablesync_worker(), apply_worker_exit(), ApplyContext, ApplyLauncherForgetWorkerStartTime(), BackgroundWorkerInitializeConnectionByOid(), CacheRegisterSyscacheCallback(), CommitTransactionCommand(), LogicalRepWorker::dbid, Subscription::enabled, ereport, errmsg(), get_rel_name(), GetSubscription(), LockSharedObject(), LOG, MemoryContextSwitchTo(), MyLogicalRepWorker, MySubscription, MySubscriptionValid, Subscription::name, LogicalRepWorker::oldest_nonremovable_xid, PGC_BACKEND, PGC_S_OVERRIDE, PGC_SUSET, proc_exit(), LogicalRepWorker::relid, Subscription::retaindeadtuples, Subscription::retentionactive, SetConfigOption(), StartTransactionCommand(), LogicalRepWorker::subid, subscription_change_cb(), Subscription::synccommit, TopMemoryContext, TransactionIdIsValid, and LogicalRepWorker::userid.
Referenced by ParallelApplyWorkerMain(), and SetupApplyOrSyncWorker().
Definition at line 101 of file syncutils.c.
References relation_states_validity, and SYNC_RELATIONS_STATE_NEEDS_REBUILD.
Referenced by ParallelApplyWorkerMain(), and SetupApplyOrSyncWorker().
| void launch_sync_worker | ( | LogicalRepWorkerType | wtype, |
| int | nsyncworkers, | ||
| Oid | relid, | ||
| TimestampTz * | last_start_time | ||
| ) |
Definition at line 117 of file syncutils.c.
References Assert(), LogicalRepWorker::dbid, DSM_HANDLE_INVALID, GetCurrentTimestamp(), logicalrep_worker_launch(), max_sync_workers_per_subscription, MyLogicalRepWorker, MySubscription, Subscription::name, now(), Subscription::oid, OidIsValid, TimestampDifferenceExceeds(), LogicalRepWorker::userid, wal_retrieve_retry_interval, WORKERTYPE_SEQUENCESYNC, and WORKERTYPE_TABLESYNC.
Referenced by ProcessSequencesForSync(), and ProcessSyncingTablesForApply().
| void logicalrep_pa_worker_stop | ( | ParallelApplyWorkerInfo * | winfo | ) |
Definition at line 679 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(), SIGUSR2, SpinLockAcquire, SpinLockRelease, and LogicalRepCtxStruct::workers.
Referenced by pa_free_worker().
| void logicalrep_reset_seqsync_start_time | ( | void | ) |
Definition at line 872 of file launcher.c.
References InvalidOid, LogicalRepWorker::last_seqsync_start_time, logicalrep_worker_find(), LW_SHARED, LWLockAcquire(), LWLockRelease(), MyLogicalRepWorker, LogicalRepWorker::subid, and WORKERTYPE_APPLY.
Referenced by FinishSyncWorker().
| int logicalrep_sync_worker_count | ( | Oid | subid | ) |
Definition at line 927 of file launcher.c.
References Assert(), i, isSequenceSyncWorker, isTableSyncWorker, LogicalRepCtx, LWLockHeldByMe(), max_logical_replication_workers, LogicalRepWorker::subid, and LogicalRepCtxStruct::workers.
Referenced by logicalrep_worker_launch(), ProcessSequencesForSync(), and ProcessSyncingTablesForApply().
| void logicalrep_worker_attach | ( | int | slot | ) |
Definition at line 757 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 | ( | LogicalRepWorkerType | wtype, |
| Oid | subid, | ||
| Oid | relid, | ||
| bool | only_running | ||
| ) |
Definition at line 258 of file launcher.c.
References Assert(), i, LogicalRepWorker::in_use, isParallelApplyWorker, LogicalRepCtx, LWLockHeldByMe(), max_logical_replication_workers, OidIsValid, LogicalRepWorker::proc, LogicalRepWorker::relid, LogicalRepWorker::subid, LogicalRepWorker::type, LogicalRepCtxStruct::workers, and WORKERTYPE_TABLESYNC.
Referenced by ApplyLauncherMain(), FindDeletedTupleInLocalRel(), logicalrep_reset_seqsync_start_time(), logicalrep_worker_stop(), logicalrep_worker_wakeup(), ProcessSequencesForSync(), ProcessSyncingTablesForApply(), wait_for_table_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, | ||
| bool | retain_dead_tuples | ||
| ) |
Definition at line 324 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, ReplicationSlot::data, LogicalRepWorker::dbid, DEBUG1, DSM_HANDLE_INVALID, elog, ereport, errcode(), errhint(), errmsg(), errmsg_internal(), ERROR, LogicalRepWorker::generation, GetCurrentTimestamp(), i, LogicalRepWorker::in_use, Int32GetDatum(), InvalidPid, InvalidTransactionId, InvalidXLogRecPtr, LogicalRepWorker::last_lsn, LogicalRepWorker::last_recv_time, LogicalRepWorker::last_send_time, LogicalRepWorker::last_seqsync_start_time, LogicalRepWorker::launch_time, LogicalRepWorker::leader_pid, logicalrep_pa_worker_count(), logicalrep_sync_worker_count(), logicalrep_worker_cleanup(), LogicalRepCtx, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), max_active_replication_origins, max_logical_replication_workers, max_parallel_apply_workers_per_subscription, max_sync_workers_per_subscription, MAXPGPATH, MyProcPid, MyReplicationSlot, now(), OidIsValid, LogicalRepWorker::oldest_nonremovable_xid, 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_SEQUENCESYNC, WORKERTYPE_TABLESYNC, WORKERTYPE_UNKNOWN, and ReplicationSlotPersistentData::xmin.
Referenced by ApplyLauncherMain(), launch_sync_worker(), and pa_launch_parallel_worker().
| void logicalrep_worker_stop | ( | LogicalRepWorkerType | wtype, |
| Oid | subid, | ||
| Oid | relid | ||
| ) |
Definition at line 652 of file launcher.c.
References Assert(), isParallelApplyWorker, logicalrep_worker_find(), logicalrep_worker_stop_internal(), LW_SHARED, LWLockAcquire(), LWLockRelease(), OidIsValid, and WORKERTYPE_TABLESYNC.
Referenced by AlterSubscription_refresh(), and DropSubscription().
| void logicalrep_worker_wakeup | ( | LogicalRepWorkerType | wtype, |
| Oid | subid, | ||
| Oid | relid | ||
| ) |
Definition at line 723 of file launcher.c.
References Assert(), logicalrep_worker_find(), logicalrep_worker_wakeup_ptr(), LW_SHARED, LWLockAcquire(), LWLockRelease(), OidIsValid, and WORKERTYPE_TABLESYNC.
Referenced by apply_handle_stream_start(), and FinishSyncWorker().
| void logicalrep_worker_wakeup_ptr | ( | LogicalRepWorker * | worker | ) |
Definition at line 746 of file launcher.c.
References Assert(), LWLockHeldByMe(), LogicalRepWorker::proc, PGPROC::procLatch, and SetLatch().
Referenced by AtEOXact_LogicalRepWorkers(), logicalrep_worker_wakeup(), ProcessSyncingTablesForApply(), and wait_for_worker_state_change().
Definition at line 293 of file launcher.c.
References Assert(), i, LogicalRepWorker::in_use, lappend(), LogicalRepCtx, LW_SHARED, LWLockAcquire(), LWLockHeldByMe(), LWLockRelease(), max_logical_replication_workers, NIL, LogicalRepWorker::proc, LogicalRepWorker::subid, and LogicalRepCtxStruct::workers.
Referenced by AlterSubscription(), AtEOXact_LogicalRepWorkers(), DropSubscription(), and logicalrep_worker_detach().
| void maybe_reread_subscription | ( | void | ) |
Definition at line 5038 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 471 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 1599 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 623 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 519 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 1548 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 1581 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 1410 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 1154 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 1506 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 1342 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 1315 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 1370 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 1424 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 1219 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 1555 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 1588 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 1626 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 XLogRecPtrIsValid.
Referenced by apply_handle_stream_abort(), apply_handle_stream_commit(), and apply_handle_stream_prepare().
| void ProcessSequencesForSync | ( | void | ) |
Definition at line 94 of file sequencesync.c.
References CommitTransactionCommand(), FetchRelationStates(), InvalidOid, LogicalRepWorker::last_seqsync_start_time, launch_sync_worker(), logicalrep_sync_worker_count(), logicalrep_worker_find(), LW_SHARED, LWLockAcquire(), LWLockRelease(), MyLogicalRepWorker, pgstat_report_stat(), LogicalRepWorker::subid, and WORKERTYPE_SEQUENCESYNC.
Referenced by ProcessSyncingRelations().
| void ProcessSyncingRelations | ( | XLogRecPtr | current_lsn | ) |
Definition at line 155 of file syncutils.c.
References elog, ERROR, MyLogicalRepWorker, ProcessSequencesForSync(), ProcessSyncingTablesForApply(), ProcessSyncingTablesForSync(), LogicalRepWorker::type, WORKERTYPE_APPLY, WORKERTYPE_PARALLEL_APPLY, WORKERTYPE_SEQUENCESYNC, 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 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().
| void ReplicationOriginNameForLogicalRep | ( | Oid | suboid, |
| Oid | relid, | ||
| char * | originname, | ||
| Size | szoriginname | ||
| ) |
Definition at line 641 of file worker.c.
References OidIsValid, and snprintf.
Referenced by AlterSubscription(), AlterSubscription_refresh(), binary_upgrade_replorigin_advance(), CreateSubscription(), DropSubscription(), LogicalRepSyncTableStart(), ParallelApplyWorkerMain(), ProcessSyncingTablesForApply(), ProcessSyncingTablesForSync(), run_apply_worker(), and run_tablesync_worker().
| void set_apply_error_context_origin | ( | char * | originname | ) |
Definition at line 6301 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 5514 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 5869 of file worker.c.
References am_leader_apply_worker(), am_sequencesync_worker(), am_tablesync_worker(), Assert(), BackgroundWorkerUnblockSignals(), before_shmem_exit(), CacheRegisterSyscacheCallback(), Subscription::conninfo, DEBUG1, die, elog, GetCurrentTimestamp(), InitializeLogRepWorker(), InvalidateSyncingRelStates(), 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(), SequenceSyncWorkerMain(), and TableSyncWorkerMain().
| void start_apply | ( | XLogRecPtr | origin_startpos | ) |
Definition at line 5583 of file worker.c.
References AbortOutOfAnyTransaction(), Subscription::disableonerr, DisableSubscriptionAndExit(), LogicalRepApplyLoop(), MyLogicalRepWorker, MySubscription, Subscription::oid, PG_CATCH, PG_END_TRY, PG_RE_THROW, PG_TRY, pgstat_report_subscription_error(), replorigin_reset(), and LogicalRepWorker::type.
Referenced by run_apply_worker(), and run_tablesync_worker().
| void store_flush_position | ( | XLogRecPtr | remote_lsn, |
| XLogRecPtr | local_lsn | ||
| ) |
Definition at line 3939 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 5381 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 1687 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 1862 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 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().
|
extern |
Definition at line 469 of file worker.c.
Referenced by LogicalRepApplyLoop(), and ProcessParallelApplyMessage().
|
extern |
Definition at line 472 of file worker.c.
Referenced by copy_sequences(), InitializeLogRepWorker(), LogicalParallelApplyLoop(), LogicalRepApplyLoop(), LogicalRepSyncSequences(), maybe_reread_subscription(), pa_allocate_worker(), pa_launch_parallel_worker(), request_publisher_status(), send_feedback(), set_apply_error_context_origin(), start_table_sync(), store_flush_position(), and stream_start_internal().
|
extern |
Definition at line 471 of file worker.c.
Referenced by apply_spooled_messages(), begin_replication_step(), LogicalParallelApplyLoop(), LogicalRepApplyLoop(), and store_flush_position().
|
extern |
Definition at line 484 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 499 of file worker.c.
Referenced by ApplyWorkerMain(), logicalrep_worker_onexit(), and ParallelApplyWorkerMain().
|
extern |
Definition at line 477 of file worker.c.
Referenced by copy_read_data(), copy_table(), fetch_remote_table_info(), logicalrep_worker_onexit(), LogicalRepApplyLoop(), LogicalRepSyncSequences(), LogicalRepSyncTableStart(), ProcessSyncingTablesForSync(), request_publisher_status(), run_apply_worker(), run_tablesync_worker(), send_feedback(), and set_stream_options().
|
extern |
Definition at line 56 of file launcher.c.
Referenced by am_leader_apply_worker(), am_parallel_apply_worker(), am_sequencesync_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(), FindDeletedTupleInLocalRel(), FinishSyncWorker(), get_candidate_xid(), InitializeLogRepWorker(), IsLogicalWorker(), launch_sync_worker(), logicalrep_reset_seqsync_start_time(), logicalrep_worker_attach(), logicalrep_worker_detach(), logicalrep_worker_onexit(), LogicalRepSyncSequences(), 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(), ProcessSequencesForSync(), ProcessSyncingRelations(), ProcessSyncingTablesForApply(), ProcessSyncingTablesForSync(), run_tablesync_worker(), set_stream_options(), SetupApplyOrSyncWorker(), should_apply_changes_for_rel(), start_apply(), stop_conflict_info_retention(), stream_abort_internal(), stream_cleanup_files(), stream_open_file(), stream_start_internal(), stream_stop_internal(), subxact_info_read(), subxact_info_write(), UpdateWorkerStats(), wait_for_local_flush(), wait_for_table_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 479 of file worker.c.
Referenced by adjust_xid_advance_interval(), apply_handle_commit_prepared(), apply_handle_delete(), apply_handle_insert(), apply_handle_prepare_internal(), apply_handle_rollback_prepared(), apply_handle_truncate(), apply_handle_update(), can_advance_nonremovable_xid(), clear_subscription_skip_lsn(), copy_sequence(), copy_sequences(), copy_table(), DisableSubscriptionAndExit(), fetch_remote_table_info(), FetchRelationStates(), FindDeletedTupleInLocalRel(), FinishSyncWorker(), InitializeLogRepWorker(), launch_sync_worker(), logicalrep_rel_open(), LogicalRepApplyLoop(), LogicalRepSyncSequences(), LogicalRepSyncTableStart(), maybe_reread_subscription(), maybe_start_skipping_changes(), pa_can_start(), pa_launch_parallel_worker(), pa_start_subtrans(), pa_stream_abort(), ParallelApplyWorkerMain(), ProcessParallelApplyInterrupts(), ProcessSyncingTablesForApply(), report_sequence_errors(), ReportApplyConflict(), resume_conflict_info_retention(), run_apply_worker(), run_tablesync_worker(), set_stream_options(), SetupApplyOrSyncWorker(), should_apply_changes_for_rel(), should_stop_conflict_info_retention(), start_apply(), start_sequence_sync(), start_table_sync(), stop_conflict_info_retention(), update_retention_status(), and wait_for_local_flush().
|
extern |
Definition at line 125 of file tablesync.c.
Referenced by AllTablesyncsReady(), FetchRelationStates(), and ProcessSyncingTablesForApply().