Sql-server – SQL Server Troubleshooting Replication and Long-Running fn_dblog query

replicationsql-server-2008transaction-logtransactional-replication

I am trying to get (pull) Transactional Replication working again for a subscriber.

Currently, in Replication Monitor I am seeing messages in the Publisher to Distributor tab and the Distributor to Subscriber tab.

In the distributor to subscriber history, I see 'concurrent snapshot for publication 'XX' not available'. In the publisher to distributor history, I see the Log Reader Agent initializing and then waiting for a response from the server (every 5 minutes the message is logged again).

Ultimately the execution of sp_replcmds fails.

I think there may be many unreplicated transactions which are causing the Log Reader Agent to hang. Following Troubleshooting LogReader Timeouts

I ran dbcc opentran and then attempted to run

select  [Transaction ID], count([Transaction ID]) as 'Count log entries'
from::fn_dblog('42006:31381:2',null) 
where [Description] = 'REPLICATE'
group by [Transaction ID]

This query did not return any results after over 40 minutes. Moreover, when I just run SELECT count(*) FROM ::fn_dblog(NULL, NULL) I am not getting results after a long time (20 minutes).

I am starting to think there is something up with the size of my transaction log, or some kind of corruption, or something.

Any help would be greatly appreciated.

Best Answer

If fn_dblog is hanging you may try some third party tools from ApexSQL, RedGate or Idera. Or you can try to backup the transaction log file and use fn_dump_dblog just to exclude problems with an online transaction log. You can find more info on this DBA post