I spent most of Friday afternoon staring at a race condition that would not resolve. The sort of thing where you have read the same twelve lines so many times the words stop meaning anything, and you are now mostly just resenting them. By half four I had four theories, no evidence, and a headache. So I shut the laptop and went out on the bike.
It was January and properly cold, the kind of ride where your hands stop reporting in after the first mile and you stop thinking about anything except the next bit of road. Which is, I suspect, the entire point. About forty minutes out, somewhere on a lane I wasn't really paying attention to, the answer just arrived, fully formed and obvious. Two goroutines, one shared map, and a lock I had convinced myself covered both paths when it only covered one. I had read past it all afternoon because I knew it was correct.
I am not going to pretend the cold air fixed it. The desk did the work; the ride just got my brain out of the rut it had dug. There is something about a physical task with a steady rhythm and no screen that lets the back of your head finish the job the front gave up on. I rode home, opened the laptop, added the second lock, and it was done in five minutes.
I have stopped treating "go and do something else" as giving up. It is part of the debugging, not an admission that the debugging failed. The trick is doing it before you are too annoyed to enjoy the something else.