Skip to content

Commit 27d721c

Browse files
committed
Log exceptions to the trace and make them fail a trace validation.
1 parent 3ec089e commit 27d721c

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

specifications/ewd998/EWD998ChanTrace.tla

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,23 @@ TraceNextConstraint ==
191191
\* BP:: line below is the first step towards diagnosing a divergence. Once
192192
\* hit, advance evaluation with step over (F10) and step into (F11).
193193
BP::
194-
\/ IsInitiateToken(logline)
195-
\/ IsPassToken(logline)
196-
\/ IsRecvToken(logline)
197-
\/ IsSendMsg(logline)
198-
\/ IsRecvMsg(logline)
199-
\/ IsDeactivate(logline)
200-
\/ IsTrm(logline)
194+
/\ \/ IsInitiateToken(logline)
195+
\/ IsPassToken(logline)
196+
\/ IsRecvToken(logline)
197+
\/ IsSendMsg(logline)
198+
\/ IsRecvMsg(logline)
199+
\/ IsDeactivate(logline)
200+
\/ IsTrm(logline)
201+
\* Fail trace validation if the log contains a failure message. As an alternative,
202+
\* we could have used TraceInv below, which would cause TLC to print the current
203+
\* trace upon its violation. For the sake of consistency, we use the
204+
\* TraceAccepted approach for all trace validation.
205+
/\ "failure" \notin DOMAIN logline
206+
207+
TraceInv ==
208+
LET l == TraceLog[TLCGet("level")] IN
209+
/\ "failure" \notin DOMAIN l
210+
/\ (l.event \in {"<", ">"} /\ l.pkt.msg.type = "trm") => \A n \in Node: ~active[n]
201211

202212
-----------------------------------------------------------------------------
203213

specifications/ewd998/impl/src/EWD998.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ public EWD998(final Map<Integer, Pair> nodes, final int myId, final boolean isIn
188188
assert inbox.isEmpty();
189189
return;
190190
} else {
191+
logline.add("failure", new JsonPrimitive(String.format("Unknown message type: %s", msg.get(TYPE).getAsString())));
192+
System.out.println(logline);
191193
throw new IllegalArgumentException("Unknown message type");
192194
}
193195

@@ -354,10 +356,13 @@ private void sendMsg(final int sender, final int receiver, final JsonObject msg)
354356
return;
355357
} catch (SocketTimeoutException | ConnectException thisIsFineWillRetry) {
356358
if (retry > 3) {
357-
// Stay silent if it failed less than three times. If it fails more than three
359+
// Stay silent if it a transient failure. If it fails more than three
358360
// times, the user will likely want to inspect. Note that EWD998 assumes
359361
// reliable message infrastructure and doesn't consider network failure.
360362
thisIsFineWillRetry.printStackTrace();
363+
logline.add("failure", new JsonPrimitive(thisIsFineWillRetry.toString()));
364+
System.out.println(logline);
365+
return;
361366
}
362367
Thread.sleep(500L * retry);
363368
}

0 commit comments

Comments
 (0)