A server runs its apps under a process manager. Most of them are services that run all the time. One is not: it is a nightly loader. The process manager starts it once a day on a cron-style schedule. It downloads a partner’s daily list and replaces a database table with it. An API on the same server answers lookups from that table.

One day the loader stopped running, and nothing failed. A scheduled job that lives only in a process manager’s saved list is one save away from being gone. And a service that serves stale data looks healthy.

Key facts

  • The process manager’s saved list holds 11 apps. There should be 12: the nightly loader is the missing one.
  • The loader’s last load was on the morning of day two, with 61,421 rows. Nothing on day three, nothing since.
  • There was no crash, no error line, no restart loop and no alert.
  • In the last 20,000 log lines of each API worker: 467 answers “not on today’s list” and 23 real quotes, all from a list that was no longer today’s.
  • The table’s newest load was 39 hours old, for a job that runs every 24.

What happened

The server ran out of memory, and the process manager restarted. Out-of-memory kills were not new on this kind of server; one cause of them has its own story. What was new is what came after.

Within minutes of the restart, the process list was saved again. A process manager keeps a dump file of the apps it should run, so it can bring them back after a reboot. The dump file and its backup carry the same save time. The saved list holds 11 apps. The loader is not one of them.

The loader’s own log tells the rest. It shows three loads:

  • Day one, in the morning, at its scheduled time.
  • Day one, late in the evening: a hand run.
  • Day two, in the morning, at its scheduled time: 61,421 rows.

Then nothing on day three, and nothing since. The schedule lived inside the process manager’s list. Once the loader was out of that list, nothing anywhere was going to start it.

Why nothing failed

A job that is not in the list cannot fail. It does not crash, because it never starts. It writes no error line, because it does not run. It cannot enter a restart loop or trip a process alert, because the process manager does not know it exists.

So every place you would look for trouble was quiet. The process list showed 11 apps online. That looks complete to anyone who does not remember there should be a twelfth name. It is the same shape as a green run where the publish job never ran: green meant nothing broke, not that the work got done.

The API stayed green

The API on the same server had no idea the list was old. It kept answering every request from the table, and the table still held the list from day two.

In the last 20,000 log lines of each worker, there were 467 answers “not on today’s list” and 23 real quotes. All of them came from a list that was no longer today’s. Any of them could be wrong for today, and the caller had no way to tell.

Every status check on the API was green. A service that serves stale data looks exactly like a healthy one: it is up, it answers, it does not throw. It is only wrong.

Here is what each check said:

CheckWhat it said
Process list11 online
API healthGreen
Error logEmpty
Data age39 h

Three of the four checks look at processes. Only one looks at the data, and it is the only one that told the truth.

How it was found

No alert found it. A person asked a plain question: “does it work today?”

The answer came from the one number that could show it: the time of the table’s newest load. It was 39 hours old, for a job that runs every 24.

What we do not know

Why the loader was missing at the moment of the save is not known. We do not know who or what ran the save. We also do not know whether the restart brought back an older list that never had the loader in it, so that the save only made the gap permanent.

This article does not claim a cause, because none is proven. When it was written, the loader had not yet been put back, so there is no “after” here.

What is known is enough to act on. The only copy of the schedule was a saved snapshot, and a snapshot taken at a bad moment keeps the bad moment. It is a cousin of a pause that lived in one worker’s memory: state that lives in one place goes when that place goes.

Check your own

  • Check the data, not the job. Put a freshness check on every table or file a scheduled job fills. Alert when the newest load is older than the schedule plus a margin: for a daily load, 26 hours.
  • Keep the app list in the repository. Write the apps and their schedules in the process manager’s config file, in the repository, and start from it. Then the saved dump is a cache, not the only copy.
  • Compare before you save. After any restart of the process manager, compare the running list with that file before anyone saves. A save taken at a bad moment makes the bad moment permanent.
  • Count the names. “11 apps online” reads as healthy unless something knows it should be 12.
  • Make the consumer say how old its data is. Put the load time in the answer or in a health endpoint, so “stale” is visible to the caller.
  • Give a once-a-day job a dead-man’s switch. The job reports in after each run, and silence raises the alert. Process monitors only see things that are running.

A sketch of the first one, with made-up names:

// Check the data, not the job.
// Daily load: 24 h plus a margin.
const LIMIT_H = 26;
const HOUR_MS = 3_600_000;

async function checkFresh() {
  const last =
    await newestLoadTime();
  const ageH =
    (Date.now() - last) / HOUR_MS;
  if (ageH > LIMIT_H) {
    const h = Math.round(ageH);
    await alert(`stale: ${h} h`);
    process.exit(1);
  }
}

// Run it on its own timer,
// not inside the loader.
checkFresh();

Common questions

Why not just alert when the process crashes?

The loader never crashed. It was not in the list, so it never started, and a process alert only watches things that run. Silence needs its own alarm.

Why 26 hours and not 24?

A daily load does not land at the same minute every day. The margin covers a slow or late run without waking anyone, and a load that is really missing is still caught soon after it should have run.

Melta is free; get it on the App Store or Google Play.