syncthing/lib/protocol
Jakob Borg 744ef0d8ac
lib/protocol: Avoid data loss on database wipe by higher version numbers (fixes #3876) (#6605)
This makes version vector values clock based instead of just incremented
from zero. The effect is that a vector that is created from scratch
(after database reset) will have a higher value for the local device
than what it could have been previously, causing a conflict. That is, if
we are A and we had

    {A: 42, B: 12}

in the old scheme, a reset and rescan would give us

    {A: 1}

which is a strict ancestor of the older file (this might be wrong). With
the new scheme we would instead have

    {A: someClockTime, b: otherClockTime}

and the new version after reset would become

    {A: someClockTime+delta}

which is in conflict with the previous entry (better).
In case the clocks are wrong (current time is less than the value in the
vector) we fall back to just simple increment like today.

This scheme is ineffective if we suffer a database reset while at the
same time setting the clock back far into the past. It's however no
worse than what we already do.

This loses the ability to emit the "added" event, as we can't look for
the magic 1 entry any more. That event was however already broken
(#5541).

Another place where we infer meaning from the vector itself is in
receive only folders, but there the only criteria is that the vector is
one item long and includes just ourselves, which remains the case with
this change.

* wip
2020-05-06 08:47:02 +02:00
..
benchmark_test.go lib/model, lib/protocol: Use error handling to avoid panic on non-started folder (fixes #6174) (#6212) 2019-12-04 10:46:55 +01:00
bep_extensions.go lib/protocol: Zero pad index ID strings 2020-03-17 07:40:52 +01:00
bep.pb.go lib/db: Deduplicate block lists in database (fixes #5898) (#6283) 2020-01-24 08:35:44 +01:00
bep.proto lib/db: Deduplicate block lists in database (fixes #5898) (#6283) 2020-01-24 08:35:44 +01:00
bufferpool_test.go Fix bufferpool puts (ref #4976) (#6125) 2019-11-06 10:53:10 +00:00
bufferpool.go Fix bufferpool puts (ref #4976) (#6125) 2019-11-06 10:53:10 +00:00
common_test.go lib/model, lib/protocol: Use error handling to avoid panic on non-started folder (fixes #6174) (#6212) 2019-12-04 10:46:55 +01:00
compression_test.go Add 'lib/protocol/' from commit 'f91191218b192ace841c878f161832d19c09145a' 2015-09-22 19:34:29 +02:00
compression.go lib/protocol, lib/discover, lib/db: Use protocol buffer serialization (fixes #3080) 2016-07-04 10:40:29 +00:00
conflict_test.go all: Become a Go module (fixes #5148) (#5384) 2018-12-18 12:36:38 +01:00
counting.go all: Add comment to ensure correct atomics alignment (fixes #5813) 2019-07-13 14:05:39 +01:00
debug.go all, lib/logger: Refactor SetDebug calls (#6054) 2019-10-04 13:03:34 +02:00
deviceid_test.go all: Even more boring linter fixes (#5501) 2019-02-02 11:45:17 +01:00
deviceid_test.pb.go all: Upgrade github.com/gogo/protobuf and regenerate (fixes #6085) 2019-10-18 09:53:59 +02:00
deviceid_test.proto all: Update protobuf package 1.0.0 -> 1.2.0 (#5452) 2019-01-14 11:53:36 +01:00
deviceid.go lib/protocol: faster Luhn algorithm and better testing (#6475) 2020-03-29 22:28:04 +02:00
doc.go Add 'lib/protocol/' from commit 'f91191218b192ace841c878f161832d19c09145a' 2015-09-22 19:34:29 +02:00
errors.go lib: chmod -x on progressemitter.go and errors.go (#5281) 2018-10-21 16:08:14 +01:00
hello_test.go all: Even more boring linter fixes (#5501) 2019-02-02 11:45:17 +01:00
hello.go all: Tweak error creation (#6391) 2020-03-03 22:40:00 +01:00
LICENSE
luhn_test.go lib/protocol: faster Luhn algorithm and better testing (#6475) 2020-03-29 22:28:04 +02:00
luhn.go lib/protocol: faster Luhn algorithm and better testing (#6475) 2020-03-29 22:28:04 +02:00
nativemodel_darwin.go lib/model, lib/protocol: Use error handling to avoid panic on non-started folder (fixes #6174) (#6212) 2019-12-04 10:46:55 +01:00
nativemodel_unix.go lib/model, lib/protocol: Implement temporary indexes (fixes #950) 2016-04-15 10:59:41 +00:00
nativemodel_windows_test.go lib/model, lib/protocol: Handle request concurrency in model (#5216) 2018-11-13 08:53:55 +01:00
nativemodel_windows.go lib/model, lib/protocol: Use error handling to avoid panic on non-started folder (fixes #6174) (#6212) 2019-12-04 10:46:55 +01:00
protocol_test.go lib/protocol: Zero pad index ID strings 2020-03-17 07:40:52 +01:00
protocol.go lib/protocol, rc, utils: Add mutex Unlock before panic (#6556) 2020-04-20 14:52:16 +02:00
vector_test.go lib/protocol: Avoid data loss on database wipe by higher version numbers (fixes #3876) (#6605) 2020-05-06 08:47:02 +02:00
vector.go lib/protocol: Avoid data loss on database wipe by higher version numbers (fixes #3876) (#6605) 2020-05-06 08:47:02 +02:00
wireformat.go lib/model, lib/protocol: Add contexts sending indexes and download-progress (#6176) 2019-11-25 11:07:36 +01:00