Add bolt+routing with automatic failover and retry support#84
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extends mgclient with client-side routing support for Memgraph HA clusters by introducing routing table parsing, target selection with optional address resolution, transient error classification, and a router API that can connect to READ/WRITE servers and execute managed transactions with retry/backoff.
Changes:
- Added public routing APIs to
mgclient.h(routing table, transient error classification, resolver interface, router config/router lifecycle, managed execute helpers). - Implemented routing table parsing, coordinator refresh + failover, read round-robin selection, and managed execute retry/backoff in
src/mgrouting.c(+ internal test seam insrc/mgrouting.h). - Added routing unit/integration tests + example and updated CI to optionally spin up an HA cluster and exercise routing.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/routing.cpp | New routing/execute tests (includes cluster-gated cases). |
| tests/encoder.cpp | Updates GTest instantiation macros (modernization). |
| tests/decoder.cpp | Updates GTest instantiation macros (modernization). |
| tests/CMakeLists.txt | Adds routing test + builds routing example. |
| src/mgrouting.h | Internal routing helpers exposed for white-box tests. |
| src/mgrouting.c | Core routing/router implementation (refresh/connect/execute). |
| src/CMakeLists.txt | Adds routing implementation to build. |
| include/mgclient.h | Public API additions for routing/router/retry. |
| examples/routing.c | New example demonstrating client-side routing usage. |
| .github/workflows/ci.yml | Adds optional HA cluster setup and routing example run. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
as51340
approved these changes
Jul 13, 2026
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.
Extends the
mgclientAPI to include bolt+routing with automatic failover and retry logic.This includes:
TransientError/low-level transport failures indicated byint mg_error_is_transient(in error)-> tells us whether a request should be retried.mg_router_config_*functions for configuring session params (e.g. SSL, resolver) and retry policy (retries, backoff)."host:port"addresses to reachable ones (e.g. for working with port forwards).mg_router_*functions for creating/destroying the router; connecting read/write sessions; routing table (fetch, refresh).mg_router_execute_readandmg_router_execute_writefunctions.