I'd been staring at the same race condition for the better part of a day. The kind where the test fails one run in thirty, never under a debugger, never when you add the logging that would tell you anything. I'd read the code so many times the words had stopped meaning things. So I gave up, which is to say I put on a helmet and went out on the bike.
Forty minutes, nothing heroic, just the loop along the canal and back before the light went. I wasn't trying to think about the bug. That's the trick, if it is one: you can't sit down and decide to have the insight. You have to occupy the front of your brain with something undemanding, the road, your legs, the wind, and let the back of it keep turning the problem over without you supervising.
Somewhere past the second bridge it just arrived, fully formed and slightly smug. The lock wasn't the problem. The problem was that I was releasing it before the callback ran, on the assumption the callback was synchronous, and one code path made it asynchronous. Obvious, in hindsight. Obvious the way these things always are once your brain has stopped clenching around them. I could see the exact lines. I spent the rest of the ride almost wanting it to be over so I could go and fix it, which is a daft thing to feel about a canal.
I'm wary of dressing this up as productivity advice, because the moment "go for a ride to solve bugs" becomes a technique it stops working. You can't instrumentalise it. If I'd gone out cynically, watch ticking, waiting for the answer to be delivered, I'd have come back with sore legs and the same bug. The whole point is that you genuinely let go of it.
What I do believe, plainly, is that staring harder has a ceiling and I hit it hours before I admit it. Past a certain point more screen time is just rereading the same wrong assumption with more conviction. The brain needs the input to stop so it can do the quieter work, and movement seems to be the thing that gives it permission. A walk does it. The shower cliché does it. For me, lately, it's the bike.
The fix, when I got home, was three lines and took two minutes. The day it took to get to those three lines was mostly me refusing to step away from the desk. I'd like to say I've learned to leave sooner. I haven't, not really. But I left this time, and the canal sorted it out, and that'll do.