RSCBC-302: Replica read from specific replica - #503
Open
Matt-Woz wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
It introduces new public APIs where at least one is missing rustdoc and one new core options type doesn’t follow established option-type attributes, creating avoidable public-API inconsistency.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds end-to-end support for reading documents from a specific replica, including an SDK-facing strategy API, new result/options types, core KV/memdx plumbing, retry/wrap behavior, and performer/protocol integrations.
Changes:
- Introduces
Collection::get_replicawithGetReplicaStrategy/ReplicaIndexandGetReplicaResult/GetReplicaOptionsin the SDK layer. - Implements replica routing + wrap logic in
couchbase-core, including new memdx opcode/request/response and helper logic to advance across replicas. - Extends error modeling and performer mappings to represent replica-specific error cases and capabilities.
File summaries
| File | Description |
|---|---|
| sdk/couchbase/src/results/kv_results.rs | Adds GetReplicaResult SDK result type with decoding helpers and core-result conversion. |
| sdk/couchbase/src/options/kv_options.rs | Adds GetReplicaOptions for SDK-level configuration (retry strategy). |
| sdk/couchbase/src/lib.rs | Exposes get_replica_strategy module publicly. |
| sdk/couchbase/src/get_replica_strategy.rs | Adds public strategy API for selecting a replica by index (with optional wrapping). |
| sdk/couchbase/src/error.rs | Adds replica-specific error kinds and maps core errors into SDK errors (including replica-not-found). |
| sdk/couchbase/src/collection_crud.rs | Adds Collection::get_replica operation wired through tracing + core client. |
| sdk/couchbase/src/clients/couchbase_core_kv_client.rs | Translates SDK strategy/options into core agent call and converts the result type. |
| sdk/couchbase/src/clients/core_kv_client.rs | Exposes get_replica across backend variants (core + couchbase2 stub). |
| sdk/couchbase-core/src/vbucketrouter.rs | Propagates replica index/topology info into NoServerAssigned and adds wrap test coverage. |
| sdk/couchbase-core/src/vbucketmap.rs | Fixes replica index bounds check and adds tests for valid/invalid positions. |
| sdk/couchbase-core/src/retry.rs | Refactors retry decision logic into reusable retry_after_error helper. |
| sdk/couchbase-core/src/results/kv.rs | Adds GetReplicaResult at core results level. |
| sdk/couchbase-core/src/replica_helpers.rs | Adds wrap/advance logic for replica selection and comprehensive unit tests. |
| sdk/couchbase-core/src/options/crud.rs | Adds core GetReplicaOptions and GetReplicaStrategy used by the agent/crudcomponent. |
| sdk/couchbase-core/src/memdx/response.rs | Adds GetReplicaResponse decoding and tracing attributes. |
| sdk/couchbase-core/src/memdx/request.rs | Adds GetReplicaRequest request model. |
| sdk/couchbase-core/src/memdx/ops_crud.rs | Implements memdx CRUD operation for GetReplica. |
| sdk/couchbase-core/src/memdx/opcode.rs | Adds memdx opcode mapping for GetReplica (0x83). |
| sdk/couchbase-core/src/lib.rs | Registers internal replica_helpers module. |
| sdk/couchbase-core/src/kvclient_ops.rs | Adds get_replica to KV client ops trait and implementation. |
| sdk/couchbase-core/src/error.rs | Extends NoServerAssigned context and tracks is_replica on memdx errors. |
| sdk/couchbase-core/src/crudcomponent.rs | Implements core get_replica orchestration, routing, wrapping, and retry integration. |
| sdk/couchbase-core/src/agent_ops.rs | Exposes Agent::get_replica operation with optional top-level spans. |
| performer/src/translations/kv_options.rs | Adds proto→SDK translations for GetReplicaOptions and GetReplicaStrategy. |
| performer/src/translations/common.rs | Maps new SDK error kinds to corresponding proto exception types. |
| performer/src/performer.rs | Advertises SdkGetReplica capability. |
| performer/src/common/content.rs | Enables content decoding for GetReplicaResult via existing decoder abstraction. |
| performer/src/commands/sdk.rs | Adds command building/plumbing for the new GetReplica operation + transcoder support. |
| performer/src/commands/kv.rs | Adds GetReplicaCommand execution and result-to-proto mapping. |
Review details
- Files reviewed: 29/29 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+57
to
+63
| pub struct GetReplicaOptions<'a> { | ||
| pub key: &'a [u8], | ||
| pub scope_name: &'a str, | ||
| pub collection_name: &'a str, | ||
| pub strategy: GetReplicaStrategy, | ||
| pub retry_strategy: Arc<dyn RetryStrategy>, | ||
| } |
Comment on lines
+362
to
+367
| pub async fn get_replica( | ||
| &self, | ||
| id: impl AsRef<str>, | ||
| strategy: impl Into<GetReplicaStrategy>, | ||
| options: impl Into<Option<GetReplicaOptions>>, | ||
| ) -> crate::error::Result<GetReplicaResult> { |
|
| Project | couchbase-rs |
| Branch | get_replica-33888600930-202-1 |
| Testbed | ubuntu-latest |
🚨 1 Alert
| Benchmark | Measure Units | View | Benchmark Result (Result Δ%) | Upper Boundary (Limit %) |
|---|---|---|---|---|
| upsert_and_get | Latency microseconds (µs) | 📈 plot 🚷 threshold 🚨 alert (🔔) | 454.22 µs(+16.39%)Baseline: 390.25 µs | 448.79 µs (101.21%) |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result microseconds (µs) (Result Δ%) | Upper Boundary microseconds (µs) (Limit %) |
|---|---|---|---|
| query | 📈 view plot 🚷 view threshold | 441.17 µs(+5.16%)Baseline: 419.54 µs | 482.47 µs (91.44%) |
| upsert_and_get | 📈 view plot 🚷 view threshold 🚨 view alert (🔔) | 454.22 µs(+16.39%)Baseline: 390.25 µs | 448.79 µs (101.21%) |
|
| Project | couchbase-rs |
| Branch | get_replica-33888600930-202-2 |
| Testbed | ubuntu-latest |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result microseconds (µs) (Result Δ%) | Upper Boundary microseconds (µs) (Limit %) |
|---|---|---|---|
| query | 📈 view plot 🚷 view threshold | 443.97 µs(+5.82%)Baseline: 419.54 µs | 482.47 µs (92.02%) |
| upsert_and_get | 📈 view plot 🚷 view threshold | 430.01 µs(+10.19%)Baseline: 390.25 µs | 448.79 µs (95.82%) |
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.
No description provided.