Showing posts with label multithreading. Show all posts
Showing posts with label multithreading. Show all posts

Wednesday, March 28, 2012

Multithreading?

Hi

Can an application populate two Grids from the database,
simultaneously without using the multithreading using ADO.NET

Thanks in advance
MR_FBI
mr_fbi2020@.yahoo.comMr_FBI (mr_fbi2020@.yahoo.com) writes:
> Can an application populate two Grids from the database,
> simultaneously without using the multithreading using ADO.NET

My guess is that you can't.

From a database perspective, you need two different connections, and that's
not a big deal. ADO .Net can handle that. Then I don't know about data
binding and all that, but since calls in ADO .Net are synchronous, I can't
see how you could fill the grids without multiple threads.

But if you want to know for sure, you should find a forum devoted to
..Net programming.

--
Erland Sommarskog, SQL Server MVP, sommar@.algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Erland Sommarskog <sommar@.algonet.se> wrote in message news:<Xns94992E388188Yazorman@.127.0.0.1>...
> Mr_FBI (mr_fbi2020@.yahoo.com) writes:
> > Can an application populate two Grids from the database,
> > simultaneously without using the multithreading using ADO.NET
>
> My guess is that you can't.
> From a database perspective, you need two different connections, and that's
> not a big deal. ADO .Net can handle that. Then I don't know about data
> binding and all that, but since calls in ADO .Net are synchronous, I can't
> see how you could fill the grids without multiple threads.
> But if you want to know for sure, you should find a forum devoted to
> .Net programming.

Thank you, I think you are right. As soon as I get my VS.NET 2003, I
will try myself. :)
Best Regards|||Yes. You can call a stored procedure that returns 2 resultsets. Just fill the
dataset and then bind each table to each datagrid. It's simply a single call
without multi calls/threads.

--
-oj
http://www.rac4sql.net

"Mr_FBI" <mr_fbi2020@.yahoo.com> wrote in message
news:861074e2.0402231132.73707b3b@.posting.google.c om...
> Hi
> Can an application populate two Grids from the database,
> simultaneously without using the multithreading using ADO.NET
> Thanks in advance
> MR_FBI
> mr_fbi2020@.yahoo.com

Multithreading SQL connections

Hi there
I am working on the design of a system that its’ main function will be to
talk to devices over TCP/IP. There can be up to 50,000 devices that I need t
o
talk to within an hour period.
There will be a Queue on SQL 2005 which will contain requests for these
devices. I will need to check this queue and depending on the information on
the queue I need to talk to the devices. There will be one request for each
device every hour, therefore I need to be able to process multiple
communications at one time.
Here is my question: Should I create independent threads which would read
SQL and do pretty much everything, having a collection of about 50 or so
threads doing this? I have heard that I should avoid this high number of
connections to SQL at one time.
The other solution that I came up with is to have one SQL reader and have
the communication sockets as the threads, so they do their job and return. I
n
this thread communication scenario should I destroy the thread once I am
done, or should I have thread communication and keep the thread alive and
just send new requests to it?
I know this is pretty broad, but any help would be appreciated.
Thank you,
Spike S50 connections at a time in SQL Server is not an issue at all. Especially
if you are using connection pooling. When you say Queue what exactly do you
mean? Is this a regular table or is this a Queue from Service Broker?
Andrew J. Kelly SQL MVP
"Spike Spiegel" <cbb_spike@.hotmail.com> wrote in message
news:8AFEA5E5-1E9B-4D23-BFD9-1AEB25230AF6@.microsoft.com...
> Hi there
> I am working on the design of a system that its' main function will be to
> talk to devices over TCP/IP. There can be up to 50,000 devices that I need
> to
> talk to within an hour period.
> There will be a Queue on SQL 2005 which will contain requests for these
> devices. I will need to check this queue and depending on the information
> on
> the queue I need to talk to the devices. There will be one request for
> each
> device every hour, therefore I need to be able to process multiple
> communications at one time.
> Here is my question: Should I create independent threads which would read
> SQL and do pretty much everything, having a collection of about 50 or so
> threads doing this? I have heard that I should avoid this high number of
> connections to SQL at one time.
> The other solution that I came up with is to have one SQL reader and have
> the communication sockets as the threads, so they do their job and return.
> In
> this thread communication scenario should I destroy the thread once I am
> done, or should I have thread communication and keep the thread alive and
> just send new requests to it?
> I know this is pretty broad, but any help would be appreciated.
> Thank you,
> Spike S|||Hi Andrew
Sorry, I should have not used the word queue. It is basically just a table
with a very log record, about 50 fields, my application would be pulling fro
m
it.
What do you mean by "connection pooling?"
Right I am running a test and basically I am opening a connection using the
System.Data.SqlClient.SqlConnection class, and reading my record with
SqlConnection + SqlDataReader and writing records with the SqlConnection.+
TSQL statement. Are these the most efficient/fastest way to do this? I am
very interested in speed here.
If I were to create a thread and send the SqlConnection to the thread for
them all to share the same connection, would that make the code more
efficient?
What would be a good threshold for number of threads? 100? 500? 1000? 10000?
Please let me know.
Thank you,
Spike S.|||> What do you mean by "connection pooling?"
I would google for more details but essentially it is used by .net to make
the process of connecting and disconnecting much more efficient. You retain
a pool of connections that stay connected all the time. These are then
handed out as the app requests new connections and instead of closing it
completely it just cleans it up and makes it ready for the next user. It's
the default behavior with .net.

> Right I am running a test and basically I am opening a connection using
> the
> System.Data.SqlClient.SqlConnection class, and reading my record with
> SqlConnection + SqlDataReader and writing records with the SqlConnection.+
> TSQL statement. Are these the most efficient/fastest way to do this? I am
> very interested in speed here.
Actually using stored procedures to read and write the data is the most
efficient way.

> What would be a good threshold for number of threads? 100? 500? 1000?
> 10000?
Testing is the only way to know for sure.
Andrew J. Kelly SQL MVP
"Spike Spiegel" <cbb_spike@.hotmail.com> wrote in message
news:96A7733E-31CD-4744-9DD9-FD8CF64278A0@.microsoft.com...
> Hi Andrew
> Sorry, I should have not used the word queue. It is basically just a table
> with a very log record, about 50 fields, my application would be pulling
> from
> it.
> What do you mean by "connection pooling?"
> Right I am running a test and basically I am opening a connection using
> the
> System.Data.SqlClient.SqlConnection class, and reading my record with
> SqlConnection + SqlDataReader and writing records with the SqlConnection.+
> TSQL statement. Are these the most efficient/fastest way to do this? I am
> very interested in speed here.
> If I were to create a thread and send the SqlConnection to the thread for
> them all to share the same connection, would that make the code more
> efficient?
> What would be a good threshold for number of threads? 100? 500? 1000?
> 10000?
> Please let me know.
> Thank you,
> Spike S.|||Hi Andrew
Thank you very much for all the information.
I did some testing, using the connection pooling, and it is exactly what I
was looking for, I can have around 50 threads before I see a performance hit
.
This is the first time I posted into a managed Microsoft newsgroup. From
this experience I will not think twice before checking the managed group
again.
Thank you again for all your help.
Take care,
Spike S.|||Please note that Andy doesn't have anything to do with the MSDN managed
newsgroup program/policy/whatever you want to call it. Andy doesn't work for
Microsoft and is out here helping everybody on his own dime. That, in my
opinion, means he deserves even more thanks. :-)
Sincerely,
Steve Dybing
This posting is provided "AS IS" with no warranties, and confers no rights.
"Spike Spiegel" <cbb_spike@.hotmail.com> wrote in message
news:74D54EA9-786B-45AE-8007-88804D2A4B56@.microsoft.com...
> Hi Andrew
> Thank you very much for all the information.
> I did some testing, using the connection pooling, and it is exactly what I
> was looking for, I can have around 50 threads before I see a performance
> hit.
> This is the first time I posted into a managed Microsoft newsgroup. From
> this experience I will not think twice before checking the managed group
> again.
> Thank you again for all your help.
> Take care,
> Spike S.|||Double thanks to Andrew then...|||Double you are welcome.
Andrew J. Kelly SQL MVP
"Spike Spiegel" <cbb_spike@.hotmail.com> wrote in message
news:A5A1E014-F5C1-43E4-8956-F9D19EA5C153@.microsoft.com...
> Double thanks to Andrew then...|||Ahhh gee Thanks Steve :)
Andrew J. Kelly SQL MVP
"Steve Dybing [MSFT]" <steve.dybing@.online.microsoft.com> wrote in message
news:eFQhpyFdGHA.3908@.TK2MSFTNGP04.phx.gbl...
> Please note that Andy doesn't have anything to do with the MSDN managed
> newsgroup program/policy/whatever you want to call it. Andy doesn't work
> for Microsoft and is out here helping everybody on his own dime. That, in
> my opinion, means he deserves even more thanks. :-)
> --
> Sincerely,
> Steve Dybing
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> "Spike Spiegel" <cbb_spike@.hotmail.com> wrote in message
> news:74D54EA9-786B-45AE-8007-88804D2A4B56@.microsoft.com...
>sql

Multithreading SMO

I have been experimenting with multithreading the SMO database objects to increase performance in my application but i never seem to beable to push the cpu load of the system above 25% (4 processor server).

Has anyone successfully been multithreading these objects?

Niklas,

SMO can be used in multithreaded scenario, but improvements in performance highly depend on the design on your application. SMO applications are usually not CPU-bound, and the best strategy is usually to optmize the number of queries to the SQL Server SMO has to perform.

Here is a couple of great articles written by one of SMO architects Michiel Wories:

http://blogs.msdn.com/mwories/archive/2005/05/02/smoperf1.aspx

http://blogs.msdn.com/mwories/archive/2005/05/02/smoperf2.aspx

Multithreading SMO

I have been experimenting with multithreading the SMO database objects to increase performance in my application but i never seem to beable to push the cpu load of the system above 25% (4 processor server).

Has anyone successfully been multithreading these objects?

Niklas,

SMO can be used in multithreaded scenario, but improvements in performance highly depend on the design on your application. SMO applications are usually not CPU-bound, and the best strategy is usually to optmize the number of queries to the SQL Server SMO has to perform.

Here is a couple of great articles written by one of SMO architects Michiel Wories:

http://blogs.msdn.com/mwories/archive/2005/05/02/smoperf1.aspx

http://blogs.msdn.com/mwories/archive/2005/05/02/smoperf2.aspx

Multithreading in Sql Server

Hi,
Does sqlserver 2000 supports multi threading?
If so how can we implement it?
As per my knowledge it supports Symmetric multi
processing.
Can you please confirm this?
I posted this in english query section.Iam reposting it
here since this group is more relevant.
Thanks in adavance.
-SriramSQL automatically handles multiple processors... However when you go into
SQL Enterprise Manager, right click your server registration and select
properties, one of the tabs will allow you to choose how many of the
processors to use, 0 means use them all...
One of the diferences between SQL Standard and SQL Enterprise is how much
multi processing goes on during maintenance, like creating indexes... Of
course SQL Enterprise is more scalable.
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Sriram" <surapureddysriram@.yahoo.co.in> wrote in message
news:a08a01c4794f$2d51cf50$a601280a@.phx.gbl...
> Hi,
> Does sqlserver 2000 supports multi threading?
> If so how can we implement it?
> As per my knowledge it supports Symmetric multi
> processing.
> Can you please confirm this?
> I posted this in english query section.Iam reposting it
> here since this group is more relevant.
> Thanks in adavance.
> -Sriram
>|||You don't normally control threading within an application. AFAIK - SQL
Server is a multi-threaded application; there is nothing to "implement".
Perhaps you are confusing multiple threads with multiple processors. If so,
then see Wayne's response.
"Sriram" <surapureddysriram@.yahoo.co.in> wrote in message
news:a08a01c4794f$2d51cf50$a601280a@.phx.gbl...
> Hi,
> Does sqlserver 2000 supports multi threading?
> If so how can we implement it?
> As per my knowledge it supports Symmetric multi
> processing.
> Can you please confirm this?
> I posted this in english query section.Iam reposting it
> here since this group is more relevant.
> Thanks in adavance.
> -Sriram
>

