Skip to content

Commit 8cd6ce9

Browse files
committed
Account for duplicated messages
(Oops, bit of an oversight that)
1 parent d1426a6 commit 8cd6ce9

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

ReplicaEngine/tla/ReplicaEngine.tla

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,30 @@ begin
198198
ConsumerLoop:
199199
while replication_requests /= {} do
200200
with replication_request \in replication_requests do
201-
req := replication_request;
202-
replication_requests := replication_requests \ {replication_request};
201+
if replication_request.type = ADD
202+
then
203+
(* Never see two ADDs - if duplicated, one of them is a RETRY_ADD *)
204+
either
205+
(* Process ADD without duplication *)
206+
replication_requests := replication_requests \ {replication_request};
207+
req := replication_request;
208+
or
209+
(* Process ADD and leave a duplicate RETRY_ADD for later *)
210+
replication_requests := (replication_requests \ {replication_request})
211+
\cup {[replication_request EXCEPT !.type = RETRY_ADD]};
212+
req := replication_request;
213+
or
214+
(* Process duplicate RETRY_ADD and leave the original ADD *)
215+
req := [replication_request EXCEPT !.type = RETRY_ADD];
216+
end either;
217+
else
218+
req := replication_request;
219+
either
220+
skip;
221+
or
222+
replication_requests := replication_requests \ {replication_request};
223+
end either;
224+
end if;
203225
end with;
204226

205227
if req.type = DELETE

0 commit comments

Comments
 (0)