Skip to content

Commit

Permalink
Replica should ignore out-of-date DecisionHints
Browse files Browse the repository at this point in the history
Defensively check for slotNum usefulness before applying the
DecisionHint. Otherwise, if we got an old duplicate or a mis-sent
DecisionHint it could do something nasty.
  • Loading branch information
clinedome-work committed Apr 28, 2014
1 parent ac85e9f commit 1457e69
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ class Replica(localLeader: ActorRef,
logger.warning("Received exception applying decision {}: {}", decision, t)
}

case decisionHint @ DecisionHint(decisionHintSlotNum) =>
case decisionHint @ DecisionHint(decisionHintSlotNum) if decisionHintSlotNum >= slotNum =>
slotNum = decisionHintSlotNum + 1

outstandingProposals.filter((k, _) => k > decisionHintSlotNum)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ class ReplicaTest extends NiceTest with BeforeAndAfterAll {
}

describe ("in response to a DecisionHint") {
it("ignores the DH if it's out of date") {
val localLeader = TestProbe()
val replica = makeReplica(localLeader.ref, 5)
replica ! DecisionHint(2)

assert(5 === replica.underlyingActor.slotNum)
localLeader.expectNoMsg()
}
it("updates the slotNum") {
val localLeader = TestProbe()
val replica = makeReplica(localLeader.ref, 2)
Expand Down

0 comments on commit 1457e69

Please sign in to comment.