Urgent.News

What's breaking now, across hundreds of outlets.

Tech

Zero-Downtime Database Migration Playbook

To move a database without downtime, keep the old database live as the source of truth. Copy the existing data, stream every new change to the new store and check that the two match until they agree. Then move reads and writes over in small steps you can undo. Retire the old database only after the new one has run alone, with no problems, for an agreed period. Why do database migrations cause…

Performing a database migration without any downtime requires careful planning and execution. The key is to keep the old database live as the source of truth while copying the existing data to the new store. Every new change must be streamed to the new store and continuously compared to ensure they match until they agree.

The copy process involves taking a consistent snapshot of the old database and simultaneously loading it into the new store. At the same time, all changes made since the snapshot must be captured and replayed until the new store has caught up. This is achieved through a technique called change data capture (CDC).

The migration process can be broken down into three main phases. First, a full load of existing data is performed. Next, the changes cached during the load are applied. Finally, ongoing replication ensures that the new store remains up-to-date with the latest changes from the old database. This is accomplished by collecting changes from the database logs through the engine's own interface.

To keep the backfill process safe, it is important to record the log position before the snapshot. This ensures that no changes fall into the gap between the copy and the stream. The copy should be done in throttled batches to prevent slowing down the production database that users still depend on. Additionally, every write should be idempotent, meaning that a batch that runs twice will produce the same result.

Transformations should also be handled in the pipeline rather than manually, with the mapping kept in version-controlled code with tests.

During the migration, the application should not be aware that a migration is happening. It is crucial to serve all reads from the old database, even as writes are being performed on both the old and new databases simultaneously. This approach, known as CDC, is preferred over dual writes whenever possible. Dual writes should only be used when CDC cannot do the job, such as when the new data model can only be produced by application logic or when the old database's change log cannot be read.

To reconcile any differences between the old and new stores, they must be continuously checked against each other at multiple levels of detail. This includes checking row counts per table or tenant, missing or duplicated batches (every few minutes), checksums per key range (hourly or nightly), field-level diffs on samples (daily), and shadow reads (continuously during the read stage). Shadow reads involve querying production queries to the new store and comparing the results, without users seeing the new store's answer.

The migration process should be moved in stages, starting with moving reads first, a slice at a time, behind a feature flag. Writes should only be moved once the new store is serving all reads correctly. Shadow reads can be used to compare results, with users only seeing the old store. Read ramp-ups involve serving real reads from the new store for a limited number of internal tenants, gradually increasing the percentage of traffic until all traffic is served by the new store.

At each step, error rates and latency must match the baseline, and users should be kept on one store at all times.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

Colombia's cadastre in a table: 174 metrics per municipality and neighborhood (Parquet, CC BY 4.0)

We bring together in a single table all the cadastral slices published by Aptología: 174 metrics and 49,201 rows, by municipality of Colombia and by neighborhood of Bogotá and Medellín, in Parquet and…

  • La tabla de catastro colombiano contiene 174 métricas y 49.201 filas
  • Datos disponibles por municipio y barrio de Bogotá y Medellín
  • Información sobre valor del suelo, avalúo, altura de construcciones y categorías

SMS Alerts Service Explained — Transactional Notifications API Expiry Budgets

Integration option Pick this when Evidence to require before committing Submit SMS and poll its status Your marketplace needs outbound requests only, with no delivery webhook A documented status…

  • Opt for integration with outbound SMS and polling status for marketplaces without delivery webhooks
  • Consider token lifecycle controls, such as expiration budgets and token revocation/renewal options

More from Tuesday, 1 December 2026 →