Can your change be safely reverted?

There isn't a one-size-fits all solution, but it's important to consider revertable changes.

An often-overlooked use case for code or infrastructure changes, is the ability to revert.

Sometimes we do think about this, when it comes to things like destructive database changes. We may be careful not to delete the users table, without a backup.

But I often see this concern being forgotten about more menial changes, and sometimes it can bite!

Here’s a random example:

Your HTTP server sets a session cookie for every visitor, which contains the user name as a simple string. This has been working fine for months… until you decide that it would be good to store additional information in the cookie. Like maybe the user’s favorite flavor of ice cream.

You can no longer use a simple string. You need some way for your cookie to contain multiple pieces of information. Maybe you choose for a comma-separated list. This is perfect, because your code can easily split on commas, and use the first value as the user name, and the second value as the favorite ice cream flavor. And if the second value doesn’t exist, no problem… you can set it the next time you send a cookie their way.

You’ve now got a nifty ice cream flavor storing cookie, and it’s 100% backward compatible! All old cookies still work, with no problem, and new cookies will be gracefully upgraded.

But what happens if you ever have to revert the ice cream flavor feature?

What if you discover that tracking ice cream flavors just puts too much load on your database. And it wasn’t really very useful anyway… so now you’re going to revert the code.

Except now, all your users sessions are invalid. Whoops!

And the reason is that alice,vanilla isn’t a valid user name. 🤔

What’s the solution? Although I can think of a handfull of potential solutions to this type of problem, sadly, there isn’t a single one-size-fits all solution.

The point here isn’t how to solve the problem. The point is to be aware of the potential for the problem in the first place, so that you can plan for such eventualities.

How would you solve this type of problem? Send me an email, and let me know. 🙂

Share this