Search in sources :

Example 11 with FragmentTaskMessage

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

the class TestRepairLog method setBinaryLogUniqueId.

public static Pair<Long, Long> setBinaryLogUniqueId(TransactionInfoBaseMessage msg, UniqueIdGenerator spbuig, UniqueIdGenerator mpbuig) {
    Iv2InitiateTaskMessage taskMsg = null;
    if (msg instanceof Iv2InitiateTaskMessage) {
        taskMsg = (Iv2InitiateTaskMessage) msg;
    } else if (msg instanceof FragmentTaskMessage) {
        taskMsg = ((FragmentTaskMessage) msg).getInitiateTask();
    }
    if (taskMsg != null && taskMsg.getStoredProcedureName().startsWith("@ApplyBinaryLog")) {
        ParameterSet params = taskMsg.getStoredProcedureInvocation().getParams();
        long spuid = spbuig == null ? 0 : spbuig.getNextUniqueId();
        long mpuid = mpbuig.getNextUniqueId();
        when(params.toArray()).thenReturn(new Object[] { null, 0l, 0l, spuid, mpuid, null });
        return Pair.of(spuid, mpuid);
    }
    return Pair.of(Long.MIN_VALUE, Long.MIN_VALUE);
}
Also used : ParameterSet(org.voltdb.ParameterSet) FragmentTaskMessage(org.voltdb.messaging.FragmentTaskMessage) Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage)

Example 12 with FragmentTaskMessage

use of org.voltdb.messaging.FragmentTaskMessage 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 13 with FragmentTaskMessage

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

the class MpPromoteAlgo method createRepairMessage.

VoltMessage createRepairMessage(Iv2RepairLogResponseMessage msg) {
    if (msg.getPayload() instanceof CompleteTransactionMessage) {
        return msg.getPayload();
    } else {
        FragmentTaskMessage ftm = (FragmentTaskMessage) msg.getPayload();
        // We currently don't want to restart read-only MP transactions because:
        // 1) We're not writing the Iv2InitiateTaskMessage to the first
        // FragmentTaskMessage in read-only case in the name of some unmeasured
        // performance impact,
        // 2) We don't want to perturb command logging and/or DR this close to the 3.0 release
        // 3) We don't guarantee the restarted results returned to the client
        // anyway, so not restarting the read is currently harmless.
        boolean restart = !ftm.isReadOnly();
        if (restart) {
            assert (ftm.getInitiateTask() != null);
            m_interruptedTxns.add(ftm.getInitiateTask());
        }
        CompleteTransactionMessage rollback = new CompleteTransactionMessage(ftm.getInitiatorHSId(), ftm.getCoordinatorHSId(), ftm.getTxnId(), ftm.isReadOnly(), 0, // Force rollback as our repair operation.
        true, // no acks in iv2.
        false, // Indicate rollback for repair as appropriate
        restart, ftm.isForReplay());
        return rollback;
    }
}
Also used : FragmentTaskMessage(org.voltdb.messaging.FragmentTaskMessage) CompleteTransactionMessage(org.voltdb.messaging.CompleteTransactionMessage)

Example 14 with FragmentTaskMessage

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

the class InitiatorMailbox method repairReplicasWithInternal.

private void repairReplicasWithInternal(List<Long> needsRepair, VoltMessage repairWork) {
    assert (lockingVows());
    if (repairWork instanceof Iv2InitiateTaskMessage) {
        Iv2InitiateTaskMessage m = (Iv2InitiateTaskMessage) repairWork;
        Iv2InitiateTaskMessage work = new Iv2InitiateTaskMessage(m.getInitiatorHSId(), getHSId(), m);
        m_scheduler.handleMessageRepair(needsRepair, work);
    } else if (repairWork instanceof FragmentTaskMessage) {
        // We need to get this into the repair log in case we've never seen it before.  Adding fragment
        // tasks to the repair log is safe; we'll never overwrite the first fragment if we've already seen it.
        m_repairLog.deliver(repairWork);
        m_scheduler.handleMessageRepair(needsRepair, repairWork);
    } else if (repairWork instanceof CompleteTransactionMessage) {
        // CompleteTransactionMessages should always be safe to handle.  Either the work was done, and we'll
        // ignore it, or we need to clean up, or we'll be restarting and it doesn't matter.  Make sure they
        // get into the repair log and then let them run their course.
        m_repairLog.deliver(repairWork);
        m_scheduler.handleMessageRepair(needsRepair, repairWork);
    } else {
        throw new RuntimeException("Invalid repair message type: " + repairWork);
    }
}
Also used : FragmentTaskMessage(org.voltdb.messaging.FragmentTaskMessage) Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) CompleteTransactionMessage(org.voltdb.messaging.CompleteTransactionMessage)

