Skip to main content
Loading

Write policy

Overview

With the XDR parameter write-policy at the datacenter (DC) or namespace level, you can control the behavior of XDR writes on the target DC.

Values for write-policy

  • auto (default): Behavior depends on the bin-policy and which bins are updated at the source.
    • If bin-policy is all:
      • If all bins of the record are shipped, after considering the ignore-bin configuration, the remote record is replaced or created.
      • If a subset of bins is shipped, after considering the ignore-bin configuration, the remote record is updated.
    • If bin-policy is only-changed, changed-and-specified, or changed-or-specified, the remote record is updated.
    • If bin-policy is only-specified and a subset of bins is shipped, the remote record is updated.
  • update: creates the record or updates it if it already exists. Merges 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 existing bins for the record.
    • Not allowed when bin-policy is 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. 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