Model¶
This page says what the model of request proves and what it does not. The model is
models/request_reply.py, written with musil. The rules it
checks are in Operations.
Run it¶
What it checks¶
The model has one request, 0 to 2 repliers and a deadline. Its faults are a handler that never ends, one replier crash, one connection drop (up to 2 in the tests) and refusals (1 by default).
A drop loses every frame toward the requester. The replier can still read the request copy of the
closed connection, at any later time. After a busy outcome, the requester can retry once.
After a copy sent again with a known id, the program sends its replies again or does nothing.
On the replier's side the deadline passes for each connection on its own, at any time: before or after the requester's deadline, and before or after the one of another connection.
| Property | Holds with | Fails without it |
|---|---|---|
| Every request gets an outcome, also after a retry | the deadline | one hung handler, one crash, one lost frame or a partly refused retry leaves it open |
| A replier runs one id at most once | repeats sent only to a replier that drops repeated ids | a repeat runs the handler again |
| A replier runs one id at most once | the id is kept until every deadline passed | an id forgotten while the handler runs, or when it is done, runs again |
| A replier runs one id at most once | the id is kept until every deadline passed | kept only until the deadline of the copy that ran, a late copy of another connection runs again |
| A replier runs one id at most once | a retry only when every replier refused | a retry to a replier that ran it, and does not drop repeats, runs it again |
In a busy outcome, a replier that refused did not run it |
one copy without an end per connection | a second copy runs while the busy end is delivered |
In a busy outcome, a replier that refused did not run it |
a copy sent again is never refused | the old copy is read late and runs |
In a busy outcome, a replier that refused did not run it |
the requester stops reading the old connection | an old busy end arrives while the new copy runs |
In a busy outcome, a replier that refused did not run it |
a refusal is sent only on the connection that brought the copy | the busy end answers a copy sent again, which then runs |
completed means every reply arrived |
the reply count in the end | a reply lost in a connection drop goes unseen |
| No reply reaches the caller twice | the requester takes only the next reply number | a reply sent again is counted twice |
| No reply reaches the caller after the outcome | late replies are dropped | a reply in flight at the deadline is delivered |
With no replier connected the outcome is unroutable, and never expired |
the requester detects that there is no replier | the request waits and ends expired |
The tests also show that these states can happen:
completedwith zero replies, and with many repliesexpiredwith a crashed replier after one reply arrivedcompletedafter a retry of abusyrequest, with one and with two repliers- a second
busyafter a retry completedafter a connection drop lost the end, because it was sent again (without sending again, this state cannot happen)- a replier that runs a request after the requester got
expired completedafter a replier refused a copy whose connection had closed
They show that one state cannot happen: completed after a retry when one of two repliers already
ran the request.
The C core¶
tests/test_conformance.py takes 12000 random runs of the model and makes the same calls on
PeerState, the Python layer over the C core. After every step the two agree on the outcome, the
replies received, the requests given to each handler and the replies after the outcome. Half of
the runs store replies and send them again, and half store none.
It does not replay:
- a copy read from a closed connection: one
rf_peerhas one connection at a time; - a deadline that passes on one side only: the test uses one clock;
- calls that the model never makes, and frames that arrive in pieces. The C tests, the fuzz
targets in
core/andtests/test_peer_state*.pycover these.
What it does not prove¶
- A requester that stops waiting (rule 15). It sends nothing, so the repliers behave as in a run where it keeps waiting.
- A second process that sends a copy (rule 16). The model has one requester. A test sends one request from two processes.
- Two requests at once. The model has one id, so it does not check that a reply goes to the right request.
- A replier that restarts after a crash with an empty store of ids.
- Why a replier refuses. The model has refusals that can happen to any copy, not a store with a size or a longest deadline.
- A replier that restarts and then refuses a request that it ran before the restart.
- Sending again in more than one step. The model sends all stored replies and the end at once. A program that limits the replies it stores is the same as one that does nothing.
- The arithmetic of deadlines. The model assumes that the keep time covers the difference between the deadlines of two copies. It does not see a keep time that is too short, or senders whose clocks differ too much (rule 14).
- A replier that is connected but has no handler for the key.
- Repliers that differ: in one run, all of them drop repeated ids or none does.
- More than 2 repliers, more than 2 replies, more than one retry, or more than one fault of each kind.
- The bytes. The model has frames, not the header in Wire format.
- The C code in
core/, beyond the runs in The C core.