My first time breaking production

Every engineer has a first time breaking something in production. This week I found out about mine.
Every record in this system has two IDs. They look almost the same, but different parts of the system use different ones. In August I built a new feature, and my implementation saved records under the wrong one. It also read them back with that same ID, so in my own testing everything looked fine.
But the new system doesn’t work on its own yet. We’re replacing an old system bit by bit, and until that’s done, both use the same data. The old system looks records up by the other ID, so it couldn’t find anything my feature had saved.
0001234580012345 ✕It went through our own testing and then the client’s acceptance testing, and slipped past everyone. The tests created their data the same way my code did, with the wrong ID, and checked it the same way too. Everything agreed with everything, so everything passed. Then it sat in production for about three weeks.
When the first report came in, I thought it was a fluke. A few minutes after the end of the day, with everyone gone home, I was still looking into it just to be sure, and found the mismatch: I’d been using the wrong ID all along. The two look almost the same, so working out which records were which took hours. I stayed until 1 a.m. tracing them and writing it up. Production had to wait until the next morning, when the client said yes.
In my defence, every column in that database is named in Japanese, and it was my first month on the project.
Next time:
- Keep good logs. They’re how you find everything a bug touched.
- Test new code against the systems it has to work with, not only on its own.
- Don’t test with data the same code created. Use real data, or data from another system.
And building something new is a lot easier than fitting into a system someone else built.