Search in sources :

Example 6 with SiteProcedureConnection

use of org.voltdb.SiteProcedureConnection in project voltdb by VoltDB.

the class TestMpTransactionState method testOneSitePartitionedReadWithBuddyRollback.

@Test
public void testOneSitePartitionedReadWithBuddyRollback() throws IOException {
    long txnId = 1234l;
    int batch_size = 3;
    Iv2InitiateTaskMessage taskmsg = new Iv2InitiateTaskMessage(0, 0, (txnId - 1), txnId, System.currentTimeMillis(), true, false, new StoredProcedureInvocation(), 0, 0, false);
    int hsids = 1;
    buddyHSId = 0;
    long[] non_local = configureHSIds(hsids);
    MpTestPlan plan = createTestPlan(batch_size, true, false, false, non_local);
    Mailbox mailbox = mock(Mailbox.class);
    SiteProcedureConnection siteConnection = mock(SiteProcedureConnection.class);
    MpTransactionState dut = new MpTransactionState(mailbox, taskmsg, allHsids, partMasters, buddyHSId, false);
    // emulate ProcedureRunner's use for a single local fragment
    dut.setupProcedureResume(true, plan.depsToResume);
    dut.createLocalFragmentWork(plan.localWork, false);
    // This will be passed a FragmentTaskMessage with no deps
    dut.createAllParticipatingFragmentWork(plan.remoteWork);
    // we should send one message
    verify(mailbox).send(eq(new long[] { buddyHSId }), (VoltMessage) any());
    // to simplify, offer messages first
    // offer all the necessary fragment responses to satisfy deps
    // just be lazy and perturb the buddy response here
    plan.generatedResponses.get(plan.generatedResponses.size() - 1).setStatus(FragmentResponseMessage.UNEXPECTED_ERROR, new EEException(1234));
    for (FragmentResponseMessage msg : plan.generatedResponses) {
        System.out.println("Offering response: " + msg);
        dut.offerReceivedFragmentResponse(msg);
    }
    // We're getting an error, so this should throw something
    boolean threw = false;
    try {
        dut.recursableRun(siteConnection);
        fail();
    } catch (EEException eee) {
        if (eee.getErrorCode() == 1234) {
            threw = true;
        }
    }
    assertTrue(threw);
}
Also used : StoredProcedureInvocation(org.voltdb.StoredProcedureInvocation) Mailbox(org.voltcore.messaging.Mailbox) SiteProcedureConnection(org.voltdb.SiteProcedureConnection) Iv2InitiateTaskMessage(org.voltdb.messaging.Iv2InitiateTaskMessage) FragmentResponseMessage(org.voltdb.messaging.FragmentResponseMessage) EEException(org.voltdb.exceptions.EEException) Test(org.junit.Test)

Example 7 with SiteProcedureConnection

use of org.voltdb.SiteProcedureConnection in project voltdb by VoltDB.

the class RejoinProducer method doFinishingTask.

