Skip to content

Add bolt+routing with automatic failover and retry support#84

Merged
mattkjames7 merged 20 commits into
masterfrom
bolt-routing
Jul 13, 2026
Merged

Add bolt+routing with automatic failover and retry support#84
mattkjames7 merged 20 commits into
masterfrom
bolt-routing

Conversation

@mattkjames7

@mattkjames7 mattkjames7 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Extends the mgclient API to include bolt+routing with automatic failover and retry logic.

This includes:

  • Functions to parse the routing table in order to view the cluster's topology.
  • Error classification: Bolt TransientError/low-level transport failures indicated by int mg_error_is_transient(in error) -> tells us whether a request should be retried.
  • Added a router:
    • mg_router_config_* functions for configuring session params (e.g. SSL, resolver) and retry policy (retries, backoff).
    • Resolver for mapping advertised "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).
  • Managed transactions by passing work functions to mg_router_execute_read and mg_router_execute_write functions.

@mattkjames7 mattkjames7 self-assigned this Jul 9, 2026
@mattkjames7 mattkjames7 added Docs needed Docs needed and removed documentation documentation labels Jul 9, 2026
@mattkjames7 mattkjames7 changed the title Add bolt+routing support Add bolt+routing with automatic failover and retry support Jul 10, 2026
@mattkjames7 mattkjames7 requested a review from Copilot July 10, 2026 08:06

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in src/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.

Comment thread src/mgrouting.c
Comment thread src/mgrouting.c
Comment thread src/mgrouting.c
Comment thread .github/workflows/ci.yml
Comment thread tests/routing.cpp
@mattkjames7 mattkjames7 requested a review from as51340 July 10, 2026 11:45
@mattkjames7 mattkjames7 marked this pull request as ready for review July 10, 2026 11:45
@cursor

cursor Bot commented Jul 10, 2026

Copy link
Copy Markdown

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.

@mattkjames7 mattkjames7 merged commit 0ab0544 into master Jul 13, 2026
17 checks passed
@mattkjames7 mattkjames7 deleted the bolt-routing branch July 13, 2026 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants