mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
A legacy History writer holds a token on its board's gate until its write is confirmed, with no expiry, so an uncertain write can never become invisible to a chain migration. A writer that died kept its token forever, and the only way to remove it was the offline tool with every server stopped. Maintainer decision of 2026-09-30: build online recovery - liveness heartbeats and fencing on History inserts - and keep the offline tool as the fallback. Each writer on an upgraded server now writes a lease beside its token (historyWriterLeases) and renews it while it works. Before every legacy History insert it claims the row id in the lease; only an active lease can claim. Recovery takes a lease only after it has been expired for another full lease period (HISTORY_WRITER_LEASE_MS, default 30 s). It sets the lease to fenced, so the old writer can neither renew nor claim. A claimed row id is then fenced by a tombstone under that id, so the unique _id makes a late insert fail, and a row that had already landed stays. Only then is the token removed. Safety rests on the fence; clocks only decide when a lease may be taken, and a slow writer that is taken loses its write with an error. Tombstones use the reserved board id #history-writer-fence and are invisible to every board reader. A Sync append refuses a tombstone as its planned row. A chain migration takes abandoned writers by itself while the board drains, a full gate does the same once, and releases/recover-history-writer.cjs --recover-expired does it on demand, online. Tokens without a lease (older servers) are listed and still need the offline procedure. MongoDB tests with two clients: a writer that died after claiming a row is taken and its late insert fails; a fenced slow writer cannot claim; a row that landed before the fence is kept; live writers and lease-less tokens are not taken; a migration drains a dead writer and completes on the real chain head. A full-app test covers the production binding. 563 server tests pass. Thanks to xet7 !
Features by menu
Start with Features, the menu-based documentation index. See September 2026 additions for the newest guides.
See menu implementation audit for test evidence and known implementation gaps.