today I wanted to explain the following error:
OpsMgr Management Configuration Service failed to execute 'SnapshotSynchronization' engine work item due to the following exception
Microsoft.EnterpriseManagement.ManagementConfiguration.DataAccessLayer.DataAccessException: Data access operation failed
at Microsoft.EnterpriseManagement.ManagementConfiguration.DataAccessLayer.DataAccessOperation.ExecuteSynchronously(Int32 timeoutSeconds, WaitHandle stopWaitHandle)
at Microsoft.EnterpriseManagement.ManagementConfiguration.CmdbOperations.CmdbDataProvider.GetConfigurationSnapshotNextBatch(SnapshotProcessWatermark watermark)
at Microsoft.EnterpriseManagement.ManagementConfiguration.Engine.TracingConfigurationDataProvider.GetConfigurationSnapshotNextBatch(SnapshotProcessWatermark watermark)
at Microsoft.EnterpriseManagement.ManagementConfiguration.Engine.SnapshotSynchronizationWorkItem.TransferData(SnapshotProcessWatermark initialWatermark)
System.InvalidCastException: Specified cast is not valid.
at Microsoft.EnterpriseManagement.ManagementConfiguration.CmdbOperations.ManagedEntitySnapshotReadOperation.ReadData(SqlDataReader reader)
The monitoring in the environment will still work, however no configuration will be sent between the Management Servers or to the agents. That means if you import new MPs or edit overrides, the changes will not be propagates, thus leaving a static SCOM environment.
First thing to check is in the OperationsManager Database, since this is the "live" DB of SCOM.
InvalidCastExceptions usually occur when there are blank values in fields where the field is not nullable, because there was a sproc which tried to cast something, but couldn`t due to an unexpected format.
Therefore you should first check for a blank displayname:
FROM MTV_HealthService where displayname= ' '
In my case, there was a cluster resource which was causing the configuration to break with the exception above.
After deleting both cluster nodes from the SCOM console, and after these were rediscovered, also the cluster resource got discovered successfully and did not cause any further issues.
Please remember a direct update on the SCOM databases is not supported, unless you open a support call. So if after rediscovery values are still null, you should open a support call at Microsoft and not try to update the null values directly in the OpsDB!