use of org.voltdb.messaging.Iv2RepairLogResponseMessage in project voltdb by VoltDB.
the class TestRepairLog method validateRepairLog.
// validate the invariants on the RepairLog contents:
// Every entry in the log should have a unique, constantly increasing SP handle.
// There should be only one FragmentTaskMessage per MP TxnID
// There should be at most one FragmentTaskMessage uncovered by a CompleteTransactionMessage
// There should be no CompleteTransactionMessages indicating restart
private void validateRepairLog(List<Iv2RepairLogResponseMessage> stuff, long binaryLogSpUniqueId, long binaryLogMpUniqueId) {
long prevHandle = Long.MIN_VALUE;
Long mpTxnId = null;
for (Iv2RepairLogResponseMessage imsg : stuff) {
if (imsg.getSequence() > 0) {
assertTrue(imsg.getHandle() > prevHandle);
prevHandle = imsg.getHandle();
if (imsg.getPayload() instanceof FragmentTaskMessage) {
assertEquals(null, mpTxnId);
mpTxnId = imsg.getTxnId();
} else if (imsg.getPayload() instanceof CompleteTransactionMessage) {
// can see bare CompleteTransactionMessage, but if we've got an MP
// in progress this should close it
assertFalse(((CompleteTransactionMessage) imsg.getPayload()).isRestart());
if (mpTxnId != null) {
assertEquals((long) mpTxnId, imsg.getTxnId());
}
mpTxnId = null;
}
} else {
assertTrue(imsg.hasHashinatorConfig());
}
}
}
use of org.voltdb.messaging.Iv2RepairLogResponseMessage in project voltdb by VoltDB.
the class MpPromoteAlgo method repairSurvivors.
/** Send missed-messages to survivors. Exciting! */
public void repairSurvivors() {
// out corrections!
if (this.m_promotionResult.isCancelled()) {
tmLog.debug(m_whoami + "skipping repair message creation for cancelled Term.");
return;
}
tmLog.debug(m_whoami + "received all repair logs and is repairing surviving replicas.");
for (Iv2RepairLogResponseMessage li : m_repairLogUnion) {
// send the repair log union to all the survivors. SPIs will ignore
// CompleteTransactionMessages for transactions which have already
// completed, so this has the effect of making sure that any holes
// in the repair log are filled without explicitly having to
// discover and track them.
VoltMessage repairMsg = createRepairMessage(li);
tmLog.debug(m_whoami + "repairing: " + m_survivors + " with: " + TxnEgo.txnIdToString(li.getTxnId()));
if (tmLog.isTraceEnabled()) {
tmLog.trace(m_whoami + "repairing with message: " + repairMsg);
}
m_mailbox.repairReplicasWith(m_survivors, repairMsg);
}
m_promotionResult.set(new RepairResult(m_maxSeenTxnId));
}
use of org.voltdb.messaging.Iv2RepairLogResponseMessage in project voltdb by VoltDB.
the class InitiatorMailbox method handleLogRequest.
/** Produce the repair log. This is idempotent. */
private void handleLogRequest(VoltMessage message) {
Iv2RepairLogRequestMessage req = (Iv2RepairLogRequestMessage) message;
List<Iv2RepairLogResponseMessage> logs = m_repairLog.contents(req.getRequestId(), req.isMPIRequest());
tmLog.debug("" + CoreUtils.hsIdToString(getHSId()) + " handling repair log request id " + req.getRequestId() + " for " + CoreUtils.hsIdToString(message.m_sourceHSId) + ". ");
for (Iv2RepairLogResponseMessage log : logs) {
send(message.m_sourceHSId, log);
}
}
use of org.voltdb.messaging.Iv2RepairLogResponseMessage in project voltdb by VoltDB.
the class SpPromoteAlgo method repairSurvivors.
/** Send missed-messages to survivors. */
public void repairSurvivors() {
// out corrections!
if (this.m_promotionResult.isCancelled()) {
tmLog.debug(m_whoami + "Skipping repair message creation for cancelled Term.");
return;
}
int queued = 0;
tmLog.debug(m_whoami + "received all repair logs and is repairing surviving replicas.");
for (Iv2RepairLogResponseMessage li : m_repairLogUnion) {
List<Long> needsRepair = new ArrayList<Long>(5);
for (Entry<Long, ReplicaRepairStruct> entry : m_replicaRepairStructs.entrySet()) {
if (entry.getValue().needs(li.getHandle())) {
++queued;
tmLog.debug(m_whoami + "repairing " + CoreUtils.hsIdToString(entry.getKey()) + ". Max seen " + entry.getValue().m_maxSpHandleSeen + ". Repairing with " + li.getHandle());
needsRepair.add(entry.getKey());
}
}
if (!needsRepair.isEmpty()) {
if (tmLog.isTraceEnabled()) {
tmLog.trace(m_whoami + "repairing: " + CoreUtils.hsIdCollectionToString(needsRepair) + " with message: " + li.getPayload());
}
m_mailbox.repairReplicasWith(needsRepair, li.getPayload());
}
}
tmLog.debug(m_whoami + "finished queuing " + queued + " replica repair messages.");
m_promotionResult.set(new RepairResult(m_maxSeenTxnId));
}
use of org.voltdb.messaging.Iv2RepairLogResponseMessage in project voltdb by VoltDB.
the class SpPromoteAlgo method deliver.
/** Process a new repair log response */
@Override
public void deliver(VoltMessage message) {
if (message instanceof Iv2RepairLogResponseMessage) {
Iv2RepairLogResponseMessage response = (Iv2RepairLogResponseMessage) message;
if (response.getRequestId() != m_requestId) {
tmLog.debug(m_whoami + "rejecting stale repair response." + " Current request id is: " + m_requestId + " Received response for request id: " + response.getRequestId());
return;
}
ReplicaRepairStruct rrs = m_replicaRepairStructs.get(response.m_sourceHSId);
if (rrs.m_expectedResponses < 0) {
tmLog.debug(m_whoami + "collecting " + response.getOfTotal() + " repair log entries from " + CoreUtils.hsIdToString(response.m_sourceHSId));
}
// Long.MAX_VALUE has rejoin semantics
if (response.getHandle() != Long.MAX_VALUE) {
m_maxSeenTxnId = Math.max(m_maxSeenTxnId, response.getHandle());
}
if (response.getPayload() != null) {
m_repairLogUnion.add(response);
if (tmLog.isTraceEnabled()) {
tmLog.trace(m_whoami + " collected from " + CoreUtils.hsIdToString(response.m_sourceHSId) + ", message: " + response.getPayload());
}
}
if (rrs.update(response)) {
tmLog.debug(m_whoami + "collected " + rrs.m_receivedResponses + " responses for " + rrs.m_expectedResponses + " repair log entries from " + CoreUtils.hsIdToString(response.m_sourceHSId));
if (areRepairLogsComplete()) {
repairSurvivors();
}
}
}
}
Aggregations