Skip to main content
Loading

Write policy

With the XDR parameter write-policy at the dc/namespace level, you can control the behavior of XDR writes on the target datacenter. Allowable values:

  • auto (default): The behavior depends on the bin-policy and which bins got updated at the source.
    • With the default bin-policy (all) :
      • If all the bins of the record are shipped, after taking into consideration the ignore-bin configuration, the remote record is replaced or created.
      • If a subset of bins of the record are shipped, after taking into consideration the ignore-bin configuration, the remote record is updated.
    • If bin-policy is set to only-changed, changed-and-specified or changed-or-specified, the remote record is updated.
    • If bin-policy is set to only-specified and a subset of bins of the record are shipped, the remote record is updated.
  • update: creates the record or updates the record if it already exists. Merges previously existing bins with the new bins being written.
  • replace: creates the record or replaces it entirely if a previous version of the record already exists. Deletes already existing bins for the record.
    • Not allowed when bin-policy is set to only-changed, changed-and-specified or changed-or-specified.

Example

xdr {
dc DC1 {
node-address-port 10.1.0.1 3000
namespace nameSpaceName {
write-policy replace
...
}
}
}

Write-policy vs bin-policy vs ignore-bin

The interaction between write-policy=auto and bin-policy and ignore-bin is complex. Let us try to explain with an example. Consider a situation where a record already has bins (b1, b2, b3).

Shipping happens as follows when ignore-bin has (b3) and an update comes with bins (b2, b3) (no b1).

bin-policyallonly-changedchanged-and-specifiedchanged-or-specified
(ignore-bin honored)(ignore-bin honored)(ignore-bin not honored)(ignore-bin not honored)
write-policy
auto(b1, b2) as update(b2) as updatenothing(b2, b3) as update
update(b1, b2) as update(b2) as updatenothing(b2, b3) as update
replace(b1, b2) as replacenot allowednot allowednot allowed

Shipping happens as follows when ignore-bin has (b4) and an update comes with bins (b2, b3) (no b1).

bin-policyallonly-changedchanged-and-specifiedchanged-or-specified
(ignore-bin honored)(ignore-bin honored)(ignore-bin not honored)(ignore-bin not honored)
write-policy
auto(b1, b2, b3) as replace(b2, b3) as updatenothing(b2, b3) as update
update(b1, b2, b3) as update(b2, b3) as updatenothing(b2, b3) as update
replace(b1, b2, b3) as replacenot allowednot allowednot allowed

Shipping happens as follows when ignore-bin has (b3) and an update comes with bins b2=NULL (b2 gets deleted).

bin-policyallonly-changedchanged-and-specifiedchanged-or-specified
(ignore-bin honored)(ignore-bin honored)(ignore-bin not honored)(ignore-bin not honored)
write-policy
auto(b1) as update
(b2 not deleted on dest)
(b2) deletenothing(b2) delete
update(b1) as update
(b2 not deleted on dest)
(b2) deletenothing(b2) delete
replace(b1) as replace
(b2 deleted on dest)
not allowednot allowednot allowed

Shipping happens as follows when ignore-bin has (b4) and an update comes with bins b2=NULL (b2 gets deleted).

bin-policyallonly-changedchanged-and-specifiedchanged-or-specified
(ignore-bin honored)(ignore-bin honored)(ignore-bin not honored)(ignore-bin not honored)
write-policy
auto(b1, b3) as replace
(b2 deleted on dest)
(b2) deletenothing(b2) delete
update(b1, b3) as update
(b2 not deleted on dest)
(b2) deletenothing(b2) delete
replace(b1, b3) as replace
(b2 deleted on dest)
not allowednot allowednot allowed