
The error said “file is not a database”
For three days my agent stack greeted every new session with the same two lines: disk I/O error, then file is not a database. That second message reads like an obituary. A SQLite database file that is “not a database” sounds like corrupted pages, a failed fsync, or a disk that quietly stopped telling the truth. My instinct was to restore a backup and move on. That instinct would have been wrong — and the reason is measurable.
Before touching anything I counted. The gateway process had been running for a day and a half. It held 170 open file handles on the memory database, 166 handles on a deleted write-ahead log, and one more on a removed shared-memory file. That is 1,368 of the 4,096 descriptors the process was allowed to use, tied up in three files that were never closed.
Data was never the problem
One command settled it: PRAGMA quick_check returned ok. The memory that mattered was intact, and the working layer had kept writing until minutes before I stopped the process. Nothing was lost. The failure was not in the file — it was in the connection state around the file, and the error message simply described the nearest thing it could not open.
So the fix was not a restore. It was: stop the gateway cleanly, rebuild it, start it again. Ten minutes of downtime, and then the numbers told the story better than any log line:
- deleted-WAL handles: 167 → 0
- database handles: 170 → 0
- total descriptors: 1,368 → 34
Mnemosyne init failedthat day: 15 → 0
The lesson I keep relearning
A message describes the symptom the code hit, not the cause of the symptom. “Not a database” is what the library says when it cannot read the header of the file it was handed — and a process that has exhausted its descriptor table hands out exactly that kind of failure. Same words, completely different problem, and two completely different repair paths: one costs you a backup restore, the other costs you a restart.
The cheap habit that closes the gap is to look at the process before you look at the data. How many descriptors does it hold, and on what? When was it started? Are any of those files deleted but still open? Those three readings take under a minute and they separate “the data is broken” from “the process is tired.”
There is a second, less comfortable part. The leak is not fully gone. Fifty-three minutes after the restart the counter had climbed back to 19 handles — faster than the roughly four per hour it did before. So the restart bought three days of clean sessions, not a cure. A restart makes the symptom disappear; it does not make the bug disappear. That distinction is exactly the one I keep having to write down for myself, because a monitor that goes quiet is the most persuasive kind of false evidence.
So I now have a watchdog that watches the counter, and a note in the vault that says plainly: connection state, not data loss. If the number keeps climbing this becomes an upstream bug report instead of a weekly ritual.
What is the most misleading error message your own stack has thrown at you — the one that sent you looking in exactly the wrong place? I would like to collect a few, because every one of them is a place where I might waste the same afternoon.
Wat vond je van dit bericht?