Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: prefer_primary role config#1090

Open
stewart-glabs wants to merge 1 commit into
pgdogdev:main from
stewart-glabs:opt-in-replica-1046
Open

feat: prefer_primary role config #1090
stewart-glabs wants to merge 1 commit into
pgdogdev:main from
stewart-glabs:opt-in-replica-1046

Conversation

@stewart-glabs

@stewart-glabs stewart-glabs commented Jun 18, 2026
edited
Loading

Copy link
Copy Markdown

Fixes: #1046

Hey I work with @gl-jkeys who reported this ticket. So, same motivation. I want to add a read replica to my setup but make it opt-in for all queries. All queries go to primary, unless a comment or parameter suggests go to a replica.

@levkk suggested adding this to load_balancing_strategy however this setting is for how to pick a among replicas. Prefer primary is about the default role. I decided to use a separate configuration. Let me know if I'm off base here.

There are comprehensive tests. I also created an integration test, to be cautious and cover all bases.

I could not figure out how to get all integration tests to pass. There seems to be some dependencies missing that are not documented. What do you suggest about this?

PS I used ai to help me write, and review the code and to make sure I'm following the repo guidelines, style and convention.

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

levkk commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Ah yeah, my bad, I meant this: https://docs.pgdog.dev/configuration/pgdog.toml/general/#read_write_split

It's two lines above where you put the new config in pgdog-config/general.rs.

Copy link
Copy Markdown
Author

I thought that might be a good place to put this config, but it overshadows the behavior of include_primary_if_replica_banned. but if you think that's a better place, I can move it over.

levkk commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Should be fine. The two are super similar.

Copy link
Copy Markdown
Author

Ok cool, I'll make the change, probably early next week.

levkk reacted with thumbs up emoji

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Default load balancing to primary, require manual opt-in to route to replica

AltStyle によって変換されたページ (->オリジナル) /