Tuesday, March 27, 2012
Deadlocks
I have recently directed a query that used to run on my main server to
another server that is a Pull Subscriber to a Transactional Replication from
the main server.
I now face deadlocks from time to time when the query is being run. The
deadlocked process is the proccess executing the query. I never faced such a
deadlock when the query was running on the main server.
Any ideas?
I was thinking to add either NOLOCK or set the transaction isolation level
to READUNCOMITED.
YanivYaniv ,shalom
http://www.sql-server-performance.com/deadlocks.asp
"Yaniv" <yanive@.rediffmail.com> wrote in message
news:O63ZcRGDGHA.376@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I have recently directed a query that used to run on my main server to
> another server that is a Pull Subscriber to a Transactional Replication
> from the main server.
> I now face deadlocks from time to time when the query is being run. The
> deadlocked process is the proccess executing the query. I never faced such
> a deadlock when the query was running on the main server.
> Any ideas?
> I was thinking to add either NOLOCK or set the transaction isolation level
> to READUNCOMITED.
>
> Yaniv
>
>|||NOLOCK or READ UNCOMMITTED will make your queries return incorrect results
at lightning speed. It would be better to find out what is wrong with the
query and to fix it.
READ COMMITTED SNAPSHOT is very good for reporting, but shouldn't be used to
calculate modifications of the database because the results can become stale
between the read and the write. It's too bad that it's not available in SQL
2000.
READ COMMITTED is usually sufficient for reporting, unless aggregates are
used, in which case you should use SERIALIZABLE.
If your query is used to calculate modifications of the database, then READ
COMMITTED is not sufficient.
REPEATABLE READ is insufficient if the query used to calculate modifications
of the database includes aggregates.
All of these statements depend on how tolerant your queries (and users) are
to error (in the scientific sense). For example, if you have 1 million rows
and you're calculating an average, then it really doesn't matter if a few
rows change, appear, or disappear during the calculation, so READ COMMITTED
should be OK in that case. The bottom line is that the ISOLATION LEVEL
should be determined on a case-by-case basis.
"Yaniv" <yanive@.rediffmail.com> wrote in message
news:O63ZcRGDGHA.376@.TK2MSFTNGP10.phx.gbl...
> Hi,
> I have recently directed a query that used to run on my main server to
> another server that is a Pull Subscriber to a Transactional Replication
> from the main server.
> I now face deadlocks from time to time when the query is being run. The
> deadlocked process is the proccess executing the query. I never faced such
> a deadlock when the query was running on the main server.
> Any ideas?
> I was thinking to add either NOLOCK or set the transaction isolation level
> to READUNCOMITED.
>
> Yaniv
>
>|||In my case I can afford to issue this query in READUNCOMITTED but thinking
again I find READPAST more suitable.
As per finding the cause to the problem I have no progress yet. This query
have been used for a long time on my main server without experiencing a
dealock.
--
"Brian Selzer" <brian@.selzer-software.com> wrote in message
news:exay9MHDGHA.1280@.TK2MSFTNGP10.phx.gbl...
> NOLOCK or READ UNCOMMITTED will make your queries return incorrect results
> at lightning speed. It would be better to find out what is wrong with the
> query and to fix it.
> READ COMMITTED SNAPSHOT is very good for reporting, but shouldn't be used
> to calculate modifications of the database because the results can become
> stale between the read and the write. It's too bad that it's not
> available in SQL 2000.
> READ COMMITTED is usually sufficient for reporting, unless aggregates are
> used, in which case you should use SERIALIZABLE.
> If your query is used to calculate modifications of the database, then
> READ COMMITTED is not sufficient.
> REPEATABLE READ is insufficient if the query used to calculate
> modifications of the database includes aggregates.
> All of these statements depend on how tolerant your queries (and users)
> are to error (in the scientific sense). For example, if you have 1
> million rows and you're calculating an average, then it really doesn't
> matter if a few rows change, appear, or disappear during the calculation,
> so READ COMMITTED should be OK in that case. The bottom line is that the
> ISOLATION LEVEL should be determined on a case-by-case basis.
> "Yaniv" <yanive@.rediffmail.com> wrote in message
> news:O63ZcRGDGHA.376@.TK2MSFTNGP10.phx.gbl...
>
Wednesday, March 21, 2012
Deadlock Issues When performing reports on subscriber
to our Reporting Database Server. All of our reports are run off of our
Reporting Database Server. We have no queries that are performing Update or
Exclusive locks except for the sp_MS stored procedures being used for the
Transactional replication.
I'm trying to identify the root cause of the issue. We don't want to apply
the trace flags to our production servers for capturing the deadlock
information. We have the profiler gathering all the report requests and we
were even lucky enough to capture a deadlock victim error, but we don't have
the process that was allowed to continue. We also have a job set up to
report spids that are marked as blocked, but we didn't have this set up in
time to catch our last deadlock. We experience most our deadlocks on days
that we have high transaction volume (Fridays) and also days that reports are
more frequently requested (Mondays).
Potential Issue #1:
Our reporting server is a Dell PowerEdge 1750, 2 Processors, and only 2GB
RAM. We are looking at upgrading this to a HP 4 Proc dual core with 16GB RAM
which I'm sure will help out but I don't want to just mask what the real
issue is. I'm thinking potentially there could be lock escalation occurring
during high TX volume days by the replication sp_MSIns* procedures due to the
fact that we only have 2GB RAM. Does this sound likely?
Potential Issue #2:
After analyzing one of the reports I have noticed that the query is
accessing a view that has a union all. We cannot index this view due to the
union all, so a table scan is being performed on close to 4 Million rows. My
idea is to break this into two different views and then index each view by
order date to shorten the duration of the Shared Lock. Could the length of
time the Shared Lock being held be the main reason for our deadlock issues
especially on high volume TX days? I'm also considering either setting the
reports Isolation level to Read Uncommitted or use the ReadPast hint to avoid
the Shared Lock all together.
Any other suggestions?
I would have a look at replicating the execution of stored procedures and
using the nolock hints.
run sp_replcounters to get an idea of how many commands per transaction you
have. If its a one to one, replicating the execution of stored procedures
won't help you much, but if its out by several orders of magnitude you will
get a huge improvement in performance and considerably reduced locking.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Larry Herbinaux" <LarryHerbinaux@.discussions.microsoft.com> wrote in
message news:B006BDC6-5B21-4E3E-97D7-80AB6BB6056B@.microsoft.com...
> We have transactional replication being performed from our TX Database
> Server
> to our Reporting Database Server. All of our reports are run off of our
> Reporting Database Server. We have no queries that are performing Update
> or
> Exclusive locks except for the sp_MS stored procedures being used for the
> Transactional replication.
> I'm trying to identify the root cause of the issue. We don't want to
> apply
> the trace flags to our production servers for capturing the deadlock
> information. We have the profiler gathering all the report requests and
> we
> were even lucky enough to capture a deadlock victim error, but we don't
> have
> the process that was allowed to continue. We also have a job set up to
> report spids that are marked as blocked, but we didn't have this set up in
> time to catch our last deadlock. We experience most our deadlocks on days
> that we have high transaction volume (Fridays) and also days that reports
> are
> more frequently requested (Mondays).
> Potential Issue #1:
> Our reporting server is a Dell PowerEdge 1750, 2 Processors, and only 2GB
> RAM. We are looking at upgrading this to a HP 4 Proc dual core with 16GB
> RAM
> which I'm sure will help out but I don't want to just mask what the real
> issue is. I'm thinking potentially there could be lock escalation
> occurring
> during high TX volume days by the replication sp_MSIns* procedures due to
> the
> fact that we only have 2GB RAM. Does this sound likely?
> Potential Issue #2:
> After analyzing one of the reports I have noticed that the query is
> accessing a view that has a union all. We cannot index this view due to
> the
> union all, so a table scan is being performed on close to 4 Million rows.
> My
> idea is to break this into two different views and then index each view by
> order date to shorten the duration of the Shared Lock. Could the length
> of
> time the Shared Lock being held be the main reason for our deadlock issues
> especially on high volume TX days? I'm also considering either setting
> the
> reports Isolation level to Read Uncommitted or use the ReadPast hint to
> avoid
> the Shared Lock all together.
> Any other suggestions?
|||One thing to try is to use WITH (NOLOCK) option on your table selects.
Since you are not updating the data on the subscriber it may help. I
have banged my head against these union views in the past and its
always a killer. Also checking to make sure the underlaying tables
have indexes is another thing...
Hope it helps..
Aravin.
|||Union all is also faster than a union, but it may return duplicates.
Evaluate your union to discover if the potential for duplicates exist and
whether this is problematic for you.
Hilary Cotter
Looking for a SQL Server replication book?
http://www.nwsu.com/0974973602.html
Looking for a FAQ on Indexing Services/SQL FTS
http://www.indexserverfaq.com
"Query Builder" <querybuilder@.gmail.com> wrote in message
news:1176397959.616208.3310@.y80g2000hsf.googlegrou ps.com...
> One thing to try is to use WITH (NOLOCK) option on your table selects.
> Since you are not updating the data on the subscriber it may help. I
> have banged my head against these union views in the past and its
> always a killer. Also checking to make sure the underlaying tables
> have indexes is another thing...
> Hope it helps..
> Aravin.
>
|||Larry - I'd personally identify the cause of the deadlock before proceeding.
If you are using profiler then I'd turn it off and just set up the trace
flags. Are you using SQL 2005? If so you can use trace flag 1222 which is
lightweight and provides more easily digestible info than before.
Paul Ibison
Monday, March 19, 2012
deadlock errors
I'm setting up a push merge replication, after the initial merge agent completes without errors I move the subscriber from a wired connection to a wireless connection. At this point I get an error…
The schema script …Program Files\Microsoft SQL Server\MSSQL\REPLDATA\unc\[table]_93.sch' could not be propagated to the subscriber.
(Source: Merge Replication Provider (Agent); Error number: -2147201001)
Cannot drop the table '[table]' because it is being used for replication.
(Source: dfdmfvltgh09 (Data source); Error number: 3724)
After this error the initial merge agent kicks off again trying to apply the initial snapshot where I then get the following deadlock errors.
Transaction (Process ID 53) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
(Source: dfdmfvltgh09 (Data source); Error number: 1205)
The process could not deliver the snapshot to the Subscriber.
(Source: Merge Replication Provider (Agent); Error number: -2147201001)
All are getting set up on sql 2000 sp4 on a push.We are trying to set up 10 units that all are pointing to the same dlink router model dwl-2100AP.5 are working the other 5 are coming up with this error.Anybody have any ideas what could be causing this.I don’t mind the getting cut off due to poor network connectivity, I really want to stop the initial merge agent from kicking off after it’s already completed.
Thank you in advanced,
Pauly C
Let's tackle the snapshot failure first. Are you saying merge is trying to apply the snapshot twice, once on the wired network and once on the wireless network? Are these two networks on the same domain?
|||Yes, the snapshot completes without errors, and replication works, changes get propergated back and forth between the subscriber and publisher, then when they move the subscriber to a wireless connection the first error occurs and the initial merge agent starts again.After applying some of the snapshot it gets the deadlock error. and it keeps trying to apply the initial merge agaent over and over.
|||And yes they are on the same domain. Somebody told me they were able to ping a machine that wasn't connected and actually got results. I did not see this with my own eyes so I'm not sure how true it is.