Violation of PRIMARY KEY constraint during Delta Resource Memberhip update (or Right click actions)

Article:TECH143676  |  Created: 2010-11-08  |  Updated: 2010-11-08  |  Article URL http://www.symantec.com/docs/TECH143676
Article Type
Technical Solution


Issue



In the NS Log viewer, the following messages are seen:
 

Process: w3wp
Thread ID: 9
Module: w3wp.exe
Source: Altiris.NS.ItemManagement.ItemAction.GetActionsForItems
Description: Unable to retrieve ItemAction. Guid:{a12a6dcf-1d49-4f9f-923b-112129a14ab5} Exception:System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint 'PK__#3F4B23F0__403F4829'. Cannot insert duplicate key in object 'dbo.@agents'.
The statement has been terminated.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.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.SqlDataReader.ConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   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.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
   at Altiris.NS.DataAccessLayer.Implementation.Altiris_Monitor_Common_DALInstalledAgents.GetInstalledAgents__Flattened(String machineGuids)
   at Altiris.NS.DataAccessLayer.Implementation.Altiris_Monitor_Common_DALInstalledAgents.GetInstalledAgents(List`1 machineGuids)
   at Altiris.Monitor.Solution.InstalledAgentAction.DoesItemActionApply(GuidCollection itemGuids)
   at Altiris.NS.ItemManagement.ItemAction.GetActionsForItems(GuidCollection itemGuids, ItemLoadFlags itemLoadFlags)


or


Process: AeXSvc
Thread ID: 70
Module: AeXSVC.exe
Source: Altiris.NS.StandardItems.Collection.NSDataSrcBasedResourceCollection.DeltaUpdateMembership
Description: Unexpected exception has occurred during the execution of the SQL for delta collection update for '798784d8-3e67-40b7-95f1-af1def8892a5'. Full update is run instead.

( Exception Details: System.Data.SqlClient.SqlException: Violation of PRIMARY KEY constraint 'PK__#CurrentCollecti__55EA88B7'. Cannot insert duplicate key in object 'dbo.#CurrentCollectionEval'.
The statement has been terminated.
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
   at System.Data.SqlClient.SqlInternalConnection.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.SqlDataReader.ConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   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.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
   at System.Data.SqlClient.SqlCommand.ExecuteScalar()
   at Altiris.NS.StandardItems.Collection.NSDataSrcBasedResourceCollection.DeltaUpdateMembership() )
( Exception logged from:
   at Altiris.Diagnostics.Logging.EventLog.ReportException(Int32 severity, String strMessage, String category, Exception exception)
   at Altiris.NS.Logging.EventLog.ReportException(Int32 severity, String strMessage, Exception exception)
   at Altiris.NS.StandardItems.Collection.NSDataSrcBasedResourceCollection.DeltaUpdateMembership()
   at Altiris.NS.StandardItems.Collection.NSDataSrcBasedResourceCollection.UpdateMembershipCore(ICollectionUpdateMessage updateMessage)
   at Altiris.NS.StandardItems.Collection.NSResourceCollectionBase.<>c__DisplayClass4.<UpdateMembership>b__0(IDatabaseContext ctx)
   at Altiris.Database.DatabaseContext`1.PerformWithDeadlockRetryHelper(Int32 retries, Boolean inTransaction, Getter`1 getContext, Action`1 action, Action`1 retry)
   at Altiris.Database.DatabaseContext`1.PerformWithDeadlockRetry(Int32 retries, Boolean startNewTransaction, IsolationLevel isolationLevel, Boolean independentContext, Action`1 action, Action`1 retry)
   at Altiris.Database.DatabaseContext`1.PerformWithDeadlockRetry(Int32 retries, Boolean startNewTransaction, Action`1 action, Action`1 retry)
   at Altiris.NS.ContextManagement.DatabaseContext.PerformWithDeadlockRetry(Int32 retries, Action`1 action, Action`1 retry)
   at Altiris.NS.StandardItems.Collection.NSResourceCollectionBase.UpdateMembership(ICollectionUpdateMessage updateMessage)
   at Altiris.NS.StandardItems.Collection.NSResourceCollectionBase.Altiris.NS.ItemManagement.IResourceCollection.UpdateMembership(INSMessage UpdateMessage)
   at Altiris.NS.StandardItems.Collection.DeltaCollectionUpdateSchedule.DeltaUpdateCollections(GuidCollection collectionGuids, DateTime lastRunTime)
   at Altiris.NS.StandardItems.Collection.DeltaCollectionUpdateSchedule.OnSchedule_Impl()
   at Altiris.NS.StandardItems.Collection.DeltaCollectionUpdateSchedule.OnSchedule(String identifier)
   at Altiris.NS.StandardItems.ContainerUpdateSchedule.<>c__DisplayClass2.<RunFilterDeltaUpdate>b__0(IDatabaseContext ctx)
   at Altiris.Database.DatabaseContext`1.PerformWithDeadlockRetryHelper(Int32 retries, Boolean inTransaction, Getter`1 getContext, Action`1 action, Action`1 retry)
   at Altiris.Database.DatabaseContext`1.PerformWithDeadlockRetry(Int32 retries, Boolean startNewTransaction, IsolationLevel isolationLevel, Boolean independentContext, Action`1 action, Action`1 retry)
   at Altiris.Database.DatabaseContext`1.PerformWithDeadlockRetry(Int32 retries, Boolean startNewTransaction, Action`1 action, Action`1 retry)
   at Altiris.Database.DatabaseContext`1.PerformWithDeadlockRetry(Int32 retries, Boolean startNewTransaction, Action`1 action)
   at Altiris.NS.ContextManagement.DatabaseContext.PerformWithDeadlockRetry(Int32 retries, Action`1 action)
   at Altiris.NS.StandardItems.ContainerUpdateSchedule.RunFilterDeltaUpdate(String identifier)
   at Altiris.NS.StandardItems.ContainerUpdateSchedule.RunDeltaUpdate(String identifier)
   at Altiris.NS.StandardItems.ContainerUpdateSchedule.OnSchedule(String identifier)
   at Altiris.NS.Scheduling.ScheduleService.ProcessSchedule(String scheduleId)
   at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.PrivateProcessMessage(RuntimeMethodHandle md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
   at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
   at System.Runtime.Remoting.Messaging.ServerObjectTerminatorSink.SyncProcessMessage(IMessage reqMsg)
   at System.Runtime.Remoting.Lifetime.LeaseSink.SyncProcessMessage(IMessage msg)
   at System.Runtime.Remoting.Messaging.ServerContextTerminatorSink.SyncProcessMessage(IMessage reqMsg)
   at System.Runtime.Remoting.Channels.CrossContextChannel.SyncProcessMessageCallback(Object[] args)
   at System.Runtime.Remoting.Channels.ChannelServices.DispatchMessage(IServerChannelSinkStack sinkStack, IMessage msg, IMessage& replyMsg)
   at System.Runtime.Remoting.Channels.DispatchChannelSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
   at System.Runtime.Remoting.Channels.BinaryServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
   at System.Runtime.Remoting.Channels.SoapServerFormatterSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
   at System.Runtime.Remoting.MetadataServices.SdlChannelSink.ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, IMessage& responseMsg, ITransportHeaders& responseHeaders, Stream& responseStream)
   at System.Runtime.Remoting.Channels.Tcp.TcpServerTransportSink.ServiceRequest(Object state)
   at System.Runtime.Remoting.Channels.SocketHandler.ProcessRequestNow()
   at System.Runtime.Remoting.Channels.RequestQueue.ProcessNextRequest(SocketHandler sh)
   at System.Runtime.Remoting.Channels.SocketHandler.BeginReadMessageCallback(IAsyncResult ar)
   at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
   at System.Net.ContextAwareResult.CompleteCallback(Object state)
   at System.Threading.ExecutionContext.runTryCode(Object userData)
   at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Net.ContextAwareResult.Complete(IntPtr userToken)
   at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
   at System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
   at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
 )
( Extra Details:  Type=System.Data.SqlClient.SqlException Src=.Net SqlClient Data Provider )

 



In the Resourcekeychanged table, you note that there are a lot of entries for the computers that show up in multiple tables. (In one case, there was over 500 entries for a single machine)


Environment



Symantec Management Platform 7.x

Monitor Solution 7.0


Cause



Computer records are showing up under two different tables:

- in RM_ResourceComputer
- in itemresource_nonpartitioned (with a ClassGuid of Network Resource / Device)

 

The NS resource merge scheduled task was running (doesn't throw any errors) but does not merge the duplicate records.


Solution



To work-around this issue:

1) Run this SQL query:

  select *
  from rm_ResourceComputer
  where guid in (select guid from itemresource_nonpartitioned)

 

   ...This will indicate which computers are showing up in multiple tables

2) Find the computers in the NS console and do a right-click Delete

 

An alternate solution is to

1) run this Query

select *
  from rm_ResourceComputer
  where guid in (select guid from RM_ResourceVirtual_Machine)
 

2) delete the computer that shows up from ONE of the 2 tables if the computer is a virtual machine delete the line from the RM_resourcecomputer.


NOTE:: If you can provide more information about how this may be occurring, please contact Symantec Support. We would like to find a resolution for this issue.



Legacy ID



52122


Article URL http://www.symantec.com/docs/TECH143676


Terms of use for this information are found in Legal Notices