summaryrefslogtreecommitdiff
path: root/src/include/storage
diff options
context:
space:
mode:
authorAlvaro Herrera2012-07-16 22:43:21 +0000
committerAlvaro Herrera2012-07-17 02:55:33 +0000
commitf34c68f09671c4566854c7e20e9253d4f335c0b0 (patch)
treedcfea396da6622644aca0cf35799e6cc13fa1137 /src/include/storage
parentdd16f9480ac67ab0c6b0102d110cd5121ed9ab46 (diff)
Introduce timeout handling framework
Management of timeouts was getting a little cumbersome; what we originally had was more than enough back when we were only concerned about deadlocks and query cancel; however, when we added timeouts for standby processes, the code got considerably messier. Since there are plans to add more complex timeouts, this seems a good time to introduce a central timeout handling module. External modules register their timeout handlers during process initialization, and later enable and disable them as they see fit using a simple API; timeout.c is in charge of keeping track of which timeouts are in effect at any time, installing a common SIGALRM signal handler, and calling setitimer() as appropriate to ensure timely firing of external handlers. timeout.c additionally supports pluggable modules to add their own timeouts, though this capability isn't exercised anywhere yet. Additionally, as of this commit, walsender processes are aware of timeouts; we had a preexisting bug there that made those ignore SIGALRM, thus being subject to unhandled deadlocks, particularly during the authentication phase. This has already been fixed in back branches in commit 0bf8eb2a, which see for more details. Main author: Zoltán Böszörményi Some review and cleanup by Álvaro Herrera Extensive reworking by Tom Lane
Diffstat (limited to 'src/include/storage')
-rw-r--r--src/include/storage/proc.h13
-rw-r--r--src/include/storage/standby.h3
2 files changed, 3 insertions, 13 deletions
diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h
index 31f7099a635..e10aafe99e4 100644
--- a/src/include/storage/proc.h
+++ b/src/include/storage/proc.h
@@ -15,7 +15,6 @@
#define _PROC_H_
#include "access/xlogdefs.h"
-#include "datatype/timestamp.h"
#include "storage/latch.h"
#include "storage/lock.h"
#include "storage/pg_sema.h"
@@ -222,8 +221,6 @@ extern int DeadlockTimeout;
extern int StatementTimeout;
extern bool log_lock_waits;
-extern volatile bool cancel_from_timeout;
-
/*
* Function Prototypes
@@ -246,19 +243,11 @@ extern void ProcQueueInit(PROC_QUEUE *queue);
extern int ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable);
extern PGPROC *ProcWakeup(PGPROC *proc, int waitStatus);
extern void ProcLockWakeup(LockMethod lockMethodTable, LOCK *lock);
+extern void CheckDeadLock(void);
extern bool IsWaitingForLock(void);
extern void LockErrorCleanup(void);
extern void ProcWaitForSignal(void);
extern void ProcSendSignal(int pid);
-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(TimestampTz now,
- TimestampTz fin_time, bool deadlock_only);
-extern bool disable_standby_sig_alarm(void);
-extern void handle_standby_sig_alarm(SIGNAL_ARGS);
-
#endif /* PROC_H */
diff --git a/src/include/storage/standby.h b/src/include/storage/standby.h
index ed3b66b35df..7024fc4f3c2 100644
--- a/src/include/storage/standby.h
+++ b/src/include/storage/standby.h
@@ -33,8 +33,9 @@ extern void ResolveRecoveryConflictWithTablespace(Oid tsid);
extern void ResolveRecoveryConflictWithDatabase(Oid dbid);
extern void ResolveRecoveryConflictWithBufferPin(void);
-extern void SendRecoveryConflictWithBufferPin(ProcSignalReason reason);
extern void CheckRecoveryConflictDeadlock(void);
+extern void StandbyDeadLockHandler(void);
+extern void StandbyTimeoutHandler(void);
/*
* Standby Rmgr (RM_STANDBY_ID)