mirror of
https://github.com/wekan/wekan.git
synced 2026-11-25 10:48:06 -05:00
An instance on 10.96 went offline at every restart. wekan-control ran bin/database-autopick synchronously and unbounded before anything opened the web port - and that comparison starts each database on a temporary port to read it, which on a real instance is minutes. Until it returned a browser got a connection timeout, and the reason was in `snap logs`, the last place somebody whose site is down thinks to look. That is #6592 one step earlier than #6592 was fixed. The database WAIT already serves a "waiting for its database" page; the helpers for it were defined 200 lines BELOW the comparison that needed them. They move up, and the comparison uses them - after the same grace period, so a comparison that finishes in seconds does not flash a page up and teach proxies to cache a 503 for a healthy site. And a bound: WEKAN_AUTOPICK_TIMEOUT, 900s by default. When it runs out WeKan says so, changes nothing, and starts on the database already selected. Stopping the comparison is safe - it never deletes anything on either side, and the merge it may be in the middle of only INSERTS what is missing, so a partial one is fewer documents copied and the next start finishes the job. Serving the site beats finishing the comparison. WEKAN_AUTOPICK was an env var and nothing else, so an admin whose site was down had no supported way to skip the comparison. It is a snap config key now, with the bound beside it: snap set wekan autopick=false snap set wekan autopick-timeout=1800 The timeout message names all three of those, because somebody reading it is somebody whose site just came up late. This is the other half of the mtime fix. Before that, the comparison ran at EVERY start - autopick's own mongod stamped the files the staleness check reads - so every restart took the site down for a comparison that could never conclude. One made it recur; this one makes it survivable. Thanks to xet7 !