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

Async psycopg driver throws errors when sqlalchemy lazy loads relationships #20

Closed
Makcal opened this issue Mar 3, 2024 · 3 comments
Closed
Labels
bug Something isn't working

Comments

@Makcal
Copy link
Member

Makcal commented Mar 3, 2024

Describe the bug

Async psycopg driver throws errors (greenlet has not been spawned) when sqlalchemy lazy loads relationships.

Possible affect:

I suppose that due to sa_relationship_kwargs={"lazy": "joined"} used now large and redundant amounts of data are loaded through relations (i.e. user -> invitation -> other user -> other invitation -> ...).

Known solutions:

  1. Make DB connections synchronous
  2. Prevent relationships to be lazy loaded by loading it manually or at the moment when a main object is loaded
    The very last option is chosen

Reproduction

  1. Remove sa_relationship_kwargs={"lazy": "joined"} from relationship definitions
  2. Run tests

Screenshots / Additional context

Some info

@Makcal Makcal added the bug Something isn't working label Mar 3, 2024
@Makcal Makcal added this to InNoHassle Mar 3, 2024
@github-project-automation github-project-automation bot moved this to 📋 Backlog in InNoHassle Mar 3, 2024
@Makcal Makcal moved this from 📋 Backlog to 🏗 In progress in InNoHassle Mar 3, 2024
@Makcal Makcal moved this from 🏗 In progress to 📋 Backlog in InNoHassle Mar 3, 2024
@Makcal Makcal pinned this issue Mar 3, 2024
@Makcal
Copy link
Member Author

Makcal commented Mar 10, 2024

Should be rechecked after e9bdf66

Makcal added a commit that referenced this issue May 23, 2024
@Makcal
Copy link
Member Author

Makcal commented May 23, 2024

All relationships are removed out of harm's way. Honestly, they are nightmare. I don't know how to make them work properly (without tons of extra methods or attributes) with asynchronous DB drivers.
Solved in e6fa5bb

@Makcal Makcal closed this as completed May 23, 2024
@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in InNoHassle May 23, 2024
@Makcal
Copy link
Member Author

Makcal commented May 23, 2024

Maybe use joinedload()/selectinload() to request only specified relationships (reference). Maybe in future...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Archived in project
Development

No branches or pull requests

1 participant