Urgent.News

One page, thousands of outlets. See who else covered it.

Editions

Tech

The Worker Kept Hitting the Old Database After the Config Was Changed

The failure I keep on a throwaway server has no traceback. The API reports the new database, the background job writes to the old database, and every status check still says green. It is the kind of bug that can survive a code review because the diff is correct but the process is stale. This is a controlled reproduction, not a production incident report, so the database URLs are fake and the…

A worker application continued to write to an outdated database, even after a configuration change. The API and a scheduled job reported different database targets, but no errors appeared and the worker's exit code remained zero. The discrepancy was hidden inside a process that no one considered restarting. To reproduce the bug, a minimal setup was created with separate files for the configuration, API, and worker processes.

The configuration function reads the environment variable at call time, so import-time caching does not cause the issue. The API and worker used different environment setups, with the worker reading the old database URL instead of the new one. Debugging revealed that the worker process started before the environment was updated.

The root cause was that the worker's process environment did not reflect the new configuration. The issue was resolved by terminating the worker and starting a new instance with the updated environment. In a real deployment, this may involve restarting the worker service, recreating the container, or rolling the process group after a configuration change.

To prevent similar issues, it is essential to compare process start time with deployment time before declaring the change complete. A decision table can help distinguish between likely causes, such as a fresh process seeing the new URL, a worker process starting before the change, or a stale configuration source.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

More from Monday 17 August →