Microsoft KB Archive/326483

= FIX: The Merge Agent incorrectly deletes rows after a primary key violation occurs =

Article ID: 326483

Article Last Modified on 10/11/2005

-

APPLIES TO


 * Microsoft SQL Server 2000 Standard Edition

-



This article was previously published under Q326483



BUG #: 361118 (SQL Server 8.0)



SYMPTOMS
In a merge replication environment, a row is missing at the publisher at and all the subscribers.

Additionally, two rows that have the same primary key value exist in the conflict table for the article. For example, the conflict table for the article contains text that is similar to the following: Primary Key   Reason_Code  Conflict_Type   Reason_Text 1            2627         6               The row was inserted at 'publisher' but could not be inserted at 'subscriber'. Violation of PRIMARY KEY constraint 'pkey_constraint'. Cannot insert duplicate key in object 'Article'.

Primary Key   Reason_Code  Conflict_Type   Reason_Text 1            2627         5               The row was inserted at 'subscriber' but could not be inserted at 'publisher'. Violation of PRIMARY KEY constraint 'pkey_constraint'. Cannot insert duplicate key in object 'Article'.



CAUSE
During the download phase of the Merge Agent execution, the INSERT statement for the missing row is run before the compensating DELETE statement is run for the primary key violation.



Service pack information
To resolve this problem, obtain the latest service pack for Microsoft SQL Server 2000. For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

290211 How to obtain the latest SQL Server 2000 service pack

Hotfix information
Note The following hotfix was created before the release of Microsoft SQL Server 2000 Service Pack 3.

Note You must install SQL Server 2000 SP2 before you apply this hotfix.

A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Microsoft SQL Server 2000 service pack that contains this hotfix.

To resolve this problem immediately, contact Microsoft Product Support Services to obtain the hotfix. For a complete list of Microsoft Product Support Services telephone numbers and information about support costs, visit the following Microsoft Web site:

http://support.microsoft.com/contactus/?ws=support

Note In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The usual support costs will apply to additional support questions and issues that do not qualify for the specific update in question.

The English version of this hotfix has the file attributes (or later file attributes) that are listed in the following table. The dates and times for these files are listed in coordinated universal time (UTC). When you view the file information, it is converted to local time. To find the difference between UTC and local time, use the Time Zone tab in the Date and Time tool in Control Panel.   Date         Time     Size          File name -  12-Jul-2002  22:28    32,580 bytes  Qfe359375.sql Note Because of file dependencies, the most recent hotfix or feature that contains the files may also contain additional files.Note While this hotfix greatly reduces the chance of the problem occurring, the hotfix does not completely prevent the problem.

To install this hotfix, follow these steps:
 * 1) Install SQL Server 2000 SP2.
 * 2) Connect as a member of the system administrator role or as the sa by using Query Analyzer or Osql.exe, and then run Qfe359375.sql. Run this script on the publisher or on any subscriber.
 * 3) Stop all running replication agents on your server.
 * 4) Connect as a member of the system administrator role or as the sa by using Query Analyzer or Osql.exe, and then run sp_vupgrade_replication against the publisher and the subscriber database.
 * 5) Test the scenario for the bug that is fixed in this build to make sure that your problem is resolved.



WORKAROUND
If you still experience the problem after you apply the hotfix, we recommend that you increase the generation batch size of the Merge Agent. To do this, use the -UploadGenerationsPerBatch parameter or the -DownloadGenerationsPerBatch parameter.

Warning If the network is not stable, increasing the generation batch size of the Merge Agent can have an adverse effect. If you make the generation batch bigger, you increase the chance of interrupting the batch. If the batch is interrupted, you must resend the whole batch. Like the hotfix, this workaround corrects the problem. However, it does not prevent the problem.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.

Keywords: kbbug kbfix kbsqlserv2000presp3fix kbqfe kbsqlserv2000sp3fix kbhotfixserver KB326483

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.