aboutsummaryrefslogtreecommitdiff
path: root/src/model/k2v/item_table.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-01-10 11:01:49 +0100
committerAlex Auvolat <alex@adnab.me>2023-01-10 11:03:52 +0100
commit9f5419f465de3ddbb9afc91464d0eb00636049b9 (patch)
treeca32f851cda043cfe61873ea46268605f1e2c8ed /src/model/k2v/item_table.rs
parenta48e2e0cb2bdc75e14dfde199dbca0a779b1316b (diff)
downloadgarage-9f5419f465de3ddbb9afc91464d0eb00636049b9.tar.gz
garage-9f5419f465de3ddbb9afc91464d0eb00636049b9.zip
Make K2V item timestamps globally increasing on each node
Diffstat (limited to 'src/model/k2v/item_table.rs')
-rw-r--r--src/model/k2v/item_table.rs7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/model/k2v/item_table.rs b/src/model/k2v/item_table.rs
index a22df68a..1ba9bb46 100644
--- a/src/model/k2v/item_table.rs
+++ b/src/model/k2v/item_table.rs
@@ -73,7 +73,8 @@ impl K2VItem {
this_node: Uuid,
context: &Option<CausalContext>,
new_value: DvvsValue,
- ) {
+ node_ts: u64,
+ ) -> u64 {
if let Some(context) = context {
for (node, t_discard) in context.vector_clock.iter() {
if let Some(e) = self.items.get_mut(node) {
@@ -98,7 +99,9 @@ impl K2VItem {
values: vec![],
});
let t_prev = e.max_time();
- e.values.push((t_prev + 1, new_value));
+ let t_new = std::cmp::max(t_prev + 1, node_ts + 1);
+ e.values.push((t_new, new_value));
+ t_new
}
/// Extract the causality context of a K2V Item