Skip to content

Commit c7d21d2

Browse files
committed
Refactoring: advance local check point separately
1 parent 0165d83 commit c7d21d2

File tree

2 files changed

+29
-40
lines changed

2 files changed

+29
-40
lines changed

versionmap/tla/versionmap.tla

Lines changed: 29 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -159,64 +159,53 @@ begin
159159
/\ indexing_seqno = NULL \/ indexing_seqno < replication_request.seqno
160160
/\ lucene.document = NULL \/ lucene.document.seqno < replication_request.seqno
161161
then
162-
162+
163+
if replication_request.append_only
164+
then
165+
(* fast path *)
166+
lucene.buffered_operation := replication_request;
167+
else
168+
append_only_unsafe_up_to := replication_request.seqno;
169+
170+
if replication_request.type = INDEX
171+
then
172+
lucene.buffered_operation := replication_request;
173+
indexing_seqno := replication_request.seqno;
174+
elsif replication_request.type = DELETE
175+
then
176+
lucene.buffered_operation := [ type |-> DELETE ];
177+
deletion_seqno := replication_request.seqno;
178+
end if;
179+
end if;
180+
163181
if replication_request.seqno > local_check_point + 1
164182
then
165183
(* cannot advance local check point *)
166184
seqnos_above_local_check_point := seqnos_above_local_check_point
167185
\union {replication_request.seqno};
168186

169187
else
188+
189+
AdvanceLocalCheckPoint:
190+
170191
(* advance local check point *)
171192
local_check_point := CHOOSE n \in (local_check_point .. next_seqno):
172193
/\ n > local_check_point
173194
/\ (n + 1) \notin seqnos_above_local_check_point
174195
/\ ((local_check_point + 2) .. n) \subseteq seqnos_above_local_check_point;
175196
seqnos_above_local_check_point := { n \in seqnos_above_local_check_point: local_check_point < n };
176-
end if;
177-
178-
if replication_request.append_only
179-
then
180-
lucene.buffered_operation := replication_request;
197+
181198
if deletion_seqno /= NULL /\ deletion_seqno <= local_check_point
182199
then
183200
deletion_seqno := NULL;
184201
end if;
185-
else
186-
if replication_request.type = INDEX
187-
then
188-
lucene.buffered_operation := replication_request;
189-
if replication_request.seqno <= local_check_point
190-
then
191-
indexing_seqno := NULL;
192-
else
193-
indexing_seqno := replication_request.seqno;
194-
end if;
195-
196-
if deletion_seqno /= NULL /\ deletion_seqno <= local_check_point
197-
then
198-
deletion_seqno := NULL;
199-
end if;
200-
201-
elsif replication_request.type = DELETE
202-
then
203-
lucene.buffered_operation := [ type |-> DELETE ];
204-
if replication_request.seqno <= local_check_point
205-
then
206-
deletion_seqno := NULL;
207-
else
208-
deletion_seqno := replication_request.seqno;
209-
end if;
210-
211-
if indexing_seqno /= NULL /\ indexing_seqno <= local_check_point
212-
then
213-
indexing_seqno := NULL;
214-
end if;
215-
216-
end if;
217202

218-
append_only_unsafe_up_to := replication_request.seqno;
203+
if indexing_seqno /= NULL /\ indexing_seqno <= local_check_point
204+
then
205+
indexing_seqno := NULL;
206+
end if;
219207
end if;
208+
220209
end if;
221210
end while;
222211
lucene.state := CLOSED;
@@ -520,5 +509,5 @@ VersionMapContainsNoEntriesBeforeLocalCheckPoint == /\ \/ deletion_seqno = NULL
520509

521510
=============================================================================
522511
\* Modification History
523-
\* Last modified Fri Feb 16 16:00:45 GMT 2018 by davidturner
512+
\* Last modified Fri Feb 16 16:22:27 GMT 2018 by davidturner
524513
\* Created Tue Feb 13 13:02:51 GMT 2018 by davidturner
-489 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)