NHibernate Commit Transaction收到后'COMMIT TRANSACTION请求没有对应的BEGIN TRANSACTION。 '
我将事务范围用于分布式事务和 NHibernate 内部事务。 在所有操作之后,我检查 Transaction.Current
是否未中止并尝试提交 NHibernate 事务。
有时我会收到此错误:
COMMIT TRANSACTION 请求没有对应的 BEGIN TRANSACTION。 此会话中活动的事务已提交或中止 通过另一个会话。
使用以下堆栈跟踪:
System.Data.SqlClient.SqlConnection.OnError(SqlException异常, 布尔中断连接) в System.Data.SqlClient.SqlInternalConnection.OnError(SqlException 异常,布尔中断连接) в System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) × System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior、SqlCommand cmdHandler、SqlDataReader dataStream、 BulkCopySimpleResultSet BulkCopyHandler、TdsParserStateObject 状态Obj) в System.Data.SqlClient.TdsParser.TdsExecuteTransactionManagerRequest(Byte[] 缓冲区,TransactionManagerRequestType 请求,字符串 transactionName, TransactionManagerIsolationLevel isoLevel,Int32 超时, SqlInternalTransaction事务,TdsParserStateObject stateObj, 布尔值 isDelegateControlRequest) в System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransactionYukon(TransactionRequest transactionRequest、字符串 transactionName、隔离级别 iso、 SqlInternalTransaction 内部事务,布尔值 isDelegateControlRequest) в System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransaction(TransactionRequest transactionRequest、字符串名称、IsolationLevel iso、 SqlInternalTransaction 内部事务,布尔值 isDelegateControlRequest) в System.Data.SqlClient.SqlInternalTransaction.Commit() × System.Data.SqlClient.SqlTransaction.Commit() × NHibernate.Transaction.AdoTransaction.Commit()。
主要问题是这个错误是偶尔发生的。这可能是什么原因?
I use Transaction scope for distributed transactions and NHibernate inner transactions.
After all operations I check if Transaction.Current
is not aborted and try to commit NHibernate transaction.
Sometimes I receive this error:
The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.
The transaction active in this session has been committed or aborted
by another session.
With the following stacktrace:
System.Data.SqlClient.SqlConnection.OnError(SqlException exception,
Boolean breakConnection) в
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection) в
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj) в System.Data.SqlClient.TdsParser.Run(RunBehavior
runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj) в
System.Data.SqlClient.TdsParser.TdsExecuteTransactionManagerRequest(Byte[]
buffer, TransactionManagerRequestType request, String transactionName,
TransactionManagerIsolationLevel isoLevel, Int32 timeout,
SqlInternalTransaction transaction, TdsParserStateObject stateObj,
Boolean isDelegateControlRequest) в
System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransactionYukon(TransactionRequest
transactionRequest, String transactionName, IsolationLevel iso,
SqlInternalTransaction internalTransaction, Boolean
isDelegateControlRequest) в
System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransaction(TransactionRequest
transactionRequest, String name, IsolationLevel iso,
SqlInternalTransaction internalTransaction, Boolean
isDelegateControlRequest) в
System.Data.SqlClient.SqlInternalTransaction.Commit() в
System.Data.SqlClient.SqlTransaction.Commit() в
NHibernate.Transaction.AdoTransaction.Commit().
The main problem that this error is occasional. What could be the reason for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来您没有通过集中代码打开会话,而是每次都关闭会话事务,否则我看不到发生这种情况的原因..
确保您在发生此错误的位置具有相同的代码路径抛出..可能正在查看堆栈跟踪。
looks like you are not opening your sesions through a centralized code but closing the session transaction every time, else i dont see a reason for this happening..
make sure you have the same code path that is being used at the location where this error is thrown.. probably looking at the stack trace.