MaxxVolk / Maximus.Connectivity.Monitoring

Multi-protocol connectivity testing for SCOM, including ping, HTTP, SSL/TLS, TCP, etc.
MIT License
3 stars 2 forks source link

Import error #2

Closed iv777 closed 3 years ago

iv777 commented 3 years ago

Hello!

I have SCOM 2019 with SQL 2019 CU8. Trying to import: image

MaxxVolk commented 3 years ago

Hi iv777,

Thanks for reporting the issue.

So far, I've tried to remove and re-import the MP in my test environment, and it was imported successfully. At the moment, I'm building another test environment, so will let you know. Meanwhile, could you confirm if you importing MP build 232 at the first time, or upgrading from previous MP release?

iv777 commented 3 years ago

It is a clean SCOM install and first try of import MP Maximus.Connectivity.Monitoring. The base library was installed successfully image

I suspect the error is related to SQL 2019...

MaxxVolk commented 3 years ago

I managed to get the same error using your scenario. However, import was OK for few other management groups with SQL 2017. Trying to resolve the issue, I upgraded OLEDB and ODBC drivers to the latest version -- that didn't help. Upgrading SCOM to UR 2 also didn't help. So, most likely it's an SQL issue. That might be related to enumeration type I use. Not many MPs define new enumerations, and standard ones were imported directly via SQL scripts, not SDK.

So, if you have another SCOM environment using SQL 2017, could you try import in that management group?

iv777 commented 3 years ago

Sorry, we are not planning to install another SCOM. But thanks for your attention!

MaxxVolk commented 3 years ago

I see. Anyway, I may continue this in background, or might log a call with MS.

The actual error happens in stored procedure call:

exec dbo.p_MPImportXML @ManagementPackXML=N'<MP XML here>' ',@MPKeyToken=N'fd5098a6a3259696',@VersionDependentId='EEBFB27F-87B4-634E-E684-FD3BBB7517A0',@Username=N'name'

in particular, it complains about this XML line:

<Property ID="TestId" Type="guid" AutoIncrement="false" Key="true" CaseSensitive="false" MaxLength="256" MinLength="0" Required="false" Scale="0" />

That, probably, means, that you won't be able to import any MPs, which define classes with guid-typed properties.

MaxxVolk commented 3 years ago

I think it's related to default value, which is null. I'll try to add empty guid default value and test if this helps.

MaxxVolk commented 3 years ago

I found the problem. I wasn't related to neither guid-typed fields, nor to enumeration. It's all about any default value, which start with '-' char. This is because SQL 2019 perform predictive function call, i.e. tries to execute a function, even it its result will not be used.

In the following fragment, fn_MPReferencedObjectId will never be called if property type is 0 (int), however, SQL 2019 calls it anyway, and as result it tries to convert "-1" to guid, as the nested function logic says -- if any "-" in the input -- it's a guid.

CREATE function [dbo].[fn_GetDefaultGuidPropValue] (@DefaultValue nvarchar(256),@MPName nvarchar(256), @MPKeyToken nvarchar(32),@PropType tinyint)
    RETURNS nvarchar(3000)
AS 
BEGIN
DECLARE @ConvertValue nvarchar(3000)

IF @PropType = 5
    BEGIN
    -- If we are passed in a Guid, just return it.  Due to xsd grammar, only GUIDS will contain the '-' character
    IF CHARINDEX(N'-', @DefaultValue, 1) > 0 
        SET @ConvertValue = @DefaultValue
    ELSE
        SET @ConvertValue = dbo.fn_MPReferencedObjectId(@MPName, @MPKeyToken, @DefaultValue)
    END
ELSE
 SET @ConvertValue = @DefaultValue

RETURN @ConvertValue
END

I think, the easiest way to fix is to use non-negative default value.

MaxxVolk commented 3 years ago

Please try the latest release 1.0.0.235. It has a workaround for SCOM 2019.