Level 10: Troubleshooting
Troubleshooting replication can be a daunting task. There are a lot of moving parts involved in any replication setup and the tools available do not always make it simple to identify a problem. This last level of the Replication Stairway will show you the places that provide the information necessary to solve most problems.
Finding the Problem
Level 9 of this Stairway introduced the Replication Monitor. If you enable all the warnings offered by that tool, it will warn you if something isn’t right. But often that is all the information you can get from that tool. And occasionally, even if you manage to find an actual error message, it is pointing in the wrong direction. To show you how to get more information we will walk through the troubleshooting process of some of the more common issues.
For this example, we work with a transactional replication setup, with one subscriber, where the person who performed the set up forgot to grant any permission to the relevant Windows accounts, and their associated SQL Server logins.
When you open the Replication Monitor, you will see a lot of red error symbols indicating a problem with the publication, as shown in Figure 1. Drilling down to the Agents tab for the publication reveals that both agents are having a problem.
Selecting “View Details” in the context menu for the Log Reader Agent entry opens the details dialog, shown in Figure 2.
As you can see, there is not a lot more information available here. However, the error message recommends checking out the “agent job history in the Jobs folder”. This refers to the Job History for the SQL Server Agent job that runs the Log Reader Agent.
The history there will look like the one shown in Figure 3.
Inside the Job History you can see one of the following four symbols next to every execution and every step of each execution:
They indicate: Failure, Success, Running, and Retrying.
For some job steps more than one entry gets logged in the history. If that happens and there was a failure or retry, the last logged row often does not contain any detail. Instead you need to check out the details of the row immediately preceding the last.
In Figure 3, you can see that the agent keeps retrying step 2. You also see more than one entry per step and retry attempt, so to see the reason for the continued retries click on the row immediately preceding the most recent retry indication row. That row is highlighted in Figure 3.
The bottom half of the Job History dialog will now show a detailed message with runtime information about this recent execution. This log text is shown in Figure 4.
All the way at the bottom you can see the reason for the failures: The remote server cannot be identified as a valid publisher.
This message is just one of the many things that make troubleshooting replication difficult. It might mean that the publisher you selected is not publishing anymore. In our case, however, it means that the login used by the Log Reader Agent to connect to the distribution database does not have the permissions required to see the publisher information that is stored in the distribution database. (If you need a refresher on the required permissions go back to Level 3 and 4 of this Stairway.)
Granting the missing permissions however seems not solve the problem. The Job History of the Log Reader Agent still shows continuous retires. Checking the log of the newest execution reveals that there is a different problem now: The agent cannot connect to the publication database. This information is again all the way at the bottom, as shown in Figure 5.
After granting the necessary access to the publication database the Log Reader Agent starts the next execution successfully.
Let us turn our attention back to the replication monitor. In Figure 1, both jobs were showing an error condition. However, depending on when this problem came to your attention, the Snapshot Agent might still have shown the “I am running” sign, like the one shown in Figure 7.
The replication monitor actually relies on the Snapshot Agent to regularly report status information. Only if that report fails to get sent for an extended period of time, the replication monitor will report a problem.
The problem reported in that case is again not very specific. It just states that the Snapshot Agent did not log any progress in 10 minutes. You can see this message by opening the Snapshot Agent detail dialog that is shown in Figure 8.
The error message recommends to check, manually, that records are still being replicated and that the network connections are up. A quick check in the target database reveals that records are not getting replicated. Checking the network connections doesn’t reveal a problem either so we need to look for the real cause of the problem in another place.
The Job Activity Monitor tells us right away that there is a problem with the Snapshot Agent Job. This is reflected in Figure 9.
Opening the history for the Snapshot Agent Job, as shown in Figure 10, reveals that the problems started in step 2.
The details for the selected step are given in Figure 11.
The error message is the same that we saw before in Figure 4. It again means that the account used to connect to the distribution database has not been granted all required permissions.
Unlike the Log Reader and the Distribution Agents, the Snapshot Agent is not scheduled to run continuously, so after every change you need to restart it to see if your change was successful.
The easiest way to restart the Snapshot agent is to drill down to the Agents tab for the publication in question in replication monitor. A right click on the row for the snapshot agent opens the context menu which contains a “Start Agent” entry. This is shown in Figure 12.
After restarting the snapshot agent it fails right away with a new error. You can see this error in Figure 13.
This time the Snapshot Agent detail dialog shows an error message that is a little more helpful than the last time. It informs that the login used by the Snapshot Agent does not have access to the publication database. The details of this error are shown in Figure 14.
After granting access to the publication database only the access to the snapshot share is left to do. This problem like the last one can be solved with just the information provided by the replication monitor. It informs of the problem the same way it did for the publication database access problem and the detail of the error reported is shown in Figure 15.
After fixing this last problem, the publication is up and running. The Agents tab for our publication in replication monitor informs us that the Snapshot Agent completed successfully after creating a snapshot of two articles while the Log Reader Agent is still running but was able to successfully complete a least one action. This all is shown in Figure 16.
The subscription in this setup however is still not working. Opening the All Subscriptions tab for our publication in replication monitor shows the subscription as uninitialized. You can see this in Figure 17.
To get more information, connect to the subscriber in Object Explorer (in SQL Server Management Studio) and drill down to the subscription. After a right mouse click the context menu opens. This is shown in Figure 18.
Clicking on “View Synchronization Status” opens a dialog that contains status information about the subscription. This dialog is shown in Figure 19.
This dialog tells us that the distribution agent started successfully and that it is still running. There is no sign of a problem here either, so let’s check out the Distribution Agent job history. You can get there either by using the Job Activity Monitor or by clicking on “View Job History” in the dialog in Figure 19.
From the Distribution Agent Job History we can tell that there is a problem that causes continuous retries. This is shown in Figure 20.
The problem details are shown in Figure 21.
All the way at the end we can see that the Distribution Agent can’t connect to the subscription database.
After fixing that problem we are confronted with the same situation as before. The subscription is still not initialized. To get a meaningful problem description we again have to dive all the way down to the Distribution Agent’s Job History. The Agent seems still to be in an endless retry loop. The error message of the most recent execution is shown in Figure 22.
This error message seems strangely familiar and again it means that the account in question can’t see the available publishers. This time however it is not enough to grant access to the distribution database. To solve this problem the login used by the Distribution Agent needs to be part of the Publication Access List. Check back in Level 4 of this Stairway for details about the PAL.
After fixing this problem we have one last access issue to solve. After having not been very helpful to us trying to work on the previous issues, the replication monitor now wakes up and tells us about the remaining one. This is shown in Figure 23.
A double click on the subscription with the problem opens the Subscription Detail dialog that is shown in Figure 24.
All the way at the bottom we get to see the reason for the problem. The Access to the Snapshot Share is denied.
After granting the account used to execute the Distribution Agent access to that share, replication finally starts working. Depending on how long it took you to resolve all the issues, you might see a performance warning as shown in Figure 25.
That warning however does not need to worry you at this point. It is normal to see some performance alerts right after setting up replication. These alerts usually go away after a few minutes.
Other Tools and Scenarios
While the preceding scenario is not very likely to happen in your environment, it illustrates all the different places where you might need to look to find information about problems. As the setup was a transactional replication setup, all the dialogs shown where specific to that type of replication. However, for merge and snapshot replication you can look in the same places to find the necessary troubleshooting information.
For transactional replication there is one more tool that you should add to your tool box. It is the tracer token. Tracer tokens were introduced in Level 9 of this Stairway. They allow you to measure the latency between the publisher and the distributor as well as between the distributor and the subscriber. But they also can be used to check for problems. If you insert a tracer token and it gets replicated to the subscriber in a reasonable amount of time you can be fairly confident that everything is working. If you regularly insert a tracer token into the stream you can even detect trends like an increasing latency and identify problems before they become painful.
Finally you need to be aware of the fact that sometimes, on rare occasions, the replication monitor can show misleading information. An example is shown in Figure 26.
It looks like everything is working as expected. However, if you look closely you will see that the Latency is “00:00:00”. That is a value that is not very likely to happen in a live system, so if it shows up is might be an indicator of a problem. In this case the subscription did not finish the initialization step, because it for some reason could not find the existing snapshot. The subscription detail dialog showed that the initial snapshot is not available. You can see this message in Figure 27.
So while the replication monitor is a very helpful tool, if you have been notified of a problem and the replication monitor is looking like everything is in great shape, make sure to look twice to not miss a suddle hint that could help identifying the problem.
If there is an unresolveble problem in the replicated data, the Distribution Agent will keep trying to resolve it. You can see an example in Figure 28.
This problem is caused by a row that was updated on the publisher but can’t be found on the subscriber. This problem will not resolve by itself, but the Distribution Agent will keep trying and every time it executes, the main screen of the replication monitor shows that everything is running normally. So depending on when you open replication monitor, you might see that there is a problem or you might not. Therefore we again offer this advice: If you suspect a problem, make sure to look a little deeper to not miss something helpful. Here the recent failing synchronizations shown in Figure 28 are an indicator that something is not quite right.
Most problems, like the one metioned above, will show up in the detail dialog for the subscription. The error messages also contains links to information, that can help you with the further analysis of the problem.
This Level did a walkthrough of a troubleshooting scenario for a transactional replication setup. Several places that provide information helpful for troubleshooting a replication problem were pointed out. At the end some special error scenarios where mentioned.
This Level concludes this Stairway about replication.
If you have comments or questions feel free to contact me at ReplicationStairway@sqlity.net.