Add reader database cluster support#1417
Merged
shangyian merged 13 commits intoDataJunction:mainfrom Jun 21, 2025
Merged
Conversation
✅ Deploy Preview for thriving-cassata-78ae72 canceled.
|
agorajek
approved these changes
Jun 20, 2025
Member
agorajek
left a comment
There was a problem hiding this comment.
This is great. I think it will make our life better.
| getattr(defn, "operation", None) == OperationType.MUTATION | ||
| for defn in document.definitions | ||
| ) | ||
| except (GraphQLError, json.JSONDecodeError): |
Member
There was a problem hiding this comment.
Which of the above lines could trigger a GraphQLError ?
Collaborator
Author
There was a problem hiding this comment.
If the user inputs an invalid GraphQL query, then calling parse(query) could result in a GraphQLError.
|
|
||
| request._receive = receive # type: ignore | ||
|
|
||
| # Set up the database session based on whether it's a mutation or not |
|
|
||
| uri: str | ||
| pool_size: int = 20 | ||
| max_overflow: int = 20 |
Member
There was a problem hiding this comment.
I think we may still want to do -1 here for better sleep, no?
Collaborator
Author
There was a problem hiding this comment.
I changed this default to 100
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for using a reader database cluster (for the metadata database) for read-only operations, along with the default writer database cluster for all other operations. It improves scalability by offloading read traffic from the writer database, and it sets up support for read/write-aware session management across both REST and GraphQL interfaces. The reader cluster configs are optional, so users who don't have a read replica setup can just set the writer cluster.
GETrequest and route to the reader session.Settings
The settings for configuring a metadata database are now done via the nested
writer_dbandreader_dbfields, each with aDatabaseConfigmodel to support detailed connection settings likepool_size,max_overflow,connect_timeout, etc..envfiles should be updated to includeREADER_DB__URIand other nested settings if reader DB is used:Test Plan
Locally. Modified unit tests.
make checkpassesmake testshows 100% unit test coverageDeployment Plan
N/A