December 9, 2004 at 8:18 am
December 10, 2004 at 2:58 am
The problem happens when a transactions is rolled back on the table where you have the Identity column has the primary key. The identity value does not get resets. When such unused identity values are generated, you get this Pkey violation error message.
You can check this by using dbcc checkident, the current identity value and current column should same. It would be different when such rollbacks happens.
You can reseed these DBCC CHECKIDENT -reseed
This wil be able to solve the problem you are facing
ranga
December 11, 2004 at 5:41 am
Could it be that you do not have identity ranges set for each of your databases? You should specify a range of identities per database to ensure that inserts from one database do not use the same identity values as another database (which would cause primary key violations). By setting "Not for replication" (which you have correctly done), you ensure that replicated values from one database do not cause a reseeding of the identity values - but you must ensure you have the ranges set for identity values.
December 15, 2004 at 11:32 am
Yes, when you initially create the publication (I do not believe you can do this after the fact), you have a list of articles you can add to the publication. Go into the details for the article and set up identity ranges. This will probably eliminate the problem entirely. As far as what the range values should be set at, that's up to you. Estimate a day's traffic and start from there, I guess.
December 15, 2004 at 12:21 pm
Yes, we have ranges set up already, but thanks for the advice.
Actually, we finally found the answer by calling Microsoft directly. It is a known (but not public) bug that occurs when you drop and recreate the publication. The fix will be in SQL Server SP4, whenever that comes out. Here's the word, straight from the multi-billion-dollar horse's mouth:
In your situation, the primary key violation was caused by a known issue in SQL Server merge replication. When you drop an article and re-add it to the publication, it does not keep accurate track of any higher values that came in from subscribers and when it reassigns the identity ranges there may be conflicts. This won't happen every time.
December 15, 2004 at 12:32 pm
wow, thanks a bunch. I guess that also covers the current merge issue I'm having, but I'll probably give them a call anyway. Maybe if enough of us have the same kind of error, Microsoft will realize that it's an important issue that should be fixed soon.
December 30, 2004 at 3:05 pm
I was just told Q1 of 2005. It will be fixed in Yukon as well, which is slated to be released the end of 2005.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply