mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
Add idle_in_transaction_session_timeout.
Vik Fearing, reviewed by Stéphane Schildknecht and me, and revised slightly by me.
This commit is contained in:
@ -229,6 +229,7 @@ Section: Class 25 - Invalid Transaction State
|
||||
25007 E ERRCODE_SCHEMA_AND_DATA_STATEMENT_MIXING_NOT_SUPPORTED schema_and_data_statement_mixing_not_supported
|
||||
25P01 E ERRCODE_NO_ACTIVE_SQL_TRANSACTION no_active_sql_transaction
|
||||
25P02 E ERRCODE_IN_FAILED_SQL_TRANSACTION in_failed_sql_transaction
|
||||
25P03 E ERRCODE_IDLE_IN_TRANSACTION_SESSION_TIMEOUT idle_in_transaction_session_timeout
|
||||
|
||||
Section: Class 26 - Invalid SQL Statement Name
|
||||
|
||||
|
@ -30,6 +30,7 @@ volatile bool InterruptPending = false;
|
||||
volatile bool QueryCancelPending = false;
|
||||
volatile bool ProcDiePending = false;
|
||||
volatile bool ClientConnectionLost = false;
|
||||
volatile bool IdleInTransactionSessionTimeoutPending = false;
|
||||
volatile uint32 InterruptHoldoffCount = 0;
|
||||
volatile uint32 QueryCancelHoldoffCount = 0;
|
||||
volatile uint32 CritSectionCount = 0;
|
||||
|
@ -70,6 +70,7 @@ static void InitCommunication(void);
|
||||
static void ShutdownPostgres(int code, Datum arg);
|
||||
static void StatementTimeoutHandler(void);
|
||||
static void LockTimeoutHandler(void);
|
||||
static void IdleInTransactionSessionTimeoutHandler(void);
|
||||
static bool ThereIsAtLeastOneRole(void);
|
||||
static void process_startup_options(Port *port, bool am_superuser);
|
||||
static void process_settings(Oid databaseid, Oid roleid);
|
||||
@ -597,6 +598,8 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
|
||||
RegisterTimeout(DEADLOCK_TIMEOUT, CheckDeadLockAlert);
|
||||
RegisterTimeout(STATEMENT_TIMEOUT, StatementTimeoutHandler);
|
||||
RegisterTimeout(LOCK_TIMEOUT, LockTimeoutHandler);
|
||||
RegisterTimeout(IDLE_IN_TRANSACTION_SESSION_TIMEOUT,
|
||||
IdleInTransactionSessionTimeoutHandler);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1178,6 +1181,13 @@ LockTimeoutHandler(void)
|
||||
kill(MyProcPid, SIGINT);
|
||||
}
|
||||
|
||||
static void
|
||||
IdleInTransactionSessionTimeoutHandler(void)
|
||||
{
|
||||
IdleInTransactionSessionTimeoutPending = true;
|
||||
InterruptPending = true;
|
||||
SetLatch(MyLatch);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns true if at least one role is defined in this database cluster.
|
||||
|
@ -2065,6 +2065,17 @@ static struct config_int ConfigureNamesInt[] =
|
||||
NULL, NULL, NULL
|
||||
},
|
||||
|
||||
{
|
||||
{"idle_in_transaction_session_timeout", PGC_USERSET, CLIENT_CONN_STATEMENT,
|
||||
gettext_noop("Sets the maximum allowed duration of any idling transaction."),
|
||||
gettext_noop("A value of 0 turns off the timeout."),
|
||||
GUC_UNIT_MS
|
||||
},
|
||||
&IdleInTransactionSessionTimeout,
|
||||
0, 0, INT_MAX,
|
||||
NULL, NULL, NULL
|
||||
},
|
||||
|
||||
{
|
||||
{"vacuum_freeze_min_age", PGC_USERSET, CLIENT_CONN_STATEMENT,
|
||||
gettext_noop("Minimum age at which VACUUM should freeze a table row."),
|
||||
|
@ -529,6 +529,7 @@
|
||||
#session_replication_role = 'origin'
|
||||
#statement_timeout = 0 # in milliseconds, 0 is disabled
|
||||
#lock_timeout = 0 # in milliseconds, 0 is disabled
|
||||
#idle_in_transaction_session_timeout = 0 # in milliseconds, 0 is disabled
|
||||
#vacuum_freeze_min_age = 50000000
|
||||
#vacuum_freeze_table_age = 150000000
|
||||
#vacuum_multixact_freeze_min_age = 5000000
|
||||
|
Reference in New Issue
Block a user