Skip to content

Checks: migration, backfills and cutovers

Templates for the four migration, backfills and cutovers stories. Unlike most checks, these run once per migration rather than on every commit, so write them as part of the cutover runbook, and make the runbook refuse to continue when one fails.

C-13: the newest revision wins, in either order

Section titled “C-13: the newest revision wins, in either order”
  • Proves: when a backfill and live replication write the same row, the target ends with the newest source revision whichever arrives last.
  • Fails for: unconditional upserts. The backfill that overwrote a live update.
  • Harness needs: apply a write through each path directly.
@ParameterizedTest
@ValueSource(strings = {"live-then-backfill", "backfill-then-live"})
void theNewestRevisionWinsWhateverTheArrivalOrder(String order) {
var rev7 = customer("C-42", "[email protected]", 7);
var rev8 = customer("C-42", "[email protected]", 8);
if (order.equals("live-then-backfill")) { live.apply(rev8); backfill.apply(rev7); }
else { backfill.apply(rev7); live.apply(rev8); }
assertThat(target.customer("C-42").sourceRevision()).isEqualTo(8);
assertThat(target.customer("C-42").email()).isEqualTo("[email protected]");
}

C-14: rollback keeps every acknowledged write

Section titled “C-14: rollback keeps every acknowledged write”
  • Proves: after cutting over, accepting orders and rolling back, every order a customer was told about exists exactly once in the old system and reaches its fulfillment run.
  • Fails for: routing-only rollback. The rollback that lost successful orders.
  • Harness needs: drive the router; read acknowledgements from the customer’s side (confirmation emails or captured payments).
@Test
void rollingBackKeepsEveryAcknowledgedOrder() {
router.cutOverTo(NEW_SYSTEM);
var acknowledged = IntStream.range(0, 12)
.mapToObj(i -> storefront.placeOrder(sampleOrder(i)))
.filter(OrderResult::confirmed)
.map(OrderResult::orderId)
.toList();
cutover.rollBack(); // the real procedure, not router.switchTo()
for (var id : acknowledged) {
assertThat(oldSystem.ordersWithId(id)).as(id).hasSize(1);
}
assertThat(oldSystem.nextFulfillmentRun().orderIds()).containsAll(acknowledged);
assertThat(acknowledged).hasSameSizeAs(mailSink.confirmationsSince(router.cutOverAt()));
}
@Test
void theReportNamesSwappedValuesThatTotalsHide() {
source.load(row("SKU-A", 7), row("SKU-B", 3));
target.load(row("SKU-A", 3), row("SKU-B", 7));
var report = reconciliation.compare("reservations", "sku");
assertThat(report.rowCountsMatch()).isTrue(); // the trap: this alone passes
assertThat(report.differences())
.extracting(Difference::key, Difference::signedDifference)
.containsExactlyInAnyOrder(tuple("SKU-A", -4), tuple("SKU-B", 4));
assertThat(report.netDifference()).isZero();
assertThat(report.passed()).isFalse();
}
  • Proves: a shadow comparison reports every eligible request, including those with no candidate response, and fails the release gate when coverage is below threshold.
  • Fails for: matched-pairs reporting. The shadow test that missed the dangerous requests.
  • Harness needs: feed the comparator a recorded hour of outcomes.
@Test
void missingResponsesCountAgainstTheReleaseGate() {
var hour = new ArrayList<ShadowOutcome>();
for (int i = 0; i < 950; i++) hour.add(matched(i));
for (int i = 950; i < 1000; i++) hour.add(candidateTimedOut(i, lineItems(240)));
var report = comparator.report(hour);
assertThat(report.eligible()).isEqualTo(1000);
assertThat(report.matched()).isEqualTo(950);
assertThat(report.candidateMissing()).isEqualTo(50);
assertThat(report.coverage()).isEqualTo(0.95);
assertThat(releaseGate.evaluate(report, minCoverage(0.99), minAgreement(0.999)).passed()).isFalse();
assertThat(report.missingRequests()).hasSize(50); // listed, so they can be replayed
}

Written and edited by Abhinav Taduka, enterprise software architect.