예제 #1
0
        public void AbortTransaction(long transactionId, OrleansTransactionAbortedException reason)
        {
            if (transactionsTable.TryGetValue(transactionId, out Transaction tx))
            {
                bool justAborted = false;

                lock (tx)
                {
                    if (tx.State == TransactionState.Started ||
                        tx.State == TransactionState.PendingDependency)
                    {
                        tx.State    = TransactionState.Aborted;
                        justAborted = true;
                    }
                }

                if (justAborted)
                {
                    foreach (var waiting in tx.WaitingTransactions)
                    {
                        var cascading = new OrleansCascadingAbortException(waiting.Info.TransactionId, tx.TransactionId);
                        AbortTransaction(waiting.Info.TransactionId, cascading);
                    }

                    tx.CompletionTimeUtc = DateTime.UtcNow;
                    tx.AbortingException = reason;
                }
            }
        }
예제 #2
0
        public void AbortTransaction(long transactionId, OrleansTransactionAbortedException reason)
        {
            this.metrics.AbortTransactionRequestCounter++;
            this.metrics.AbortedTransactionCounter++;
            if (this.logger.IsEnabled(LogLevel.Debug))
            {
                this.logger.LogDebug($"Abort transaction {transactionId} due to reason {reason}");
            }
            if (transactionsTable.TryGetValue(transactionId, out Transaction tx))
            {
                bool justAborted = false;

                lock (tx)
                {
                    if (tx.State == TransactionState.Started ||
                        tx.State == TransactionState.PendingDependency)
                    {
                        tx.State    = TransactionState.Aborted;
                        justAborted = true;
                    }
                }

                if (justAborted)
                {
                    foreach (var waiting in tx.WaitingTransactions)
                    {
                        var cascading = new OrleansCascadingAbortException(waiting.Info.TransactionId, tx.TransactionId);
                        AbortTransaction(waiting.Info.TransactionId, cascading);
                    }

                    tx.CompletionTimeUtc = DateTime.UtcNow;
                    tx.AbortingException = reason;
                }
            }
        }
예제 #3
0
        public void Abort(TransactionInfo transactionInfo, OrleansTransactionAbortedException reason)
        {
            abortedTransactions.TryAdd(transactionInfo.TransactionId, 0);
            foreach (var g in transactionInfo.WriteSet.Keys)
            {
                g.Abort(transactionInfo.TransactionId).Ignore();
            }

            // TODO: should we wait for the abort tasks to complete before returning?
            // If so, how do we handle exceptions?

            // There is no guarantee that the WriteSet is complete and has all the grains.
            // Notify the TM of the abort as well.
            this.tmService.AbortTransaction(transactionInfo.TransactionId, reason).Ignore();
        }
예제 #4
0
        public void Abort(ITransactionInfo info, OrleansTransactionAbortedException reason)
        {
            var transactionInfo = (TransactionInfo)info;

            var participants = transactionInfo.Participants.Keys.ToList();

            if (logger.IsEnabled(LogLevel.Trace))
            {
                logger.Trace($"abort {transactionInfo} {string.Join(",", participants.Select(p => p.ToString()))} {reason}");
            }

            // send one-way abort messages to release the locks and roll back any updates
            foreach (var p in participants)
            {
                p.Abort(transactionInfo.TransactionId);
            }
        }
예제 #5
0
        public void Abort(ITransactionInfo info, OrleansTransactionAbortedException reason)
        {
            var transactionInfo = (TransactionInfo)info;

            if (logger.IsEnabled(LogLevel.Trace))
            {
                logger.Trace($"abort {transactionInfo} {reason}");
            }

            var participants = transactionInfo.Participants.Keys.ToList();

            if (!transactionInfo.PrepareMessagesSent)
            {
                // send one-way abort messages to release the locks and roll back any updates
                foreach (var p in participants)
                {
                    p.Abort(transactionInfo.TransactionId);
                }
            }
        }
예제 #6
0
        public void Abort(ITransactionInfo info, OrleansTransactionAbortedException reason)
        {
            this.statistics.TrackTransactionFailed();
            var transactionInfo = (TransactionInfo)info;

            List <ParticipantId> participants = transactionInfo.Participants.Keys.ToList();

            if (logger.IsEnabled(LogLevel.Trace))
            {
                logger.Trace($"abort {transactionInfo} {string.Join(",", participants.Select(p => p.ToString()))} {reason}");
            }

            // send one-way abort messages to release the locks and roll back any updates
            foreach (var p in participants)
            {
                p.Reference.AsReference <ITransactionalResourceExtension>()
                .Abort(p.Name, transactionInfo.TransactionId)
                .Ignore();
            }
        }
예제 #7
0
 public TransactionStatus GetTransactionStatus(long transactionId, out OrleansTransactionAbortedException abortingException)
 {
     abortingException = null;
     if (transactionsTable.TryGetValue(transactionId, out Transaction tx))
     {
         if (tx.State == TransactionState.Aborted)
         {
             lock (tx)
             {
                 abortingException = tx.AbortingException;
             }
             return(TransactionStatus.Aborted);
         }
         else if (tx.State == TransactionState.Committed || tx.State == TransactionState.Checkpointed)
         {
             return(TransactionStatus.Committed);
         }
         else
         {
             return(TransactionStatus.InProgress);
         }
     }
     return(TransactionStatus.Unknown);
 }
예제 #8
0
 public Task AbortTransaction(long transactionId, OrleansTransactionAbortedException reason)
 {
     return(this.transactionManagerService.AbortTransaction(transactionId, reason));
 }
예제 #9
0
 public void Abort(ITransactionInfo transactionInfo, OrleansTransactionAbortedException reason)
 {
     throw new OrleansTransactionsDisabledException();
 }
예제 #10
0
 public Task AbortTransaction(long transactionId, OrleansTransactionAbortedException reason)
 {
     tm.AbortTransaction(transactionId, reason);
     return(Task.CompletedTask);
 }
 public Task AbortTransaction(long transactionId, OrleansTransactionAbortedException reason)
 {
     throw new OrleansTransactionsDisabledException();
 }