long2ice / asynch

An asyncio ClickHouse Python Driver with native (TCP) interface support.
https://github.com/long2ice/asynch
Apache License 2.0
185 stars 43 forks source link

Connection failure leaves connection in an unusable state #82

Closed KPull closed 8 months ago

KPull commented 1 year ago

When a query eventually made its way into the ExecuteContext, if establishing the connection raised an error within the __aenter__ section, the connection was not being cleared up. Subsequent queries to the same connection (in a pool) would state that the "previous query should be finished first."

In this pull request, we attempt to disconnect the connection (essentially doing the same thing __aexit__ does), marking it as stale within its associated pool, if the connection fails to be establish.

Thanks to @borgmatthew as well who helped with identifying the issue.

itssimon commented 8 months ago

This could potentially fix https://github.com/long2ice/asynch/issues/93 too.

@long2ice mind taking a look at this?

long2ice commented 8 months ago

Thanks!

itssimon commented 8 months ago

Thanks for merging this! If you get a chance, would you mind creating a new release so we can benefit from this fix?

SaneBow commented 7 months ago

Nicely done! When can we have a new release available with this fix?

tiejunhu commented 7 months ago

Also expecting a new release for this fix