|
| 1 | +# XDCR Protostellar Behaviour |
| 2 | + |
| 3 | +### PushDocument |
| 4 | + |
| 5 | +PushDocument exposes two values for CAS, one is the CheckCas and one is the StoreCAS. The |
| 6 | +CheckCas represents the typical Compare And Swap operation of other memcached commands. If |
| 7 | +a CheckCas is specified, conflict resolution is disabled and assuming the CAS check completes, |
| 8 | +the write will be accepted. If CheckCas is set to the value of '0' explicitly, it is expected |
| 9 | +that the document must not exist and a AddWithMeta will be performed. StoreCAS represents the |
| 10 | +new CAS value for the document being pushed, and in cases where conflict resolution is in use, |
| 11 | +this is the value that is compared for conflict resolution. |
| 12 | + |
| 13 | +A pseudocode explanation of the logic is: |
| 14 | + |
| 15 | +``` |
| 16 | +if req.CheckCas != nil: |
| 17 | + if *req.CheckCas == 0: |
| 18 | + AddWithMeta() |
| 19 | + else: |
| 20 | + SetWithMeta(CheckCas: req.CheckCas, Options: SkipConflictResolution) |
| 21 | +else: |
| 22 | + SetWithMeta(CheckCas: 0, Options: 0) |
| 23 | +``` |
| 24 | + |
| 25 | +Additionally, if IsDeleted is specified on the PushDocument operation, it is assumed that this |
| 26 | +is an attempt to delete the document, and as such CheckCas will optionally control whether a |
| 27 | +pure CAS check is performed (and 0 is an invalid value). |
| 28 | + |
| 29 | +There are a number of conflict related errors that can be returned by the PushDocument operation |
| 30 | +based on a number of different factors. Namely whether or not CheckCas is being applied as well as |
| 31 | +whether conflict logging is enabled for the operation. |
| 32 | + |
| 33 | +ConflictLogging=true: |
| 34 | + |
| 35 | +- Error:Aborted Code:TRUE_CONFLICT |
| 36 | + This case will occur when the operation would otherwise succeed, but a true conflict was detected |
| 37 | + and the client has not provided an explicit CAS value (to verify they have the existing document |
| 38 | + already available to them locally). This error will also include additional error context which |
| 39 | + includes the conflicted documents meta-data and contents. Note that this error can only be |
| 40 | + returned if the TrueConflicts parameter is set to true. |
| 41 | + |
| 42 | +- Error:Aborted Code:CAS_MISMATCH |
| 43 | + This case will occur when a CAS was explicitly provided to the operation, but the target document |
| 44 | + has been updated and has a different CAS value. |
| 45 | + |
| 46 | +- Error:Aborted Code:DOC_NEWER |
| 47 | + This case occurs when a new document is rejected because it is older than the document that |
| 48 | + already exists. The concept of 'newer' uses the buckets configured conflict resolution mode. |
| 49 | + |
| 50 | +ConflictLogging=false: |
| 51 | + |
| 52 | +### CheckDocument |
| 53 | + |
| 54 | +CheckDocument has precisely the same mechanics as PushDocument does, with the exception that in the |
| 55 | +cases where a PushDocument operation would write changes to the document, CheckDocument will return |
| 56 | +success and do no write. |
0 commit comments