all groups > sql server replication > april 2007 >
You're in the

sql server replication

group:

Transactional replication reliabiliy



Re: Transactional replication reliabiliy Paul Ibison
4/6/2007 12:00:00 AM
sql server replication: There is the option to initialize with backup which prevents any sort of
locking on the publisher, or there is the "Concurrent access during
snapshot generation" option. Either way, there would be no problem on the
publisher.
That aside, once set up it is very robust and even schma changes are easily
replicated to the subscriber in SQL Server 2005. The most likely problem is
subscribers exceeding the retention period but you can set up alerts so
you'll know about this well in advance.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com

Transactional replication reliabiliy andsm
4/6/2007 4:24:01 AM
I thinking of usage of transactional replication in one of projects. The
transaction replication will be used between several servers. Most of servers
(TransDBs) will be used for entering data (high writing activity, lots of
concurrent users on each of the servers), and data from the servers, for most
of tables, will be replicated to other server, QueryDB. The QueryDB will have
not only queries, but also will be used for writing, and data from tables
which will be changed on QueryDB will be replicated by transactional
replication to other servers. Any table will be either repliucated to
QueryDB, or replicated from QueryDB, or not replicated at all, no tables
which are replicated from QueryDB and back. QueryDB and other servers will
have different set of tables, but all tables which are replicated from/to
will have same structure.
In order to prevent accidental changes, tables which are replicated to
QueryDB will have triggers, not for replication, which will prevent any
changes in the tables. Same for tables replicated from QueryDB to TransDB on
TransDB.

The question is - which reliability/availability I may expect from
transactional replication? I understand what its relatively easy to fix
problems caused by fallen replication (and when other simpler ways not works)
- its recreate publication, apply snapshot etc. But since system is 24x6, I
can not create publication during week, only on wekends - because creation of
publication lock tables preventing concurrent updates. May I expect 99.99%
Re: Transactional replication reliabiliy andsm
4/6/2007 5:08:02 AM
Creation of publication locking tables. You may check - add empty
transactional publication to DB, next in one of windows in Management Studio
open transaction and write "delete from [tablename] where 1=0". It will place
IX lock on table. Next execute sp_addarticle for the table. You will see what
executing hanging, it attempts to place Sch_M lock on the table. So
replication lock table, even in SQL2k5... - and if not that locking, planning
for high replication availability may become much easier.

About snapshot generation. I am not checked it for SQL2k5 yet, but in SQL2k,
even with 'concurrent' snapshot option, snapshot generation locking tables -
for shorter amount of time what with 'native', but locking. - And it is
written in documentation. Is SQL2k5 snapshot generation with concurrent
option lock tables or it is not lock it at all?

[quoted text, click to view]
Re: Transactional replication reliabiliy Raymond Mak [MSFT]
4/6/2007 10:05:23 AM
If you are going for 5 9s availability, initialize with backup is the way to
go as Paul has already mentioned. That said, we do support a new sync_method
= 'database snapshot' in SQL2005 EE SP2 which should incur lower locking
contention at the publisher compared with concurrent snapshot (which is not
to say locks aren't taken at all).

-Raymond

[quoted text, click to view]

Re: Transactional replication reliabiliy Paul Ibison
4/6/2007 6:34:50 PM
OK - I assumed you were talking exclusively about when the snapshot is
taken. The schema modification lock taken when sp_addarticle is executed is
presumably taken to mark the object as replicated so I wouldn't expect much
can be done about it, but it'll be a very short-term one.
During initialization for concurrent snapshot generation the shared locks
exist only for a few seconds - if this is too much have a look at "database
snapshot" for the @sync_method.
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com

Re: Transactional replication reliabiliy andsm
4/7/2007 11:00:01 AM
Locks which I see during creation of transactional publication and genaration
of snapshot with @sync_option = 'database snapshot', on SQL2k5 SP2 EE:

1. During publication creation - it place Sch_M locks on all tables selected
for replication, during execution of sp_addarticle. Bad, but not much - since
it lock only one object at time.

2. During snapshot generation, with option 'database snapshot' -
It place S locks on all tables which selected for replication. And its
really bad and it means downtime for system, which should work 24x6. Are any
ways to reduce locking and remove the downtime? If I will use initialization
from backup, what will be with locks?

[quoted text, click to view]
Re: Transactional replication reliabiliy Raymond Mak [MSFT]
4/7/2007 7:33:14 PM
Regarding 2, the shared locks will only be held for as long as it takes to
create the database snapshot which should be a minimal amount of time. Of
course, if that is still unacceptable, 'initialize with backup' is the way
to go.

-Raymond
[quoted text, click to view]

Re: Transactional replication reliabiliy Raymond Mak [MSFT]
4/7/2007 7:51:43 PM
As a sort of academic exercise, if the snapshot agent has trouble acquiring
shared table locks when sync_method = 'database snapshot', I am a bit
curious to know what is going on in the system that is blocking the snapshot
agent. I know it is always theoretically possible to have such situations
but it is better to wrap my head around a concrete example (or perhaps do
something about it).

-Raymond

[quoted text, click to view]

Re: Transactional replication reliabiliy Paul Ibison
4/7/2007 8:44:57 PM
Interesting - and many thanks for posting up your findings. My understanding
(from reading only) was that 'database snapshot' results in lower locking
than the concurrent option but your research shows that this is not
necessarily the case. It looks like "initialization from backup" or a nosync
initialization is your only option. If you have a couple of mins, please can
you drop me an email me at Paul.Ibison@ReplicationAnswers.Com offline about
this (- I'd email you directly but your account is an anonymous one).
Cheers,
Paul Ibison SQL Server MVP, www.replicationanswers.com

Re: Transactional replication reliabiliy andsm
4/8/2007 9:18:02 PM
It is very simple - on the system snapshot agent will be unable to get
shared table locks because it constantly will be deadlocked. - The system
have several thousands users at peak time and several hundreds users during
time with minimal activity, high writing activity, OLTP, finance processing
system.

And I not see what can be done here - since in case if any transaction, due
to the locks, will be delayed - affected users will be very unhappy and will
start to complain to customer support because they may lose $$ due to the
delays.

[quoted text, click to view]
Re: Transactional replication reliabiliy Raymond Mak [MSFT]
4/9/2007 9:55:41 AM
Thanks for the feedback. Given your scenario, snapshot processing definitely
(sync_method = 'database snapshot' or not) is *not* suitable as generating a
snapshot incurs significant system resource contention even if there aren't
any deadlocks or lock contention. That said, the snapshot agent does attempt
to mutate the lock acquisition sequence upon encountering a deadlock so for
a system with more or less consisent access patterns across different
tables, the snapshot agent should eventually grab the table locks in a way
that avoids deadlocks with any concurrent processes. I am guessing that
there are probably too many "hot" tables in your system at any given time
for the snapshot agent to converge to a deadlock-free lock acquisition
sequence in a timely manner. Theoretically, you can try breaking up your
publication into multiple publications with smaller number of articles to
minimize the chance of deadlocks during snapshot generation.

-Raymond

[quoted text, click to view]

AddThis Social Bookmark Button