-
Notifications
You must be signed in to change notification settings - Fork 55
Load balancer tweaks #180
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
Load balancer tweaks #180
Conversation
Bug ReportIncorrect quoting in Comments? Email us. Your free trial ends in 7 days. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
A set of updates to introduce and wire up a new read/write split configuration, improve Go simple protocol support, and expand test coverage.
- Add
read_write_split
config option to direct reads to primary or only replicas, and propagate it throughShard
andCluster
. - Refactor the admin
SET
command JSON parsing and include the newread_write_split
parameter. - Enhance Go integration tests: fix simple-protocol parameter handling and add new load-balancer tests.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
pgdog/src/net/parameter.rs | Return zero when no mutable params to avoid non-deterministic hash |
pgdog/src/net/messages/parameter_status.rs | Add standard_conforming_strings to default parameter status |
pgdog/src/config/mod.rs | Introduce ReadWriteSplit enum and default on General |
pgdog/src/backend/pool/shard.rs | Wire up rw_split field for read routing |
pgdog/src/backend/pool/replicas.rs | Clean up LoadBalancingStrategy imports and match arms |
pgdog/src/backend/pool/cluster.rs | Pass rw_split through cluster and shards |
pgdog/src/admin/set.rs | Extend SET command for read_write_split and JSON parsing |
integration/go/go_pgx/pg_tests_test.go | Fix simple protocol tests to use pgtype.Numeric and assert errors |
integration/go/go_pgx/load_balancer_test.go | Add end-to-end load balancer tests for read/write routing |
integration/go/go_pgx/go.mod | Bump various Go dependencies |
Comments suppressed due to low confidence (2)
pgdog/src/backend/pool/shard.rs:1
- Update this module-level doc comment to mention the new
rw_split
field and how it affects read routing behavior.
//! A shard is a collection of replicas and a primary.
pgdog/src/net/messages/parameter_status.rs:66
- Consider adding a unit test to verify that
standard_conforming_strings
appears in the defaultParameterStatus
list.
ParameterStatus {
#[serde(default)] | ||
pub read_write_strategy: ReadWriteStrategy, | ||
/// Read write split. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Expand this doc comment to explain the read_write_split
option semantics, e.g. whether the primary will be included or excluded for read queries.
/// Read write split. | |
/// Determines whether read queries are split from write queries. | |
/// When enabled, read queries may be routed to replicas, while write queries | |
/// are always routed to the primary database. The primary database may or may not | |
/// be included in the pool of nodes handling read queries, depending on the | |
/// specific configuration of the load balancing strategy. |
Copilot uses AI. Check for mistakes.
assert.NoError(t, err) | ||
defer conn.Close(context.Background()) | ||
|
||
rows, err := conn.Query(context.Background(), command, pgx.QueryExecModeSimpleProtocol) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an assert.NoError(t, err)
after this query to catch any errors during the admin command execution.
rows, err := conn.Query(context.Background(), command, pgx.QueryExecModeSimpleProtocol) | |
rows, err := conn.Query(context.Background(), command, pgx.QueryExecModeSimpleProtocol) | |
assert.NoError(t, err) |
Copilot uses AI. Check for mistakes.
Bug Report
Comments? Email us. Your free trial ends in 7 days. |
Bug Report
Comments? Email us. Your free trial ends in 7 days. |
Reviewing... 🍎 |
Description
read_write_split
configuration option. If set toinclude_primary
, the primary will be used for read queries. If set toexclude_primary
, only replicas will be used for read queries.EmptyQueryResponse
when client sends an empty query instead of an error.