private void doFinishingTask(final SiteProcedureConnection siteConnection) {
    /*
         * Don't notify the rejoin coordinator yet. The stream snapshot may
         * have not finished on all nodes, let the snapshot completion
         * monitor tell the rejoin coordinator.
         *
         * This used to block on the completion interest, but this raced
         * with fragments from the MPI that needed dummy responses. If the fragments
         * came after the EOF then they wouldn't receive dummy responses
         * and then the MPI wouldn't invoke SnapshotSaveAPI.logParticipatingHostCount
         */
    final SiteTasker finishingTask = new SiteTasker() {

        @Override
        public void run(SiteProcedureConnection siteConnection) {
            throw new RuntimeException("Unexpected execution of run method in rejoin producer.");
        }

        @Override
        public void runForRejoin(SiteProcedureConnection siteConnection, TaskLog rejoinTaskLog) throws IOException {
            if (!m_snapshotCompletionMonitor.isDone()) {
                m_taskQueue.offer(this);
                return;
            }
            SnapshotCompletionEvent event = null;
            Map<String, Map<Integer, Pair<Long, Long>>> exportSequenceNumbers = null;
            Map<Integer, Long> drSequenceNumbers = null;
            Map<Integer, Map<Integer, Map<Integer, DRConsumerDrIdTracker>>> allConsumerSiteTrackers = null;
            long clusterCreateTime = -1;
            try {
                event = m_snapshotCompletionMonitor.get();
                if (!m_schemaHasNoTables) {
                    REJOINLOG.debug(m_whoami + "waiting on snapshot completion monitor.");
                    exportSequenceNumbers = event.exportSequenceNumbers;
                    m_completionAction.setSnapshotTxnId(event.multipartTxnId);
                    drSequenceNumbers = event.drSequenceNumbers;
                    allConsumerSiteTrackers = event.drMixedClusterSizeConsumerState;
                    clusterCreateTime = event.clusterCreateTime;
                    // Tells EE which DR version going to use
                    siteConnection.setDRProtocolVersion(event.drVersion);
                }
                REJOINLOG.debug(m_whoami + " monitor completed. Sending SNAPSHOT_FINISHED " + "and handing off to site.");
                RejoinMessage snap_complete = new RejoinMessage(m_mailbox.getHSId(), Type.SNAPSHOT_FINISHED);
                m_mailbox.send(m_coordinatorHsId, snap_complete);
            } catch (InterruptedException crashme) {
                VoltDB.crashLocalVoltDB("Interrupted awaiting snapshot completion.", true, crashme);
            } catch (ExecutionException e) {
                VoltDB.crashLocalVoltDB("Unexpected exception awaiting snapshot completion.", true, e);
            }
            if (exportSequenceNumbers == null) {
                // Send empty sequence number map if the schema is empty (no tables).
                exportSequenceNumbers = new HashMap<String, Map<Integer, Pair<Long, Long>>>();
            }
            setJoinComplete(siteConnection, exportSequenceNumbers, drSequenceNumbers, allConsumerSiteTrackers, m_schemaHasNoTables == false, /* requireExistingSequenceNumbers */
            clusterCreateTime);
        }
    };
    try {
        finishingTask.runForRejoin(siteConnection, null);
    } catch (IOException e) {
        VoltDB.crashLocalVoltDB("Unexpected IOException in rejoin", true, e);
    }
}
Also used : RejoinMessage(org.voltdb.messaging.RejoinMessage) TaskLog(org.voltdb.rejoin.TaskLog) SnapshotCompletionEvent(org.voltdb.SnapshotCompletionInterest.SnapshotCompletionEvent) IOException(java.io.IOException) SiteProcedureConnection(org.voltdb.SiteProcedureConnection) DRConsumerDrIdTracker(org.voltdb.DRConsumerDrIdTracker) ExecutionException(java.util.concurrent.ExecutionException) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

SiteProcedureConnection (org.voltdb.SiteProcedureConnection)7 Test (org.junit.Test)6 Mailbox (org.voltcore.messaging.Mailbox)6 StoredProcedureInvocation (org.voltdb.StoredProcedureInvocation)6 FragmentResponseMessage (org.voltdb.messaging.FragmentResponseMessage)6 Iv2InitiateTaskMessage (org.voltdb.messaging.Iv2InitiateTaskMessage)6 ArrayList (java.util.ArrayList)4 List (java.util.List)4 EEException (org.voltdb.exceptions.EEException)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ExecutionException (java.util.concurrent.ExecutionException)1 DRConsumerDrIdTracker (org.voltdb.DRConsumerDrIdTracker)1 SnapshotCompletionEvent (org.voltdb.SnapshotCompletionInterest.SnapshotCompletionEvent)1 VoltTable (org.voltdb.VoltTable)1 BorrowTaskMessage (org.voltdb.messaging.BorrowTaskMessage)1 RejoinMessage (org.voltdb.messaging.RejoinMessage)1 TaskLog (org.voltdb.rejoin.TaskLog)1