Files
wekan/server/lib
Lauri Ojansivu 4a09551397 Report database health in Admin Panel / Problems, and fix a missing index automatically.
The reported crash series (.tools/crash) was invisible from inside WeKan:
MongoDB aborting on every checkpoint, restarting, aborting again, with
every query in between slow - and the admin found it in the container log.
Admin Panel / Problems / Database problems now gets a row for each thing
WeKan can measure from its side of the socket, from a probe that runs 30 s
after startup and every five minutes (server/lib/databaseHealth.js, the
pure decisions in models/lib/databaseHealth.js):

- db.restart: serverStatus.uptime went down while WeKan kept running - the
  database process restarted; points at the fatal-assertion/fsync cause and
  the storage page.
- db.network-filesystem: getCmdLineOpts' dbPath, when it is a directory
  this process can see (snap, embedded database, shared volume), is on a
  CIFS/SMB, NFS or FUSE filesystem (fs.statfs f_type).
- db.slow-storage: serverStatus.opLatencies reads averaged over 100 ms
  across the interval, on a real number of reads - the storage latency
  behind the "Slow query" lines.
- db.disk-space: dbStats fsUsedSize/fsTotalSize below 5% or 512 MiB free -
  the real "no space left on device", before it happens.
- db.index-created: the one remediation WeKan can do itself. ensureIndex
  (server/lib/mongoStartup.js) now reports an index it created on a
  collection that already held documents - until then every query on it
  was a collection scan - as found and fixed; a new, empty collection
  getting its indexes at first start stays silent.

All rows go through the existing `database` stream (recordDatabaseHealth in
server/lib/databaseProblems.js: same shape, same per-minute quieting per
type), so they land on the same page as what the database itself says.
FerretDB answers only some of these commands; each step is independent and
what it cannot answer is skipped. Nothing here can throw into startup or
sits on a request path.

tests/databaseHealth.test.cjs drives every decision (including the
reported case: 519 MB used, 10 GiB free is NOT a space problem) and pins
the wiring.

Thanks to xet7 !
2026-09-11 11:23:53 +03:00
..