Debugging a Docker Heisenbug in production
medium.com
medium.com
I looked at the code, and it was straightforward: The "add number" view had a check for "ability to add number", and so did the homepage. The homepage would redirect you to the "add number" view if you could have a number but didn't, and the "add number" view would redirect you to the homepage if you couldn't have a number, with the message "you can't change your number", but there was no way for this to happen more than once (the checks are complementary).
Because this is a privacy-focused service, logs were minimal, basically only the path of the request, the time and the backend that served it. We managed to at least see the path the bug took, and, indeed, it was bounced multiple times between the two pages.
There was no clue as to this anywhere, the pages used complementary checks from data on the session, the session was stored on a central redis cache, all workers were running the same code, everything.
The bug remained elusive, until I noticed that the requests would be served first by worker 1, then by worker 2, then by 1 again, etc, until the cycle broke when a request for page 1 was served by worker 2. This could only mean that the workers couldn't agree on the check, and, sure enough, the configuration on one of the hosts had, mistakenly, pointed the cache to local memory rather than redis.
That was a pretty interesting bug.
For us the main reason to go with overlay networking is that it basically solves service discovery (in our specific case) over the entire cluster out of the box (by using Docker internal DNS). No need to change anything in the services themselves, they just need to connect to each other using DNS names.
Great report!
When I see debugging like that, I wonder how many people on the planet have the basic knowledge necessary to understand it (need: OS/process/kernel/networking/etc...)? And how many of them could have performed the debugging AND find the bug?
Then I realize that's the level we need to be able to operate the service and I'm like. Ouchhhhh.
More of these, everyone!
excuse my cynicism but this is why keeping up with the latest cool things doesn't necissarily mean a better sysadmin^W excuse me 'cloud devops engineer'
I find that pretty super hip.