浏览代码

Add an assertion in apply_op.

Jing Yang 4 年之前
父节点
当前提交
aa8e4854d1
共有 1 个文件被更改,包括 10 次插入0 次删除
  1. 10 0
      kvraft/src/server.rs

+ 10 - 0
kvraft/src/server.rs

@@ -120,6 +120,16 @@ impl KVServer {
             let (applied_unique_id, _) = curr.get();
             if *applied_unique_id >= unique_id {
                 // Redelivered.
+                // It is guaranteed that we have no pending queries with the
+                // same unique_id, because
+                // 1. When inserting into queries, we first check the unique_id
+                // is strictly larger than the one in applied_op.
+                // 2. When modifying entries in applied_op, the unique_id can
+                // only grow larger. And we make sure there is no entries with
+                // the same unique_id in queries.
+                // TODO(ditsing): in case 2), make sure there is no entries in
+                // queries that have a smaller unique_id.
+                assert!(!state.queries.contains_key(&unique_id));
                 return;
             }
         }