put_doc_if_newer should check replica_trans_id
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
- Samuele Pedroni: Approve
- John A Meinel (community): Approve
-
Diff: 150 lines (+79/-15)4 files modifiedsrc/u1db.c (+25/-13)
u1db/backends/__init__.py (+6/-0)
u1db/errors.py (+1/-1)
u1db/tests/test_backends.py (+47/-1)
Changed in u1db: | |
assignee: | nobody → Eric Casteleijn (thisfred) |
Changed in u1db: | |
status: | Confirmed → In Progress |
Changed in u1db: | |
status: | In Progress → Fix Committed |
Changed in u1db: | |
status: | Fix Committed → Fix Released |
probably wants bug #1006879 before completing.