Skip to main content

Module shadow

Module shadow 

Source
Expand description

shadow — run the old query and the new one side by side and report where they disagree, in membership AND in order. shadow — run the old query and the new one side by side and say where they disagree.

Lesson 4 of the migration playbook, which is the one that decides whether anyone dares cut over: serve reads from the old path while computing the new answer beside it, and compare the order too, not just the membership. Score drift produces identical sets in different orders, and a paginated UI turns that into user-visible churn.

It also carries lesson 2 without being asked to. A writer nobody remembered to update shows up here as rows the new path is missing — which is the same signal TABLE.VERIFY reports after the fact, seen before the cutover instead of after.

Structs§

Compared
Rows the new side lacks, rows it invents, and the first ordering difference. Membership and order are reported separately because they fail for different reasons: a missing row is a writer nobody updated, a reordering is score drift.
Divergence
What one comparison found.
ShadowReport
Outcome of a shadow run — the paste-able conclusion.

Enums§

Shape
How to read a reply into rows. Guessing is not free here — reading ZRANGE … WITHSCORES as a plain list silently treats every score as a row key and reports a divergence on every sample — so the two ambiguous shapes are told apart by the caller, not by a heuristic.

Functions§

compare
Compare two readings: what is missing, what is extra, and where the orders first part company.
print_report
Print the report the way lesson 4 asks for: the first divergence with both sort keys, because that one line names the drifting writer.
rows_of
Read a reply into ordered rows under shape. Paged is recognised from the reply itself, so passing Flat for a kevy index reply still does the right thing rather than reporting nonsense.
run
Run both commands samples times and compare each pair.
run_shadow_cli
shadow [-h host] [-p port] --old "<cmd>" --new "<cmd>" [--old-pairs] [--new-flat] [--samples n]