Auto retry read-only queries outside transactions#243
Conversation
c32f253 to
afff2fb
Compare
edgedb/asyncio_con.py
Outdated
| # if the new impl fails to connect it will be in an inconsistent | ||
| # state. Use the old impl instead because it is in a consistent | ||
| # state. | ||
| self._inner._impl = impl |
There was a problem hiding this comment.
I'm not sure this is the best way to solve this 😕
There was a problem hiding this comment.
Call _AsyncIOConnectionImpl.terminate() and make sure the latter sets _protocol to None, which would make is_closed() return True and there should be no inconsistency downstream.
There was a problem hiding this comment.
What's the context of this? Github doesn't show previous commits any more.
The impl is designed as throw off thing (if connection is broken impl should be replaced with the new one). And is_closed() after connect fails must be invariant of the impl itself (if it's not, this is a bug, let's fix it).
And/or let's make a _AsyncIOConnectionImpl.connect a static function/constructor (because we can't do real constructors awaitable in python), so we don't even assign it to the connection if connection was not established.
There was a problem hiding this comment.
Well, I see, we don't ensure that all gone well on timeout or cancellation. Anyway, assigning to self._inner._impl after connection succeed looks like more robust solution.
There was a problem hiding this comment.
assigning to self._inner._impl after connection succeed looks like more robust solution.
changed
afff2fb to
1883585
Compare
68437c3 to
c89ca2f
Compare
|
@tailhook Paul, can you please take a look at this? I'll also do a review, but I'm less knowledgeable in this code now. |
tailhook
left a comment
There was a problem hiding this comment.
So the biggest question so far is why we have a separate capabilities cache? I think query cache should keep capabilities field around.
Do you foresee bigger capability cache than query cache?
I removed the capabilities cache and added capabilities to the query cache. |
tailhook
left a comment
There was a problem hiding this comment.
Let's fix reconnect condition. Other than that, looks good to me.
Changes ======= * support protocol version 0.12 (by @fmoor in 5ce52ed) * Update to protocol version 0.13 (by @1st1 in c690250, 8by @fmoor in 5ce52ed, by @jaclarke in a5a6218 for #253) * Lookup edgedb.toml recursively in parent directories (by @fmoor in d9a12b8 for #245) * Update connection parameter resolution (by @jaclarke in 085f574 for #241) * Implement EDGEDB_CLIENT_SECURITY (by @fmoor in ac46c37) * Add optional/required `query_single*` methods + rename `retrying_transaction` + update pool to `create_client` API (by @jaclarke in f2ae0d0 for #249) Deprecations ============ * Deprecate Pool.acquire() and Pool.release() (by @fmoor in 2d501e9 for #217) * Rename tls_verify_hostname to tls_security (by @fmoor in 2086b86) Fixes ===== * Do not attempt to del transport in connection_lost if it has been already (by @elprans in c719e79 for #215) * Retry if start() raises a retryable error (#228) (by @fantix in ffaae01 for #228) * Fix broken pool connection cleanup (by @fantix in be44959 for #222) * Fix deprecated usage of SSLContext (#231) (by @elprans in f73f999 for #231) * Bugfix: _borrowed_for is now set entering a transaction (#233) (by @fantix in bf763d1 for #233) * Send zero arguments as zero-length bytes in proto 0.12 (#238) (by @tailhook in f51dd51 for #238) * Fix retrying_transaction() on network errors (by @fmoor in cc001e6) * Fix connection and retry options on AsyncIOPool (#237) (by @tailhook in 44e279f for #237) * Auto retry read-only queries outside transactions (#243) (by @fmoor in 76bb586 for #243) * Fix `credentials_file` argument typo on `async_connect` (#252) (by @mkniewallner in b21b70a for #252)
Changes ======= * support protocol version 0.12 (by @fmoor in 5ce52ed) * Update to protocol version 0.13 (by @1st1 in c690250, 8by @fmoor in 5ce52ed, by @jaclarke in a5a6218 for #253) * Lookup `edgedb.toml` recursively in parent directories (by @fmoor in d9a12b8 for #245) * Update connection parameter resolution (by @jaclarke in 085f574 for #241) * Implement `EDGEDB_CLIENT_SECURITY` (by @fmoor in ac46c37) * Add optional/required `query_single*` methods + rename `retrying_transaction` + update pool to `create_client` API (by @jaclarke in f2ae0d0 for #249) Deprecations ============ * Deprecate `Pool.acquire()` and `Pool.release()` (by @fmoor in 2d501e9 for #217) * Rename `tls_verify_hostname` to `tls_security` (by @fmoor in 2086b86) Fixes ===== * Do not attempt to del transport in `connection_lost` if it has been already (by @elprans in c719e79 for #215) * Retry if `start()` raises a retryable error (#228) (by @fantix in ffaae01 for #228) * Fix broken pool connection cleanup (by @fantix in be44959 for #222) * Fix deprecated usage of `SSLContext` (#231) (by @elprans in f73f999 for #231) * Bugfix: `_borrowed_for` is now set entering a transaction (#233) (by @fantix in bf763d1 for #233) * Send zero arguments as zero-length bytes in proto 0.12 (#238) (by @tailhook in f51dd51 for #238) * Fix `retrying_transaction()` on network errors (by @fmoor in cc001e6) * Fix connection and retry options on `AsyncIOPool` (#237) (by @tailhook in 44e279f for #237) * Auto retry read-only queries outside transactions (#243) (by @fmoor in 76bb586 for #243) * Fix `credentials_file` argument typo on `async_connect` (#252) (by @mkniewallner in b21b70a for #252)
Changes ======= * support protocol version 0.12 (by @fmoor in 5ce52ed) * Update to protocol version 0.13 (by @1st1 in c690250, 8by @fmoor in 5ce52ed, by @jaclarke in a5a6218 for #253) * Lookup `edgedb.toml` recursively in parent directories (by @fmoor in d9a12b8 for #245) * Update connection parameter resolution (by @jaclarke in 085f574 for #241) * Implement `EDGEDB_CLIENT_SECURITY` (by @fmoor in ac46c37) * Add optional/required `query_single*` methods + rename `retrying_transaction` + update pool to `create_client` API (by @jaclarke in f2ae0d0 for #249) Deprecations ============ * Deprecate `Pool.acquire()` and `Pool.release()` (by @fmoor in 2d501e9 for #217) * Rename `tls_verify_hostname` to `tls_security` (by @fmoor in 2086b86) Fixes ===== * Do not attempt to del transport in `connection_lost` if it has been already (by @elprans in c719e79 for #215) * Retry if `start()` raises a retryable error (#228) (by @fantix in ffaae01 for #228) * Fix broken pool connection cleanup (by @fantix in be44959 for #222) * Fix deprecated usage of `SSLContext` (#231) (by @elprans in f73f999 for #231) * Bugfix: `_borrowed_for` is now set entering a transaction (#233) (by @fantix in bf763d1 for #233) * Send zero arguments as zero-length bytes in proto 0.12 (#238) (by @tailhook in f51dd51 for #238) * Fix `retrying_transaction()` on network errors (by @fmoor in cc001e6) * Fix connection and retry options on `AsyncIOPool` (#237) (by @tailhook in 44e279f for #237) * Auto retry read-only queries outside transactions (#243) (by @fmoor in 76bb586 for #243) * Fix `credentials_file` argument typo on `async_connect` (#252) (by @mkniewallner in b21b70a for #252)
Changes ======= * support protocol version 0.12 (by @fmoor in 5ce52ed) * Update to protocol version 0.13 (by @1st1 in c690250, 8by @fmoor in 5ce52ed, by @jaclarke in a5a6218 for #253) * Lookup `edgedb.toml` recursively in parent directories (by @fmoor in d9a12b8 for #245) * Update connection parameter resolution (by @jaclarke in 085f574 for #241) * Implement `EDGEDB_CLIENT_SECURITY` (by @fmoor in ac46c37) * Add optional/required `query_single*` methods + rename `retrying_transaction` + update pool to `create_client` API (by @jaclarke in f2ae0d0 for #249) Deprecations ============ * Deprecate `Pool.acquire()` and `Pool.release()` (by @fmoor in 2d501e9 for #217) * Rename `tls_verify_hostname` to `tls_security` (by @fmoor in 2086b86) Fixes ===== * Do not attempt to del transport in `connection_lost` if it has been already (by @elprans in c719e79 for #215) * Retry if `start()` raises a retryable error (#228) (by @fantix in ffaae01 for #228) * Fix broken pool connection cleanup (by @fantix in be44959 for #222) * Fix deprecated usage of `SSLContext` (#231) (by @elprans in f73f999 for #231) * Bugfix: `_borrowed_for` is now set entering a transaction (#233) (by @fantix in bf763d1 for #233) * Send zero arguments as zero-length bytes in proto 0.12 (#238) (by @tailhook in f51dd51 for #238) * Fix `retrying_transaction()` on network errors (by @fmoor in cc001e6) * Fix connection and retry options on `AsyncIOPool` (#237) (by @tailhook in 44e279f for #237) * Auto retry read-only queries outside transactions (#243) (by @fmoor in 76bb586 for #243) * Fix `credentials_file` argument typo on `async_connect` (#252) (by @mkniewallner in b21b70a for #252)
fixes #239