Skip to content

sql: implement idle_in_transaction_session_timeout #5924

@archiecobbs

Description

@archiecobbs

For any application performing transactions, it's important that the application be able to configure an explicit limit on how long a transaction thread will block trying to perform the transaction.

Enhancement Request: Add support for an SQL variable like this:

SET transaction_timeout = 2500

This will then cause an immediate retry exception (and transaction rollback) if any statement (or the overall transaction?) takes longer than 2500 milliseconds to complete.

It is important that the corresponding SQLError has either existing the "retry" error code ("CR000") or a new, well-documented timeout error code; the application will likely end-up treating these in the same way as retry errors.

Note that this is only a partial solution to the overall problem of controlling timeouts: there also needs to be a timeout configured on the client's PostgreSQL driver itself (for example, there could be a network hang between the local client and the CockroachDB node it's talking to via JDBC). This part of the problem is not within CockroachDB's realm of control, however, it would be nice and helpful for SQL users if CockroachDB also provided a clearly documented way to configure the local PostgreSQL driver timeout. E.g., there are some timeout parameters shown here.

Thanks.

Discussion thread: https://groups.google.com/forum/#!topic/cockroach-db/FpBemFJM4w8

Metadata

Metadata

Assignees

Labels

A-sql-executorSQL txn logicC-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)O-communityOriginated from the community

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions