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

Add query.usingMaster() to explicitly choose master data source #3125

Merged
merged 4 commits into from
Jul 3, 2023

Conversation

rbygrave
Copy link
Member

@rbygrave rbygrave commented Jul 3, 2023

When we have a read replica with potential for replication lag, and config a read only DataSource to use that read replica, by default a query executed without a current transaction will use the read replica.

We specify usingMaster() when we explicitly want to execute a query and use the master data source.

When we have a read replica with potential for replication lag, and config a read only DataSource to use that read replica, by default a query executed without a current transaction will use the read replica.

We specify usingMaster() when we explicitly want to execute a query and use the master data source.
@rbygrave rbygrave self-assigned this Jul 3, 2023
…ommit()

Originally, ImplicitReadOnlyTransaction was built to support read-only DataSource where the connections are using autoCommit true. This change modified ImplicitReadOnlyTransaction to also support use with the main DataSource where the connection are not using autoCommit true.

This is also now needed for the query.usingMaster() case where we have an implicit read only transaction but use the main DataSource with underlying connection requiring explicit commit() at the end of the transaction.
@rbygrave rbygrave added this to the 13.20.1 milestone Jul 3, 2023
@rbygrave rbygrave merged commit bb02d74 into master Jul 3, 2023
2 checks passed
@rbygrave rbygrave deleted the feature/query-usingMaster branch July 3, 2023 10:48
rbygrave added a commit that referenced this pull request Jul 3, 2023
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.

None yet

1 participant