-
Notifications
You must be signed in to change notification settings - Fork 867
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
remove receiving EOF from backend after cancel … #1641
Conversation
…tocol the server closes the connection once cancel is sent (connection reset exception is always thrown) quote "The server will process this [cancel] request and then close the connection. For security reasons, no direct reply is made to the cancel request message." https://www.postgresql.org/docs/current/protocol-flow.html
@mahmoudbahaa , this change breaks Can you please elaborate on why do you need the change? TL;DR: I'm reverting this change (and aaccf43) in 48 hours unless there's a clarification. Just in case: statementWithTimeout.setQueryTimeoutMs(1);
try { statementWithTimeout.executeQuery("select 1"); } catch (Throwable ignored) { }
statement.executeQuery("select 1"); Of course, Unfortunately, we don't have query identifier in PostgreSQL, so the only thing we can do is to set
We don't really want the following:
So if you ever use If you want to quickly shut down the connection, then you need to call |
@vlsi ok i got your point. but since
so the cancel request never receive any EOF and even if it does it doesn't mean the request was processed. to actually make sure the request was processed we need to wait for the connection to be closed. NOT for a reply to the cancel request. that is the correct indication of whether the cancel request was processed. so if you want to you can wait for |
backend code does the following:
Apparently, if pgjdbc detects EOF, it means the backend has processed the request. |
never mind I got what you mean since sending new query reset cancelRequested to false so we will be sure that cancelRequested will not affect the next query since this way we are sure that cancelRequested is set to true before the query is sent setting it back to false. so yes I think you should go ahead with the revert |
although adding a comment to the revert so everybody would understand why it is there and don't remove it by mistake it in the future would also be a good idea |
since according to protocol the server closes the connection immediately once cancel is sent (connection reset exception is always thrown) and that was slowing the close considerably (the 1000 close used to take 22 seconds because of this now it takes 1-1.5 seconds on my machine. I also changed the timeout of the test from 20 seconds to 2 seconds.
quote:
." https://www.postgresql.org/docs/current/protocol-flow.html
All Submissions:
New Feature Submissions:
Changes to Existing Features: