Skip to content

lib/model: Check folder error before sync-waiting (fixes #6793) - #6847

Merged
imsodin merged 1 commit into
syncthing:mainfrom
imsodin:model/errStateAndSyncWait
Jul 31, 2020
Merged

imsodin merged 1 commit into
syncthing:mainfrom
imsodin:model/errStateAndSyncWait

Conversation

@imsodin

@imsodin imsodin commented Jul 22, 2020

Copy link
Copy Markdown
Member

There's two related elements here: 1. folder.pull should not defer f.setState(FolderIdle). The actual underlying pull already takes care of folder state (either error or idle). 2. For scanning and (real) pulling we always check folder health/error before setting status. We don't do the same for sync-waiting. This means an existing error gets "half-cleared": State changes to sync-waiting, but error remains (as errors are only touched by setError). Thus when the actual puller calls setError, it sees the same error before and after and thus returns early without setting the folder state back to error. Regardless of this issue I believe it makes sense to check folder health before acquiring the iolimiter token to get the error notification to the user faster.

I don't entirely get the separation of setState and setError though. Given setError is called with nil, it seems like one shouldn't call setState when an error is set/"active", but that's not enforced. If that's not the case and setState is meant to override errors, it doesn't do that (no s.err = nil). To me it would feel simpler and more robust if setState did clear previous error states. Does anyone have any insights into why things work as they do at the moment?

@calmh

calmh commented Jul 30, 2020

Copy link
Copy Markdown
Member

Probably just evolution. Maybe setState and setError should be combined. Either we are in a "doing something" or "waiting for something" state, when there implicitly can't be an error, or we are done with something and the outcome determines if we are now in an error state or not...

@calmh calmh left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably fine, unless we want to improve it further.

Generally I think we have too many exit paths so it's not clear to me how/when a folder changes state back, hence the defer. Maybe the state and/or error setting should happen in just one (outermost) place and the various inner pieces just communicate by returning errors upwards. Or something.

@imsodin

imsodin commented Jul 31, 2020

Copy link
Copy Markdown
Member Author

I agree it could and should be improved, however I'd anyway like to get this fix in the way things work currently going. So when it gets improved it start from a sounder base.

@imsodin
imsodin merged commit a85bc1c into syncthing:main Jul 31, 2020
@imsodin
imsodin deleted the model/errStateAndSyncWait branch July 31, 2020 17:26
@imsodin
imsodin restored the model/errStateAndSyncWait branch July 31, 2020 17:26
@calmh calmh added this to the v1.9.0 milestone Aug 18, 2020
calmh added a commit to calmh/syncthing that referenced this pull request Aug 19, 2020
* main: (368 commits)
  build: We now target Go 1.14
  lib/fs: Disable ioctl on ppc (fixes syncthing#6898) (syncthing#6901)
  gui, man, authors: Update docs, translations, and contributors
  lib/dialer: Try dialing without reuse in parallel (fixes syncthing#6892) (syncthing#6893)
  cmd/stcrashreceiver: Don't crash on nil err
  all: Remove need to restart syncthing (syncthing#6883)
  lib/db: Don't put truncated files (ref syncthing#6855, ref syncthing#6501) (syncthing#6888)
  lib/osutil: Check returned error instead of info (ref syncthing#6885) (syncthing#6887)
  gui, man, authors: Update docs, translations, and contributors
  lib/osutil: Preserve perms in AtomicWriter (fixes #tbd) (syncthing#6885)
  lib/fs: Fix WatchRename test for FreeBSD (fixes syncthing#6613)
  lib/fs: Unwrap mtimeFile, get fd the "correct" way (ref syncthing#6875) (syncthing#6877)
  lib/model: Don't close file early (fixes syncthing#6875) (syncthing#6876)
  lib/fs: Unwrap mtimeFile, get fd the "correct" way (ref syncthing#6875) (syncthing#6877)
  gui, man, authors: Update docs, translations, and contributors
  lib/fs: Fix WatchRename test for FreeBSD (fixes syncthing#6613)
  lib/model: Don't close file early (fixes syncthing#6875) (syncthing#6876)
  lib/db: Log context on panic (syncthing#6872)
  gui: Don't show pull order on SO folders (ref syncthing#6807) (syncthing#6871)
  lib/model: Check folder error before sync-waiting (fixes syncthing#6793) (syncthing#6847)
  ...
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Aug 1, 2021
@syncthing syncthing locked and limited conversation to collaborators Aug 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants