Issue Details (XML | Word | Printable)

Key: CORE-3209
Type: Bug Bug
Status: Closed Closed
Resolution: Won't Fix
Priority: Critical Critical
Assignee: Unassigned
Reporter: Mark Kharitonov
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Firebird Core

Deadlock inside embedded database

Created: 01/Nov/10 10:49 AM   Updated: 15/Nov/10 11:43 AM
Component/s: None
Affects Version/s: 2.5.0
Fix Version/s: None

Time Tracking:
Not Specified

Environment: Windows 7, .NET 4

Planning Status: Unspecified


 Description  « Hide
Failed to send result to server 32W2K3SP2VM-DEV.
NHibernate.Exceptions.GenericADOException: could not update: [ExecutionEntry#113_27_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 454728 ---> FirebirdSql.Data.Common.IscException: deadlock
update conflicts with concurrent update
concurrent transaction number is 454728
   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()
   --- End of inner exception stack trace ---
   at FirebirdSql.Data.FirebirdClient.FbCommand.ExecuteNonQuery()
   at NHibernate.AdoNet.AbstractBatcher.ExecuteNonQuery(IDbCommand cmd)
   at NHibernate.AdoNet.NonBatchingBatcher.AddToBatch(IExpectation expectation)
   at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session)
   --- End of inner exception stack trace ---
   at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session)
   at NHibernate.Persister.Entity.AbstractEntityPersister.UpdateOrInsert(Object id, Object[] fields, Object[] oldFields, Object rowId, Boolean[] includeProperty, Int32 j, Object oldVersion, Object obj, SqlCommandInfo sql, ISessionImplementor session)
   at NHibernate.Persister.Entity.AbstractEntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Boolean hasDirtyCollection, Object[] oldFields, Object oldVersion, Object obj, Object rowId, ISessionImplementor session)
   at NHibernate.Action.EntityUpdateAction.Execute()
   at NHibernate.Engine.ActionQueue.Execute(IExecutable executable)
   at NHibernate.Engine.ActionQueue.ExecuteActions(IList list)
   at NHibernate.Engine.ActionQueue.ExecuteActions()
   at NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session)
   at NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event)
   at NHibernate.Impl.SessionImpl.Flush()
   at NHibernate.Transaction.AdoTransaction.Commit()
   at Shunra.Infra.DAL.NHibernate.Transaction.Commit()
   at NetworkCatcher.Entities.Agent.Server.DBHelper.DoUpdate(IPersistentObject obj)
   at NetworkCatcher.Entities.Agent.Server.DBHelper.Update(IPersistentObject obj)
   at NetworkCatcher.Entities.Agent.Server.ExecutionManager.ExecutionEntry.OnResultsSent(Int32 resultsCount)
   at NetworkCatcher.Entities.Agent.Server.ExecutionManager.OnResultsSentToServer(ProtocolSampleBulk results)
   at NetworkCatcher.Entities.Agent.Server.RunResultManager.SendToServer(ProtocolSampleBulk results)


 All   Comments   Work Log   Change History   Version Control   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Dmitry Yemanov added a comment - 01/Nov/10 10:59 AM
Why do you think it's a bug? It's a regular update conflict causing by two transactions updating the same record simultaneously. What is your transaction isolation mode?

Mark Kharitonov added a comment - 01/Nov/10 02:39 PM
That is what I was afraid of - that we are doing something wrong.

We are using NHibernate ORM for working with the database, so I am not sure what is the right answer. Can you tell me what should be our transaction isolation mode and I will check it?

The regular mode of operation is that there are many concurrent writes and relatively rare reads.

Thanks a lot.

Dmitry Yemanov added a comment - 01/Nov/10 02:53 PM
I don't have any knowledge in NHibernate or the .NET provider, so you'd better ask this in the appropriate support lists (I'd start with firebird-net-provider at SourceForge).

Commonly, you shouldn't be afraid of update conflicts but process them properly instead. If you have updates concurring for the same record and this is normal in your application (is it some aggregated table?) then you should serialize those updates (e.g. with explicit read locking), or handle update conflicts and re-attempt the operation (re-run the update statement for read-committed isolation mode, restart the transaction for snapshot isolation mode).

Mark Kharitonov added a comment - 02/Nov/10 08:28 AM
We do write concurrently, but never to the same record. Is it possible to have this kind of an error when two different records are being updated?

Thanks.

Dmitry Yemanov added a comment - 02/Nov/10 08:36 AM
No, it's impossible. You're surely updating the same record (maybe indirectly, inside triggers). Or selecting the same set of records using SELECT WITH LOCK. You may try turning the v2.5 tracing feature on and then analyze the log to find out the problematic statements.

Mark Kharitonov added a comment - 02/Nov/10 08:42 AM
Thanks for the prompt reply. And how do I turn tracing on, pardon my ignorance?


Mark Kharitonov added a comment - 15/Nov/10 07:21 AM
Hi. I am trying to validate the embedded database and here is what I get:

c:\dev\Firebird-2.5.0.26124-0_Win32\bin>gfix -validate c:\Logs\AGENT.FB
unavailable database

Something is wrong, obviously. Any hints?

Thanks.

Dmitry Yemanov added a comment - 15/Nov/10 11:43 AM
Copy fbembed.dll as fbclient.dll and make it available to gfix, or install a standalone FB server.