mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 04:49:41 -05:00
0d77882c3bba856a5ea1248dfddbf73bda24ef49
5
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
6ec619e438 | Bound platform resources and report runtime failures. | ||
|
|
30e8e38f6c |
Fix the two bugs Admin Panel / Problems / Database problems was reporting.
The page was doing its job and nobody had acted on it. Two real WeKan bugs were
sitting there as rows marked "unknown / unclassified", whose advice was to add a
rule to models/lib/databaseErrors.js. Both are fixed, and both now classify.
1. moveSwimlane, four times over a week:
Error: update is not available on the server. Please use updateAsync()
Board.ensureDefaultSwimlaneId() called the SYNCHRONOUS Swimlanes.upsert().
Meteor 3 removed it on the server, so every move that reached the default
swimlane self-heal threw. The async twin already existed one function below.
This getter is synchronous and cannot await, so the upsert is now STARTED and
not waited for: the self-heal still happens, and the call returns what is in
the cache - which every caller already had to handle, because it was
undefined before the self-heal existed at all. A caller that needs the
swimlane back in the same tick uses ensureDefaultSwimlaneIdAsync().
2. moveList:
ValidationError: Failed validation
Cannot read properties of undefined (reading 'title')
List.move() inserted a new list with `title: this.title`. When a list has no
title, `title` is required by the schema, so the insert fails validation - and
collection2's own error formatter then reads a property of the undefined field
and throws, which is why the admin saw a crash naming neither the list nor the
real problem. It now says what is wrong before the insert: "This list has no
title, so it cannot be moved to another board. Give it a title first." The two
console.log lines that used to sit there printed the title to a log nobody
reads and did not stop the crash; they are gone.
And two classifier rules so neither reads as "unknown" again. Both say plainly
that this is WeKan's bug rather than the database's or the admin's - there is
nothing to configure - and send the reporter to the right place: upgrade, then
open an issue with the method name. Severity `warning`, the vocabulary this
stream uses.
Thanks to xet7 !
|
||
|
|
08be34b70d |
Fix #6533: a busy write is now actually retried, which nothing had ever done.
The crash loop is gone - a transient database error no longer ends the boot
(00startupResilience) or the process (00processErrors) - and the reporter's 10.49
log is the same contention arriving in front of a user instead:
Exception while invoking method '/users/updateAsync' MongoServerError:
... [collection.go:191 sqlite.(*collection).UpdateAll]
[db.go:151 fsql.(*DB).InTransaction] database is locked (5) (SQLITE_BUSY)
That error goes to the CLIENT. The user's edit fails, and they reload to find out
what happened - which is exactly the complaint, "they only see new cards after a
reload". And it was not supposed to: models/lib/databaseErrors.js has classified a
locked SQLite as { id: 'deadlock', act: 'retry' } with "Retried automatically."
since it was written, and 00processErrors says "the write is retried by whatever
issued it". Nothing read `act`. No code in WeKan retried anything, anywhere.
SQLITE_BUSY is the one database error a client is meant to handle itself. SQLite
has a single writer; a second writer arriving while the lock is held is told to
come back, and nothing was applied - FerretDB takes the lock before the
transaction (_txlock=immediate), so a BUSY answer means the write did not happen.
Retrying the same write is the documented behaviour and stays idempotent: Meteor
has already chosen the _id, so a retry that raced a duplicate is refused by the
unique index rather than inserted twice.
server/00retryBusyWrites.js wraps insertAsync / updateAsync / upsertAsync /
removeAsync on Mongo.Collection.prototype: a transient database error is retried
with exponential backoff and full jitter, bounded at 5 attempts and 2s in total
(WEKAN_DB_RETRY_*). Bounded on purpose - retrying for longer holds a method
invocation and its slot in the connection pool while the contention it is waiting
for gets worse. When it still fails the ORIGINAL error is thrown unchanged, so a
database that is genuinely stuck looks exactly as it did before and nothing is
hidden; anything that is not transient is rethrown on the first attempt, so a full
disk is not waited on four times before being reported.
It is loaded from server/imports.js, which runs after the Meteor packages, so this
wrapper sits OUTSIDE the ones collection2 and collection-hooks put on the same
prototype - and that is how it sees the error at all, because by then the busy
error is collection2's ValidationError with the database's message inside it,
which is the form in the reporter's SyncedCron traces.
Writes only. Every error in the reports is a write, which is what contends for the
one writer; SQLite in WAL mode does not block a reader against a writer, and
wrapping every read would put this on the hottest path in the server for no
reported failure.
Retries are counted and summarised at most once a minute, so a contended database
is visible without the log becoming the new problem, and a write finally given up
on is recorded for Admin Panel / Problems - except an eventlog write, which is how
the recorder writes, and reporting its failure would call the recorder from inside
itself.
The reporter asked outright whether PostgreSQL is an option for a snap
installation. It is, and it has been: the deadlock rule's advice now says how -
snap set wekan wekan-ferretdb-handler=postgresql wekan-ferretdb-url=... , or
docker-compose-ferretdb-v1-postgresql.yml in Docker - instead of only saying that
SQLite has one writer.
tests/sqliteBusyRetry.test.cjs loads the real module against a stub collection
prototype and exercises the behaviour: a busy write is retried and succeeds with
its arguments and its collection unchanged, collection2's ValidationError form is
recognised too, a full disk is thrown at once and never retried, an endlessly busy
database gets the original error after a bounded number of attempts AND a bounded
wall-clock time, the backoff grows and is jittered and capped on the shipped
numbers, the summary is rate-limited, reads are left unwrapped, wrapping twice is
a no-op, and the eventlog write is retried without reporting on itself.
Thanks to Nissulya and xet7 !
Fixes #6533,
|
||
|
|
ca0e36e371 |
Database problems: show what the database actually said.
A database problem arrived in Admin Panel / Problems / Database problems with an empty Category, Name and Action, a severity of warning, and a detail that said "The database returned an error WeKan has no rule for. Read the message below" - with no message anywhere below, or above, or on the page at all. So the row said that something happened and nothing about what. Nothing was wrong with the classifier or the recorder. EventLog has a SimpleSchema attached, and collection2 cleans every insert against it with filter:true, so a field the schema does not declare is dropped silently on the way to the database. The four fields the database stream uses - type (the rule id), db (which database said it), kind and message - were never added to that schema, so they were the four things thrown away, and they are exactly the four the page shows in Category, Name, Action and the message it told the admin to read. The other four streams were unaffected because they only ever write schema fields. The schema declares them now, and a test pins the general rule instead of the one instance: for each of the five event loggers, every key of the document it inserts must be declared in the EventLog schema, so the next field somebody adds to a logger cannot vanish the same way. The message is shown too - the Detail cell carries WeKan's reading of the error and then the database's own sentence, which is the one thing an admin can search for or paste into an issue - and the stream search looks at message, db, kind and type, so searching for "postgresql" or for a phrase out of the message finds the row that displays it. The unclassified advice no longer promises a message "below": the message follows in the same cell. Because that message is now stored and displayed, it loses its credentials first. A database that refuses a login or cannot be reached quotes the connection URL back, password and all - "failed to connect to mongodb://wekan:s3cret@mongo:27017" - so classifyDatabaseError redacts the userinfo of any URL in the message before returning it, keeping the host, the port and the database name, which are what makes the message useful. It is done there rather than in the recorder so no future caller can forget it. The message is also sanitized like every other stream's detail: one line, control characters out, capped. Thanks to xet7 ! |
||
|
|
21300f5cb4 |
Say which database has which problem, in Admin Panel / Problems.
WeKan runs on MongoDB or on FerretDB v1 over SQLite, PostgreSQL, MySQL, MariaDB or SAP HANA, and each answers a broken query, a full disk or a refused login in its own words. Those words reached an admin as an opaque string: "Error 1064 (42000): You have an error in your SQL syntax" with no way to know which database said it, that it is FerretDB's bug rather than their data, and that upgrading FerretDB is the fix. models/lib/databaseErrors.js is the translation - pure, so it is unit-tested without a database: a message in, and out comes which database said it, what kind of problem it is, what it means, what the admin should do, and whether WeKan can do anything itself. Sixteen rules, every one of them a message a real database produced in the conformance runs or the documented wording of the condition: injection refused by FerretDB's SQL guard, the syntax errors of all four dialects, the two permission failures that stopped MySQL and MariaDB dead this week, authentication, disk full, connection limits, deadlocks (retried), lost connections (reconnected), timeouts, duplicate keys (which is an index doing its job, not a problem), unimplemented operations, and a handler the binary was not built with. server/lib/databaseProblems.js records them into a new `database` event stream, one per problem per minute - a database that is down answers every query - and watches Meteor._debug, which is where a database error surfaces without wrapping every call site in the app. Admin Panel / Problems has the pane, and its first column is the database that said it. Thanks to xet7 ! |