put_doc_if_newer should check replica_trans_id

Bug #1006876 reported by John A Meinel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
U1DB
Fix Released
High
Eric Casteleijn

Bug Description

a split out from bug #999574

put_doc_if_newer currently gets a replica_trans_id which it then passes on to set_sync_info.

We should be checking some constraints, and aborting the stream if they are violated.

1) If replica_gen is greater than the replica_gen stored in sync_log, then we just accept the document, and update as normal.
2) If replica_gen is equal to the replica_gen stored in the sync_log, then replica_trans_id must match exactly
3) If replica_gen is less than or equal to the gen stored in the sync_log, then the document must not be newer. If we see the document as newer, then we know we have gotten divergence and should abort the stream. The cases are:
  a) we sync, get some new documents, and then the source is reverted to a state where it has the documents, but not the knowledge that the sync was done. In this case, a follow up sync should be sending the same content, resulting in all 'converged' cases.
  b) Same case, but in the mean time we got other new data in the target. Any new data should 'supersede'
 In either case, it shouldn't be observed that documents that are 'older' than where our sync point is at are considered newer than what is in the target.

Related branches

Revision history for this message
John A Meinel (jameinel) wrote :

probably wants bug #1006879 before completing.

Revision history for this message
John A Meinel (jameinel) wrote :

Note that this could potentially be done in insert_doc_from_source or somewhere along those lines, however the data is being stored (and thus passed) to put_doc_if_newer, so it makes sense to do it at that level. That is also the level that we do the transaction.

Also, this is the change that makes it safe to do a partial sync after rollback, rather than just aborting because the generation seen is older than we expect. (It is ok, as long as all of those documents would not trigger an update in the target replica.)

Revision history for this message
John A Meinel (jameinel) wrote :

bug #1006897 will need to be addressed once this one is completed.

John O'Brien (jdobrien)
Changed in u1db:
assignee: nobody → Eric Casteleijn (thisfred)
Revision history for this message
Eric Casteleijn (thisfred) wrote :

In cases 2 and 3, we continue syncing but do not store the document at all, correct?

Changed in u1db:
status: Confirmed → In Progress
Changed in u1db:
status: In Progress → Fix Committed
Changed in u1db:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.