Ejemplo n.º 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;
                }
            }
        }
Ejemplo n.º 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;
                }
            }
        }