Daniel Coulbourne presented a very enlightening talk about Verbs, an event sourcing package that has been in the works for a while.
Earlier in the day, he and John Rudolph Drexler were walking around the conference with a ziploc bag containing $1,500 cash, signing up people to play their pyramid scheme game: the more people you recruited, the more votes you received.
During the talk, Daniel showed the leaderboard on screen and realized that at least two players had entered a single bonus code multiple times, gaining extra votes. He then merged a PR fixing the bug for future entries.
However, in a “normal” app storing the current state for each user, you would be hard-pressed to figure out how to remove the illegitimate points, while retaining legitimate ones.
That’s the beauty of event sourcing: since each vote and bonus code was stored an event, he was able to wipe out the database and re-run the events to determine the correct vote tallies.
(And of course, since he was doing this live, he accidentally wiped out the migrations
table too and had to restore it…)
Once he re-processed the events, the leaderboard showed correct results, removing the extra votes from those users.
This was a powerful example of how event sourcing can be to prevent, catch, or clean up from certain types of bugs.
His agency, thunk.dev, also wrote up this blog post about the game overall.