Skip to main content

Module mirror

Module mirror 

Source
Expand description

Continuous traffic mirroring.

Replays a sampled share of live (simple-query) write statements to a secondary backend, asynchronously and off the client hot path: the data path does a non-blocking try_send into a bounded queue and moves on; a background worker drains the queue and applies each statement to the mirror backend. When the queue is full, statements are dropped (and counted) rather than slowing the client — mirroring is best-effort.

This is the on-ramp to the PG->Nano migration mirror (Batch G2): point the mirror at a HeliosDB-Nano instance and its write set tracks the primary. (Result diffing for blue/green validation already lives in shadow_execute; this module is the continuous write tail.)

Structs§

CutoverTarget
Target the proxy redirects client traffic to after a migration cutover. New connections route here (with these credentials/database substituted for the client’s), making the cutover transparent to the application.
MigrationStatus
Operator-facing migration status (served at /api/migration/status).
MirrorHandle
Handle held by the server: a bounded sender plus the sampling policy.
MirrorMetrics
Counters surfaced for observability.
TableSnapshot
Per-table snapshot result.

Functions§

snapshot_tables
Snapshot-bootstrap the secondary: for each table, read all existing rows from the source (primary) and copy them into the mirror target, creating the table there if needed. Returns a per-table report. Used by POST /api/migration/snapshot to seed a migration with existing data before/alongside the continuous write tail.
spawn
Spawn the mirror worker. Returns a handle for the data path to feed.
status
Compute a migration status snapshot from the live counters.