-
Notifications
You must be signed in to change notification settings - Fork 46
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
getting ClientConnectionClosedError randomly #287
Comments
This is likely NOT an issue of edgedb-python. 2 things in your application:
Please @ me only if you still have problems. |
I also tried using
using uvicorn in code
it works well but after some time it throughs error
|
I did some modifications according to https://github.com/fastapi-users/fastapi-users/discussions/663, currently it's working |
Good to know that it finally worked for you! For the loop binding issue, though it is usually not assumed in a way that the loop is only attached on the first |
I can confirm that after restarting instance (1.4+5ffe34b), python-edgedb does not reconnect automatically (edgedb.errors.ClientConnectionClosedError) I used this option :
It is a file watcher, it must always be up even if server is killing connections, so I had to use client.ensure_connected() |
That might be fixed in #349, could you please check again with the latest edgedb-python release please? |
Getting those a lot
|
@monomonedula, does your transaction take a lot of time? Transactions should not be left open while you're doing some slow work like downloading files, sending emails, or doing any sort of complex computation (generally any network tasks aren't great there). So if that work takes longer than EdgeDB's server-side timeout even occasionally, you'll get these errors. And it's better to split this transaction into two or more in this case. Also, presumably this exception is a result of other exception in the code, right? (because this is a rollback). Do you see that exception as part of traceback? (you don't have to show that to us, just we want to make sure that it's visible or we have to fix something to make it visible). That might help you figuring out what takes too much time. |
@tailhook , nope it doesn't do any long-running stuff. I'm getting those at different random places in code. It gets worse when there are more concurrent connections to the server (not the same database, but the EdgeDB server itself). Namely, when I switched from running tests in parallel to running them sequentially, it got much better. However, reducing load doesn't look like a solution, cause those are just normal tests, without any heavy-lifting. To give some more context: I'm also running this from inside docker-compose (the EdgeDB server, however, is on a standalone bare-metal deployment). The previous testing flow relied on creating and using a bunch of (4 at a time, 15 in total) temporary databases for test purposes and it seems like the EdgeDB server didn't handle it quite well, because tests failed every time due to ClientConnectionClosedError appearing at random places (without any specific pattern). Note that the load was pretty insignificant, every of the databases operated about < 30 objects. |
@tailhook here's a full traceback of a similar case (i lost the original one)
|
@fantix is it possible that connection is pre-emptied by the server because of too many connections or something? |
Also few notes for ourselves on how we can improve debugging of such cases after we figure out the real issue:
|
I just double checked the server code, I don't think we are closing any frontend connection actively other than killng the idle ones, even if there are a lot of connections on different databases. @monomonedula I assume you're running on a recent version of edgedb-python, right? So I think, except for reruning the test after we apply the suggestions from @tailhook for debugging on the client-side, it might also be worth looking at the server logs for anything interesting, and/or the server metrics like |
@fantix the link you gave for observability docs gives me 404 |
@monomonedula Sorry it was just moved to: https://www.edgedb.com/docs/reference/http#observability |
I'm too getting the |
There's the |
Thank you for your reply. I saw the method but the docs state something different: |
I am connecting to EdgeDB-SERVER in a GCP VM, using FASTAPI, code is given below
API code file and edgedb.toml are already in the same directory.
Whenever I send a request got my response
but randomly get ClientConnectionClosedError.
just before and after the error
conn.json(query)
in random_test.ipynb. It works most of the time but sometimes I got ClientConnectionClosedError@elprans @fantix @1st1 @tailhook
The text was updated successfully, but these errors were encountered: