Skip to content

Commit

Permalink
bug(scheduler): Expire clients before we decide to delay message
Browse files Browse the repository at this point in the history
We now expire client requests (i.e time them out) before we decide that we
should delay a message. This is because if the delayed message is the last thing
in the agenda, it would never be scheduled since we would never get to expire
the previous call, so it would get into an infinte loop and keep delaying.
  • Loading branch information
symbiont-daniel-gustafsson committed Jan 25, 2021
1 parent 44e2af3 commit 5ccb071
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/scheduler/src/scheduler/pure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -350,22 +350,7 @@
(= drop? :delay) (do
(log/debug :delaying-message body)
[data' {:events []}])
:else (let [[data' expired-clients] (expired-clients data' timestamp)
_ (doseq [client expired-clients]
(db/append-network-trace! (:test-id data')
(:run-id data')
{:message (:event client)
:args (:args client)
:from (:to client)
:to (:from client)
:kind (:kind client)
:sent-logical-time (:logical-time data')
:recv-logical-time (:logical-time data')
:recv-simulated-time (:clock data')
:dropped false
:jepsen-type :info
:jepsen-process (-> client :from parse-client-id)}))
is-from-client? (re-matches #"^client:\d+$" (:from body))
:else (let [is-from-client? (re-matches #"^client:\d+$" (:from body))
dropped? (= drop? :drop)
_ (log/debug :sent-logical-time body)
sent-logical-time (or (-> body :sent-logical-time)
Expand Down Expand Up @@ -688,7 +673,22 @@
(if-let [entry (-> data :agenda peek)]
(if (time/before? (:next-tick data) (:at entry))
(tick! data)
(execute! data))
(let [[data' expired-clients] (expired-clients data (:at entry))]
(doseq [client expired-clients]
(db/append-network-trace! (:test-id data')
(:run-id data')
{:message (:event client)
:args (:args client)
:from (:to client)
:to (:from client)
:kind (:kind client)
:sent-logical-time (:logical-time data')
:recv-logical-time (:logical-time data')
:recv-simulated-time (:clock data')
:dropped false
:jepsen-type :info
:jepsen-process (-> client :from parse-client-id)}))
(execute! data')))
(if (time/before? (:next-tick data) (time/plus-nanos (time/init-clock)
(:min-time-ns data)))
(tick! data)
Expand Down

0 comments on commit 5ccb071

Please sign in to comment.