-
Notifications
You must be signed in to change notification settings - Fork 3
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
Review db connections in API and background tasks #649
Comments
For the record: the following test passes, which (unexpectedly) shows that the async def test_sync_db_close(db_sync, db):
"""
This test is used as an example to show that the commit() method is not
enough to fully close a db_sync connection.
"""
from fractal_server.app.models.task import Task
from fractal_server.app.db import DB
db.add(
Task(
name="mytask",
input_type="image",
output_type="zarr",
command="cmd",
source="/source",
)
)
await db.commit()
await db.close()
new_db_sync = next(DB.get_sync_db())
task = new_db_sync.get(Task, 1)
debug(task)
task.name = "new_name"
new_db_sync.merge(task)
new_db_sync.commit()
debug(new_db_sync.identity_map)
assert new_db_sync.identity_map
new_db_sync.close()
debug(new_db_sync.identity_map)
assert not new_db_sync.identity_map |
Also, for the record:
|
Ref (related to "ghost" connections that seems to always be present): |
Recap of current status:
Nothing left to do in this issue, closing. |
Thanks for the great overview & the deep dive into this @tcompa ! Very good to hear and additional motivation for me to try & get the postgres setup running at FMI :) |
Ref #647
db_sync.commit
statement before the long workflow execution is not fully closing the session. This is visible via the presence of a non-trivial identity map. Adding an explicitdb_sync.close
seems to work, and then the session is re-opened uponmerge
. Shall we move towards context-managers? Probably that's the best way to go.Point 1 is a bug. Point 2 is a bit unclear, but for sure it requires some update.
The text was updated successfully, but these errors were encountered: