dbTalk Databases Forums  

Deadlock that does not make sence.

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Deadlock that does not make sence. in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Mike Malter
 
Posts: n/a

Default Deadlock that does not make sence. - 09-08-2003 , 12:33 PM






I am getting a deadlock error message that is perplexing me.

Our scenario is like this; separate applications using ADO and ADO.NET with EnterpriseServices are coexisting in this project. The
database and stored procedures are what we have in common. We are doing some testing now to see how well these different
applications can get along with each other, and in one of our tests, ADO edits random records and ADO.NET selects all records, we
have received a deadlock error in the ADO.NET application.

We are both in a transaction when this occurs. The transaction on the ADO side is per record, and the transaction on the ADO.NET
side is for the entire select.

I can understand that the select will want to read a record that is locked by the edit, however the edit is so quick that I would
think that the select would not be blocked very long. If that were the case, where the select was blocked too long, wouldn't there
be a timeout instead of a deadlock?

The other factor here is that if we only edit 5 records we never get a deadlock. If we edit more than that, we always get a
deadlock.

Any insight into this perplexing problem would be very welcomed.

Mike



Reply With Quote
  #2  
Old   
Itzik Ben-Gan
 
Posts: n/a

Default Re: Deadlock that does not make sence. - 09-08-2003 , 12:38 PM






Hard to say without having access to your db, but the scenario you describe
doesn't sound like deadlock proof.
Sometimes deadlock might occur because of lack of appropriate indexes, and
sometimes because of the way your applications/transactions are written.
Best way to figure this out is to use Profiler to trace statement starting,
deadlock and deadlock chain events. Once you identify the conflicting
processes, reopen the trace file and filter by process id's. Move your way
upwards from the deadlock event and write down a time-based chain of events
under columns representing the different processes. Examine the tables'
indexes and try to figure out the cause of the deadlock.

--
BG, SQL Server MVP
Solid Quality Learning
www.solidqualitylearning.com


"Mike Malter" <mikemalter (AT) nospam (DOT) com> wrote

Quote:
I am getting a deadlock error message that is perplexing me.

Our scenario is like this; separate applications using ADO and ADO.NET
with EnterpriseServices are coexisting in this project. The
database and stored procedures are what we have in common. We are doing
some testing now to see how well these different
applications can get along with each other, and in one of our tests, ADO
edits random records and ADO.NET selects all records, we
have received a deadlock error in the ADO.NET application.

We are both in a transaction when this occurs. The transaction on the ADO
side is per record, and the transaction on the ADO.NET
side is for the entire select.

I can understand that the select will want to read a record that is locked
by the edit, however the edit is so quick that I would
think that the select would not be blocked very long. If that were the
case, where the select was blocked too long, wouldn't there
be a timeout instead of a deadlock?

The other factor here is that if we only edit 5 records we never get a
deadlock. If we edit more than that, we always get a
deadlock.

Any insight into this perplexing problem would be very welcomed.

Mike





Reply With Quote
  #3  
Old   
Vassilis Devletoglou
 
Posts: n/a

Default Re: Deadlock that does not make sence. - 09-08-2003 , 02:05 PM



First of all, do you have triggers on your tables? If you do, that's the
place you need to check.

Second, make sure both your applications use Optimistic concurrency control.
Especially the one that only reads should be optimistic.

Finally,
open your books online and check for the "ROWLOCK" documentation. It gives
you a list of query hints like "Read Past" which skips locked rows, or
HoldLock which will wait for the records.




"Mike Malter" <mikemalter (AT) nospam (DOT) com> wrote

Quote:
I am getting a deadlock error message that is perplexing me.

Our scenario is like this; separate applications using ADO and ADO.NET
with EnterpriseServices are coexisting in this project. The
database and stored procedures are what we have in common. We are doing
some testing now to see how well these different
applications can get along with each other, and in one of our tests, ADO
edits random records and ADO.NET selects all records, we
have received a deadlock error in the ADO.NET application.

We are both in a transaction when this occurs. The transaction on the ADO
side is per record, and the transaction on the ADO.NET
side is for the entire select.

I can understand that the select will want to read a record that is locked
by the edit, however the edit is so quick that I would
think that the select would not be blocked very long. If that were the
case, where the select was blocked too long, wouldn't there
be a timeout instead of a deadlock?

The other factor here is that if we only edit 5 records we never get a
deadlock. If we edit more than that, we always get a
deadlock.

Any insight into this perplexing problem would be very welcomed.

Mike





Reply With Quote
  #4  
Old   
Gert-Jan Strik
 
Posts: n/a

Default Re: Deadlock that does not make sence. - 09-08-2003 , 02:07 PM



Just some general information here. Maybe it is of some help to you.

In SQL-Server, there are basically two situations that may lead to
deadlocks:
1. Locks are acquired in different order in different transactions. This
is the 'classic' deadlock. The chance is increased when the transactions
can not use an index to lock at row level. The chance is also increased
when there are many lock requests, or when memory is low.

