Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Not recovering from interrupted database connection while query is executing #93

Open
itssimon opened this issue Feb 29, 2024 · 6 comments

Comments

@itssimon
Copy link

If the connection to the ClickHouse database is interrupted while a query is executing, asynch is unable to recover from it. Any subsequent queries fail with the following exception:

ProgrammingError: some records have not been fetched. fetch the remaining records before executing the next query

It looks like this is because the is_query_executing attribute on the Connection remains True if the end of stream packet was missed.

I'm not even sure how to work around this. I've had to restart my application to recover from this, which is far from ideal.

@itssimon
Copy link
Author

This may also be related to #71

@tiejunhu
Copy link

still got this issue with latest master version

@boolka
Copy link
Contributor

boolka commented Jun 1, 2024

Got this error too. And think i get the point. When we was release the connection to the pool we need to call reset_state. Then connection will be passed to new consumer clean

@boolka
Copy link
Contributor

boolka commented Jun 1, 2024

@tiejunhu you can use my hint right now.

...
try:
    await cursor.execute(...)
except (SocketTimeoutError, NetworkError, gaierror):
    await conn.close()

You must close connection mannually on some network errors

@tiejunhu
Copy link

tiejunhu commented Jun 3, 2024

@tiejunhu you can use my hint right now.

...
try:
    await cursor.execute(...)
except (SocketTimeoutError, NetworkError, gaierror):
    await conn.close()

You must close connection mannually on some network errors

Thank you. I used a similar solution: close the connection before returning it to the pool, then retry the request.

@stankudrow
Copy link
Contributor

@tiejunhu , @itssimon , @boolka , hi. The Pool API changed, could you see if the reconnection is broken and the issue is back?

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

No branches or pull requests

4 participants