Skip to content

Fix concurrent session crash in GraphQL multi-field queries#2024

Merged
shangyian merged 1 commit intoDataJunction:mainfrom
shangyian:fix-graphql-concurrent
Apr 19, 2026
Merged

Fix concurrent session crash in GraphQL multi-field queries#2024
shangyian merged 1 commit intoDataJunction:mainfrom
shangyian:fix-graphql-concurrent

Conversation

@shangyian
Copy link
Copy Markdown
Collaborator

Summary

GraphQL resolvers shared a single AsyncSession via info.context["session"]. Strawberry resolves top-level fields concurrently, so a query like { findNodes(...) searchTags(...) } would fire two await session.execute() calls on the same session simultaneously, causing an InvalidCachedStatementError like "concurrent operations are not permitted". This was a latent bug in all resolvers and could be triggered by a client sending multiple top-level fields in one request.

Each resolver now creates its own session via resolver_session(info), a new helper in that wraps session_context(request). DataLoaders already used independent sessions and are unaffected.

Test Plan

  • PR has an associated issue: #
  • make check passes
  • make test shows 100% unit test coverage

Deployment Plan

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 19, 2026

Deploy Preview for thriving-cassata-78ae72 canceled.

Name Link
🔨 Latest commit 3ac1a54
🔍 Latest deploy log https://app.netlify.com/projects/thriving-cassata-78ae72/deploys/69e4930ae8b06c000837ea80

@shangyian shangyian marked this pull request as ready for review April 19, 2026 08:52
@shangyian shangyian merged commit 2a5bf9d into DataJunction:main Apr 19, 2026
17 checks passed
@shangyian shangyian deleted the fix-graphql-concurrent branch April 19, 2026 08:53
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.

1 participant