#include <userver/storages/postgres/options.hpp>
A structure to control timeouts for PosrgreSQL queries
There are two parameters, execute and statement.
execute parameter controls the overall time the driver spends executing a query, that includes:
statement is rather straightforward, it's the PostgreSQL server-side parameter, and it controls the time the database backend can spend executing a single statement. It is very costly to change the statement timeout often, as it requires a roundtrip to the database to change the setting.
execute timeout should always be greater than the statement timeout! If the statement timeout happens to be greater than (or too close to) the execute timeout, the driver caps the effective statement timeout to be below the execute timeout (by a small margin when the execute timeout is large enough to spare it), so that the database gets a chance to cancel the statement on its own before the driver gives up waiting on the network.
In case of a timeout, either back-end or overall, the client gets an exception and the driver tries to clean up the connection for further reuse.
Definition at line 122 of file options.hpp.
Public Types | |
| enum class | PreparedStatementsOptionOverride { kNoOverride , kEnabled , kDisabled } |
Public Member Functions | |
| constexpr | CommandControl (TimeoutDuration network_timeout_ms, TimeoutDuration statement_timeout_ms, PreparedStatementsOptionOverride prepared_statements_enabled=PreparedStatementsOptionOverride::kNoOverride) |
| constexpr CommandControl | WithExecuteTimeout (TimeoutDuration n) const noexcept |
| constexpr CommandControl | WithStatementTimeout (TimeoutDuration s) const noexcept |
| bool | operator== (const CommandControl &rhs) const |
Public Attributes | |
| TimeoutDuration | network_timeout_ms {} |
| Overall timeout for a command being executed. | |
| TimeoutDuration | statement_timeout_ms {} |
| PostgreSQL server-side timeout. | |
| PreparedStatementsOptionOverride | prepared_statements_enabled {PreparedStatementsOptionOverride::kNoOverride} |
|
strong |
Definition at line 128 of file options.hpp.
|
inlineconstexpr |
Definition at line 132 of file options.hpp.
|
inline |
Definition at line 146 of file options.hpp.
|
inlineconstexprnoexcept |
Definition at line 142 of file options.hpp.
|
inlineconstexprnoexcept |
Definition at line 144 of file options.hpp.
| TimeoutDuration storages::postgres::CommandControl::network_timeout_ms {} |
Overall timeout for a command being executed.
Definition at line 124 of file options.hpp.
| PreparedStatementsOptionOverride storages::postgres::CommandControl::prepared_statements_enabled {PreparedStatementsOptionOverride::kNoOverride} |
Definition at line 130 of file options.hpp.
| TimeoutDuration storages::postgres::CommandControl::statement_timeout_ms {} |
PostgreSQL server-side timeout.
Definition at line 126 of file options.hpp.