我们已经从 sqlite 切换到 FireBird 嵌入式服务器,因为 FB
貌似支持数据库的并发更新,但是我们有时候
有这些例外:
2010-10-28 15:49:31,242 [56] ERROR NetworkCatcher.Entities.Agent.Server.RunResultManager - Failed to send result to server 32W2K3SP2VM-DEV. NHibernate.Exceptions.GenericADOException: could not update: ExecutionEntry#89_19_32W2K3SP2VM-DEV][SQL: UPDATE Run SET ExecutionId = ?, Source = ?, Destination = ?, ProtocolId = ?, Duration = ?, SampleCount = ?, StartTime = ?, ServerHostName = ?, SamplesSentToServer = ?, SampleInterval = ?, Parameters = ? WHERE Id = ?] ---> FirebirdSql.Data.FirebirdClient.FbException: deadlock
update conflicts with concurrent update
concurrent transaction number is 31632 --->
FirebirdSql.Data.Common.IscException: deadlock
update conflicts with concurrent update
concurrent transaction number is 31632
at FirebirdSql.Data.Client.Native.FesDatabase.ParseStatusVector(IntPtr[]
statusVector)
at FirebirdSql.Data.Client.Native.FesStatement.Execute()
at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteCommand(CommandBehavior
behavior, Boolean returnsSet)
at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteCommand(CommandBehavior
behavior)
at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteNonQuery()
.
.
.
FB对此的回应是
“为什么你认为这是一个错误?这是定期更新冲突导致的
两个事务同时更新同一条记录。什么是
你的事务隔离模式?“
这句话让我困惑了两次——一次是因为我感到不愉快
惊讶地发现我可以同时写入同一条记录
第二次——我不知道我的是什么
事务隔离模式以及如何使用它来序列化写入
相同的记录。
正在更新的对象的映射是:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-
import="true">
<class name="NetworkCatcher.Entities.Agent.Server.ExecutionManager+ExecutionEntry,NC.Entities.Agent.Server" lazy="false" table="Run" entity-name="ExecutionEntry">
<id name="Id" column="Id" type="string" >
<generator class="assigned"/>
</id>
<property name="ExecutionId"/>
<property name="Source"/>
<property name="Destination"/>
<property name="ProtocolId" type="string"/>
<property name="Duration"/>
<property name="SampleCount"/>
<property name="StartTime"/>
<property name="ServerHostName"/>
<property name="m_samplesSentToServer" column="SamplesSentToServer" type="int" access="field" />
<property name="SampleInterval"/>
<property name="Parameters" type="binary"/>
</class>
</hibernate-mapping>
我确信那里有一个好心人,他知道答案
我的问题。拜托,拜托,请分享你的智慧......
Thanks.