We're installing a new SCOM 2022 UR2 environment. This is a fresh installation on fresh Windows 2022 VMs. The SQL Databases are also new, and also 2022 CU10.
After installation we are importing all the Management Packs from our existing 2019 environment.
At some point we see an error in the OpsDB by running this command:
SELECT * FROM cs.workitem
WHERE WorkItemName like '%delta%'
ORDER BY WorkItemRowId DESC
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.GetConfigurationDelta(String watermark) at Microsoft.EnterpriseManagement.ManagementConfiguration.Engine.TracingConfigurationDataProvider.GetConfigurationDelta(String watermark) at Microsoft.EnterpriseManagement.ManagementConfiguration.Engine.DeltaSynchronizationWorkItem.TransferData(String watermark) at Microsoft.EnterpriseManagement.ManagementConfiguration.Engine.DeltaSynchronizationWorkItem.ExecuteSharedWorkItem() at Microsoft.EnterpriseManagement.ManagementConfiguration.Interop.SharedWorkItem.ExecuteWorkItem() ----------------------------------- System.Data.SqlClient.SqlException (0x80131904): A severe error occurred on the current command. The results, if any, should be discarded. at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) at System.Data.SqlClient.SqlDataReader.TryHasMoreRows(Boolean& moreRows) at System.Data.SqlClient.SqlDataReader.TryReadInternal(Boolean setTimeout, Boolean& more) at System.Data.SqlClient.SqlDataReader.TryNextResult(Boolean& more) at System.Data.SqlClient.SqlDataReader.NextResult() at Microsoft.EnterpriseManagement.ManagementConfiguration.CmdbOperations.EntityChangeDeltaReadOperation.ReadData(SqlDataReader reader) at Microsoft.EnterpriseManagement.ManagementConfiguration.DataAccessLayer.ReaderSqlCommandOperation.SqlCommandCompleted(IAsyncResult asyncResult) ClientConnectionId:143f95a7-aacd-4b1e-840a-4a80d60a7ffa
This is also logged on the SCOM Management server as event 29181
The 1st time we experienced this, we just started. We couldn't find the issue so we started over. After a lot of work, we got this issue the 2nd time. We didn't want to start over again, so we did a OpsDB restore, and re-added the same Management Packs as we did before the restore, but the issue stayed away.
This went on for a long time, but now we got this issue back for the 3rd time. We have no idea what is causing this. All the Management Packs we added the first time when this occurred, were imported for a long time now without any problems. And beside that, all those Management Packs are running in our 2019 environment for years without any problem.
The only exception we can find in the database using the SQL server profiler is: incorrect syntax near ')' management configuration service
This syntax error started occurring at the same time the DeltaSynchronization issue starts.
When deep diving in this problem we found out that "PROCEDURE [CS].[p_EntityChangeDeltaList]" is causing this syntax error. When removing the selected piece of comment the problem disappears.
Even only removing the spaces last line of this comment, is enough to resolve the issue.
Problem solved we could say... but why is a comment causing an error, and why does this occur at a sudden moment, and not from the beginning? After a DB restore the problem was gone for a while, but the comment in the SQL query has always been there.