Search in sources :

Example 1 with Iv2RepairLogResponseMessage

use of org.voltdb.messaging.Iv2RepairLogResponseMessage in project voltdb by VoltDB.

the class MpPromoteAlgo 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;
        }
        // Step 1: if the msg has a known (not MAX VALUE) handle, update m_maxSeen.
        if (response.getTxnId() != Long.MAX_VALUE) {
            m_maxSeenTxnId = Math.max(m_maxSeenTxnId, response.getTxnId());
        }
        if (response.hasHashinatorConfig()) {
            Pair<Long, byte[]> proposed = response.getHashinatorVersionedConfig();
            if (proposed.getFirst() > m_newestHashinatorConfig.getFirst()) {
                m_newestHashinatorConfig = proposed;
            }
        }
        // Step 3: offer to the union
        addToRepairLog(response);
        if (tmLog.isTraceEnabled()) {
            tmLog.trace(m_whoami + " collected from " + CoreUtils.hsIdToString(response.m_sourceHSId) + ", message: " + response.getPayload());
        }
        // Step 4: update the corresponding replica repair struct.
        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));
        }
        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()) {
                TheHashinator.updateHashinator(TheHashinator.getConfiguredHashinatorType().hashinatorClass, m_newestHashinatorConfig.getFirst(), m_newestHashinatorConfig.getSecond(), true);
                repairSurvivors();
            }
        }
    }
}
Also used : Iv2RepairLogResponseMessage(org.voltdb.messaging.Iv2RepairLogResponseMessage)

Example 2 with Iv2RepairLogResponseMessage

use of org.voltdb.messaging.Iv2RepairLogResponseMessage in project voltdb by VoltDB.

the class RepairLog method deliver.

// Offer a new message to the repair log. This will truncate
// the repairLog if the message includes a truncation hint.
public void deliver(VoltMessage msg) {
    if (!m_isLeader && msg instanceof Iv2InitiateTaskMessage) {
        final Iv2InitiateTaskMessage m = (Iv2InitiateTaskMessage) msg;
        // We can't repair read only SP transactions. Just don't log them to the repair log.
        if (m.isReadOnly()) {
            return;
        }
        m_lastSpHandle = m.getSpHandle();
        truncate(m.getTruncationHandle(), IS_SP);
        m_logSP.add(new Item(IS_SP, m, m.getSpHandle(), m.getTxnId()));
    } else if (msg instanceof FragmentTaskMessage) {
        final FragmentTaskMessage m = (FragmentTaskMessage) msg;
        // We can't repair read only SP transactions. Just don't log them to the repair log.
        if (m.isReadOnly()) {
            return;
        }
        truncate(m.getTruncationHandle(), IS_MP);
        // only log the first fragment of a procedure (and handle 1st case)
        if (m.getTxnId() > m_lastMpHandle || m_lastMpHandle == Long.MAX_VALUE) {
            m_logMP.add(new Item(IS_MP, m, m.getSpHandle(), m.getTxnId()));
            m_lastMpHandle = m.getTxnId();
            m_lastSpHandle = m.getSpHandle();
        }
    } else if (msg instanceof CompleteTransactionMessage) {
        // a CompleteTransactionMessage which indicates restart is not the end of the
        // transaction.  We don't want to log it in the repair log.
        CompleteTransactionMessage ctm = (CompleteTransactionMessage) msg;
        // Restart transaction do not need to be repaired here, don't log them as well.
        if (ctm.isReadOnly() || ctm.isRestart()) {
            return;
        }
        truncate(ctm.getTruncationHandle(), IS_MP);
        m_logMP.add(new Item(IS_MP, ctm, ctm.getSpHandle(), ctm.getTxnId()));
        //Restore will send a complete transaction message with a lower mp transaction id because
        //the restore transaction precedes the loading of the right mp transaction id from the snapshot
        //Hence Math.max
        m_lastMpHandle = Math.max(m_lastMpHandle, ctm.getTxnId());
        m_lastSpHandle = ctm.getSpHandle();
    } else if (msg instanceof DumpMessage) {
        String who = CoreUtils.hsIdToString(m_HSId);
        tmLog.warn("Repair log dump for site: " + who + ", isLeader: " + m_isLeader + ", " + who + ": lastSpHandle: " + m_lastSpHandle + ", lastMpHandle: " + m_lastMpHandle);
        for (Iv2RepairLogResponseMessage il : contents(0l, false)) {
            tmLog.warn("[Repair log contents]" + who + ": msg: " + il);
        }
    } else if (msg instanceof RepairLogTruncationMessage) {
        final RepairLogTruncationMessage truncateMsg = (RepairLogTruncationMessage) msg;
        truncate(truncateMsg.getHandle(), IS_SP);
    }
}
Also used : Iv2RepairLogResponseMessage(org.voltdb.messaging.Iv2RepairLogResponseMessage) FragmentTaskMessage(org.voltdb.messaging.FragmentTaskMessage) Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) CompleteTransactionMessage(org.voltdb.messaging.CompleteTransactionMessage) DumpMessage(org.voltdb.messaging.DumpMessage) RepairLogTruncationMessage(org.voltdb.messaging.RepairLogTruncationMessage)

