Search in sources :

Example 6 with Iv2RepairLogResponseMessage

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());
        }
    }
}
Also used : Iv2RepairLogResponseMessage(org.voltdb.messaging.Iv2RepairLogResponseMessage) FragmentTaskMessage(org.voltdb.messaging.FragmentTaskMessage) AtomicLong(java.util.concurrent.atomic.AtomicLong) CompleteTransactionMessage(org.voltdb.messaging.CompleteTransactionMessage)

Example 7 with Iv2RepairLogResponseMessage

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));
}
Also used : VoltMessage(org.voltcore.messaging.VoltMessage) Iv2RepairLogResponseMessage(org.voltdb.messaging.Iv2RepairLogResponseMessage)

Example 8 with Iv2RepairLogResponseMessage

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);
    }
}
Also used : Iv2RepairLogRequestMessage(org.voltdb.messaging.Iv2RepairLogRequestMessage) Iv2RepairLogResponseMessage(org.voltdb.messaging.Iv2RepairLogResponseMessage)

Example 9 with Iv2RepairLogResponseMessage

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));
}
Also used : Iv2RepairLogResponseMessage(org.voltdb.messaging.Iv2RepairLogResponseMessage) ArrayList(java.util.ArrayList)

Example 10 with Iv2RepairLogResponseMessage

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();
            }
        }
    }
}
Also used : Iv2RepairLogResponseMessage(org.voltdb.messaging.Iv2RepairLogResponseMessage)

Aggregations

Iv2RepairLogResponseMessage (org.voltdb.messaging.Iv2RepairLogResponseMessage)21 CompleteTransactionMessage (org.voltdb.messaging.CompleteTransactionMessage)7 Test (org.junit.Test)6 FragmentTaskMessage (org.voltdb.messaging.FragmentTaskMessage)6 Iv2InitiateTaskMessage (org.voltdb.messaging.Iv2InitiateTaskMessage)6 ArrayList (java.util.ArrayList)4 AtomicLong (java.util.concurrent.atomic.AtomicLong)3 TransactionInfoBaseMessage (org.voltcore.messaging.TransactionInfoBaseMessage)3 VoltMessage (org.voltcore.messaging.VoltMessage)3 Random (java.util.Random)2 RepairResult (org.voltdb.iv2.RepairAlgo.RepairResult)2 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 InOrder (org.mockito.InOrder)1 DumpMessage (org.voltdb.messaging.DumpMessage)1 Iv2RepairLogRequestMessage (org.voltdb.messaging.Iv2RepairLogRequestMessage)1 RepairLogTruncationMessage (org.voltdb.messaging.RepairLogTruncationMessage)1