Session Timeouts
Statements for management of timeouts of the current connection.
Statements for management of timeouts of the current connection.
SET SESSION IDLE TIMEOUT
Sets the session idle timeout
SET SESSION IDLE TIMEOUT value [<time-unit>] <time-unit> ::= MINUTE | HOUR | SECOND
Parameter | Description |
---|---|
value |
The timeout duration expressed in time-unit.A value of |
time-unit |
Time unit of the timeout.Defaults to |
The SET SESSION IDLE TIMEOUT
sets an idle timeout at connection level and takes effect immediately.The statement can run outside transaction control (without an active transaction).
Setting a value larger than configured for the database is allowed, but is effectively ignored, see also [fblangref50-management-session-timeout-effective].
The current timeout set for the session can be retrieved through RDB$GET_CONTEXT
, namespace SYSTEM
and variable SESSION_IDLE_TIMEOUT
.Information is also available from MON$ATTACHMENTS
:
MON$IDLE_TIMEOUT
Connection-level idle timeout in seconds;0
if timeout is not set.
MON$IDLE_TIMER
Idle timer expiration time;contains NULL
if an idle timeout was not set, or if a timer is not running.
Both RDB$GET_CONTEXT('SYSTEM', 'SESSION_IDLE_TIMEOUT')
and MON$ATTACHMENTS.MON$IDLE_TIMEOUT
report the idle timeout configured for the connection;they do not report the effective idle timeout.
The session idle timeout is reset when [fblangref50-management-session-reset-alter] is executed.
An idle session timeout allows a use connection to close automatically after a specified period of inactivity.A database administrator can use it to enforce closure of old connections that have become inactive, to reduce unnecessary consumption of resources.It can also be used by application and tools developers as an alternative to writing their own modules for controlling connection lifetime.
By default, the idle timeout is not enabled.No minimum or maximum limit is imposed, but a reasonably large period — such as a few hours — is recommended.
When the user API call leaves the engine (returns to the calling connection) a special idle timer associated with the current connection is started
When another user API call from that connection enters the engine, the idle timer is stopped and reset to zero
If the maximum idle time is exceeded, the engine immediately closes the connection in the same way as with asynchronous connection cancellation:
all active statements and cursors are closed
all active transactions are rolled back
The network connection remains open at this point, allowing the client application to get the exact error code on the next API call.The network connection will be closed on the server side, after an error is reported or in due course as a result of a network timeout from a client-side disconnection.
Note
|
Whenever a connection is cancelled, the next user API call returns the error
in addition to
|