Multithreading in Sql Server

Hi,
Does sqlserver 2000 supports multi threading?
If so how can we implement it?
As per my knowledge it supports Symmetric multi
processing.
Can you please confirm this?
I posted this in english query section.Iam reposting it
here since this group is more relevant.
Thanks in adavance.
-Sriram
SQL automatically handles multiple processors... However when you go into
SQL Enterprise Manager, right click your server registration and select
properties, one of the tabs will allow you to choose how many of the
processors to use, 0 means use them all...
One of the diferences between SQL Standard and SQL Enterprise is how much
multi processing goes on during maintenance, like creating indexes... Of
course SQL Enterprise is more scalable.
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Sriram" <surapureddysriram@.yahoo.co.in> wrote in message
news:a08a01c4794f$2d51cf50$a601280a@.phx.gbl...
> Hi,
> Does sqlserver 2000 supports multi threading?
> If so how can we implement it?
> As per my knowledge it supports Symmetric multi
> processing.
> Can you please confirm this?
> I posted this in english query section.Iam reposting it
> here since this group is more relevant.
> Thanks in adavance.
> -Sriram
>
|||You don't normally control threading within an application. AFAIK - SQL
Server is a multi-threaded application; there is nothing to "implement".
Perhaps you are confusing multiple threads with multiple processors. If so,
then see Wayne's response.
"Sriram" <surapureddysriram@.yahoo.co.in> wrote in message
news:a08a01c4794f$2d51cf50$a601280a@.phx.gbl...
> Hi,
> Does sqlserver 2000 supports multi threading?
> If so how can we implement it?
> As per my knowledge it supports Symmetric multi
> processing.
> Can you please confirm this?
> I posted this in english query section.Iam reposting it
> here since this group is more relevant.
> Thanks in adavance.
> -Sriram
>

Multithreading in Sql Server

Hi,
Does sqlserver 2000 supports multi threading?
If so how can we implement it?
As per my knowledge it supports Symmetric multi
processing.
Can you please confirm this?
I posted this in english query section.Iam reposting it
here since this group is more relevant.
Thanks in adavance.
-SriramSQL automatically handles multiple processors... However when you go into
SQL Enterprise Manager, right click your server registration and select
properties, one of the tabs will allow you to choose how many of the
processors to use, 0 means use them all...
One of the diferences between SQL Standard and SQL Enterprise is how much
multi processing goes on during maintenance, like creating indexes... Of
course SQL Enterprise is more scalable.
--
Wayne Snyder, MCDBA, SQL Server MVP
Mariner, Charlotte, NC
www.mariner-usa.com
(Please respond only to the newsgroups.)
I support the Professional Association of SQL Server (PASS) and it's
community of SQL Server professionals.
www.sqlpass.org
"Sriram" <surapureddysriram@.yahoo.co.in> wrote in message
news:a08a01c4794f$2d51cf50$a601280a@.phx.gbl...
> Hi,
> Does sqlserver 2000 supports multi threading?
> If so how can we implement it?
> As per my knowledge it supports Symmetric multi
> processing.
> Can you please confirm this?
> I posted this in english query section.Iam reposting it
> here since this group is more relevant.
> Thanks in adavance.
> -Sriram
>|||You don't normally control threading within an application. AFAIK - SQL
Server is a multi-threaded application; there is nothing to "implement".
Perhaps you are confusing multiple threads with multiple processors. If so,
then see Wayne's response.
"Sriram" <surapureddysriram@.yahoo.co.in> wrote in message
news:a08a01c4794f$2d51cf50$a601280a@.phx.gbl...
> Hi,
> Does sqlserver 2000 supports multi threading?
> If so how can we implement it?
> As per my knowledge it supports Symmetric multi
> processing.
> Can you please confirm this?
> I posted this in english query section.Iam reposting it
> here since this group is more relevant.
> Thanks in adavance.
> -Sriram
>sql

multithreading = sqlserver deadlocks