2. Lock escalation (from row/page locks to table locks) can lead to
deadlocks. If lock escalation is caused by low memory, then lowering
your locking granularity from row locks to page locks may help.

Gert-Jan


Mike Malter wrote:
Quote:
I am getting a deadlock error message that is perplexing me.

Our scenario is like this; separate applications using ADO and ADO.NET with EnterpriseServices are coexisting in this project. The
database and stored procedures are what we have in common. We are doing some testing now to see how well these different
applications can get along with each other, and in one of our tests, ADO edits random records and ADO.NET selects all records, we
have received a deadlock error in the ADO.NET application.

We are both in a transaction when this occurs. The transaction on the ADO side is per record, and the transaction on the ADO.NET
side is for the entire select.

I can understand that the select will want to read a record that is locked by the edit, however the edit is so quick that I would
think that the select would not be blocked very long. If that were the case, where the select was blocked too long, wouldn't there
be a timeout instead of a deadlock?

The other factor here is that if we only edit 5 records we never get a deadlock. If we edit more than that, we always get a
deadlock.

Any insight into this perplexing problem would be very welcomed.

Mike

Reply With Quote
  #5  
Old   
Satish Balusa
 
Posts: n/a

Default Re: Deadlock that does not make sence. - 09-08-2003 , 03:29 PM



May be it will be more helpful if you can enable the Trace Flags (1204,
3605) and run the scenario you are describing post the Portions of the
deadlock images that (if any) get logged in the SQL Error logs.

DBCC TRACEON(1204, 3605)

--
HTH
Satish Balusa
Corillian Corp.


"Itzik Ben-Gan" <itzik (AT) REMOVETHIS (DOT) solidqualitylearning.com> wrote

Quote:
Hard to say without having access to your db, but the scenario you
describe
doesn't sound like deadlock proof.
Sometimes deadlock might occur because of lack of appropriate indexes, and
sometimes because of the way your applications/transactions are written.
Best way to figure this out is to use Profiler to trace statement
starting,
deadlock and deadlock chain events. Once you identify the conflicting
processes, reopen the trace file and filter by process id's. Move your way
upwards from the deadlock event and write down a time-based chain of
events
under columns representing the different processes. Examine the tables'
indexes and try to figure out the cause of the deadlock.

--
BG, SQL Server MVP
Solid Quality Learning
www.solidqualitylearning.com


"Mike Malter" <mikemalter (AT) nospam (DOT) com> wrote in message
news:Ot0HQ5idDHA.736 (AT) TK2MSFTNGP09 (DOT) phx.gbl...
I am getting a deadlock error message that is perplexing me.

Our scenario is like this; separate applications using ADO and ADO.NET
with EnterpriseServices are coexisting in this project. The
database and stored procedures are what we have in common. We are doing
some testing now to see how well these different
applications can get along with each other, and in one of our tests, ADO
edits random records and ADO.NET selects all records, we
have received a deadlock error in the ADO.NET application.

We are both in a transaction when this occurs. The transaction on the
ADO
side is per record, and the transaction on the ADO.NET
side is for the entire select.

I can understand that the select will want to read a record that is
locked
by the edit, however the edit is so quick that I would
think that the select would not be blocked very long. If that were the
case, where the select was blocked too long, wouldn't there
be a timeout instead of a deadlock?

The other factor here is that if we only edit 5 records we never get a
deadlock. If we edit more than that, we always get a
deadlock.

Any insight into this perplexing problem would be very welcomed.

Mike







Reply With Quote
  #6  
Old   
Mike Malter
 
Posts: n/a

Default Re: Deadlock that does not make sence. - 09-09-2003 , 12:14 PM



Gert,

Thanks for your reply.

The deal in this case is that there is only one table called parent.

What I am doing is a select on this table for two columns while the other system is doing random updates.

I am wondering if you could elaborate a little more about too many lock requests.

Thanks.

"Gert-Jan Strik" <sorry (AT) toomuchspamalready (DOT) nl> wrote

Quote:
Just some general information here. Maybe it is of some help to you.

In SQL-Server, there are basically two situations that may lead to
deadlocks:
1. Locks are acquired in different order in different transactions. This
is the 'classic' deadlock. The chance is increased when the transactions
can not use an index to lock at row level. The chance is also increased
when there are many lock requests, or when memory is low.

2. Lock escalation (from row/page locks to table locks) can lead to
deadlocks. If lock escalation is caused by low memory, then lowering
your locking granularity from row locks to page locks may help.

Gert-Jan


Mike Malter wrote:

I am getting a deadlock error message that is perplexing me.

Our scenario is like this; separate applications using ADO and ADO.NET with EnterpriseServices are coexisting in this project.
The
database and stored procedures are what we have in common. We are doing some testing now to see how well these different
applications can get along with each other, and in one of our tests, ADO edits random records and ADO.NET selects all records,
we
have received a deadlock error in the ADO.NET application.

