September 17, 2011 at 1:30 am
Hi,
I have developed a windows application in C#.net, In which billing has been performed at 4 billing windows and these computers are using indivisual software and connected with sql server installed on server by the lan network. But some time during billing I am face an error message i. e.
"Transection (ProcessID 54) was deadlocked on lock resources with another Process and has been chosen as the deadlock victim return the transaction"
Can any one tell me why this error occured and how can fix this error. Because this error never occured my side while I am checkhing it in debug mode. So please tell me how to resolve this Issue. Because of this issue peformance of my software is got poor.
September 17, 2011 at 3:01 am
This error is caused by two (or more) concurrent processes trying to acess/modify the same data and waiting for each other to finish.
A more detailed description can be found at MSDN.
Troubleshooting deadlocks is not really an easy task (at least most of the time). A good start to better understand the subject could be Barts article
September 17, 2011 at 4:05 am
Hi,
Perhaps some of your queries making lock on table.
Run SP_LOCK and check lock status of your database.
Run SQL Profiler and enable 1222 deadlock trace.
Shatrughna
September 17, 2011 at 6:25 am
LutzM (9/17/2011)
This error is caused by two (or more) concurrent processes trying to acess/modify the same data and waiting for each other to finish.A more detailed description can be found at MSDN.
Troubleshooting deadlocks is not really an easy task (at least most of the time). A good start to better understand the subject could be Barts article
There can be many things making this a problem for you, bu the basic problem is that you've created 2 (or more) processes working concurrently on the same set of data but they both have different methods of accessing that set of data.
A very simplified example: processes A and B both need objects X and Y to do their job. Process A first works on object X, then to work on object Y. Process B first works on Y then on X. If the both processes need a transaction on their operations (i.e. X should only be modified if also Y is modified and vice versa), building the both processes to work as described can easily lead to dead locks. The way to fix this would be to either a) change the order of one of the processes or b) if you can't change the order, make sure that if either is currently working the other needs to wait until the first is completely done.
That said, most of the times even with processes concurrently doing it "the wrong way", normally you will hardly ever encounter a dead lock: transactions are normally so short that hardly ever the processes are truly working concurrently. If you get this problem with only 4 end-users, you've probably not kept your transactions short enough. Most likely you have begun up a transaction and then let the end-user do some actions (may be just a message box saying: press 'OK') and then commit the transaction. This is a common beginners error: you should never, ever leave a transaction open and then give control to the end-user. Instead, ask the end-user for confirmation before you begin the transaction and do the action immediately followed by the commit (or rollback in case of an error).
September 17, 2011 at 12:37 pm
shatrughna (9/17/2011)
Hi,Perhaps some of your queries making lock on table.
Run SP_LOCK and check lock status of your database.
Cant be sure that entire table is locked. It can even be a row/key lock.
And locking is the mechanism used by all RDBMSs to ensure database consistency. Locking granularity depends on the amount of data requested/affected by the query (unless you give explicit lock hints).
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply