mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 10:48:06 -05:00
v11.21
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
bb76e7bf10 |
Snap: remove the database setting. There is one answer, and it is FerretDB.
`snap set wekan database=mongodb|ferretdb` is gone, and so is `snap run wekan.database`. WeKan runs on FerretDB on every platform; MongoDB is in the amd64/arm64 snaps to be READ while a migration is owed. A setting could say something the data did not support, and every way it could was a report: set to mongodb it kept a site on the database the snap migrates away from, for good, because nothing ever set it back - including instances a failed migration or a wrong staleness guess had put there; set to ferretdb with no FerretDB present it would have served an empty site, so the guard against that had to exist anyway; and each script carried its own copy of "which database is this, then". snap-src/bin/database-role replaces it. One helper, asked by wekan-control, mongodb-control, ferretdb-control, migration-pending, attachment-repair and the configure hook, answering from the data: a FerretDB with something in it and a migration that has finished means ferretdb, MongoDB data with the migration still owed means mongodb. An interrupted migration is told from a finished one by the importer's checkpoint, so a partial FerretDB resumes and a finished one whose marker went missing is not migrated over again (#6585). An empty FerretDB beside a MongoDB full of boards is never served. The explanatory page is no longer a dead end: when this snap cannot read the MongoDB files but a FerretDB copy is there, the copy is served - older beats unreadable - and the page says the snap keeps trying rather than giving a command to type. A snap that still has the old setting is told once that it is ignored, and it is unset. docs/Platforms/FOSS/Container/Snap/Migration-to-FerretDB.md is the design in one page: all text data to SQLite, CollectionFS and Meteor-Files attachments to the filesystem, the card History with it, which MongoDB versions can be read, when it runs, what happens when it fails, and how two copies are reconciled. The Admin Panel, Snap and CPU-platform docs point there instead of documenting a setting that no longer exists. Nine guards updated; each says in it which decision changed and why. Thanks to xet7 ! |
||
|
|
40ff8151ea |
Snap: pick the database that holds the work, and merge the other one into its history.
An email report, on an instance being served the older of its two copies: "some users are unable to log in (error: 'user not found'), and boards created after mid-July appear to be missing." That is what serving a copy looks like from the outside - the accounts and boards made after the copy was taken simply are not there. Until now the snap handled that by telling the admin to sort it out. #6583 taught it not to switch on a guess, so when both MongoDB and the migrated FerretDB have been written to since the migration it printed the two `snap set wekan database=...` commands and stayed where it was. That message is in `snap logs`; most people never see it, and their site meanwhile shows the wrong copy. A file timestamp cannot answer "which copy holds the work" - an mtime says when a file was touched, and starting a database touches its files. But both copies can be READ, so ask them. bin/db-eval.mjs gains an `evidence` command (per-collection counts, plus the newest timestamp any document carries) and bin/database-choose.mjs decides from the two answers: one holds everything the other holds, and is not older -> serve it, nothing to merge; both hold work the other does not, and one is clearly newer -> serve the newer one and copy across what only exists in the other; too close to call, or nothing readable -> change NOTHING and keep the existing message, because that case is a decision about somebody's work. "Clearly newer" is a margin, not a tie-break: six hours by default, so the writes the migration itself makes on both sides cannot decide anything. WHY THE MERGE IS SAFE, and it is WeKan's own design that makes it safe: the history is APPEND-ONLY (docs/Features/Reports/History/History.md, which gains a section 9a on exactly this). Activities, comments and the coming changeHistory rows are never rewritten in place, so they can only be ADDED to. bin/database- merge-missing.mjs therefore inserts every document whose _id is ABSENT from the chosen database and does nothing else: * a document that IS there is never overwritten - a card edited on both sides keeps the version in the copy being served, which is the newer one; * nothing is deleted, on either side; * the copy that was not chosen stays on disk, so `snap set wekan database=<the other one>` is still the way back - now a choice rather than a repair; * the work done on the copy that is not being served becomes readable in the served copy's card History instead of sitting in a database nobody opens. For the reported symptoms that means the missing users and boards are inserted rather than left behind: a user who could not log in exists again, with their own _id, and their boards with them. A three-way merge - reconciling two edits of one field - is not attempted and will not be from a script. Where the evidence cannot separate the copies, the snap still says so and hands the decision to a person. WEKAN_AUTOPICK=false turns the whole thing off, `database-autopick --dry-run` shows what it would do, and AUTOPICK_MERGE_LIMIT bounds how much it copies. tests/snapDatabaseAutopick.test.cjs covers the decision (both superset directions, the both-diverged case, one side empty or unreadable, too-close, no timestamps, and a BIGGER but older copy that must not win on size) and runs the merge against an in-memory pair of databases: what is missing is inserted, what exists is not overwritten, nothing is deleted on either side, --dry-run writes nothing, a limit is not an error, and the merge script contains no update or delete operation at all. tests/ferretdbMigrationStale.test.cjs keeps its rule - no switch on a guess - with the assertion updated to match what changed: this branch may not choose from the timestamps it has, it delegates to the one thing that can choose, and when even that cannot tell the copies apart the admin still gets both commands. Verified by running both suites and the whole node suite (381 suites, 0 failed). The snap itself cannot be built or refreshed in this sandbox, so the orchestration that starts each database on a temporary port is verified from the code and from the shapes migration-control already uses, not from a running snap. Thanks to xet7 ! |