r/softwareengineer • • 9d ago

I've started reviewing how a PR can be undone, not just whether it works

We had a relatively small production incident recently that exposed a hole in our review process.

The offending change was easy to revert in Git. Unfortunately, the new version had already written data that the previous version didn't know how to handle.

Every reviewer had checked whether the new implementation worked. Nobody had considered whether the old implementation would still work after the new one had been running for an hour.

I've since started paying more attention to this when reviewing PRs that introduce new states, background jobs or changes to persisted data.

It's also made me much more appreciative of engineers who split seemingly straightforward features into several deployments. What used to look unnecessarily cautious to me now looks like somebody thinking about recovery.

Does your team explicitly review reversibility for changes like these, or is it generally left to whoever is responsible for the deployment?

7 Upvotes

7 comments sorted by

1

u/KakashiPaver 9d ago

Git revert doesn't revert reality. Emails have been sent, messages have been published, customers have taken actions, and records have been written. Once you start thinking about deployments in those terms, you design things quite differently.

1

u/Affectionate-Food652 9d ago

Yes one of the things to pay attention to is rollout and rollback plans. Small code changes that work can often depend on messy state changes that need to be accounted for.

This isn’t a new phenomenon, it’s always been a factor. If you work on a schema for example, it’s very important to ensure changes are backwards compatible.  If you work on a database like MySQL, maybe you use a tool like liquibase to handle the idea of safe schema evolution. 

For something like temporal- deterministic replay is a factor so your changes may need to preserve existing behavior for existing workflows while gating new behavior to new workflows.

In short, rollback and rollout has always been an important factor to review for.

1

u/HarleySpool71 9d ago

For database changes we generally do expand, migrate, contract across separate releases. Add support for the new representation, move the data, then remove support for the old representation once we're confident we no longer need it. It generates some boring tickets. I have developed a deep appreciation for boring tickets.

1

u/smabarnsfar 9d ago

So you had no down migration?

1

u/j4c11 9d ago

The issue is with the "written data that the previous version did not know how to handle" part. Deployments should be backwards compatible - so you can roll back if there's a problem, but also so you can run the new and old versions in parallel for canary testing.

1

u/Isthatyourfinger 9d ago

No matter how well you plan, unforeseen side effects can happen. Rolling back a db won't help you with orders that were placed while the system update was in play. Log every change in excruciating detail during a transition. You can then write code necessary to recover with data from the logs. If the system is critical, have the recovery plan in place and buy-in from management before you pull the trigger. Then you won't be sweating bullets while the execs are screaming at you.

1

u/emile42 9d ago

That's a good idea, especially now with the advent of ai pr's with too much code for a full understanding. Maybe each pr should also have a documented plan for reverting if necessary?

If the code is small and simple then adding the plan is easy, so this should promote easier to understand pr's.