@Override public void run(SiteProcedureConnection siteConnection) { hostLog.debug("STARTING: " + this); if (!m_txnState.isReadOnly()) { // the truncation point token SHOULD be part of m_txn. However, the // legacy interaces don't work this way and IV2 hasn't changed this // ownership yet. But truncateUndoLog is written assuming the right // eventual encapsulation. siteConnection.truncateUndoLog( m_completeMsg.isRollback(), m_txnState.getBeginUndoToken(), m_txnState.m_spHandle, m_txnState.getUndoLog()); } if (!m_completeMsg.isRestart()) { doCommonSPICompleteActions(); // Log invocation to DR logToDR(siteConnection.getDRGateway()); hostLog.debug("COMPLETE: " + this); } else { // If we're going to restart the transaction, then reset the begin undo token so the // first FragmentTask will set it correctly. Otherwise, don't set the Done state or // flush the queue; we want the TransactionTaskQueue to stay blocked on this TXN ID // for the restarted fragments. m_txnState.setBeginUndoToken(Site.kInvalidUndoToken); hostLog.debug("RESTART: " + this); } final CompleteTransactionResponseMessage resp = new CompleteTransactionResponseMessage(m_completeMsg); resp.m_sourceHSId = m_initiator.getHSId(); m_initiator.deliver(resp); }
@Override public void restore(SiteProcedureConnection connection) { rejoinLog.debug("Updating the hashinator to version " + version); // Update the Java hashinator Pair<? extends UndoAction, TheHashinator> hashinatorPair = TheHashinator.updateConfiguredHashinator(version, hashinatorConfig); // Update the EE hashinator connection.updateHashinator(hashinatorPair.getSecond()); }
@Override public void runFromTaskLog(SiteProcedureConnection siteConnection) { if (!m_txnState.isReadOnly()) { // the truncation point token SHOULD be part of m_txn. However, the // legacy interaces don't work this way and IV2 hasn't changed this // ownership yet. But truncateUndoLog is written assuming the right // eventual encapsulation. siteConnection.truncateUndoLog( m_completeMsg.isRollback(), m_txnState.getBeginUndoToken(), m_txnState.m_spHandle, m_txnState.getUndoLog()); } if (!m_completeMsg.isRestart()) { // this call does the right thing with a null TransactionTaskQueue doCommonSPICompleteActions(); logToDR(siteConnection.getDRGateway()); } else { m_txnState.setBeginUndoToken(Site.kInvalidUndoToken); } }
@Override public void restore(SiteProcedureConnection connection) { VoltTable table = PrivateVoltTableFactory.createVoltTableFromBuffer(tableBlock.duplicate(), true); // Currently, only export cares about this TXN ID. Since we don't have one handy, // just use Long.MIN_VALUE to match how m_openSpHandle is initialized in // ee/storage/TupleStreamWrapper connection.loadTable( Long.MIN_VALUE, Long.MIN_VALUE, Long.MIN_VALUE, tableId, table, false, false, false); }
@Override public void runForRejoin(SiteProcedureConnection siteConnection, TaskLog taskLog) throws IOException { if (!m_txnState.isReadOnly() && !m_completeMsg.isRollback()) { // ENG-5276: Need to set the last committed spHandle so that the rejoining site gets the // accurate // per-partition txnId set for the next snapshot. Normally, this is done through undo log // truncation. // Since the task is not run here, we need to set the last committed spHandle explicitly. // // How does this work? // - Blocking rejoin with idle cluster: The spHandle is updated here with the spHandle of the // stream // snapshot that transfers the rejoin data. So the snapshot right after rejoin should have // the spHandle // passed here. // - Live rejoin with idle cluster: Same as blocking rejoin. // - Live rejoin with workload: Transactions will be logged and replayed afterward. The // spHandle will be // updated when they commit and truncate undo logs. So at the end of replay, // the spHandle should have the latest value. If all replayed transactions rolled back, // the spHandle is still guaranteed to be the spHandle of the stream snapshot that // transfered the // rejoin data, which is the correct value. siteConnection.setSpHandleForSnapshotDigest(m_txnState.m_spHandle); } if (!m_completeMsg.isRestart()) { // future: offer to siteConnection.IBS for replay. doCommonSPICompleteActions(); } if (!m_txnState.isReadOnly()) { // We need to log the restarting message to the task log so we'll replay the whole // stream faithfully taskLog.logTask(m_completeMsg); } final CompleteTransactionResponseMessage resp = new CompleteTransactionResponseMessage(m_completeMsg); resp.setIsRecovering(true); resp.m_sourceHSId = m_initiator.getHSId(); m_initiator.deliver(resp); }
@Override public void run(SiteProcedureConnection siteConnection) { siteConnection.doSnapshotWork(true); }
/* * Fetch and set the per partition txnid if necessary */ private void applyPerPartitionTxnId(SiteProcedureConnection connection) { // If there was no ID nothing to do long partitionTxnIds[] = fetchPerPartitionTxnId(); if (partitionTxnIds == null) return; connection.setPerPartitionTxnIds(partitionTxnIds, true); }