Example 3 with Iv2RepairLogResponseMessage

use of org.voltdb.messaging.Iv2RepairLogResponseMessage in project voltdb by VoltDB.

the class TestMpPromoteAlgo method makeCompleteResponse.

Iv2RepairLogResponseMessage makeCompleteResponse(long handle, long uniqueId) {
    CompleteTransactionMessage complete = mock(CompleteTransactionMessage.class);
    Iv2RepairLogResponseMessage m = mock(Iv2RepairLogResponseMessage.class);
    when(m.getPayload()).thenReturn(complete);
    when(m.getHandle()).thenReturn(-1L);
    when(m.getTxnId()).thenReturn(handle);
    return m;
}
Also used : Iv2RepairLogResponseMessage(org.voltdb.messaging.Iv2RepairLogResponseMessage) CompleteTransactionMessage(org.voltdb.messaging.CompleteTransactionMessage)

Example 4 with Iv2RepairLogResponseMessage

use of org.voltdb.messaging.Iv2RepairLogResponseMessage in project voltdb by VoltDB.

the class TestMpPromoteAlgo method makeFragResponse.

Iv2RepairLogResponseMessage makeFragResponse(long handle, long uniqueId) {
    FragmentTaskMessage frag = mock(FragmentTaskMessage.class);
    Iv2RepairLogResponseMessage m = mock(Iv2RepairLogResponseMessage.class);
    when(m.getPayload()).thenReturn(frag);
    when(m.getHandle()).thenReturn(-1L);
    when(m.getTxnId()).thenReturn(handle);
    return m;
}
Also used : Iv2RepairLogResponseMessage(org.voltdb.messaging.Iv2RepairLogResponseMessage) FragmentTaskMessage(org.voltdb.messaging.FragmentTaskMessage)

Example 5 with Iv2RepairLogResponseMessage

use of org.voltdb.messaging.Iv2RepairLogResponseMessage in project voltdb by VoltDB.

the class TestMpPromoteAlgo method makeRealCompleteResponse.

Iv2RepairLogResponseMessage makeRealCompleteResponse(long requestId, long sourceHSId, int sequence, int ofTotal, long handle) {
    CompleteTransactionMessage complete = mock(CompleteTransactionMessage.class);
    Iv2RepairLogResponseMessage m = new Iv2RepairLogResponseMessage(requestId, sequence, ofTotal, handle, handle, complete);
    m.m_sourceHSId = sourceHSId;
    return m;
}
Also used : Iv2RepairLogResponseMessage(org.voltdb.messaging.Iv2RepairLogResponseMessage) CompleteTransactionMessage(org.voltdb.messaging.CompleteTransactionMessage)

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