Example 15 with FragmentTaskMessage

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

the class SpScheduler method handleCompleteTransactionMessage.

private void handleCompleteTransactionMessage(CompleteTransactionMessage message) {
    CompleteTransactionMessage msg = message;
    if (m_isLeader) {
        msg = new CompleteTransactionMessage(m_mailbox.getHSId(), m_mailbox.getHSId(), message);
        // Set the spHandle so that on repair the new master will set the max seen spHandle
        // correctly
        advanceTxnEgo();
        msg.setSpHandle(getCurrentTxnId());
        if (m_sendToHSIds.length > 0 && !msg.isReadOnly()) {
            m_mailbox.send(m_sendToHSIds, msg);
        }
    } else {
        setMaxSeenTxnId(msg.getSpHandle());
    }
    logRepair(msg);
    TransactionState txn = m_outstandingTxns.get(msg.getTxnId());
    // now, fix that later.
    if (txn != null) {
        CompleteTransactionMessage finalMsg = msg;
        final VoltTrace.TraceEventBatch traceLog = VoltTrace.log(VoltTrace.Category.SPI);
        if (traceLog != null) {
            traceLog.add(() -> VoltTrace.instant("recvCompleteTxn", "txnId", TxnEgo.txnIdToString(finalMsg.getTxnId()), "partition", Integer.toString(m_partitionId), "hsId", CoreUtils.hsIdToString(m_mailbox.getHSId())));
        }
        final boolean isSysproc = ((FragmentTaskMessage) txn.getNotice()).isSysProcTask();
        if (m_sendToHSIds.length > 0 && !msg.isRestart() && (!msg.isReadOnly() || isSysproc)) {
            DuplicateCounter counter;
            counter = new DuplicateCounter(msg.getCoordinatorHSId(), msg.getTxnId(), m_replicaHSIds, msg);
            safeAddToDuplicateCounterMap(new DuplicateCounterKey(msg.getTxnId(), msg.getSpHandle()), counter);
        }
        Iv2Trace.logCompleteTransactionMessage(msg, m_mailbox.getHSId());
        final CompleteTransactionTask task = new CompleteTransactionTask(m_mailbox, txn, m_pendingTasks, msg);
        queueOrOfferMPTask(task);
    } else {
        // Generate a dummy response message when this site has not seen previous FragmentTaskMessage,
        // the leader may have started to wait for replicas' response messages.
        // This can happen in the early phase of site rejoin before replica receiving the snapshot initiation,
        // it also means this CompleteTransactionMessage message will be dropped because it's after snapshot.
        final CompleteTransactionResponseMessage resp = new CompleteTransactionResponseMessage(msg);
        resp.m_sourceHSId = m_mailbox.getHSId();
        handleCompleteTransactionResponseMessage(resp);
    }
}
Also used : TransactionState(org.voltdb.dtxn.TransactionState) CompleteTransactionResponseMessage(org.voltdb.messaging.CompleteTransactionResponseMessage) VoltTrace(org.voltdb.utils.VoltTrace) FragmentTaskMessage(org.voltdb.messaging.FragmentTaskMessage) CompleteTransactionMessage(org.voltdb.messaging.CompleteTransactionMessage)

Aggregations

FragmentTaskMessage (org.voltdb.messaging.FragmentTaskMessage)28 CompleteTransactionMessage (org.voltdb.messaging.CompleteTransactionMessage)9 Iv2InitiateTaskMessage (org.voltdb.messaging.Iv2InitiateTaskMessage)9 Test (org.junit.Test)6 Iv2RepairLogResponseMessage (org.voltdb.messaging.Iv2RepairLogResponseMessage)6 FragmentResponseMessage (org.voltdb.messaging.FragmentResponseMessage)5 ArrayList (java.util.ArrayList)4 TransactionInfoBaseMessage (org.voltcore.messaging.TransactionInfoBaseMessage)3 VoltTrace (org.voltdb.utils.VoltTrace)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 Matchers.anyLong (org.mockito.Matchers.anyLong)2 StoredProcedureInvocation (org.voltdb.StoredProcedureInvocation)2 TransactionState (org.voltdb.dtxn.TransactionState)2 HashMap (java.util.HashMap)1 List (java.util.List)1 Random (java.util.Random)1 Mailbox (org.voltcore.messaging.Mailbox)1 VoltMessage (org.voltcore.messaging.VoltMessage)1 ParameterSet (org.voltdb.ParameterSet)1 VoltTable (org.voltdb.VoltTable)1