Every step reported success. None of them had done the job.

I build business software that runs in shops: tills, purchasing, stock and accounting, with a server in each store that keeps selling when the internet drops and syncs to the cloud when it comes back. The bugs that cost the most there are rarely the loud ones. A crash gets reported within minutes. A step that quietly does nothing, and says it worked, can sit for weeks.

Here are four from the last few months. Each one passed every check we had at the time.

Backups that were 20 bytes each

The store servers run a small backup container that dumps the database every few hours. It logged "wrote" after every run. On one store server, every one of the ten retained backups turned out to be exactly 20 bytes.

The script did roughly this: if pg_dump ... | gzip > file; then echo wrote. A shell pipeline returns the exit status of its last command, so the if was testing gzip, not the dump. The dump was failing because the container started before the database was ready. gzip compressed nothing, succeeded, and produced a perfectly valid empty archive.

The fix was set -o pipefail, plus a second gate that rejects any output under 1 KB and logs the byte count on success. The lesson I keep coming back to: a file existing is not evidence that a backup works. Check its size, and restore one now and then.

A message broker whose volume was never used

The branch-to-cloud sync runs through a message broker. Its compose file mounted a data volume, which looked right in review. But the setting that tells the broker where to keep its data was never set, so it used the image's default, a temporary folder with no volume behind it.

Every restart had been wiping the broker's state, including every login and each consumer's read position. Nobody noticed because early on there was little state worth losing. We found it the day a restart, made to apply new access rules, wiped every login.

The fix was one line pointing the data directory at the mounted path, confirmed by restarting twice and checking that topics and users survived both times. After any broker restart we now list users and consumer groups. An empty list means the data directory has drifted again.

Editing a purchase order broke the bill that pointed at it

A store tried to save a supplier bill created from a 21-line purchase order. The save failed with a foreign key error on the order-line reference.

Someone had edited the order a few minutes earlier. The update code deleted every line and inserted fresh ones, which gave every line a new id. The bill form had been loaded before the edit, so it still carried the old ids. Worse, the database rule on that reference was "set to null on delete", so every edit of an order had also been quietly unlinking posted bills and goods receipts from their order lines.

The fix was to update lines in place, matched by product, and delete only the lines whose product actually left the order. The bill now re-links a stale reference to the order's current line for that product, or clears it with a logged warning. "Delete and re-insert the children" is a tempting shortcut for any edit screen. It works right up until something else holds a reference to those children.

Sync dropped purchase invoice lines without an error

A purchase invoice reached the cloud from a store with its header and no lines. Supplier and total were there. The products were not.

It looked like a product sync problem, because barcodes on the cloud side did not match what the store showed. That was a red herring. The cloud had zero line rows for that bill, and the logs were silent.

Every sync handler ran a cleanup step on the incoming payload, and that step skipped any field holding an array, on the assumption that child records were handled somewhere else. For invoice lines, nothing handled them. No error meant no retry and no dead-letter entry.

Fixing that exposed a second bug. The lines arrived, but every price was zero. Our ORM's create() copies only properties that map to real database columns. Price was a convenience getter and setter that converts to a cents column, so the ORM dropped it without complaint and the cents column kept its default. Writing the cents column directly fixed it.

The audit afterwards found the same array filter had been stripping the debit and credit lines off journal entries synced from stores. That was fixed in the same pass, and it is the one that still makes me wince, because those lines are the accounting.

What they have in common

In each case the system checked that a step ran, and never checked what it produced. Exit codes and "wrote" log lines all said yes.

The checks that would have caught each one are boring:

  • assert on the output, not the exit status: file size or row counts, and a test restore now and then
  • after a restart or a sync, compare counts on both sides
  • treat "skip this field" and "default this value" in shared code as places data can disappear, and log when they fire
  • when an edit replaces child rows, ask what else points at them

None of this is new. It is just easy to skip when everything is green.

Afzaal Rafiq builds Tellency, a POS and ERP for multi-store retailers, at Aiinak.