10/13/24
Recently I've taken to getting Starbucks on my way to work. I do this every fall/winter season; as soon as the Pumpkin Spice Lattes hit the shelves I, without fail, head straight to my local Starbucks. Then winter rolls in and pumpkin fades to eggnog and I start buying those lattes too. Thankfully it's only ever fall and winter but it's certainly not a cheap way to breakfast.
This has become more of a daily thing for this fall since they opened a location pretty much directly on my way to work last year, and so I've finally started using their app with their star rewards system. I still don't quite know how it works and I may never fully figure it out because I just don't care that much, but I'm pretty adamant about not leaving money on the table when possible. If I'm going to be getting drinks anyway, I might as well sacrifice some privacy for the sake of a free $8 latte every week or so.
Last week, as I was on my way out the door I went ahead and loaded $25 onto the Starbucks card as I usually do when I'm low. Doing it this way doubles the stars you get, and money/table.
This time, however, something unusual happened; just as I hit the "done" button (or whatever it is) I happened to, at that moment, go out of range of my wifi and hop onto cell data. The waiting/loading/spinny bar seemed to go on for several minutes before it finally completed and brought me back to the main screen with my total *Buck\$\$ Dollars* (or whatever they're called). But instead of $25, I wound up with $50. And, checking my bank account, I confirmed that, in fact, I had two transactions for $25 each withdrawn.
This reminded me of the "Two Generals Problem" because I believe that problem was likely the root cause of this behavior.
In computer science, we have a few different "unsolved problems" that, as the name implies, are currently unsolved- and they aren't expected to be solved any time soon. One of those problems is "The Two Generals". It goes something like this:
Two armies, each led by a general, are stationed on opposite sides of a valley. They both need to coordinate an attack to defeat a common enemy in the valley, but the only way to communicate is by sending a messenger through the dangerous terrain, where the message could easily be lost or intercepted. Both generals know that attacking alone would lead to disaster, so they need to coordinate.
One general sends a messenger proposing to attack at dawn. The messenger crosses the valley and delivers the message, but now the second general needs to send a confirmation. When that messenger arrives back, the first general wonders, "How can I be sure they received my message and will actually attack?" Another confirmation needs to be sent to that confirmation. This back-and-forth could go on forever, with no way for either side to be completely sure the other will follow through, making coordinated action impossible.
I assume that Starbucks pays their developers well, but, as I mentioned, this is an unsolved problem. When I moved from wifi to cellular data it was in a perfect moment where the transaction had gone through (somewhere) but wasn't confirmed. (probably on the app?) When I let the app continue on and do its thing, it assumed a communication failure and re-tried the transaction. Both were successful, and now I have an extra $25 in *Starbuck\$ Reward\$* (or whatever it's called).
It's a fun little reminder that everyone's human and that developers suck at their jobs- and it's not even their fault that they do.
Sometimes I have thoughts. That is all.