I created a .net program which uses multithreading. The threads
concurrently access the same db resources. This has generated no end
of sql server deadlocks, which our dba is struggling to resolve.
I am very close to giving up and going ahead and serializing all
database access for the application. This will reduce performance
quite a bit, although it will eliminate all the deadlocks.
Maybe it's our dba's fault, maybe it's sql server's fault, maybe it's
mine for building an app that hits the db so hard, but we are unable
to solve all the deadlocking issues using the errorlog and profiling
combo that has been suggested. We solve one deadlock issue, only to
see another one revealed later, perhaps on different resources,
perhaps not.
I have heard there are many applications that use the Singleton
pattern to serialize db access accross the board, just to avoid
situations like this.
Any feedback welcome.Deadlocks are usually caused by 2 or more users attempting to update the
same set of tables in opposite orders. If you have one sp that updates
Orders and then Details while another updates details first and then orders
this will eventually cause a dead lock. If they are both in the same order
you most likely get only blocking which is normal and can be controlled. Do
you have an example of 2 procedures that deadlock on each other and the
associated DDL for those tables? Deadlocking is almost always a result of a
poor schema or more likely poor data access methods. Serialization is not
the way to go, you should do it right and find the cause so you can fix it.
Maybe these will help:
http://www.support.microsoft.com/?id=224453 Blocking Problems
http://www.support.microsoft.com/?id=271509 How to monitor SQL 2000
Blocking
http://www.amazon.com/exec/obidos/tg/detail/-/B0000W86FY/qid=1077039326//ref=sr_8_xs_ap_i1_xgl14/104-0688407-7232719?v=glance&s=books&n=507846
--
Andrew J. Kelly
SQL Server MVP
"n_o_s_p_a__m" <n_o_s_p_a__m@.mail.com> wrote in message
news:1faa8782.0402170756.4a53601f@.posting.google.com...
> I created a .net program which uses multithreading. The threads
> concurrently access the same db resources. This has generated no end
> of sql server deadlocks, which our dba is struggling to resolve.
> I am very close to giving up and going ahead and serializing all
> database access for the application. This will reduce performance
> quite a bit, although it will eliminate all the deadlocks.
> Maybe it's our dba's fault, maybe it's sql server's fault, maybe it's
> mine for building an app that hits the db so hard, but we are unable
> to solve all the deadlocking issues using the errorlog and profiling
> combo that has been suggested. We solve one deadlock issue, only to
> see another one revealed later, perhaps on different resources,
> perhaps not.
> I have heard there are many applications that use the Singleton
> pattern to serialize db access accross the board, just to avoid
> situations like this.
> Any feedback welcome.|||Can't deadlocking also happen for locks other than tables? It can happen
for RID or KEY locks as well within the same table, can't it?
Christian Smith
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:OkcJl6X9DHA.548@.TK2MSFTNGP11.phx.gbl...
> Deadlocks are usually caused by 2 or more users attempting to update the
> same set of tables in opposite orders. If you have one sp that updates
> Orders and then Details while another updates details first and then
orders
> this will eventually cause a dead lock. If they are both in the same
order
> you most likely get only blocking which is normal and can be controlled.
Do
> you have an example of 2 procedures that deadlock on each other and the
> associated DDL for those tables? Deadlocking is almost always a result of
a
> poor schema or more likely poor data access methods. Serialization is not
> the way to go, you should do it right and find the cause so you can fix
it.
> Maybe these will help:
>
> http://www.support.microsoft.com/?id=224453 Blocking Problems
> http://www.support.microsoft.com/?id=271509 How to monitor SQL 2000
> Blocking
>
>
http://www.amazon.com/exec/obidos/tg/detail/-/B0000W86FY/qid=1077039326//ref=sr_8_xs_ap_i1_xgl14/104-0688407-7232719?v=glance&s=books&n=507846
> --
> Andrew J. Kelly
> SQL Server MVP
>
> "n_o_s_p_a__m" <n_o_s_p_a__m@.mail.com> wrote in message
> news:1faa8782.0402170756.4a53601f@.posting.google.com...
> > I created a .net program which uses multithreading. The threads
> > concurrently access the same db resources. This has generated no end
> > of sql server deadlocks, which our dba is struggling to resolve.
> >
> > I am very close to giving up and going ahead and serializing all
> > database access for the application. This will reduce performance
> > quite a bit, although it will eliminate all the deadlocks.
> >
> > Maybe it's our dba's fault, maybe it's sql server's fault, maybe it's
> > mine for building an app that hits the db so hard, but we are unable
> > to solve all the deadlocking issues using the errorlog and profiling
> > combo that has been suggested. We solve one deadlock issue, only to
> > see another one revealed later, perhaps on different resources,
> > perhaps not.
> >
> > I have heard there are many applications that use the Singleton
> > pattern to serialize db access accross the board, just to avoid
> > situations like this.
> >
> > Any feedback welcome.
>|||Yes there are other reasons why dead locks occur but the main reason is as I
posted. Without more details it's all a guess so the most logical or common
reason is what I posted.
--
Andrew J. Kelly
SQL Server MVP
"Christian Smith" <csmith@.digex.com> wrote in message
news:uxC%23TGY9DHA.3404@.TK2MSFTNGP09.phx.gbl...
> Can't deadlocking also happen for locks other than tables? It can happen
> for RID or KEY locks as well within the same table, can't it?
> Christian Smith
> "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
> news:OkcJl6X9DHA.548@.TK2MSFTNGP11.phx.gbl...
> > Deadlocks are usually caused by 2 or more users attempting to update the
> > same set of tables in opposite orders. If you have one sp that updates
> > Orders and then Details while another updates details first and then
> orders
> > this will eventually cause a dead lock. If they are both in the same
> order
> > you most likely get only blocking which is normal and can be controlled.
> Do
> > you have an example of 2 procedures that deadlock on each other and the
> > associated DDL for those tables? Deadlocking is almost always a result
of
> a
> > poor schema or more likely poor data access methods. Serialization is
not
> > the way to go, you should do it right and find the cause so you can fix
> it.
> > Maybe these will help:
> >
> >
> > http://www.support.microsoft.com/?id=224453 Blocking Problems
> > http://www.support.microsoft.com/?id=271509 How to monitor SQL 2000
> > Blocking
> >
> >
> >
>
http://www.amazon.com/exec/obidos/tg/detail/-/B0000W86FY/qid=1077039326//ref=sr_8_xs_ap_i1_xgl14/104-0688407-7232719?v=glance&s=books&n=507846
> >
> > --
> >
> > Andrew J. Kelly
> > SQL Server MVP
> >
> >
> > "n_o_s_p_a__m" <n_o_s_p_a__m@.mail.com> wrote in message
> > news:1faa8782.0402170756.4a53601f@.posting.google.com...
> > > I created a .net program which uses multithreading. The threads
> > > concurrently access the same db resources. This has generated no end
> > > of sql server deadlocks, which our dba is struggling to resolve.
> > >
> > > I am very close to giving up and going ahead and serializing all
> > > database access for the application. This will reduce performance
> > > quite a bit, although it will eliminate all the deadlocks.
> > >
> > > Maybe it's our dba's fault, maybe it's sql server's fault, maybe it's
> > > mine for building an app that hits the db so hard, but we are unable
> > > to solve all the deadlocking issues using the errorlog and profiling
> > > combo that has been suggested. We solve one deadlock issue, only to
> > > see another one revealed later, perhaps on different resources,
> > > perhaps not.
> > >
> > > I have heard there are many applications that use the Singleton
> > > pattern to serialize db access accross the board, just to avoid
> > > situations like this.
> > >
> > > Any feedback welcome.
> >
> >
>|||One deadlocking situation is fairly simple:
node 1: Select from some_table where rownum = 42
node 2: update some_table with (TABLOCKX) where rownum = 42
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message news:<O4PueDZ9DHA.2432@.TK2MSFTNGP09.phx.gbl>...
> Yes there are other reasons why dead locks occur but the main reason is as I
> posted. Without more details it's all a guess so the most logical or common
> reason is what I posted.
> --
> Andrew J. Kelly
> SQL Server MVP
>
> "Christian Smith" <csmith@.digex.com> wrote in message
> news:uxC%23TGY9DHA.3404@.TK2MSFTNGP09.phx.gbl...
> > Can't deadlocking also happen for locks other than tables? It can happen
> > for RID or KEY locks as well within the same table, can't it?
> >
> > Christian Smith
> >
> > "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
> > news:OkcJl6X9DHA.548@.TK2MSFTNGP11.phx.gbl...
> > > Deadlocks are usually caused by 2 or more users attempting to update the
> > > same set of tables in opposite orders. If you have one sp that updates
> > > Orders and then Details while another updates details first and then
> orders
> > > this will eventually cause a dead lock. If they are both in the same
> order
> > > you most likely get only blocking which is normal and can be controlled.
> Do
> > > you have an example of 2 procedures that deadlock on each other and the
> > > associated DDL for those tables? Deadlocking is almost always a result
> of
> a
> > > poor schema or more likely poor data access methods. Serialization is
> not
> > > the way to go, you should do it right and find the cause so you can fix
> it.
> > > Maybe these will help:
> > >
> > >
> > > http://www.support.microsoft.com/?id=224453 Blocking Problems
> > > http://www.support.microsoft.com/?id=271509 How to monitor SQL 2000
> > > Blocking
> > >
> > >
> > >
> >
> http://www.amazon.com/exec/obidos/tg/detail/-/B0000W86FY/qid=1077039326//ref=sr_8_xs_ap_i1_xgl14/104-0688407-7232719?v=glance&s=books&n=507846
> > >
> > > --
> > >
> > > Andrew J. Kelly
> > > SQL Server MVP
> > >
> > >
> > > "n_o_s_p_a__m" <n_o_s_p_a__m@.mail.com> wrote in message
> > > news:1faa8782.0402170756.4a53601f@.posting.google.com...
> > > > I created a .net program which uses multithreading. The threads
> > > > concurrently access the same db resources. This has generated no end
> > > > of sql server deadlocks, which our dba is struggling to resolve.
> > > >
> > > > I am very close to giving up and going ahead and serializing all
> > > > database access for the application. This will reduce performance
> > > > quite a bit, although it will eliminate all the deadlocks.
> > > >
> > > > Maybe it's our dba's fault, maybe it's sql server's fault, maybe it's
> > > > mine for building an app that hits the db so hard, but we are unable
> > > > to solve all the deadlocking issues using the errorlog and profiling
> > > > combo that has been suggested. We solve one deadlock issue, only to
> > > > see another one revealed later, perhaps on different resources,
> > > > perhaps not.
> > > >
> > > > I have heard there are many applications that use the Singleton
> > > > pattern to serialize db access accross the board, just to avoid
> > > > situations like this.
> > > >
> > > > Any feedback welcome.
> > >
> > >
> >
> >|||Here is the deadlock graph of the previous post:
Wait-for graph
2004-02-18 12:06:37.50 spid4
2004-02-18 12:06:37.50 spid4 Node:1
2004-02-18 12:06:37.51 spid4 KEY: 26:1124251110:2 (130092d8179c)
CleanCnt:1 Mode: U Flags: 0x0
2004-02-18 12:06:37.51 spid4 Grant List 0::
2004-02-18 12:06:37.51 spid4 Owner:0x4fce9ac0 Mode: S
Flg:0x0 Ref:1 Life:00000000 SPID:73 ECID:0
2004-02-18 12:06:37.51 spid4 SPID: 73 ECID: 0 Statement Type:
SELECT Line #: 46
2004-02-18 12:06:37.51 spid4 Input Buf: RPC Event:
S_BPI_BY_BPIID_XML;1
2004-02-18 12:06:37.53 spid4 Requested By:
2004-02-18 12:06:37.53 spid4 ResType:LockOwner Stype:'OR' Mode:
X SPID:57 ECID:0 Ec:(0x53915568) Value:0x558fa140 Cost:(0/3C)
2004-02-18 12:06:37.53 spid4
2004-02-18 12:06:37.53 spid4 Node:2
2004-02-18 12:06:37.53 spid4 KEY: 26:1124251110:1 (4a004cee256c)
CleanCnt:1 Mode: X Flags: 0x0
2004-02-18 12:06:37.53 spid4 Grant List 0::
2004-02-18 12:06:37.53 spid4 Owner:0x4edb17a0 Mode: X
Flg:0x0 Ref:1 Life:02000000 SPID:57 ECID:0
2004-02-18 12:06:37.53 spid4 SPID: 57 ECID: 0 Statement Type:
UPDATE Line #: 347
2004-02-18 12:06:37.53 spid4 Input Buf: RPC Event:
U_FAILED_ELI_CT;1
2004-02-18 12:06:37.53 spid4 Requested By:
2004-02-18 12:06:37.53 spid4 ResType:LockOwner Stype:'OR' Mode:
S SPID:73 ECID:0 Ec:(0x4872B568) Value:0x48b1e3e0 Cost:(0/0)
2004-02-18 12:06:37.53 spid4 Victim Resource Owner:
2004-02-18 12:06:37.53 spid4 ResType:LockOwner Stype:'OR' Mode: S
SPID:73 ECID:0 Ec:(0x4872B568) Value:0x48b1e3e0 Cost:(0/0)
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message news:<O4PueDZ9DHA.2432@.TK2MSFTNGP09.phx.gbl>...
> Yes there are other reasons why dead locks occur but the main reason is as I
> posted. Without more details it's all a guess so the most logical or common
> reason is what I posted.
> --
> Andrew J. Kelly
> SQL Server MVP
>
> "Christian Smith" <csmith@.digex.com> wrote in message
> news:uxC%23TGY9DHA.3404@.TK2MSFTNGP09.phx.gbl...
> > Can't deadlocking also happen for locks other than tables? It can happen
> > for RID or KEY locks as well within the same table, can't it?
> >
> > Christian Smith
> >
> > "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
> > news:OkcJl6X9DHA.548@.TK2MSFTNGP11.phx.gbl...
> > > Deadlocks are usually caused by 2 or more users attempting to update the
> > > same set of tables in opposite orders. If you have one sp that updates
> > > Orders and then Details while another updates details first and then
> orders
> > > this will eventually cause a dead lock. If they are both in the same
> order
> > > you most likely get only blocking which is normal and can be controlled.
> Do
> > > you have an example of 2 procedures that deadlock on each other and the
> > > associated DDL for those tables? Deadlocking is almost always a result
> of
> a
> > > poor schema or more likely poor data access methods. Serialization is
> not
> > > the way to go, you should do it right and find the cause so you can fix
> it.
> > > Maybe these will help:
> > >
> > >
> > > http://www.support.microsoft.com/?id=224453 Blocking Problems
> > > http://www.support.microsoft.com/?id=271509 How to monitor SQL 2000
> > > Blocking
> > >
> > >
> > >
> >
> http://www.amazon.com/exec/obidos/tg/detail/-/B0000W86FY/qid=1077039326//ref=sr_8_xs_ap_i1_xgl14/104-0688407-7232719?v=glance&s=books&n=507846
> > >
> > > --
> > >
> > > Andrew J. Kelly
> > > SQL Server MVP
> > >
> > >
> > > "n_o_s_p_a__m" <n_o_s_p_a__m@.mail.com> wrote in message
> > > news:1faa8782.0402170756.4a53601f@.posting.google.com...
> > > > I created a .net program which uses multithreading. The threads
> > > > concurrently access the same db resources. This has generated no end
> > > > of sql server deadlocks, which our dba is struggling to resolve.
> > > >
> > > > I am very close to giving up and going ahead and serializing all
> > > > database access for the application. This will reduce performance
> > > > quite a bit, although it will eliminate all the deadlocks.
> > > >
> > > > Maybe it's our dba's fault, maybe it's sql server's fault, maybe it's
> > > > mine for building an app that hits the db so hard, but we are unable
> > > > to solve all the deadlocking issues using the errorlog and profiling
> > > > combo that has been suggested. We solve one deadlock issue, only to
> > > > see another one revealed later, perhaps on different resources,
> > > > perhaps not.
> > > >
> > > > I have heard there are many applications that use the Singleton
> > > > pattern to serialize db access accross the board, just to avoid
> > > > situations like this.
> > > >
> > > > Any feedback welcome.
> > >
> > >
> >
> >|||Not sure I follow what Node1 & 2 are. Are they 2 different users? Do they
both issue a select and an update? Sometimes it can be more confusing to
only give partial details. There must be more to it than what you show.
Are they wrapped in a transaction and what other statements are between the
begin and commit? But the real question is why on earth are you using a
TABLOCKX?
--
Andrew J. Kelly
SQL Server MVP
"n_o_s_p_a__m" <n_o_s_p_a__m@.mail.com> wrote in message
news:1faa8782.0402201155.64b1af2@.posting.google.com...
> One deadlocking situation is fairly simple:
> node 1: Select from some_table where rownum = 42
> node 2: update some_table with (TABLOCKX) where rownum = 42
>
> "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:<O4PueDZ9DHA.2432@.TK2MSFTNGP09.phx.gbl>...
> > Yes there are other reasons why dead locks occur but the main reason is
as I
> > posted. Without more details it's all a guess so the most logical or
common
> > reason is what I posted.
> >
> > --
> >
> > Andrew J. Kelly
> > SQL Server MVP
> >
> >
> > "Christian Smith" <csmith@.digex.com> wrote in message
> > news:uxC%23TGY9DHA.3404@.TK2MSFTNGP09.phx.gbl...
> > > Can't deadlocking also happen for locks other than tables? It can
happen
> > > for RID or KEY locks as well within the same table, can't it?
> > >
> > > Christian Smith
> > >
> > > "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
> > > news:OkcJl6X9DHA.548@.TK2MSFTNGP11.phx.gbl...
> > > > Deadlocks are usually caused by 2 or more users attempting to update
the
> > > > same set of tables in opposite orders. If you have one sp that
updates
> > > > Orders and then Details while another updates details first and then
> > orders
> > > > this will eventually cause a dead lock. If they are both in the
same
> > order
> > > > you most likely get only blocking which is normal and can be
controlled.
> > Do
> > > > you have an example of 2 procedures that deadlock on each other and
the
> > > > associated DDL for those tables? Deadlocking is almost always a
result
> > of
> > a
> > > > poor schema or more likely poor data access methods. Serialization
is
> > not
> > > > the way to go, you should do it right and find the cause so you can
fix
> > it.
> > > > Maybe these will help:
> > > >
> > > >
> > > > http://www.support.microsoft.com/?id=224453 Blocking Problems
> > > > http://www.support.microsoft.com/?id=271509 How to monitor SQL
2000
> > > > Blocking
> > > >
> > > >
> > > >
> > >
> >
http://www.amazon.com/exec/obidos/tg/detail/-/B0000W86FY/qid=1077039326//ref=sr_8_xs_ap_i1_xgl14/104-0688407-7232719?v=glance&s=books&n=507846
> > > >
> > > > --
> > > >
> > > > Andrew J. Kelly
> > > > SQL Server MVP
> > > >
> > > >
> > > > "n_o_s_p_a__m" <n_o_s_p_a__m@.mail.com> wrote in message
> > > > news:1faa8782.0402170756.4a53601f@.posting.google.com...
> > > > > I created a .net program which uses multithreading. The threads
> > > > > concurrently access the same db resources. This has generated no
end
> > > > > of sql server deadlocks, which our dba is struggling to resolve.
> > > > >
> > > > > I am very close to giving up and going ahead and serializing all
> > > > > database access for the application. This will reduce performance
> > > > > quite a bit, although it will eliminate all the deadlocks.
> > > > >
> > > > > Maybe it's our dba's fault, maybe it's sql server's fault, maybe
it's
> > > > > mine for building an app that hits the db so hard, but we are
unable
> > > > > to solve all the deadlocking issues using the errorlog and
profiling
> > > > > combo that has been suggested. We solve one deadlock issue, only
to
> > > > > see another one revealed later, perhaps on different resources,
> > > > > perhaps not.
> > > > >
> > > > > I have heard there are many applications that use the Singleton
> > > > > pattern to serialize db access accross the board, just to avoid
> > > > > situations like this.
> > > > >
> > > > > Any feedback welcome.
> > > >
> > > >
> > >
> > >|||In article <1faa8782.0402201155.64b1af2@.posting.google.com>,
n_o_s_p_a__m@.mail.com said...
> One deadlocking situation is fairly simple:
> node 1: Select from some_table where rownum = 42
> node 2: update some_table with (TABLOCKX) where rownum = 42
Actually both would error out because they're not valid SQL statements ;)
Seriously though, why would that deadlock? Whichever grabbed the table
first would finish its work and release it for the other.

