Syncthing: Syncthing should guard against running old versions with new config

0

Problem:
I have latest release of Syncthing (v0.14.47) and during development & debugging I accidentally run older version of Syncthing v0.14.(4 or 17) and it was successfully started in background because config paths are the same (defaults).
Now, my _config.xml_ becomes a mix of old-style and new-style options but still has version=28 and who knows what can happen to other files if version will be even older(e.g. db format incompatibility).

For example:

 <configuration version="28"> # both files

-        <minDiskFree unit="%">1</minDiskFree>
+        <minDiskFreePct>0</minDiskFreePct>
-        <pullerMaxPendingKiB>0</pullerMaxPendingKiB>
+        <pullers>0</pullers>

What's expected? One of this:

  • it should fail to start early with appropriate message unless some special option is used like --allow-downgrade (or whatever)
  • or at least start in read-only mode for everything

Version Information

Syncthing Version: Any
OS Version: Any

ssergiienko picture ssergiienko  ·  5 May 2018

Most helpful comment

3

It can be a problem as it’ll (re)write attributes in an old format that is no longer understood by newer Syncthings and won’t be converted again. I think it would be sane to refuse to load a config from the future by default.

calmh picture calmh  ·  5 May 2018

All comments

-1

I don't see an actual problem though. If something was incompatible, I guess I would expect it to fail. If it didn't, it's probably ok. The new/old config stuff would get cleaned up on first config save.

AudriusButkevicius picture AudriusButkevicius  ·  5 May 2018
3

It can be a problem as it’ll (re)write attributes in an old format that is no longer understood by newer Syncthings and won’t be converted again. I think it would be sane to refuse to load a config from the future by default.

calmh picture calmh  ·  5 May 2018
0

@calmh, @AudriusButkevicius, @ssergiienko Hi there,
I wanna work on this ticket. As I understand the problem, besides the different Syncthing versions, they have different GUI Configuration versions (28 and 25). So that don't let loading config.xml for older Syncthing versions and logged "Version Conflict" with Exit code is appropriate to solve the problem. Any suggestions or comments??
Thxs.

bahadir60 picture bahadir60  ·  3 Sep 2018
0

Mmm, yes. There's a current config version, defined somewhere in config.go I think. If the config on disk has a higher number than that, it has a newer schema that we by definition don't understand.

There's a place in main.go where we check if the config was upgraded, which might be a good place to also check if the config version is too high and abort.

Alternatively the check could happen already in the config loader, but it would be nice to be able to force a start with --allow-downgrade or something, in which case having the config loader throw an error might be annoying. We don't want to pass parameters like that down to the config loader. On the other hand, having the check there and returning a known error could work. That also means we'd automatically catch things like someone posting a too new config over the API as well.

calmh picture calmh  ·  3 Sep 2018
2

@calmh Thanx, I will work on it and implement ASAP

bahadir60 picture bahadir60  ·  3 Sep 2018