We are both in a transaction when this occurs. The transaction on the ADO side is per record, and the transaction on the
ADO.NET
side is for the entire select.

I can understand that the select will want to read a record that is locked by the edit, however the edit is so quick that I
would
think that the select would not be blocked very long. If that were the case, where the select was blocked too long, wouldn't
there
be a timeout instead of a deadlock?

The other factor here is that if we only edit 5 records we never get a deadlock. If we edit more than that, we always get a
deadlock.

Any insight into this perplexing problem would be very welcomed.

Mike



Reply With Quote
  #7  
Old   
Mike Malter
 
Posts: n/a

Default Re: Deadlock that does not make sence. - 09-09-2003 , 12:16 PM



Vassilis,

Thanks for your reply.

We do not have any triggers on the table in this test.

The one that reads is using ADO.NET. Do you know how to set concurrency control to Optimistic in ADO.NET?

I will look into query hints, thanks.

Mike

"Vassilis Devletoglou" <vdev (AT) acn (DOT) gr> wrote

Quote:
First of all, do you have triggers on your tables? If you do, that's the
place you need to check.

Second, make sure both your applications use Optimistic concurrency control.
Especially the one that only reads should be optimistic.

Finally,
open your books online and check for the "ROWLOCK" documentation. It gives
you a list of query hints like "Read Past" which skips locked rows, or
HoldLock which will wait for the records.




"Mike Malter" <mikemalter (AT) nospam (DOT) com> wrote in message
news:Ot0HQ5idDHA.736 (AT) TK2MSFTNGP09 (DOT) phx.gbl...
I am getting a deadlock error message that is perplexing me.

Our scenario is like this; separate applications using ADO and ADO.NET
with EnterpriseServices are coexisting in this project. The
database and stored procedures are what we have in common. We are doing
some testing now to see how well these different
applications can get along with each other, and in one of our tests, ADO
edits random records and ADO.NET selects all records, we
have received a deadlock error in the ADO.NET application.

We are both in a transaction when this occurs. The transaction on the ADO
side is per record, and the transaction on the ADO.NET
side is for the entire select.

I can understand that the select will want to read a record that is locked
by the edit, however the edit is so quick that I would
think that the select would not be blocked very long. If that were the
case, where the select was blocked too long, wouldn't there
be a timeout instead of a deadlock?

The other factor here is that if we only edit 5 records we never get a
deadlock. If we edit more than that, we always get a
deadlock.

Any insight into this perplexing problem would be very welcomed.

Mike







Reply With Quote
  #8  
Old   
Gert-Jan Strik
 
Posts: n/a

Default Re: Deadlock that does not make sence. - 09-09-2003 , 01:57 PM



The maximum number of outstanding locks is determined by some internal
formula. A major factor in this formula is the total amount of memory
that is available to SQL-Server. If the number of actual locks comes
close to this maximum number, lock escalation will occur/increase. In
that situation, SQL-Server is more likely to 'trade in' several row
locks or page locks for one table lock. If this happens for two
processes that have locks on the same table, this results in a deadlock.

BOL has a special section for "number of locks the system can allocate"

Gert-Jan


Mike Malter wrote:
Quote:
Gert,

Thanks for your reply.

The deal in this case is that there is only one table called parent.

What I am doing is a select on this table for two columns while the other system is doing random updates.

I am wondering if you could elaborate a little more about too many lock requests.

Thanks.

"Gert-Jan Strik" <sorry (AT) toomuchspamalready (DOT) nl> wrote

Just some general information here. Maybe it is of some help to you.

In SQL-Server, there are basically two situations that may lead to
deadlocks:
1. Locks are acquired in different order in different transactions. This
is the 'classic' deadlock. The chance is increased when the transactions
can not use an index to lock at row level. The chance is also increased
when there are many lock requests, or when memory is low.

2. Lock escalation (from row/page locks to table locks) can lead to
deadlocks. If lock escalation is caused by low memory, then lowering
your locking granularity from row locks to page locks may help.

Gert-Jan


Mike Malter wrote:

I am getting a deadlock error message that is perplexing me.

Our scenario is like this; separate applications using ADO and ADO.NET with EnterpriseServices are coexisting in this project.
The
database and stored procedures are what we have in common. We are doing some testing now to see how well these different
applications can get along with each other, and in one of our tests, ADO edits random records and ADO.NET selects all records,
we
have received a deadlock error in the ADO.NET application.

We are both in a transaction when this occurs. The transaction on the ADO side is per record, and the transaction on the
ADO.NET
side is for the entire select.

I can understand that the select will want to read a record that is locked by the edit, however the edit is so quick that I
would
think that the select would not be blocked very long. If that were the case, where the select was blocked too long, wouldn't
there
be a timeout instead of a deadlock?

The other factor here is that if we only edit 5 records we never get a deadlock. If we edit more than that, we always get a
deadlock.

Any insight into this perplexing problem would be very welcomed.

Mike

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.