programmingby Linus (not that one) · 452 words · 548 views
Pudding is the duck
Rubber duck debugging, except I don't have a duck, I have a fourteen-year-old cat who weighs the same as a bag of cement and judges me. The judgement is the technique.
Rubber duck debugging, for those who haven't had it explained to them by a bloke at a meetup, is where you explain your code out loud to a rubber duck and in the process of explaining it you find the bug. Works a treat. The duck contributes nothing. That's the point.
I don't have a duck. I have a cat called Pudding who is fourteen and weighs about the same as a bag of cement and who sits on the desk next to my left monitor every single day from about nine till she gets bored.
So Pudding is the duck.
Tuesday. Bug in a payment webhook. Payments were coming through, being recorded, and then, about one time in thirty, being recorded again. Double entry. Customer sees one charge, we see two, finance sends the email with the red exclamation mark.
"Right, Pudding," I said. "The webhook fires. We check if we've seen the event ID. We haven't. We write it. We process it. Done."
Pudding looked at me.
"Except one in thirty we get it twice."
Pudding looked at the wall.
"So the check must be failing. But it can't be failing, because the ID is right there, I've logged it, it's the same ID both times."
Pudding began to wash her foot.
"Unless." I stopped. "Unless both webhooks arrive at the same time. And both of them check. And both of them see nothing. And both of them write."
Pudding paused, mid-foot, and looked at me with what I'm going to describe as contempt.
"A race. It's a race. They're doing the check and the write as two steps and there's a gap."
I made the write atomic. Unique constraint on the event ID, catch the collision, drop the duplicate. Twelve lines. Deployed it at eleven. Watched the logs through lunch. Nothing doubled.
Now here's the thing. My partner works from home too, in the other room, and she came in around two and said "were you talking to the cat again."
"Debugging."
"You said 'unless' to the cat in a voice like you'd found out who the murderer was."
"She helped."
"She's asleep on the router."
She was, in fact, asleep on the router, which explains the wifi.
I told this at the meetup on Thursday and the bloke who originally explained the duck to me said, quite seriously, that the duck works because it can't judge you, and a cat can, so it's not the same technique. I said the judgement was the technique. He didn't like that. He's a duck man.
Pudding's on the desk now. Different bug. I've started explaining it and she's already looking at the wall, which historically means I'm on the wrong track.
How hot is it?
Not rated yet
#debugging#cats#remote-work#australia#humour
Themes: rubber duck debugging · cat as rubber duck · programming humor · debugging with pets · remote work stories · australia tech · cat lovers · programming anecdotes · webhook bug · race condition
Comments
Loading comments…