mirror of
https://github.com/postgres/postgres.git
synced 2025-08-27 07:42:10 +03:00
Add lock_timeout configuration parameter.
This GUC allows limiting the time spent waiting to acquire any one heavyweight lock. In support of this, improve the recently-added timeout infrastructure to permit efficiently enabling or disabling multiple timeouts at once. That reduces the performance hit from turning on lock_timeout, though it's still not zero. Zoltán Böszörményi, reviewed by Tom Lane, Stephen Frost, and Hari Babu
This commit is contained in:
@@ -25,6 +25,7 @@ typedef enum TimeoutId
|
||||
/* Predefined timeout reasons */
|
||||
STARTUP_PACKET_TIMEOUT,
|
||||
DEADLOCK_TIMEOUT,
|
||||
LOCK_TIMEOUT,
|
||||
STATEMENT_TIMEOUT,
|
||||
STANDBY_DEADLOCK_TIMEOUT,
|
||||
STANDBY_TIMEOUT,
|
||||
@@ -35,20 +36,48 @@ typedef enum TimeoutId
|
||||
} TimeoutId;
|
||||
|
||||
/* callback function signature */
|
||||
typedef void (*timeout_handler) (void);
|
||||
typedef void (*timeout_handler_proc) (void);
|
||||
|
||||
/*
|
||||
* Parameter structure for setting multiple timeouts at once
|
||||
*/
|
||||
typedef enum TimeoutType
|
||||
{
|
||||
TMPARAM_AFTER,
|
||||
TMPARAM_AT
|
||||
} TimeoutType;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TimeoutId id; /* timeout to set */
|
||||
TimeoutType type; /* TMPARAM_AFTER or TMPARAM_AT */
|
||||
int delay_ms; /* only used for TMPARAM_AFTER */
|
||||
TimestampTz fin_time; /* only used for TMPARAM_AT */
|
||||
} EnableTimeoutParams;
|
||||
|
||||
/*
|
||||
* Parameter structure for clearing multiple timeouts at once
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
TimeoutId id; /* timeout to clear */
|
||||
bool keep_indicator; /* keep the indicator flag? */
|
||||
} DisableTimeoutParams;
|
||||
|
||||
/* timeout setup */
|
||||
extern void InitializeTimeouts(void);
|
||||
extern TimeoutId RegisterTimeout(TimeoutId id, timeout_handler handler);
|
||||
extern TimeoutId RegisterTimeout(TimeoutId id, timeout_handler_proc handler);
|
||||
|
||||
/* timeout operation */
|
||||
extern void enable_timeout_after(TimeoutId id, int delay_ms);
|
||||
extern void enable_timeout_at(TimeoutId id, TimestampTz fin_time);
|
||||
extern void enable_timeouts(const EnableTimeoutParams *timeouts, int count);
|
||||
extern void disable_timeout(TimeoutId id, bool keep_indicator);
|
||||
extern void disable_timeouts(const DisableTimeoutParams *timeouts, int count);
|
||||
extern void disable_all_timeouts(bool keep_indicators);
|
||||
|
||||
/* accessors */
|
||||
extern bool get_timeout_indicator(TimeoutId id);
|
||||
extern bool get_timeout_indicator(TimeoutId id, bool reset_indicator);
|
||||
extern TimestampTz get_timeout_start_time(TimeoutId id);
|
||||
|
||||
#endif /* TIMEOUT_H */
|
||||
|
Reference in New Issue
Block a user