-
Notifications
You must be signed in to change notification settings - Fork 37
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
Timeout is not applied to the running query when transaction is involved. #344
Comments
@JuanLuisNL: Thanks for reporting this! Is there any chance that you can provide a minimal working example, using the dockerized test setup like this: https://github.com/isoos/postgresql-dart/blob/master/test/decode_test.dart#L328-L343 ? |
Sorry for my ignorance, I don't understand what you mean). Future lockRow(String cTabla, int id) async { |
Can I provide more information to solve the problem? |
@JuanLuisNL: I was mostly offline for the past two weeks, slowly getting back to these issues. The most helpful thing would be a minimal test in our test suite that fails (as a PR or a comment here), along the lines of:
The test suite will create a local postgres instance inside a docker image, and we can run it repeatedly in CI after fixing the underlying issue. |
Sorry, I'm not familiar with that kind of testing and I don't really know what to do ( What I do to test is from "pgadmin" run this : Then from my code I run: The program stops for about 1 minute, not 5 seconds.. I'm sorry I can't do more to explain myself ... |
@JuanLuisNL: Yeah, that's a helpful description. I may need some time to look into it, but now I understand it better. |
Thank you very much |
@JuanLuisNL: I was able to create a small reproduction of the issue as a regular test: #362 Unfortunately I don't see a quick fix for it, as it will require the cancellation of the currently running query with the coordination of a client-side timer. If somebody wants to dig into it, I imagine it something like:
|
We should also consider to use the |
Thank you very much István I did the ‘statement_timeout’ (per-query + reset if needed) and it works perfectly. As before I check if there is a lock set, that command will be executed very few times, so it's not a problem to do it that way. I appreciate your help |
Could you please elaborate if this is a DB lock or something in your app? I am starting to think that |
There isn't, as sqlite3 doesn't have an obvious way to set timeouts (it's possible because you can inject a callback that it invokes once in a while, but nothing official like with postgres).
I think this is a reasonable approach 👍 We might want to suggest setting a statement timeout on the connection primarily, only altering it for rare queries that really need different values. Otherwise we'd end up sending a lot of variable changes as the effective timeout for every query jumps around. |
We already have |
@JuanLuisNL: Please give me more details on how you made the transaction + the session_timeout work. I have a pending work in #363 that is not really working yet, but I may be overlooking something. |
I was able to get that specific test working, but I'd consider that solution a hack (and other timeout tests are failing). I will need to look into this a bit more to figure out a better way handle it. |
@JuanLuisNL: after a couple of PRs #380 is now passing on the test use case you've described. I've released |
Hello
|
Hm, are you doing something conceptually different that the test case here? |
I do exactly the same:
|
Yeah, that's the same, barring the ssl mode, but if I change the test it is still working. Are you running it from a console app? Is there any zone-handler that catches and swallows unhandled exceptions? |
I run it in flutter desktop for windows and yes, I have ‘runZonedGuarded’, I have also tried try catch. |
The current implementation may have an exception emitted from the timeout timer, which is not (yet) exposed through the |
yes, the programme stops, there is no error |
@JuanLuisNL: Could you please try to set my debug branch as your dependency and give it a try? https://github.com/isoos/postgresql-dart/tree/debug I have added a few extra checks and prints to see what's happening. As described here: https://dart.dev/tools/pub/dependencies#git-packages |
Thanks for the patience and the debugging! However, this is still not there yet: I do have this statement in the Timer:
I would like to see that somewhere, and also a corresponding completed printout. If this is absent, it is very likely that the uncaught exception from the timer is also swallowed by some top-level catch-all zone. As an alternative, could you please try to just run it from a local dart app, something along the line of the test, just within a simple main method? |
Not sure what we are looking at here: did it reach the first print? How about the second? or any exception? |
Now, yes, clean up the project. Maybe I ran the previous version before. |
I'm glad it is working!
Ouch, so this localized message will screw up exception transformations like this: |
Very kind, thank you again! |
If I run this from a computer:
execute(‘BEGIN’)
String cSQL = ‘SELECT * FROM customers WHERE id = 1635 FOR UPDATE’
execute(cSQL, queryMode: QueryMode.extended, timeout: const Duration(seconds: 5))
.....
and from another order I execute the same code to check the lock, although I have a timeout of 5 seconds, the error takes about 1 minute.
SERVER: statement_timeout = 0
What could be happening?
The text was updated successfully, but these errors were encountered: