Search in sources :

Example 16 with CompleteTransactionMessage

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

the class TestRepairLog method testFuzz.

@Test
public void testFuzz() {
    TxnEgo sphandle = TxnEgo.makeZero(0);
    UniqueIdGenerator spbuig = new UniqueIdGenerator(0, 0);
    UniqueIdGenerator mpbuig = new UniqueIdGenerator(0, 0);
    sphandle = sphandle.makeNext();
    RandomMsgGenerator msgGen = new RandomMsgGenerator();
    RepairLog dut = new RepairLog();
    long spBinaryLogSpUniqueId = Long.MIN_VALUE;
    long spBinaryLogMpUniqueId = Long.MIN_VALUE;
    long mpBinaryLogMpUniqueId = Long.MIN_VALUE;
    for (int i = 0; i < 4000; i++) {
        // get next message, update the sphandle according to SpScheduler rules,
        // but only submit messages that would have been forwarded by the master
        // to the repair log.
        TransactionInfoBaseMessage msg = msgGen.generateRandomMessageInStream();
        msg.setSpHandle(sphandle.getTxnId());
        if (msg instanceof Iv2InitiateTaskMessage) {
            Pair<Long, Long> uids = setBinaryLogUniqueId(msg, spbuig, mpbuig);
            spBinaryLogSpUniqueId = Math.max(spBinaryLogSpUniqueId, uids.getFirst());
            spBinaryLogMpUniqueId = Math.max(spBinaryLogMpUniqueId, uids.getSecond());
        } else if (msg instanceof FragmentTaskMessage) {
            mpBinaryLogMpUniqueId = Math.max(mpBinaryLogMpUniqueId, setBinaryLogUniqueId(msg, null, mpbuig).getSecond());
        }
        sphandle = sphandle.makeNext();
        if (!msg.isReadOnly() || msg instanceof CompleteTransactionMessage) {
            dut.deliver(msg);
        }
    }
    List<Iv2RepairLogResponseMessage> stuff = dut.contents(1l, false);
    validateRepairLog(stuff, spBinaryLogSpUniqueId, spBinaryLogMpUniqueId);
    // Also check the MP version
    stuff = dut.contents(1l, true);
    validateRepairLog(stuff, Long.MIN_VALUE, mpBinaryLogMpUniqueId);
}
Also used : Iv2RepairLogResponseMessage(org.voltdb.messaging.Iv2RepairLogResponseMessage) FragmentTaskMessage(org.voltdb.messaging.FragmentTaskMessage) Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) AtomicLong(java.util.concurrent.atomic.AtomicLong) CompleteTransactionMessage(org.voltdb.messaging.CompleteTransactionMessage) TransactionInfoBaseMessage(org.voltcore.messaging.TransactionInfoBaseMessage) Test(org.junit.Test)

Example 17 with CompleteTransactionMessage

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

the class TestMpPromoteAlgo method testFuzz.

@Test
public void testFuzz() throws Exception {
    System.out.println("Running testFuzz");
    InitiatorMailbox mbox = mock(InitiatorMailbox.class);
    Random rand = new Random(System.currentTimeMillis());
    // Generate a random message stream to several "replicas", interrupted
    // at random points to all but one.  Validate that promotion repair
    // results in identical, correct, repair streams to all replicas.
    TxnEgo sphandle = TxnEgo.makeZero(0);
    UniqueIdGenerator uig = new UniqueIdGenerator(0, 0);
    sphandle = sphandle.makeNext();
    RandomMsgGenerator msgGen = new RandomMsgGenerator();
    boolean[] stops = new boolean[3];
    RepairLog[] logs = new RepairLog[3];
    for (int i = 0; i < 3; i++) {
        logs[i] = new RepairLog();
        stops[i] = false;
    }
    for (int i = 0; i < 4000; i++) {
        // get next message, update the sphandle according to SpScheduler rules,
        // but only submit messages that would have been forwarded by the master
        // to the repair log.
        TransactionInfoBaseMessage msg = msgGen.generateRandomMessageInStream();
        msg.setSpHandle(sphandle.getTxnId());
        sphandle = sphandle.makeNext();
        if (!msg.isReadOnly() || msg instanceof CompleteTransactionMessage) {
            if (!stops[0]) {
                logs[0].deliver(msg);
            }
            if (!stops[1]) {
                logs[1].deliver(msg);
            }
            logs[2].deliver(msg);
            // be fed any transactions
            for (int j = 0; j < 2; j++) {
                // Hacky way to get spaced failures
                if (rand.nextDouble() < (.01 / ((j + 1) * 5))) {
                    stops[j] = true;
                }
            }
        }
    }
    List<Long> survivors = new ArrayList<Long>();
    survivors.add(0l);
    survivors.add(1l);
    survivors.add(2l);
    MpPromoteAlgo dut = new MpPromoteAlgo(survivors, mbox, "bleh ");
    Future<RepairResult> result = dut.start();
    for (int i = 0; i < 3; i++) {
        List<Iv2RepairLogResponseMessage> stuff = logs[i].contents(dut.getRequestId(), true);
        System.out.println("Repair log size from: " + i + ": " + stuff.size());
        for (Iv2RepairLogResponseMessage msg : stuff) {
            msg.m_sourceHSId = (long) i;
            dut.deliver(msg);
        }
    }
    result.get();
    assertFalse(result.isCancelled());
    assertTrue(result.isDone());
    // Unfortunately, it's painful to try to stub things to make repairSurvivors() work, so we'll
    // go and inspect the guts of SpPromoteAlgo instead.  This iteration is largely a copy of the inner loop
    // of repairSurvivors()
    List<TransactionInfoBaseMessage> finalStream = new ArrayList<TransactionInfoBaseMessage>();
    for (Iv2RepairLogResponseMessage li : dut.m_repairLogUnion) {
        VoltMessage msg = dut.createRepairMessage(li);
        finalStream.add((TransactionInfoBaseMessage) msg);
    }
    // Check the sanity of the repair stream generated by the MPI.
    long lastTxnId = Long.MIN_VALUE;
    boolean seenFrag = false;
    for (TransactionInfoBaseMessage msg : finalStream) {
        if (lastTxnId == Long.MIN_VALUE) {
            lastTxnId = msg.getTxnId();
        } else {
            assertTrue(msg.getTxnId() > lastTxnId);
            lastTxnId = msg.getTxnId();
        }
        if (msg instanceof FragmentTaskMessage) {
            assertFalse(seenFrag);
            seenFrag = true;
        }
    }
}
Also used : Iv2RepairLogResponseMessage(org.voltdb.messaging.Iv2RepairLogResponseMessage) FragmentTaskMessage(org.voltdb.messaging.FragmentTaskMessage) ArrayList(java.util.ArrayList) RepairResult(org.voltdb.iv2.RepairAlgo.RepairResult) VoltMessage(org.voltcore.messaging.VoltMessage) Random(java.util.Random) CompleteTransactionMessage(org.voltdb.messaging.CompleteTransactionMessage) TransactionInfoBaseMessage(org.voltcore.messaging.TransactionInfoBaseMessage) Test(org.junit.Test)

Example 18 with CompleteTransactionMessage

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

the class RandomMsgGenerator method generateRandomMessageInStream.

public TransactionInfoBaseMessage generateRandomMessageInStream() {
    if (m_rand.nextDouble() > MPCHANCE) {
        double type = m_rand.nextDouble();
        boolean readOnly = (type < READCHANCE);
        boolean binaryLog = (!readOnly && type < BINARYLOGCHANCE);
        Iv2InitiateTaskMessage msg = makeIv2InitiateTaskMsg(readOnly, binaryLog, false);
        return msg;
    } else if (!m_mpInProgress) {
        double type = m_rand.nextDouble();
        m_currentMpReadOnly = (type < READCHANCE);
        boolean binaryLog = (!m_currentMpReadOnly && type < BINARYLOGCHANCE);
        FragmentTaskMessage msg = makeFragmentTaskMsg(m_currentMpReadOnly, false);
        msg.setStateForDurability(makeIv2InitiateTaskMsg(false, binaryLog, true), Sets.newHashSet(0, 1, 2));
        m_mpInProgress = true;
        return msg;
    } else if (m_rand.nextDouble() > MPDONECHANCE) {
        // generate another MP fragment
        FragmentTaskMessage msg = makeFragmentTaskMsg(m_currentMpReadOnly, false);
        return msg;
    } else {
        // generate MP complete
        // fake restarts
        boolean restart = (!m_currentMpReadOnly && m_rand.nextDouble() < MPRESTARTCHANCE);
        CompleteTransactionMessage msg = makeCompleteTxnMsg(m_currentMpReadOnly, restart, restart);
        if (!restart) {
            m_mpInProgress = false;
            m_mpiTxnEgo = m_mpiTxnEgo.makeNext();
        }
        return msg;
    }
}
Also used : FragmentTaskMessage(org.voltdb.messaging.FragmentTaskMessage) Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) CompleteTransactionMessage(org.voltdb.messaging.CompleteTransactionMessage)

Example 19 with CompleteTransactionMessage

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

the class MpInitiatorMailbox 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.updateLastSeenUniqueIds(work);
        m_scheduler.handleMessageRepair(needsRepair, work);
    } else if (repairWork instanceof CompleteTransactionMessage) {
        send(com.google_voltpatches.common.primitives.Longs.toArray(needsRepair), repairWork);
    } else {
        throw new RuntimeException("During MPI repair: Invalid repair message type: " + repairWork);
    }
}
Also used : Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) CompleteTransactionMessage(org.voltdb.messaging.CompleteTransactionMessage)

Aggregations

CompleteTransactionMessage (org.voltdb.messaging.CompleteTransactionMessage)19 FragmentTaskMessage (org.voltdb.messaging.FragmentTaskMessage)9 Iv2InitiateTaskMessage (org.voltdb.messaging.Iv2InitiateTaskMessage)7 Iv2RepairLogResponseMessage (org.voltdb.messaging.Iv2RepairLogResponseMessage)7 TransactionInfoBaseMessage (org.voltcore.messaging.TransactionInfoBaseMessage)4 VoltTrace (org.voltdb.utils.VoltTrace)4 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 Random (java.util.Random)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 RepairResult (org.voltdb.iv2.RepairAlgo.RepairResult)2 HashMap (java.util.HashMap)1 List (java.util.List)1 VoltMessage (org.voltcore.messaging.VoltMessage)1 ClientResponseImpl (org.voltdb.ClientResponseImpl)1 VoltTable (org.voltdb.VoltTable)1 TransactionState (org.voltdb.dtxn.TransactionState)1 CompleteTransactionResponseMessage (org.voltdb.messaging.CompleteTransactionResponseMessage)1 DumpMessage (org.voltdb.messaging.DumpMessage)1 InitiateResponseMessage (org.voltdb.messaging.InitiateResponseMessage)1