Shopify / ghostferry

The swiss army knife of live data migrations
https://shopify.github.io/ghostferry
MIT License
748 stars 70 forks source link

Report progress before cutover begins #233

Closed paarthmadan closed 3 years ago

paarthmadan commented 3 years ago

Closes #232

What was done?

This PR helps ensure progress is reported before beginning cutover.

Ghostferry, as a library, can't enforce or ensure that clients don't terminate/error-out during cutover. Custom code leaves this as a possibility.

Before notifying clients that row copy is complete, we should dispatch a progress callback.

This conditional change comes before the notification (notifyRowCopyCompletion), to avoid any possible race conditions. If the notification of row completion occurs first, the client (ex: copydb, sharding) could execute, and possibly fail, before the progress callback is emitted.


Testing

I've add an integration test for this specific use case. Namely, simulate a Ghostferry client that is killed after row copy complete has finished.

Assertions are put in place to now make sure that – even in this case – progress is reported.

I've manually tested it out as well.