Skip to content

all: Remove need to restart syncthing - #6883

Merged
calmh merged 15 commits into
syncthing:mainfrom
AudriusButkevicius:restart
Aug 18, 2020
Merged

calmh merged 15 commits into
syncthing:mainfrom
AudriusButkevicius:restart

Conversation

@AudriusButkevicius

Copy link
Copy Markdown
Member

This removes the need to restart syncthing in almost all cases.

The only two left are:

  1. Crash reporting - happens in the monitor (and monitor only re-reads the option on restart of the child process)
  2. Database tuning - everything depends on this, so we pretty much have to tear down the whole application anyway.

@AudriusButkevicius AudriusButkevicius changed the title all: all: Remove need to restart syncthing Aug 8, 2020
@AudriusButkevicius

Copy link
Copy Markdown
Member Author

Actually, crash reporting does not require restarts after all, as it's checked on every attempt to report them, and the attempts only happen on restarts.

@imsodin imsodin 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.

Cool - thanks for tackling this longstanding (unnecessary) annoyance!

The whole connection-discovery-chicken-egg is ugly (discovery needing SetAddressLister to be called and to do the config subscription in exactly the order it is otherwise it panics). Given discovery is part of managing connections, I'd setup discovery in connections.NewService making connections the chicken and discovery one of its eggs.

The rest of the comments are just nits.

Comment thread lib/config/optionsconfiguration.go Resolved
Comment thread lib/discover/cache.go Resolved
Comment thread lib/discover/manager.go
Comment on lines +25 to +30
// The Manager aggregates results from multiple Finders. Each Finder has
// an associated cache time and negative cache time. The cache time sets how
// long we cache and return successful lookup results, the negative cache
// time sets how long we refrain from asking about the same device ID after
// receiving a negative answer. The value of zero disables caching (positive
// or negative).

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.

Sounds like caching times are configurable, while they are hardcoded. I'd just keep the generic explanation how the cache retention/eviction works without explicitly talking about associated times.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

To be honest, I think all of this is an explanation how it works.

Comment thread lib/discover/global.go Resolved
@AudriusButkevicius

AudriusButkevicius commented Aug 9, 2020 •

Copy link
Copy Markdown
Member Author

I think the connection.NewService suggestion makes things worse, and breaks the nice dependency injection we have going on.

I'd be unable to supply my own implementation of discover.Finder to it anymore. I have an alternative approach, which is a wrapper around addressLister, which initially has no implementation, and then I later set the implementation once connection service is created.

This keeps the component APIs clean, and has a bit on ugly code in the wiring.

I believe this is what other dependency injection frameworks like spring do in cases like this, that is create a proxy satisfying the interface, and wire it later.

Comment thread lib/discover/manager.go Resolved
@imsodin

imsodin commented Aug 10, 2020

Copy link
Copy Markdown
Member

I guess we are getting a bit off-track here, given it's about not having to restart. And likely the issues have existed before this PR, the s/CachingMux/Manager/ change just prompted me to look at it - so feel free to skip any of this.
If this were about a nice refactor and we want to keep dependency injection, I'd separate the discovery announcement and querying to remove the co-dependency with the connection service. And on separation of concerns it's weird that local discovery does it's own caching, and for global discovery the manager handles caching. I'd probably not do any caching on the finders and let the manager handle all of it.

@AudriusButkevicius

AudriusButkevicius commented Aug 10, 2020 •

Copy link
Copy Markdown
Member Author

So I am not going down that rabbit hole in this PR. My goal is to remove the need to restart with as minimal code changes as possible.

If we want to refactor discovery, split stuff, give magic values constant names, I am fine with that, but not in this PR.

This PR already touches other things other than discovery.

@imsodin imsodin 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.

As I wrote, no need to go into that (I like to write up things I notice, if only because it sometimes makes me realize flaws in my thought process - I need to setup some personal code-linked note-taking). The new manager file not being picked up as similar enough, initially led me to believe you changed more than you really did (git diff main:lib/discover/cache.go lib/discover/manager.go is revealing).

@imsodin imsodin 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.

Thought I'd take it for a spin given I already checked the branch out for diffing and got a panic - investigating.

Comment thread lib/syncthing/syncthing.go Resolved
@calmh
calmh merged commit bf9ff17 into syncthing:main Aug 18, 2020
@AudriusButkevicius
AudriusButkevicius deleted the restart branch August 18, 2020 07:33
@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)
  ...
@AudriusButkevicius

Copy link
Copy Markdown
Member Author

I don't think those required restart ever.

@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 19, 2021
@syncthing syncthing locked and limited conversation to collaborators Aug 19, 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.

4 participants