Error handling in SQL Server replication

Source: Internet
Author: User
Tags error handling

The row was not found at the Subscriber when the error "Apply replicated command" occurred in SQL Server replication. The previous practice is to delete this copy, and then create a new copy, but this time, I suddenly want to Baidu to see how others deal with this problem, Then I found that the articles were copied from MSDN, so I decided to write down what I was doing.

Check MSDN first to determine that the error ID is 20598, which is used below, and after you have identified the error ID, there are two ways to skip this error

The first is to use the right key-copy-"Distributor Properties-" default profile-"and then create a new profile," which allows all copies of distribution to use the new configuration file, which is typically used to modify some of the public parameters.

The second is to turn on Replication Monitor, double-click the copy you want to modify, have a proxy profile under the Action menu, open it, create a new profile, and then use this profile, which modifies individual copied parameters.

After the new modified-skiperrors this item, point "value" column after the input just found the ID number, is 20598, point OK, and then hook you just created this configuration file.

Restart the agent and turn on Replication Monitor, and you will notice that it has skipped this error.

If this is a Peer-to-peer data replication, use caution because it can cause data inconsistencies in two databases, identify the cause, and then decide whether to skip the error.

For transactional replication, there are two ways to skip errors encountered during the distribution process:

The-skiperrors parameter of the Distribution Agent that can be used to skip some type of error. Transactions with errors will not be committed, but subsequent transactions will be committed.

Sp_setsubscriptionxactseqno stored procedures that can be used to skip one or more transactions that cause errors. Non-SQL Server Subscribers do not have this option.

Important matters:

In a typical replication process, you should not encounter any errors that need to be skipped. Be cautious when skipping errors, to understand the conditions in which the error occurred, the cause of the error, and the reason why you need to skip the error or specific transaction without solving it. If transactions committed at the publisher are skipped at the Subscriber, the two nodes are not fully synchronized, which can cause additional errors.

-skiperrors Parameters:

By default, the publishing agent stops when it encounters an error. If you use the-skiperrors parameter and specify an error that you expect or do not want to interfere with replication, the agent logs the error message and then continues running. For example, if you want to specify a Distribution Agent to record duplicate key violations but continue to process subsequent transactions, you need to specify that the agent skip error 2601 (a row that cannot insert a duplicate key in an object '%.*ls that has a unique index '%.*ls '). and 2627 (violating the%ls constraint '%.*ls '). Cannot insert duplicate key in object '%.*ls ':-skiperrors 2601;2627

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.