Repository navigation
all: Handle errors opening db/creating file-set (ref #5907) - #7150
Conversation
|
zomg |
@imsodin is a beast and nothing can stop him. |
Why not check if the error satisfies some reportable interface or something? Having to push down the whole reporting mechanism stack down so deep feels icky. |
There are conditions in the db package where I'd like to generate a report, but that are handled internally. Like metadata counters becoming negative or empty globals. That's stuff that should never happen, but also isn't bad enough to justify making it fatal (or just recoverable). |
| return fatalErr(err) | ||
| } | ||
|
|
||
| m.cfg.Subscribe(m) |
There was a problem hiding this comment.
We could miss a config change after initFolders but before we subscribe, so perhaps subscribe before initFolders?
There was a problem hiding this comment.
Probably better that way round, yes. However really there should be a hook or something on Subscribe to initialize the subscriber with the config that's in place while subscribing. Otherwise you can still have the race that a config change comes in while we are still initialising folders (which isn't even so unlikely, given creating the filesets and recalculating metadata can take a while).
Edit:
Though such a hook is also problematic, as to be effective it would have to block further config changes while executing the hook, and again that can take a long time and thus blocking a lot of things which causes other badness.
* main: (27 commits) lib/fs: Correct wrapping order for meaningful log-caller (syncthing#7209) all: Handle errors opening db/creating file-set (ref syncthing#5907) (syncthing#7150) cmd/relaypoolsrv: Allow validation of relay join requests by certificate (fixes syncthing#7196) (syncthing#7217) lib: Close underlying conn in protocol (fixes syncthing#7165) (syncthing#7212) lib/db: Prevent IndexID creation race (syncthing#7211) gui: Reflect change in untrusted in sharing tab (syncthing#7201) lib/db: Remove index ids when dropping folder (syncthing#7200) lib/model: Fix flaky test and add some scanning debug (syncthing#7214) lib: Consistently set suture logging (syncthing#7202) lib/model: Unflake TestIgnoreDeleteUnignore (syncthing#7208) gui: Apply changes to untrusted (ref syncthing#6443) (syncthing#7206) lib/config: Remove deprecated pending entries from config (ref syncthing#6443) (syncthing#7204) all: Store pending devices and folders in database (fixes syncthing#7178) (syncthing#6443) gui, man, authors: Update docs, translations, and contributors gui: Sort folders and devices in advanced config modal (syncthing#7192) model: Actually print folder description in "Overriding" log message gui: version.tags is an array, which is truthy when empty build: Switch to gopsutil's v3 module (syncthing#7191) build: Update notify (fixes syncthing#7076) (syncthing#7189) lib/api: Returns tags in version as list (syncthing#7190) ...
This is a first step towards graceful error handling in the db layer. It introduces error return values to
NewLowlevelandNewFileSet. That requires a mechanism in the model to handle fatal errors when starting folders, which is just a one-buffered channel for fatal errors that the model service receives from to initiate shutdown.This means that errors which were previously panics and thus reported now result in a graceful shutdown, i.e. no panic reporting. Thus I introduced failure reporting in the db. The principle is that every package is responsible for reporting it's own failures, even if that failure results in a returned error. The reasoning is, that only at the error source you can know if the error needs reporting and whether it's actually safe to report (e.g. doesn't contain paths or ids).
Previously such fatal failures would hardly ever get reported, as the reporting service gets torn down due to the fatal failure before it sends them. Now unreported failures are written to disk when the service stops and these failures are then reported on next startup.