Version vector

I roughly understand the version vector in the index message, but I’m not 100% sure of collision detections.

Node A creates the file and adds A:1 to the version vector. Node B updates the file and adds B:1 to the vector. If both A and B update at the same time, they edit their entry to 2 locally and send to each other. Say A sends its update first, B receives an update with B:1 and A:2 in the version vector, B can see that B:1 is lower than the version it has set locally so this is enough to determine there has been an update collision on this file?

I think this is right, but I wanted to be certain before I code up something.

That sounds about right. A:1,B:2 is not a descendant of A:2,B:1 nor the other way around, hence they were created concurrently with each other and are in conflict.

Perfect, thanks.

One more question, if we have the simultaneous update as set out earlier, and both nodes send out their index at the same time and they both detect the collision, do they both create a collision file?

Seems like you could end up with some nasty file creation recursion, so is there some mechanism to avoid this?

Which file wins is deterministic, so both sides make the same decision.

Is there a specification for this I can read?

The implementation is the specification, in this case.

Thanks, I was hoping there was something else, I don’t read Go so well! I’ll dig through it.

So both nodes create a

‘filename.sync-conflict-date-time-modifiedBy.ext’

file which will have the same contents due to deterministic decision making. The original file will also match and also have the same version vector. But as the conflict file is created on both nodes wouldn’t the version vector be different?

So when A gets an update from B with the conflict file in it, it looks like an update to version B:1, A:1 (from B:0, A:1). Is that how it’s supposed to work or is there some way of dealing with this.

Thanks for your patience with this, on the surface it looks simple but there are quite a few details to get right,

Only the losing side creates the conflict copy. The winning side doesn’t have the data that would go into the conflict copy.