multithreading = sqlserver deadlocks

I created a .net program which uses multithreading. The threads
concurrently access the same db resources. This has generated no end
of sql server deadlocks, which our dba is struggling to resolve.
I am very close to giving up and going ahead and serializing all
database access for the application. This will reduce performance
quite a bit, although it will eliminate all the deadlocks.
Maybe it's our dba's fault, maybe it's sql server's fault, maybe it's
mine for building an app that hits the db so hard, but we are unable
to solve all the deadlocking issues using the errorlog and profiling
combo that has been suggested. We solve one deadlock issue, only to
see another one revealed later, perhaps on different resources,
perhaps not.
I have heard there are many applications that use the Singleton
pattern to serialize db access accross the board, just to avoid
situations like this.
Any feedback welcome.Deadlocks are usually caused by 2 or more users attempting to update the
same set of tables in opposite orders. If you have one sp that updates
Orders and then Details while another updates details first and then orders
this will eventually cause a dead lock. If they are both in the same order
you most likely get only blocking which is normal and can be controlled. Do
you have an example of 2 procedures that deadlock on each other and the
associated DDL for those tables? Deadlocking is almost always a result of a
poor schema or more likely poor data access methods. Serialization is not
the way to go, you should do it right and find the cause so you can fix it.
Maybe these will help:
http://www.support.microsoft.com/?id=224453 Blocking Problems
http://www.support.microsoft.com/?id=271509 How to monitor SQL 2000
Blocking
http://www.amazon.com/exec/obidos/t...=books&n=507846
Andrew J. Kelly
SQL Server MVP
"n_o_s_p_a__m" <n_o_s_p_a__m@.mail.com> wrote in message
news:1faa8782.0402170756.4a53601f@.posting.google.com...
> I created a .net program which uses multithreading. The threads
> concurrently access the same db resources. This has generated no end
> of sql server deadlocks, which our dba is struggling to resolve.
> I am very close to giving up and going ahead and serializing all
> database access for the application. This will reduce performance
> quite a bit, although it will eliminate all the deadlocks.
> Maybe it's our dba's fault, maybe it's sql server's fault, maybe it's
> mine for building an app that hits the db so hard, but we are unable
> to solve all the deadlocking issues using the errorlog and profiling
> combo that has been suggested. We solve one deadlock issue, only to
> see another one revealed later, perhaps on different resources,
> perhaps not.
> I have heard there are many applications that use the Singleton
> pattern to serialize db access accross the board, just to avoid
> situations like this.
> Any feedback welcome.|||Can't deadlocking also happen for locks other than tables? It can happen
for RID or KEY locks as well within the same table, can't it?
Christian Smith
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:OkcJl6X9DHA.548@.TK2MSFTNGP11.phx.gbl...
> Deadlocks are usually caused by 2 or more users attempting to update the
> same set of tables in opposite orders. If you have one sp that updates
> Orders and then Details while another updates details first and then
orders
> this will eventually cause a dead lock. If they are both in the same
order
> you most likely get only blocking which is normal and can be controlled.
Do
> you have an example of 2 procedures that deadlock on each other and the
> associated DDL for those tables? Deadlocking is almost always a result of
a
> poor schema or more likely poor data access methods. Serialization is not
> the way to go, you should do it right and find the cause so you can fix
it.
> Maybe these will help:
>
> http://www.support.microsoft.com/?id=224453 Blocking Problems
> http://www.support.microsoft.com/?id=271509 How to monitor SQL 2000
> Blocking
>
>
http://www.amazon.com/exec/obidos/t...=books&n=507846
> --
> Andrew J. Kelly
> SQL Server MVP
>
> "n_o_s_p_a__m" <n_o_s_p_a__m@.mail.com> wrote in message
> news:1faa8782.0402170756.4a53601f@.posting.google.com...
>|||Yes there are other reasons why dead locks occur but the main reason is as I
posted. Without more details it's all a guess so the most logical or common
reason is what I posted.
Andrew J. Kelly
SQL Server MVP
"Christian Smith" <csmith@.digex.com> wrote in message
news:uxC%23TGY9DHA.3404@.TK2MSFTNGP09.phx.gbl...
> Can't deadlocking also happen for locks other than tables? It can happen
> for RID or KEY locks as well within the same table, can't it?
> Christian Smith
> "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
> news:OkcJl6X9DHA.548@.TK2MSFTNGP11.phx.gbl...
> orders
> order
> Do
of
> a
not
> it.
>
http://www.amazon.com/exec/obidos/t...=books&n=507846
>|||One deadlocking situation is fairly simple:
node 1: Select from some_table where rownum = 42
node 2: update some_table with (TABLOCKX) where rownum = 42
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message news:<O4PueDZ9DHA.2432@.
TK2MSFTNGP09.phx.gbl>...
> Yes there are other reasons why dead locks occur but the main reason is as
I
> posted. Without more details it's all a guess so the most logical or comm
on
> reason is what I posted.
> --
> Andrew J. Kelly
> SQL Server MVP
>
> "Christian Smith" <csmith@.digex.com> wrote in message
> news:uxC%23TGY9DHA.3404@.TK2MSFTNGP09.phx.gbl...
> orders
> order
> Do
> of
> a
> not
> it.
> http://www.amazon.com/exec/obidos/t...=books&n=507846|||Here is the deadlock graph of the previous post:
Wait-for graph
2004-02-18 12:06:37.50 spid4
2004-02-18 12:06:37.50 spid4 Node:1
2004-02-18 12:06:37.51 spid4 KEY: 26:1124251110:2 (130092d8179c)
CleanCnt:1 Mode: U Flags: 0x0
2004-02-18 12:06:37.51 spid4 Grant List 0::
2004-02-18 12:06:37.51 spid4 Owner:0x4fce9ac0 Mode: S
Flg:0x0 Ref:1 Life:00000000 SPID:73 ECID:0
2004-02-18 12:06:37.51 spid4 SPID: 73 ECID: 0 Statement Type:
SELECT Line #: 46
2004-02-18 12:06:37.51 spid4 Input Buf: RPC Event:
S_BPI_BY_BPIID_XML;1
2004-02-18 12:06:37.53 spid4 Requested By:
2004-02-18 12:06:37.53 spid4 ResType:LockOwner Stype:'OR' Mode:
X SPID:57 ECID:0 Ec0x53915568) Value:0x558fa140 Cost0/3C)
2004-02-18 12:06:37.53 spid4
2004-02-18 12:06:37.53 spid4 Node:2
2004-02-18 12:06:37.53 spid4 KEY: 26:1124251110:1 (4a004cee256c)
CleanCnt:1 Mode: X Flags: 0x0
2004-02-18 12:06:37.53 spid4 Grant List 0::
2004-02-18 12:06:37.53 spid4 Owner:0x4edb17a0 Mode: X
Flg:0x0 Ref:1 Life:02000000 SPID:57 ECID:0
2004-02-18 12:06:37.53 spid4 SPID: 57 ECID: 0 Statement Type:
UPDATE Line #: 347
2004-02-18 12:06:37.53 spid4 Input Buf: RPC Event:
U_FAILED_ELI_CT;1
2004-02-18 12:06:37.53 spid4 Requested By:
2004-02-18 12:06:37.53 spid4 ResType:LockOwner Stype:'OR' Mode:
S SPID:73 ECID:0 Ec0x4872B568) Value:0x48b1e3e0 Cost0/0)
2004-02-18 12:06:37.53 spid4 Victim Resource Owner:
2004-02-18 12:06:37.53 spid4 ResType:LockOwner Stype:'OR' Mode: S
SPID:73 ECID:0 Ec0x4872B568) Value:0x48b1e3e0 Cost0/0)
"Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message news:<O4PueDZ9DHA.2432@.
TK2MSFTNGP09.phx.gbl>...
> Yes there are other reasons why dead locks occur but the main reason is as
I
> posted. Without more details it's all a guess so the most logical or comm
on
> reason is what I posted.
> --
> Andrew J. Kelly
> SQL Server MVP
>
> "Christian Smith" <csmith@.digex.com> wrote in message
> news:uxC%23TGY9DHA.3404@.TK2MSFTNGP09.phx.gbl...
> orders
> order
> Do
> of
> a
> not
> it.
> http://www.amazon.com/exec/obidos/t...=books&n=507846|||Not sure I follow what Node1 & 2 are. Are they 2 different users? Do they
both issue a select and an update? Sometimes it can be more confusing to
only give partial details. There must be more to it than what you show.
Are they wrapped in a transaction and what other statements are between the
begin and commit? But the real question is why on earth are you using a
TABLOCKX?
Andrew J. Kelly
SQL Server MVP
"n_o_s_p_a__m" <n_o_s_p_a__m@.mail.com> wrote in message
news:1faa8782.0402201155.64b1af2@.posting.google.com...
> One deadlocking situation is fairly simple:
> node 1: Select from some_table where rownum = 42
> node 2: update some_table with (TABLOCKX) where rownum = 42
>
> "Andrew J. Kelly" <sqlmvpnooospam@.shadhawk.com> wrote in message
news:<O4PueDZ9DHA.2432@.TK2MSFTNGP09.phx.gbl>...
as I
common
happen
the
updates
same
controlled.
the
result
is
fix
2000
http://www.amazon.com/exec/obidos/t...=books&n=507846
end
it's
unable
profiling
to|||In article <1faa8782.0402201155.64b1af2@.posting.google.com>,
n_o_s_p_a__m@.mail.com said...
> One deadlocking situation is fairly simple:
> node 1: Select from some_table where rownum = 42
> node 2: update some_table with (TABLOCKX) where rownum = 42
Actually both would error out because they're not valid SQL statements ;)
Seriously though, why would that deadlock? Whichever grabbed the table
first would finish its work and release it for the other.