Skip to content
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

connection.query timeout do not work #167

Open
bubnenkoff opened this issue Sep 6, 2021 · 5 comments
Open

connection.query timeout do not work #167

bubnenkoff opened this issue Sep 6, 2021 · 5 comments

Comments

@bubnenkoff
Copy link

timeoutInSeconds in:

connection.query(sqlQuery, timeoutInSeconds: 3600)

do not work, My code is fall with timeout exception: Future not compeleted on long queries.

query timeouts sets only if they are setting on connection:

connection = PostgreSQLConnection('localhost', 5432, 'test', username: 'postgres', password: '12345', queryTimeoutInSeconds: 3600); // here 

But setting in connection.query are should work because:

timeoutInSeconds ??= _connection.queryTimeoutInSeconds;
@isoos
Copy link
Collaborator

isoos commented Sep 6, 2021

@bubnenkoff I don't see any trivial bug in the timeout parameter handling. Is there any way you could provide a reproducible code with the related DB setup?

@bubnenkoff
Copy link
Author

To reproduce you need set long timeout here:

connection = PostgreSQLConnection('localhost', 5432, 'test', username: 'postgres', password: '12345', queryTimeoutInSeconds: 3600); //  here

And to try run long request here:

connection.query(sqlQuery) // some long request that run for example 1 minute

In result you will get error:

Future not completed

See code here https://stackoverflow.com/questions/69041494/timeoutexception-on-query-cache-class
I found this issue when debug code example above.

@isoos
Copy link
Collaborator

isoos commented Sep 7, 2021

@bubnenkoff I'm not able to check this until later, to help the debugging, could you check it at what pg_sleep(<number>) will throw it an exception?
e.g. connection.query('SELECT 1, pg_sleep(2)') will likely succeed, how about connection.query('SELECT 1, pg_sleep(31)'), connection.query('SELECT 1, pg_sleep(61)'), connection.query('SELECT 1, pg_sleep(601)')?

@pedropastor
Copy link

I am having the same issue here. It breaks at 30 seconds.

TimeoutException after 0:00:30.000000: Future not completed

I am using both the timeoutInSeconds property, and as I am using futures, I am setting the timeout of the futures to 2 hours.

PostgreSQLConnection omtConnection = PostgreSQLConnection(
    config.omt_database!.host!, config.omt_database!.port!, config.omt_database!.databaseName!,
    username: config.omt_database!.username,
    password: config.omt_database!.password,
    useSSL: config.omt_database!.ssl,
    allowClearTextPassword: config.omt_database!.allowClearTextPassword,
    queryTimeoutInSeconds: 7200
);

var query = await omtConnection.query(getPatientsSql).timeout(Duration(hours: 2));

Everything is in a try catch block, it gets the error, but there is no stack information. Could it be related to any configuration in the server instead of the library?

@isoos if you point me to the right place of the library to narrow the search I can take a look

@isoos
Copy link
Collaborator

isoos commented Nov 30, 2023

@pedropastor: the package has moved to a new repository (and new versions). Please use that for further help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants