diff options
author | Simon Riggs <simon@2ndQuadrant.com> | 2010-01-23 16:37:12 +0000 |
---|---|---|
committer | Simon Riggs <simon@2ndQuadrant.com> | 2010-01-23 16:37:12 +0000 |
commit | 959ac58c04130d467fb05e63a3ceb8e2ded404c7 (patch) | |
tree | 314eeeea7c6c8afa7cbe35bfe5ecde04eff35f71 /src/include | |
parent | 4fa69e566cf1b836ae8aa9bee24ab0c556cfe94e (diff) |
In HS, Startup process sets SIGALRM when waiting for buffer pin. If
woken by alarm we send SIGUSR1 to all backends requesting that they
check to see if they are blocking Startup process. If so, they throw
ERROR/FATAL as for other conflict resolutions. Deadlock stop gap
removed. max_standby_delay = -1 option removed to prevent deadlock.
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/storage/bufmgr.h | 3 | ||||
-rw-r--r-- | src/include/storage/proc.h | 12 | ||||
-rw-r--r-- | src/include/storage/procarray.h | 7 | ||||
-rw-r--r-- | src/include/storage/procsignal.h | 3 | ||||
-rw-r--r-- | src/include/storage/standby.h | 9 |
5 files changed, 23 insertions, 11 deletions
diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h index e8e2abae1ea..dc4376ee9a5 100644 --- a/src/include/storage/bufmgr.h +++ b/src/include/storage/bufmgr.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.123 2010/01/02 16:58:08 momjian Exp $ + * $PostgreSQL: pgsql/src/include/storage/bufmgr.h,v 1.124 2010/01/23 16:37:12 sriggs Exp $ * *------------------------------------------------------------------------- */ @@ -198,6 +198,7 @@ extern void LockBuffer(Buffer buffer, int mode); extern bool ConditionalLockBuffer(Buffer buffer); extern void LockBufferForCleanup(Buffer buffer); extern bool ConditionalLockBufferForCleanup(Buffer buffer); +extern bool HoldingBufferPinThatDelaysRecovery(void); extern void AbortBufferIO(void); diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 50500903245..5a4421bfa5c 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.118 2010/01/16 10:05:50 sriggs Exp $ + * $PostgreSQL: pgsql/src/include/storage/proc.h,v 1.119 2010/01/23 16:37:12 sriggs Exp $ * *------------------------------------------------------------------------- */ @@ -16,7 +16,7 @@ #include "storage/lock.h" #include "storage/pg_sema.h" - +#include "utils/timestamp.h" /* * Each backend advertises up to PGPROC_MAX_CACHED_SUBXIDS TransactionIds @@ -145,6 +145,8 @@ typedef struct PROC_HDR /* The proc of the Startup process, since not in ProcArray */ PGPROC *startupProc; int startupProcPid; + /* Buffer id of the buffer that Startup process waits for pin on */ + int startupBufferPinWaitBufId; } PROC_HDR; /* @@ -177,6 +179,8 @@ extern void InitProcessPhase2(void); extern void InitAuxiliaryProcess(void); extern void PublishStartupProcessInformation(void); +extern void SetStartupBufferPinWaitBufId(int bufid); +extern int GetStartupBufferPinWaitBufId(void); extern bool HaveNFreeProcs(int n); extern void ProcReleaseLocks(bool isCommit); @@ -194,4 +198,8 @@ extern bool enable_sig_alarm(int delayms, bool is_statement_timeout); extern bool disable_sig_alarm(bool is_statement_timeout); extern void handle_sig_alarm(SIGNAL_ARGS); +extern bool enable_standby_sig_alarm(long delay_s, int delay_us, TimestampTz fin_time); +extern bool disable_standby_sig_alarm(void); +extern void handle_standby_sig_alarm(SIGNAL_ARGS); + #endif /* PROC_H */ diff --git a/src/include/storage/procarray.h b/src/include/storage/procarray.h index 42953b0843c..ed68be6f271 100644 --- a/src/include/storage/procarray.h +++ b/src/include/storage/procarray.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/procarray.h,v 1.30 2010/01/16 10:05:56 sriggs Exp $ + * $PostgreSQL: pgsql/src/include/storage/procarray.h,v 1.31 2010/01/23 16:37:12 sriggs Exp $ * *------------------------------------------------------------------------- */ @@ -57,13 +57,12 @@ extern bool IsBackendPid(int pid); extern VirtualTransactionId *GetCurrentVirtualXIDs(TransactionId limitXmin, bool excludeXmin0, bool allDbs, int excludeVacuum, int *nvxids); -extern VirtualTransactionId *GetConflictingVirtualXIDs(TransactionId limitXmin, - Oid dbOid, bool skipExistingConflicts); +extern VirtualTransactionId *GetConflictingVirtualXIDs(TransactionId limitXmin, Oid dbOid); extern pid_t CancelVirtualTransaction(VirtualTransactionId vxid, ProcSignalReason sigmode); extern int CountActiveBackends(void); extern int CountDBBackends(Oid databaseid); -extern void CancelDBBackends(Oid databaseid); +extern void CancelDBBackends(Oid databaseid, ProcSignalReason sigmode, bool conflictPending); extern int CountUserBackends(Oid roleid); extern bool CountOtherDBBackends(Oid databaseId, int *nbackends, int *nprepared); diff --git a/src/include/storage/procsignal.h b/src/include/storage/procsignal.h index cbe0e24c672..2a67a62a922 100644 --- a/src/include/storage/procsignal.h +++ b/src/include/storage/procsignal.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/procsignal.h,v 1.3 2010/01/16 10:05:57 sriggs Exp $ + * $PostgreSQL: pgsql/src/include/storage/procsignal.h,v 1.4 2010/01/23 16:37:12 sriggs Exp $ * *------------------------------------------------------------------------- */ @@ -37,6 +37,7 @@ typedef enum PROCSIG_RECOVERY_CONFLICT_TABLESPACE, PROCSIG_RECOVERY_CONFLICT_LOCK, PROCSIG_RECOVERY_CONFLICT_SNAPSHOT, + PROCSIG_RECOVERY_CONFLICT_BUFFERPIN, NUM_PROCSIGNALS /* Must be last! */ } ProcSignalReason; diff --git a/src/include/storage/standby.h b/src/include/storage/standby.h index 8c982cffb63..e12798045ae 100644 --- a/src/include/storage/standby.h +++ b/src/include/storage/standby.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/storage/standby.h,v 1.4 2010/01/16 10:05:57 sriggs Exp $ + * $PostgreSQL: pgsql/src/include/storage/standby.h,v 1.5 2010/01/23 16:37:12 sriggs Exp $ * *------------------------------------------------------------------------- */ @@ -19,12 +19,15 @@ extern int vacuum_defer_cleanup_age; +extern void InitRecoveryTransactionEnvironment(void); +extern void ShutdownRecoveryTransactionEnvironment(void); + extern void ResolveRecoveryConflictWithSnapshot(TransactionId latestRemovedXid); extern void ResolveRecoveryConflictWithTablespace(Oid tsid); extern void ResolveRecoveryConflictWithDatabase(Oid dbid); -extern void InitRecoveryTransactionEnvironment(void); -extern void ShutdownRecoveryTransactionEnvironment(void); +extern void ResolveRecoveryConflictWithBufferPin(void); +extern void SendRecoveryConflictWithBufferPin(void); /* * Standby Rmgr (RM_STANDBY_ID) |