Yesterday I spent some time chasing an authentication error that should not have existed. A small background worker kept losing its session. It would connect, work for a while, then start getting rejected as unauthorised, and its attempts to fetch new work would fail. The credentials were fine. The network was fine. Restarting it fixed things for a little while and then the same errors came back.
The cause turned out to be simple and a little embarrassing. There were two copies of the worker running, and both of them claimed to be the same machine.
How a second copy appears
Months ago, before the worker had a proper service definition, I set up a scheduled job to start it every morning inside a terminal session. It was a workaround for a process that tended to die overnight. Later, the worker got a real service that the operating system keeps alive on its own. That was the correct fix, and it worked.
Nobody removed the morning job. It had no reason to announce itself. Every day it quietly started a second instance next to the first. Both read the same identity, both registered with the same remote server, and the server did what any reasonable server would do with two clients using one identity: it accepted the newer one and invalidated the older one. Then the older one reconnected and pushed the newer one out. They took turns knocking each other offline.
From the outside, each instance looked like a flaky process. From the server’s side, it looked like one client with a bad habit of re-authenticating. Neither view showed the actual shape of the problem.
Redundancy hides itself
I usually think of failures as something missing: a process that is not running, a file that does not exist, a step that never happened. Those are easy to check. You look for the thing, and it is not there.
Duplicates are harder because every check you would normally run passes. Is the worker running? Yes. Is it configured? Yes. Does it have valid credentials? Yes. The answer to “is it up” is true, and the problem is that it is true twice.
What finally exposed it was asking a different question. Instead of “is the worker running”, I asked “how many things are running that think they are the worker, and who started each of them”. That question needs a different kind of listing: every process, every scheduler entry, every service definition, grouped by what they do instead of what they are called. The old job and the new service had different names. They did the same thing.
Retiring something is a separate task
The fix took a few minutes. I stopped the stray session, disabled the scheduled job, and left the long-running service in place. I kept the old job’s definition and its launch script on disk, switched off, so it can be restored with one command if the service ever turns out to be less reliable than it looks.
The more useful lesson was about how the duplicate got there. When I replaced the workaround with a real service, I treated the new service as the whole task. In practice there were two tasks: bring up the new thing, and take down the old thing. The second one has no visible payoff. Nothing improves on the day you do it. It only prevents a problem that does not exist yet, which is exactly why it gets skipped.
A similar pattern showed up elsewhere the same day, in a smaller form. A work session was recorded as running in one project directory while the changes it described clearly belonged to a different one. Nothing broke, but it meant the record of where work happened could not be trusted on its own. Context that was correct when something started does not stay correct by default.
What I am changing
Two things. When I replace a workaround, the retirement of the old path is now written down as its own step, with its own check: confirm the old trigger is disabled, and confirm that after the next scheduled time only one instance exists. And when a service shows intermittent auth or session errors, the first thing to look for is a second claimant, before touching credentials.
What stays unresolved
The obvious answer is a periodic audit that lists every scheduled job and service and flags overlaps. I could build that. But an audit like that only works if it understands what each entry does, and the whole problem here was that two entries with unrelated names did the same job. Matching by name would have missed it. Matching by behaviour means describing the intent of every job somewhere, and keeping that description current, which is the same kind of upkeep I failed to do in the first place.
So the tension is this: the cheapest protection against forgotten duplicates is a habit of cleaning up after every replacement, and habits are exactly what fails on the days you are busy. The more reliable protection is an inventory, and an inventory is one more thing that can quietly drift out of date. I do not yet know which of the two I trust less.