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

Implementation refactor for Client-based interface #286

Merged
merged 26 commits into from
Feb 2, 2022

Conversation

fantix
Copy link
Member

@fantix fantix commented Jan 5, 2022

Review note: there is one merge commit "Partially revert ..." in this branch to reserve git history; use this link to see the merged diff.

  • Merge Connection with RawConnection
  • Fix tests to use client
  • Add previously-deleted tests
  • Complete timeout implementation and add more timeout tests (will be done in a new PR)
  • Drop edgedb.connect() and replace with a single-connection Client
  • Extract base class for Client, and further remove redundant code
  • Extract redundant code from transactions and only use _iter_coroutine() on top level
  • Review how pool is implemented, simplify if possible

edgedb-python-pool drawio

fantix added 8 commits January 5, 2022 10:14
This fixes the case when EdgeDB client is global and used in an
``asyncio.run`` call, the client uses a wrong loop.
Before this fix, the client allows multiple concurrent first
connections. This wasn't an issue because the _working_addr is always
the same among the concurrent first connections. However, it was not
clear which address shall win the race and be used for upcoming
connections when multiple addresses are used in the future. After this
fix, all concurrent first connection attempts will be serialized, the
address from the first successful connection will be used for following
connections. Concurrency will be resumed as soon as the address is
found, including the previously-serialized pending "first" connections.
Switch to using a single ``_connect_args`` dict to store all connect
arguments, which is also consistent with
``con_utils.parse_connect_arguments()``.
@fantix fantix force-pushed the refactor branch 4 times, most recently from 0efc2e4 to 93516b9 Compare January 7, 2022 15:05
Also added blocking pool (single-connection only), and fixed all tests
to use client instead of connection.
@fantix fantix changed the title [WIP] Refactor [WIP] Implementation refactor for Client-based interface Jan 7, 2022
@fantix fantix force-pushed the refactor branch 2 times, most recently from 88fe5ac to d5133d1 Compare January 11, 2022 22:05
Also close blocking client socket on disconnect, and fix tests
Also extracted most duplicate code, and dropped outdated code
In this case, concurrent close() and connect() are racing. If connect()
wins, close() was releasing the connection by mistake.
@fantix fantix changed the title [WIP] Implementation refactor for Client-based interface Implementation refactor for Client-based interface Jan 18, 2022
@fantix fantix marked this pull request as ready for review January 18, 2022 21:13
@fantix fantix requested review from 1st1 and elprans January 18, 2022 22:09
Copy link
Member

@elprans elprans left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impressive work, Fantix! A net reduction of ~700 lines in the implementation despite the addition of a thread-safe concurrent blocking pool. I especially like the cleanup in the transaction implementation.

edgedb/base_client.py Outdated Show resolved Hide resolved
edgedb/blocking_client.py Outdated Show resolved Hide resolved
edgedb/base_client.py Outdated Show resolved Hide resolved
edgedb/base_client.py Outdated Show resolved Hide resolved
edgedb/__init__.py Outdated Show resolved Hide resolved
edgedb/blocking_client.py Outdated Show resolved Hide resolved
tests/test_async_retry.py Outdated Show resolved Hide resolved
Copy link
Member

@1st1 1st1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Epic work, Fantix. I think this is ready to land.

@fantix fantix merged commit 33175f1 into edgedb:master Feb 2, 2022
elprans added a commit that referenced this pull request Feb 10, 2022
Changes
=======

* Implementation refactor for Client-based interface
  (by @fantix in 33175f1 for #286)
@elprans elprans mentioned this pull request Feb 10, 2022
msullivan added a commit that referenced this pull request Feb 18, 2022
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

Successfully merging this pull request may close these issues.

3 participants