git-annex/doc/design
Joey Hess 1acdd18ea8
deal better with clock skew situations, using vector clocks
* Deal with clock skew, both forwards and backwards, when logging
  information to the git-annex branch.
* GIT_ANNEX_VECTOR_CLOCK can now be set to a fixed value (eg 1)
  rather than needing to be advanced each time a new change is made.
* Misuse of GIT_ANNEX_VECTOR_CLOCK will no longer confuse git-annex.

When changing a file in the git-annex branch, the vector clock to use is now
determined by first looking at the current time (or GIT_ANNEX_VECTOR_CLOCK
when set), and comparing it to the newest vector clock already in use in
that file. If a newer time stamp was already in use, advance it forward by
a second instead.

When the clock is set to a time in the past, this avoids logging with
an old timestamp, which would risk that log line later being ignored in favor
of "newer" line that is really not newer.

When a log entry has been made with a clock that was set far ahead in the
future, this avoids newer information being logged with an older timestamp
and so being ignored in favor of that future-timestamped information.
Once all clocks get fixed, this will result in the vector clocks being
incremented, until finally enough time has passed that time gets back ahead
of the vector clock value, and then it will return to usual operation.

(This latter situation is not ideal, but it seems the best that can be done.
The issue with it is, since all writers will be incrementing the last
vector clock they saw, there's no way to tell when one writer made a write
significantly later in time than another, so the earlier write might
arbitrarily be picked when merging. This problem is why git-annex uses
timestamps in the first place, rather than pure vector clocks.)

Advancing forward by 1 second is somewhat arbitrary. setDead
advances a timestamp by just 1 picosecond, and the vector clock could
too. But then it would interfere with setDead, which wants to be
overrulled by any change. So it could use 2 picoseconds or something,
but that seems weird. It could just as well advance it forward by a
minute or whatever, but then it would be harder for real time to catch
up with the vector clock when forward clock slew had happened.

A complication is that many log files contain several different peices of
information, and it may be best to only use vector clocks for the same peice
of information. For example, a key's location log file contains
InfoPresent/InfoMissing for each UUID, and it only looks at the vector
clocks for the UUID that is being changed, and not other UUIDs.

Although exactly where the dividing line is can be hard to determine.
Consider metadata logs, where a field "tag" can have multiple values set
at different times. Should it advance forward past the last tag?
Probably. What about when a different field is set, should it look at
the clocks of other fields? Perhaps not, but currently it does, and
this does not seems like it will cause any problems.

Another one I'm not entirely sure about is the export log, which is
keyed by (fromuuid, touuid). So if multiple repos are exporting to the
same remote, different vector clocks can be used for that remote.
It looks like that's probably ok, because it does not try to determine
what order things occurred when there was an export conflict.

Sponsored-by: Jochen Bartl on Patreon
2021-08-04 12:33:46 -04:00
..
adjusted_branches Added a comment: adjusted branche to "focus" on a specific subtree 2016-08-22 14:19:57 +00:00
assistant comment 2021-04-18 13:07:03 -04:00
encryption
exporting_trees_to_special_remotes Added a comment 2018-02-07 20:01:53 +00:00
external_backend_protocol comment 2020-07-31 16:11:10 -04:00
external_special_remote_protocol document what importKey returning Nothing does 2020-12-30 13:23:16 -04:00
git-remote-daemon Added a comment: Rolling hash chunking 2014-04-04 14:16:25 +00:00
iabackup Added a comment: 14 of 21PB, actually 2015-04-30 02:58:05 +00:00
metadata followup 2015-04-09 14:33:11 -04:00
new_repo_versions devblog 2016-05-04 14:39:53 -04:00
p2p_protocol comment 2019-04-03 13:11:34 -04:00
requests_routing Added a comment: Friendly bump to keep on the radar 2019-10-24 09:26:23 +00:00
adjusted_branches.mdwn link to the adjust manpage 2016-06-23 14:39:49 +00:00
assistant.mdwn clarify that this is mostly done (i think?) 2014-04-07 04:41:56 +00:00
balanced_preferred_content.mdwn Fix a typo 2016-02-08 10:54:08 -04:00
caching_database.mdwn followup and add link 2020-07-01 12:28:44 -04:00
encryption.mdwn Fix typo remotes.log -> remote.log 2020-03-28 13:36:45 +00:00
exporting_trees_to_special_remotes.mdwn add design document for import tree 2019-02-20 12:12:32 -04:00
external_backend_protocol.mdwn this protocol is not draft for some time 2020-10-22 19:55:29 -04:00
external_special_remote_protocol.mdwn Added GETGITREMOTENAME to extenal special remote protocol 2021-01-26 12:42:47 -04:00
gcrypt.mdwn automatically derive an annex-uuid from a gcrypt-uuids 2013-09-05 16:02:39 -04:00
git-remote-daemon.mdwn update 2015-01-15 15:58:56 -04:00
iabackup.mdwn Fix spelling in doc/design/iabackup.mdwn 2018-06-03 12:28:26 +00:00
importing_trees_from_special_remotes.mdwn improve docs about removeExportDirectory 2019-05-28 11:16:01 -04:00
metadata.mdwn update for v6 unlocked files 2015-12-26 14:59:06 -04:00
new_repo_versions.mdwn deal better with clock skew situations, using vector clocks 2021-08-04 12:33:46 -04:00
p2p_protocol.mdwn Fixed some other potential hangs in the P2P protocol 2018-11-06 14:52:32 -04:00
preferred_content.mdwn preferred content stability analysis 2014-01-22 15:55:44 -04:00
requests_routing.mdwn keep track of satisfied requests, and summarize 2014-05-09 16:41:05 -03:00
roadmap.mdwn remove priority tag (unused) 2021-02-02 12:42:20 -04:00