Skip to content

About

Migrate 20,000 order addresses while old and new clients keep editing them. The recorded run finished with zero mismatches.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

3 Commits

Folders and files

Repository files navigation

PostgreSQL Backfill

Run a live migration while old and new clients write addresses. Start a fresh disposable PostgreSQL database with docker compose up -d --wait. Set DATABASE_URL to postgres://demo:demo@127.0.0.1:55432/backfill?sslmode=disable. With Go 1.23+ and Python 3.11+, run go build -o backfill . (on Windows, output backfill.exe), then python demo.py.

Runbook

The demo seeds 20,000 existing rows, starts an HTTP service, generates concurrent traffic, interrupts the migration after a committed checkpoint, edits an order, resumes, verifies, switches readers and rolls them back. Use a fresh database for each run. CLI commands: seed, plan, run, status, verify, cutover, rollback, serve.

Decision record

A database trigger synchronizes both write representations in the same transaction. Row locks protect batches and the checkpoint advances with the updates in one commit. A session advisory lock excludes competing runners. Keep the legacy column throughout the rollback window. Synthetic latency samples measure an HTTP write followed by a read under one traffic worker.

Recorded replay

The benchmark records 20,000 synthetic orders and the exact source commit. One worker alternated writes from the two application versions and read each order back. The backfill was stopped after row 200. The verifier found zero mismatches after resume and the legacy reader returned the structured writer's final change after rollback. The observed p95 for a write/read pair rose from 26.24 ms before migration to 62.94 ms during migration. This is a single local run, with different sample counts per phase.

About

Migrate 20,000 order addresses while old and new clients keep editing them. The recorded run finished with zero mismatches.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages