Inheritance: TransactionException
コード例 #1
0
ファイル: Client.cs プロジェクト: zYg-sys/scaliendb
        /// <summary>
        /// Commit current transaction
        /// </summary>
        /// <seealso cref="StartTransaction()"/>
        /// <seealso cref="RollbackTransaction()"/>
        public void CommitTransaction()
        {
            int status = scaliendb_client.SDBP_CommitTransaction(cptr);

            result = new Result(scaliendb_client.SDBP_GetResult(cptr));
            if (status < 0)
            {
                if (status == Status.SDBP_FAILED)
                {
                    // If the nodeID of the StartTransaction differs from the nodeID of the CommitTransaction
                    // then there was a primary failover
                    result.Begin();
                    UInt64?startNodeID  = result.GetNodeID();
                    UInt64?commitNodeID = null;
                    while (!result.IsEnd())
                    {
                        commitNodeID = result.GetNodeID();
                        result.Next();
                    }

                    if (startNodeID != commitNodeID)
                    {
                        // Primary failover happened
                    }

                    result.Begin();

                    TransactionException exception = new LockExpiryException(status);
                    UpdateException(exception, result);
                    throw exception;
                }
                CheckStatus(result, status);
            }
            result.Close();
        }