Application event viewer getting filled with Event ID 7888 and 5553 every one hour.

The following errors are thrown in the application event log every hour:

Event Type: Error

Event Source: Office SharePoint Server

Event Category: User Profiles

Event ID: 5553

Date: 5/5/2008

Time: 10:00:56 AM

User: N/A

Computer: <MOSSServer>

Description:

failure trying to synch site 71911d6b-b49a-4fca-998e-156ae35d236e for ContentDB

4bc60196-9553-4bea-89f4-49f7402fcfb7 WebApp ee78bb17-c87c-4f31-bba2-85f09e523cce.

Exception message was Cannot insert duplicate key row in object

'dbo.UserMemberships' with unique index

'CX_UserMemberships_RecordId_MemberGroupId_SID'.

The statement has been terminated.

AND

Event Type: Error

Event Source: Office SharePoint Server

Event Category: Office Server General

Event ID: 7888


Date: 5/5/2008

Time: 10:00:56 AM

User: N/A

Computer: <MOSSServer>

Description:

A runtime exception was detected. Details follow.

Message: Cannot insert duplicate key row in object 'dbo.UserMemberships' with unique index 'CX_UserMemberships_RecordId_MemberGroupId_SID'.

The statement has been terminated.

Techinal Details:

System.Data.SqlClient.SqlException: Cannot insert duplicate key row in object 'dbo.UserMemberships' with unique index 'CX_UserMemberships_RecordId_MemberGroupId_SID'.

The statement has been terminated.

at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)

at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)

at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)

at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)

at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)

at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)

at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(DbAsyncResult result, String methodName, Boolean sendToPipe)

at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()

at Microsoft.Office.Server.Data.SqlSession.ExecuteNonQuery(SqlCommand command)

at Microsoft.Office.Server.UserProfiles.WSSSynchSqlSession.SynchExecuteNonQuery(SqlCommand cmd, Boolean throwOnFail)

at Microsoft.Office.Server.UserProfiles.WSSSynchSqlSession.SynchExecuteNonQuery(SqlCommand cmd)

at Microsoft.Office.Server.UserProfiles.SiteSynchronizer.WriteChangeLogConsumed()

at Microsoft.Office.Server.UserProfiles.SiteSynchronizer.Synch()

at Microsoft.Office.Server.Diagnostics.FirstChanceHandler.ExceptionFilter(Boolean fRethrowException, TryBlock tryBlock, FilterBlock filter, CatchBlock catchBlock, FinallyBlock finallyBlock)

Why this happens:

================

This normally occurs when a site collection or a content database is moved from one

web application to another without running the preparetomove

https://technet.microsoft.com/en-us/library/cc262122.aspx  command first. Without

running the preparetomove command, the SSP thinks the site is new and tries to

insert data into the UserMemberships table that already exists there. This causes

SQL to throw a duplicate key error and causes the profile synchronization job to

fail.

How to fix it:

================

1. Open a command prompt and navigate to C:\Program Files\Common Files\Microsoft

Shared\Web Server Extensions\12\BIN

2. Run 'stsadm- o preparetomove -Site <https://whatevertheguiltysiteis/>

-OldContentDb <GUID of the contentdb listed in event log error>'

3. Run 'stsadm -o sync -deleteolddatabases 0'

For more information about the deleteolddatabases command, see the following:

https://technet.microsoft.com/en-us/library/cc263196.aspx

Note

Its not necessary to follow 2 step in case we are on Sp2 , we can directly go to the 3rd step.