3

お客様に定期的に「ネストされた/同時トランザクションはサポートされていません」というメッセージが表示されます。エラー。私の側では再現できませんが、それがどのように起こるかを理解しようとしています. 次の方法でのみ発生します。

public DataTable ExecuteDataTable(CommandType type, string query, params NpgsqlParameter[] parameters)
        {
            NpgsqlCommand command = PrepareCommand(type, query, parameters);

            // Use transaction for functions with refcursors. This is necessary to prevent cursors 
            // returned by refcursor function from closing after the implicity transaction is finished 
            // (just after we do the function call).
            NpgsqlTransaction t = sqlConnection.BeginTransaction();

            try
            {
                NpgsqlDataAdapter da = new NpgsqlDataAdapter(command);
                System.Data.DataSet ds = new System.Data.DataSet();

                // Fill the DataSet using default values for DataTable names, etc
                da.Fill(ds);
                t.Commit();

                // Detach the SqlParameters from the command object, so they can be used again
                command.Parameters.Clear();

                return ds.Tables[0];
            }
            catch (Exception e)
            {
                // Commit all transactions so connection can be used again (Npgsql does not allow nested transactions)
                t.Rollback();
                // Log error and problem query
                LogError(e);
                // Throw same exception to a higher level for correct handling
                throw e;
            }
        }

エラーが発生した場合、ネストされたトランザクションを回避するために常にロールバックを試みますが、インストールによっては定期的に発生します。Npgsqlの問題か、実装上の何かですか?これはどのように起こりますか?2つのプロセスが異なるクラス、アプリからこのメソッドを同時に実行する場合、これは接続プールまたは何かに接続されていますか?

コール スタック:

2013-10-08 13:00:27.6038|Common.Logging.NLog.NLogLogger.WriteInternal|Info|Job DEFAULT.SQLServerSyncScheduledJob が JobExecutionException をスローしました: |System.InvalidOperationException: ネストされた/同時トランザクションはサポートされていません。Npgsql.NpgsqlConnection.BeginTransaction(IsolationLevel レベル) で Npgsql.NpgsqlConnection.BeginTransaction() で DbFramework.PgDataAccess.ExecuteDataTable(CommandType 型、文字列クエリ、NpgsqlParameter[] パラメータ)

4

0 に答える 0