Replication

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

1) Stop all logreader and distribution agents utilizing this distribution server.

Use the queries below to identify all Publisher and Subscriber servers.

–returns list of publishers using a distributor

sp_helpdistpublisher

–returns list of published databases

SELECT *

FROM [distribution].[dbo].[MSpublisher_databases]

–Run in each published database

–Returns publication/article/subscriber information

sp_helpsubscription

2) At each subscriber and in each subscriber database, query the


msreplication_subscriptions table for the bookmark xactid – you should find only
one row per publication in this table at each subscriber. This value indicates what
rows have already been delivered to each subscriber.

select transaction_timestamp from msreplication_subscriptions

Here is the value returned for me: 0x00000045000002560003000000000000

3) Determine SMALLEST value of ALL subscribers in ALL subscription databases. Use


that value when querying the msrepl_transactions and msrepl_commands tables in the
distribution database for rows to preserve. Now, let’s query msrepl_transaction and
msrepl_commands, using our transaction_timestamp and see if there are any other
commands that have not been propagated to either subscriber

–Be sure to use your smaller transaction_timestamp value here:

select count(*) from distribution..msrepl_commands where


xact_seqno>=0x00000045000002560003000000000000

select count(*) from distribution..msrepl_transactions where


xact_seqno>=0x00000045000002560003000000000000

4) How many rows do you get back? If around 1 million rows proceed to save those
rows. If more, determine which distribution agent is behind (lowest LSN) and see
what steps can be used to move that Distribution Agent forward.

5) Save rows returned by the above queries to temp tables before we truncate the
Replication tables:

Begin Transaction

select * into distribution..msrepl_commands_temp from distribution..msrepl_commands

where xact_seqno>=0x00000045000002560003000000000000

select * into distribution..msrepl_transactions_temp from


distribution..msrepl_transactions

where xact_seqno>=0x00000045000002560003000000000000
–did you get same row counts as in step 3), if yes, then commit the transaction

Commit Transaction

6) To verify you can query the temp tables and make sure that the rows were
selected out. Then, perform the following to truncate the two tables in the
distribution database:

truncate table distribution..msrepl_commands

truncate table distribution..msrepl_transactions

7) Once these are emptied, insert our rows back in from our temp tables:

insert into distribution..msrepl_commands

select * from distribution..msrepl_commands_temp

insert into distribution..msrepl_transactions

select * from distribution..msrepl_transactions_temp

You might also like