PostgreSQL Source Code git master
|
#include "postgres.h"
#include <unistd.h>
#include "access/xact.h"
#include "common/int.h"
#include "miscadmin.h"
#include "pgstat.h"
#include "replication/syncrep.h"
#include "replication/walsender.h"
#include "replication/walsender_private.h"
#include "storage/proc.h"
#include "tcop/tcopprot.h"
#include "utils/guc_hooks.h"
#include "utils/ps_status.h"
Go to the source code of this file.
Macros | |
#define | SyncStandbysDefined() (SyncRepStandbyNames != NULL && SyncRepStandbyNames[0] != '\0') |
Variables | |
char * | SyncRepStandbyNames |
static bool | announce_next_takeover = true |
SyncRepConfigData * | SyncRepConfig = NULL |
static int | SyncRepWaitMode = SYNC_REP_NO_WAIT |
#define SyncStandbysDefined | ( | ) | (SyncRepStandbyNames != NULL && SyncRepStandbyNames[0] != '\0') |
void assign_synchronous_commit | ( | int | newval, |
void * | extra | ||
) |
Definition at line 1056 of file syncrep.c.
References newval, SYNC_REP_NO_WAIT, SYNC_REP_WAIT_APPLY, SYNC_REP_WAIT_FLUSH, SYNC_REP_WAIT_WRITE, SYNCHRONOUS_COMMIT_REMOTE_APPLY, SYNCHRONOUS_COMMIT_REMOTE_FLUSH, SYNCHRONOUS_COMMIT_REMOTE_WRITE, and SyncRepWaitMode.
void assign_synchronous_standby_names | ( | const char * | newval, |
void * | extra | ||
) |
Definition at line 1050 of file syncrep.c.
References SyncRepConfig.
bool check_synchronous_standby_names | ( | char ** | newval, |
void ** | extra, | ||
GucSource | source | ||
) |
Definition at line 991 of file syncrep.c.
References SyncRepConfigData::config_size, GUC_check_errcode(), GUC_check_errdetail, GUC_check_errmsg, guc_malloc(), LOG, newval, SyncRepConfigData::num_sync, syncrep_parse_error_msg, syncrep_parse_result, syncrep_scanner_finish(), syncrep_scanner_init(), and syncrep_yyparse().
|
static |
Definition at line 695 of file syncrep.c.
References a, b, and pg_cmp_u64().
Referenced by SyncRepGetNthLatestSyncRecPtr().
|
static |
Definition at line 790 of file syncrep.c.
References a, b, SyncRepStandbyData::sync_standby_priority, and SyncRepStandbyData::walsnd_index.
Referenced by SyncRepGetCandidateStandbys().
|
static |
Definition at line 363 of file syncrep.c.
References dlist_delete_thoroughly(), dlist_node_is_detached(), LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MyProc, SYNC_REP_NOT_WAITING, PGPROC::syncRepLinks, and PGPROC::syncRepState.
Referenced by SyncRepWaitForLSN().
void SyncRepCleanupAtProcExit | ( | void | ) |
Definition at line 373 of file syncrep.c.
References dlist_delete_thoroughly(), dlist_node_is_detached(), LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MyProc, and PGPROC::syncRepLinks.
Referenced by ProcKill().
int SyncRepGetCandidateStandbys | ( | SyncRepStandbyData ** | standbys | ) |
Definition at line 711 of file syncrep.c.
References SyncRepStandbyData::apply, WalSnd::apply, SyncRepStandbyData::flush, WalSnd::flush, i, SyncRepStandbyData::is_me, max_wal_senders, WalSnd::mutex, MyWalSnd, SyncRepConfigData::num_sync, palloc(), SyncRepStandbyData::pid, WalSnd::pid, qsort, SpinLockAcquire, SpinLockRelease, standby_priority_comparator(), WalSnd::state, SYNC_REP_PRIORITY, SyncRepStandbyData::sync_standby_priority, WalSnd::sync_standby_priority, SyncRepConfigData::syncrep_method, SyncRepConfig, SyncRepStandbyData::walsnd_index, WalSndCtl, WalSndCtlData::walsnds, WALSNDSTATE_STOPPING, WALSNDSTATE_STREAMING, SyncRepStandbyData::write, WalSnd::write, and XLogRecPtrIsInvalid.
Referenced by pg_stat_get_wal_senders(), and SyncRepGetSyncRecPtr().
|
static |
Definition at line 650 of file syncrep.c.
References SyncRepStandbyData::apply, Assert, cmp_lsn(), SyncRepStandbyData::flush, i, palloc(), pfree(), qsort, and SyncRepStandbyData::write.
Referenced by SyncRepGetSyncRecPtr().
|
static |
Definition at line 617 of file syncrep.c.
References SyncRepStandbyData::apply, SyncRepStandbyData::flush, i, SyncRepStandbyData::write, write, and XLogRecPtrIsInvalid.
Referenced by SyncRepGetSyncRecPtr().
|
static |
Definition at line 817 of file syncrep.c.
References am_cascading_walsender, application_name, SyncRepConfigData::member_names, SyncRepConfigData::nmembers, pg_strcasecmp(), SYNC_REP_PRIORITY, SyncRepConfigData::syncrep_method, SyncRepConfig, and SyncStandbysDefined.
Referenced by SyncRepInitConfig().
|
static |
Definition at line 543 of file syncrep.c.
References i, InvalidXLogRecPtr, SyncRepConfigData::num_sync, pfree(), SYNC_REP_PRIORITY, SyncRepConfigData::syncrep_method, SyncRepConfig, SyncRepGetCandidateStandbys(), SyncRepGetNthLatestSyncRecPtr(), and SyncRepGetOldestSyncRecPtr().
Referenced by SyncRepReleaseWaiters().
void SyncRepInitConfig | ( | void | ) |
Definition at line 402 of file syncrep.c.
References application_name, DEBUG1, ereport, errmsg_internal(), WalSnd::mutex, MyWalSnd, SpinLockAcquire, SpinLockRelease, WalSnd::sync_standby_priority, and SyncRepGetStandbyPriority().
Referenced by ProcessPendingWrites(), StartLogicalReplication(), StartReplication(), WalSndLoop(), and WalSndWaitForWal().
|
static |
Definition at line 329 of file syncrep.c.
References Assert, dlist_iter::cur, dlist_container, dlist_insert_after(), dlist_push_head(), dlist_reverse_foreach, mode, MyProc, NUM_SYNC_REP_WAIT_MODE, PGPROC::syncRepLinks, WalSndCtlData::SyncRepQueue, PGPROC::waitLSN, and WalSndCtl.
Referenced by SyncRepWaitForLSN().
void SyncRepReleaseWaiters | ( | void | ) |
Definition at line 431 of file syncrep.c.
References announce_next_takeover, application_name, DEBUG3, elog, ereport, errmsg(), WalSnd::flush, LOG, WalSndCtlData::lsn, LSN_FORMAT_ARGS, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MyWalSnd, WalSnd::state, SYNC_REP_PRIORITY, SYNC_REP_WAIT_APPLY, SYNC_REP_WAIT_FLUSH, SYNC_REP_WAIT_WRITE, WalSnd::sync_standby_priority, SyncRepConfigData::syncrep_method, SyncRepConfig, SyncRepGetSyncRecPtr(), SyncRepWakeQueue(), WalSndCtl, WALSNDSTATE_STOPPING, WALSNDSTATE_STREAMING, and XLogRecPtrIsInvalid.
Referenced by ProcessStandbyReplyMessage().
void SyncRepUpdateSyncStandbysDefined | ( | void | ) |
Definition at line 921 of file syncrep.c.
References i, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), NUM_SYNC_REP_WAIT_MODE, WalSndCtlData::sync_standbys_defined, SyncRepWakeQueue(), SyncStandbysDefined, and WalSndCtl.
Referenced by UpdateSharedMemoryConfig().
void SyncRepWaitForLSN | ( | XLogRecPtr | lsn, |
bool | commit | ||
) |
Definition at line 148 of file syncrep.c.
References Assert, DestNone, dlist_node_is_detached(), ereport, errcode(), errdetail(), errmsg(), InterruptHoldoffCount, LSN_FORMAT_ARGS, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), Min, mode, MyLatch, MyProc, pg_read_barrier, ProcDiePending, QueryCancelPending, ResetLatch(), set_ps_display_remove_suffix(), set_ps_display_suffix(), sprintf, SYNC_REP_NOT_WAITING, SYNC_REP_WAIT_COMPLETE, SYNC_REP_WAIT_FLUSH, SYNC_REP_WAITING, WalSndCtlData::sync_standbys_defined, SyncRepCancelWait(), PGPROC::syncRepLinks, SyncRepQueueInsert(), SyncRepRequested, PGPROC::syncRepState, SyncRepWaitMode, update_process_title, WaitLatch(), PGPROC::waitLSN, WalSndCtl, WARNING, whereToSendOutput, WL_LATCH_SET, and WL_POSTMASTER_DEATH.
Referenced by EndPrepare(), RecordTransactionAbortPrepared(), RecordTransactionCommit(), and RecordTransactionCommitPrepared().
|
static |
Definition at line 864 of file syncrep.c.
References Assert, dlist_mutable_iter::cur, dlist_container, dlist_delete_thoroughly(), dlist_foreach_modify, WalSndCtlData::lsn, LW_EXCLUSIVE, LWLockHeldByMeInMode(), mode, NUM_SYNC_REP_WAIT_MODE, pg_write_barrier, PGPROC::procLatch, SetLatch(), SYNC_REP_WAIT_COMPLETE, PGPROC::syncRepLinks, WalSndCtlData::SyncRepQueue, PGPROC::syncRepState, PGPROC::waitLSN, and WalSndCtl.
Referenced by SyncRepReleaseWaiters(), and SyncRepUpdateSyncStandbysDefined().
|
static |
Definition at line 95 of file syncrep.c.
Referenced by SyncRepReleaseWaiters().
SyncRepConfigData* SyncRepConfig = NULL |
Definition at line 97 of file syncrep.c.
Referenced by assign_synchronous_standby_names(), pg_stat_get_wal_senders(), SyncRepGetCandidateStandbys(), SyncRepGetStandbyPriority(), SyncRepGetSyncRecPtr(), and SyncRepReleaseWaiters().
|
static |
Definition at line 98 of file syncrep.c.
Referenced by assign_synchronous_commit(), and SyncRepWaitForLSN().