Admin Panel / Problems showed "Created the missing index "-modifiedAt" on
lists" at every start, from every pod. server/models/users.js passed the
list sort options ('-modifiedAt', 'title', ...) to ensureIndex as
strings: the driver read each as a field name, so lists got indexes on
fields named "-modifiedAt", "-title" and "-sort" (on no document, kept up
to date on every list write), and ensureIndex compared a string's JSON
with an index key object's, which never matched, so all six were
re-created and reported every time.
models/lib/indexKeys.cjs turns the sort options into one single-field
index per field ({ modifiedAt: 1 }, { title: 1 }, { sort: 1 }; one serves
both directions) and finds the stray single-field "-x" indexes, which
startup now drops; a compound index containing such a field is left
alone. ensureIndex turns a string key into the key it means, with a
warning, instead of indexing a field named after it.
tests/listSortIndexes.test.cjs uses the reporter's real index list, runs
ensureIndex itself against a fake collection (a string key creates the
real index once and reports it once), and fails on any ensureIndex call
in the tree whose key is not an index key object.
Thanks to Raymond-Voogt and xet7 !
Fixes#6794,
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 !