-
Notifications
You must be signed in to change notification settings - Fork 3.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sql: implement idle_in_transaction_session_timeout #5924
Comments
@archiecobbs Looks like postgres only supports |
@petermattis Having Right now the amount of time you could get stuck is (theoretically) unbounded, and this would fix that. |
Yes, |
FWIW, a unit test I'm running in Java against Cockroach hangs forever. This is the situation that motivated creating this issue. Why this test is hanging whereas it doesn't hang with other databases (e.g., MySQL) is a related question. Here's the stack trace of the thread that's stuck forever waiting for some response:
Sorry I don't have more debug info (I'm go-ignorant). Let me know if you want instructions on how to reproduce. |
Which version of cockroachdb are you running? We had a deadlock in last week's beta that will be fixed in the new version being released today. If that doesn't fix it, please file a separate issue with more information about what exactly you're trying to do, and any relevant bits of the server logs (by default in |
Version I have is:
I'll upgrade tomorrow, try again, and then update this issue. Thanks. |
I'm getting the same behavior with this version:
Two different tests are hanging. The first one hangs sometimes, the second one hangs always. Test setup:
Test 1: Open two transactions T1 and T2 T1: At this point T2 hangs - sometimes:
Test 2: Open 10 transactions T1, T2, ..., T10 T1: Test hangs at this point:
To run these tests yourself:
|
FYI, test produces same hanging behavior with beta-20160519. |
Created separate issue #7556 for the deadlock problem. |
Some more related comments in #7556 (comment) |
@petermattis should this be 1.0? Could you assign if so, remove the 1.0 milestone otherwise. |
Given our plumbing of context everywhere, this seems relatively straightforward to do on the surface. |
Because this feature is not already on our 1.1 roadmap, I'm moving this to "Later." |
This looks like a good starter project. |
This new session variable has identical semantics to the `statement_timeout` variable in Postgres, but also allows you to pass an interval as an argument. Passing an integer is also allowed in order to be compatible with Postgres. Fixes cockroachdb#20789. Touches cockroachdb#5924. Release note (sql change): Add `statement_timeout` session variable.
What is the incremental work left on this ticket after implementing |
@andreimatei to comment and close |
Statement timeouts and transaction timeouts are different; adding statement_timeout doesn't address the need for a transaction timeout. This transaction is primarily about transaction timeouts (perhaps using the postgres variable |
We now have a Confusingly, this variable is only implemented now as a no-op: root@127.0.0.1:59509/movr> SET idle_in_transaction_session_timeout = 10;
ERROR: invalid value for parameter "idle_in_transaction_session_timeout": "10"
SQLSTATE: 22023
DETAIL: this parameter is currently recognized only for compatibility and has no effect in CockroachDB.
HINT: Available values: 0 Despite showing up in SHOW ALL: variable | value
------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------
idle_in_session_timeout | 0
idle_in_transaction_session_timeout | 0 |
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:
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
The text was updated successfully, but these errors were encountered: