Пример #1
0
 public void handleCompleteTransactionMessage(CompleteTransactionMessage message) {
   if (m_isLeader) {
     CompleteTransactionMessage replmsg = new CompleteTransactionMessage(message);
     // Set the spHandle so that on repair the new master will set the max seen spHandle
     // correctly
     advanceTxnEgo();
     replmsg.setSpHandle(getCurrentTxnId());
     if (m_sendToHSIds.length > 0) {
       m_mailbox.send(m_sendToHSIds, replmsg);
     }
   } else {
     setMaxSeenTxnId(message.getSpHandle());
   }
   TransactionState txn = m_outstandingTxns.get(message.getTxnId());
   // We can currently receive CompleteTransactionMessages for multipart procedures
   // which only use the buddy site (replicated table read).  Ignore them for
   // now, fix that later.
   if (txn != null) {
     Iv2Trace.logCompleteTransactionMessage(message, m_mailbox.getHSId());
     final CompleteTransactionTask task =
         new CompleteTransactionTask(txn, m_pendingTasks, message, m_drGateway);
     queueOrOfferMPTask(task);
     // If this is a restart, then we need to leave the transaction state around
     if (!message.isRestart()) {
       m_outstandingTxns.remove(message.getTxnId());
     }
   }
 }
Пример #2
0
 @Override
 public long getSpHandle() {
   return m_completeMsg.getSpHandle();
 }
Пример #3
0
  // 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;
      // We can't repair read only SP transactions. Just don't log them to the repair log.
      // 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);
    }
  }