Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fix recovery

  • Loading branch information...
commit db22ed3a834aa7223d2e6f4aed3dcea7e407a503 1 parent 970554b
@dgomezferro authored
View
12 src/main/java/com/yahoo/pasc/paxos/handlers/acceptor/AcceptorPrepare.java
@@ -26,11 +26,13 @@
import com.yahoo.pasc.Message;
import com.yahoo.pasc.paxos.handlers.PaxosHandler;
+import com.yahoo.pasc.paxos.handlers.learner.Learner;
import com.yahoo.pasc.paxos.messages.PaxosDescriptor;
import com.yahoo.pasc.paxos.messages.Prepare;
import com.yahoo.pasc.paxos.messages.Prepared;
import com.yahoo.pasc.paxos.state.InstanceRecord;
import com.yahoo.pasc.paxos.state.PaxosState;
+import com.yahoo.pasc.paxos.state.IidAcceptorsCounts;
public class AcceptorPrepare extends PaxosHandler<Prepare> {
@@ -62,19 +64,19 @@
// send learned (executed) requests
LongArrayList learnedReqs = new LongArrayList();
long currIid = Math.max(minIid + 1, maxForgotten + 1);
- while (currIid <= maxExecuted) {
+ while (currIid < minIid + state.getMaxInstances()) {
+ InstanceRecord instance = state.getInstancesElement(currIid);
+ IidAcceptorsCounts acceptors = state.getAcceptedElement(currIid);
// checks that the iid is correct and that the instance is "fully" accepted, i.e., it has all requests
- if (state.getInstancesIid(currIid) == currIid && state.getIsAcceptedElement(currIid)) {
+ if (instance != null && instance.getIid() == currIid && acceptors != null && acceptors.isAccepted()) {
LOG.trace("Adding learned req with iid {}", currIid);
learnedReqs.add(currIid);
- } else {
- LOG.trace("Not adding learned for iid {}. Stored iid {} learned {} ",
- new Object[] { currIid, state.getInstancesIid(currIid), state.getIsAcceptedElement(currIid) });
}
currIid++;
}
// send accepted requests
+ currIid = Math.max(minIid + 1, maxForgotten + 1);
LongArrayList acceptedReqs = new LongArrayList();
while (currIid < minIid + state.getMaxInstances()) {
InstanceRecord instance = state.getInstancesElement(currIid);
View
5 src/main/java/com/yahoo/pasc/paxos/handlers/proposer/ProposerRequest.java
@@ -80,8 +80,9 @@
new Object[] { state.getFirstDigestId(), state.getCurrIid(), request.getIid(),
state.getFirstInstanceId(), clientId, timestamp, repTs });
- return state.getIsLeader() ? Arrays.<PaxosDescriptor> asList(new Accept.Descriptor(requestIid),
- new Accepted.Descriptor(requestIid)) : null;
+ return state.getIsLeader() && state.getCompletedPhaseOne() ?
+ Arrays.<PaxosDescriptor> asList(new Accept.Descriptor(requestIid), new Accepted.Descriptor(requestIid)) :
+ null;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.