PostgreSQL Source Code
git master
|
#include <signal.h>
#include "access/xlogdefs.h"
#include "catalog/pg_subscription.h"
#include "datatype/timestamp.h"
#include "miscadmin.h"
#include "replication/logicalrelation.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) ((worker)->leader_pid != InvalidPid) |
Typedefs | |
typedef struct LogicalRepWorker | LogicalRepWorker |
typedef enum ParallelTransState | ParallelTransState |
typedef enum PartialFileSetState | PartialFileSetState |
typedef struct ParallelApplyWorkerShared | ParallelApplyWorkerShared |
typedef struct ParallelApplyWorkerInfo | ParallelApplyWorkerInfo |
Enumerations | |
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 | ) | ((worker)->leader_pid != InvalidPid) |
Definition at line 308 of file worker_internal.h.
typedef struct LogicalRepWorker LogicalRepWorker |
typedef struct ParallelApplyWorkerInfo ParallelApplyWorkerInfo |
typedef struct ParallelApplyWorkerShared ParallelApplyWorkerShared |
typedef enum ParallelTransState ParallelTransState |
typedef enum PartialFileSetState PartialFileSetState |
enum ParallelTransState |
Enumerator | |
---|---|
PARALLEL_TRANS_UNKNOWN | |
PARALLEL_TRANS_STARTED | |
PARALLEL_TRANS_FINISHED |
Definition at line 93 of file worker_internal.h.
enum PartialFileSetState |
Enumerator | |
---|---|
FS_EMPTY | |
FS_SERIALIZE_IN_PROGRESS | |
FS_SERIALIZE_DONE | |
FS_READY |
Definition at line 116 of file worker_internal.h.
bool AllTablesyncsReady | ( | void | ) |
Definition at line 1580 of file tablesync.c.
References CommitTransactionCommand(), FetchTableStates(), NIL, pgstat_report_stat(), and table_states_not_ready.
Referenced by ApplyWorkerMain(), pa_can_start(), and process_syncing_tables_for_apply().
|
inlinestatic |
Definition at line 317 of file worker_internal.h.
References am_tablesync_worker(), isParallelApplyWorker, and MyLogicalRepWorker.
Referenced by logicalrep_worker_detach(), pa_can_start(), pa_set_fileset_state(), and pa_xact_finish().
|
inlinestatic |
Definition at line 324 of file worker_internal.h.
References isParallelApplyWorker, and MyLogicalRepWorker.
Referenced by apply_spooled_messages(), apply_worker_exit(), clear_subscription_skip_lsn(), DisableSubscriptionAndExit(), get_transaction_apply_action(), get_worker_name(), InitializeApplyWorker(), IsLogicalParallelApplyWorker(), maybe_reread_subscription(), pa_decr_and_wait_stream_block(), pa_free_worker(), pa_get_fileset_state(), process_syncing_tables(), should_apply_changes_for_rel(), and store_flush_position().
|
inlinestatic |
Definition at line 311 of file worker_internal.h.
References MyLogicalRepWorker, OidIsValid, and LogicalRepWorker::relid.
Referenced by am_leader_apply_worker(), apply_handle_begin_prepare(), apply_handle_origin(), apply_handle_stream_prepare(), apply_worker_exit(), ApplyWorkerMain(), DisableSubscriptionAndExit(), get_worker_name(), InitializeApplyWorker(), maybe_reread_subscription(), process_syncing_tables(), should_apply_changes_for_rel(), start_apply(), and start_table_sync().
void apply_dispatch | ( | StringInfo | s | ) |
Definition at line 3285 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 4916 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 XLogRecPtrIsInvalid.
Referenced by LogicalParallelApplyLoop(), and LogicalRepApplyLoop().
void apply_spooled_messages | ( | FileSet * | stream_fileset, |
TransactionId | xid, | ||
XLogRecPtr | lsn | ||
) |
Definition at line 2025 of file worker.c.
References am_parallel_apply_worker(), appendBinaryStringInfo(), 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, initStringInfo(), len, MAXPGPATH, maybe_start_skipping_changes(), MemoryContextReset(), MemoryContextSwitchTo(), MyLogicalRepWorker, palloc(), pgstat_report_activity(), remote_final_lsn, repalloc(), resetStringInfo(), 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 InitializeApplyWorker | ( | void | ) |
Definition at line 4445 of file worker.c.
References ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, am_parallel_apply_worker(), am_tablesync_worker(), apply_worker_exit(), ApplyContext, ApplyLauncherForgetWorkerStartTime(), BackgroundWorkerInitializeConnectionByOid(), CacheRegisterSyscacheCallback(), CommitTransactionCommand(), LogicalRepWorker::dbid, Subscription::enabled, ereport, errmsg(), get_rel_name(), get_worker_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(), SUBSCRIPTIONOID, Subscription::synccommit, TopMemoryContext, and LogicalRepWorker::userid.
Referenced by ApplyWorkerMain(), and ParallelApplyWorkerMain().
Definition at line 272 of file tablesync.c.
References table_states_valid.
Referenced by ApplyWorkerMain(), and ParallelApplyWorkerMain().
void logicalrep_pa_worker_stop | ( | ParallelApplyWorkerInfo * | winfo | ) |
Definition at line 618 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 832 of file launcher.c.
References Assert(), i, LogicalRepCtx, LWLockHeldByMe(), max_logical_replication_workers, OidIsValid, LogicalRepWorker::relid, 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 692 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 ApplyWorkerMain(), and ParallelApplyWorkerMain().
LogicalRepWorker* logicalrep_worker_find | ( | Oid | subid, |
Oid | relid, | ||
bool | only_running | ||
) |
Definition at line 249 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 | ( | Oid | dbid, |
Oid | subid, | ||
const char * | subname, | ||
Oid | userid, | ||
Oid | relid, | ||
dsm_handle | subworker_dsm | ||
) |
Definition at line 306 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, 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::userid, WaitForReplicationWorkerAttach(), wal_receiver_timeout, WARNING, and LogicalRepCtxStruct::workers.
Referenced by ApplyLauncherMain(), pa_launch_parallel_worker(), and process_syncing_tables_for_apply().
Definition at line 594 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 661 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 681 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 281 of file launcher.c.
References Assert(), i, LogicalRepWorker::in_use, lappend(), LogicalRepCtx, LWLockHeldByMe(), max_logical_replication_workers, NIL, LogicalRepWorker::proc, res, LogicalRepWorker::subid, and LogicalRepCtxStruct::workers.
Referenced by AtEOXact_LogicalRepWorkers(), DropSubscription(), and logicalrep_worker_detach().
char* LogicalRepSyncTableStart | ( | XLogRecPtr * | origin_startpos | ) |
Definition at line 1244 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, err(), errcode(), ERRCODE_DUPLICATE_OBJECT, errmsg(), ERROR, get_relkind_objtype(), GetSubscriptionRelState(), GetTransactionSnapshot(), GetUserId(), GetUserNameFromId(), InvalidOid, InvalidXLogRecPtr, LockRelationOid(), LogRepWorkerWalRcvConn, LSN_FORMAT_ARGS, MyLogicalRepWorker, MySubscription, NAMEDATALEN, NoLock, Subscription::oid, OidIsValid, Subscription::owner, 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(), res, RLS_ENABLED, RowExclusiveLock, SpinLockAcquire, SpinLockRelease, StartTransactionCommand(), LogicalRepWorker::subid, superuser_arg(), 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().
void maybe_reread_subscription | ( | void | ) |
Definition at line 3872 of file worker.c.
References am_parallel_apply_worker(), am_tablesync_worker(), apply_worker_exit(), ApplyContext, ApplyLauncherForgetWorkerStartTime(), Assert(), Subscription::binary, CommitTransactionCommand(), Subscription::conninfo, Subscription::dbid, elog(), equal(), ereport, errmsg(), ERROR, FreeSubscription(), get_worker_name(), GetSubscription(), IsTransactionState(), LOG, MemoryContextSwitchTo(), MyLogicalRepWorker, MySubscription, MySubscriptionValid, Subscription::name, newsub(), Subscription::origin, Subscription::owner, 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 469 of file applyparallelworker.c.
References ApplyContext, elog(), HASHCTL::entrysize, ERROR, HASH_BLOBS, HASH_CONTEXT, hash_create(), HASH_ELEM, HASH_ENTER, hash_search(), HASHCTL::hcxt, ParallelApplyWorkerInfo::in_use, HASHCTL::keysize, 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, ParallelApplyWorkerEntry::xid, and ParallelApplyWorkerShared::xid.
Referenced by apply_handle_stream_start().
void pa_decr_and_wait_stream_block | ( | void | ) |
Definition at line 1594 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 1543 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 1576 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 1405 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 1149 of file applyparallelworker.c.
References Assert(), CHECK_FOR_INTERRUPTS, data, ereport, errcode(), errmsg(), ERROR, GetCurrentTimestamp(), IsTransactionState(), LOGICAL_REP_MODE_IMMEDIATE, logical_replication_mode, 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, WAIT_EVENT_LOGICAL_APPLY_SEND_DATA, 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 1501 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 1337 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 1310 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 1365 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 1419 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 1214 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 1550 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 1583 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 1621 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 647 of file tablesync.c.
References am_parallel_apply_worker(), am_tablesync_worker(), process_syncing_tables_for_apply(), and process_syncing_tables_for_sync().
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 461 of file worker.c.
References OidIsValid, and snprintf.
Referenced by AlterSubscription(), AlterSubscription_refresh(), ApplyWorkerMain(), CreateSubscription(), DropSubscription(), LogicalRepSyncTableStart(), ParallelApplyWorkerMain(), process_syncing_tables_for_apply(), and process_syncing_tables_for_sync().
void set_apply_error_context_origin | ( | char * | originname | ) |
Definition at line 5058 of file worker.c.
References apply_error_callback_arg, ApplyContext, MemoryContextStrdup(), and ApplyErrorCallbackArg::origin_name.
Referenced by ApplyWorkerMain(), and ParallelApplyWorkerMain().
void store_flush_position | ( | XLogRecPtr | remote_lsn, |
XLogRecPtr | local_lsn | ||
) |
Definition at line 3449 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 4199 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 1453 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 1627 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 1605 of file tablesync.c.
References Assert(), CatalogTupleUpdate(), CharGetDatum(), elog(), ERROR, heap_freetuple(), heap_modify_tuple(), HeapTupleIsValid, LOGICALREP_TWOPHASE_STATE_DISABLED, LOGICALREP_TWOPHASE_STATE_ENABLED, LOGICALREP_TWOPHASE_STATE_PENDING, ObjectIdGetDatum(), RelationGetDescr, RowExclusiveLock, SearchSysCacheCopy1, SUBSCRIPTIONOID, HeapTupleData::t_self, table_close(), table_open(), and values.
Referenced by ApplyWorkerMain(), and CreateSubscription().
|
extern |
Definition at line 305 of file worker.c.
Referenced by HandleParallelApplyMessage(), and LogicalRepApplyLoop().
|
extern |
Definition at line 308 of file worker.c.
Referenced by InitializeApplyWorker(), 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 307 of file worker.c.
Referenced by apply_spooled_messages(), begin_replication_step(), LogicalParallelApplyLoop(), LogicalRepApplyLoop(), and store_flush_position().
|
extern |
Definition at line 320 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 335 of file worker.c.
Referenced by ApplyWorkerMain(), logicalrep_worker_onexit(), and ParallelApplyWorkerMain().
|
extern |
Definition at line 313 of file worker.c.
Referenced by ApplyWorkerMain(), copy_read_data(), copy_table(), fetch_remote_table_info(), logicalrep_worker_onexit(), LogicalRepApplyLoop(), LogicalRepSyncTableStart(), process_syncing_tables_for_sync(), and send_feedback().
|
extern |
Definition at line 61 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(), ApplyWorkerMain(), DisableSubscriptionAndExit(), ensure_last_message(), InitializeApplyWorker(), 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_for_apply(), process_syncing_tables_for_sync(), 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 315 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(), ApplyWorkerMain(), clear_subscription_skip_lsn(), copy_table(), DisableSubscriptionAndExit(), fetch_remote_table_info(), FetchTableStates(), InitializeApplyWorker(), 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(), should_apply_changes_for_rel(), start_apply(), and start_table_sync().