-
Notifications
You must be signed in to change notification settings - Fork 177
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
No response from the database when same SQL statement is sent to the database multiple times #658
Comments
You can enable debug logging to see at which point the statement gets stuck. This should help to identify the cause. |
Hope this is going to help:
|
Alright, the database reports a query timeout after 60 seconds. With you receiving an exception that propagates the timeout, everything is fine here and I'm not sure what else the driver could do. |
It appears that we had the same problem as you. It seems to be the same solution you were offering, but I have confirmed that adding a condition, e.g. @spc16670 |
When you serialize to a pure string the values you are passing make the SQL query unique enough from the perspective of the database - so it is another way to apply the same workaround. I am still not sure where the fix to this is supposed to be applied - the database? |
Sorry if I have misunderstood something. What I have tried is to execute a query with embedded parameters (without using a prepared statement) directly against However, I have only been able to reproduce it using production code, and I am sorry that I cannot publish a sample. |
I have tried the check by adding r2dbc-postgresql/src/main/java/io/r2dbc/postgresql/client/ReactorNettyClient.java Line 176 in a13c02c When hanging, |
Perhaps it is related to this: https://stackoverflow.com/questions/53295322/postgresql-statement-timeout |
Current Behavior
We decided to use r2dbc in our new new project what required porting some of our existing blocking code onto a reactive stack. This included paging functions - these were rewritten to preserve the semantics from the traditional model. Instead of creating Fluxes and reading items to page limit, the SQL query is written to use LIMIT with OFFSET.
We noticed that that the query would always time out while fetching the 7th page.
Solution
It turned out that 'salting' the SQL statement to make it unique solves the issue. As a workaround we wrap all queries we send to the database into a sub query:
The above fixes the problem - all our queries now return without timeout as expected, even if 10s of pages are involved.
This however seriously undermined our confidence in our new stack. We cannot tell for sure if the problem is with the driver, the DatabaseClient Spring class, or the database. The solution to the problem we found was more of a luck rather than anything else, neither the driver nor the database would offer any clues as to which end was causing the behaviour. We have taken a guess that the database is responding with data but the driver fails to notice the response therefore triggering the statement timeout exception.
I will try to rewrite our code to provide a reproduction here when I have more time.
The text was updated successfully, but these errors were encountered: