Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TimeoutEntity_EndpointIdx validation error due to braces "[" and "]" used in schema name, even though correct index defined. #349

Closed
roel-charita opened this issue Nov 7, 2018 · 5 comments

Comments

@roel-charita
Copy link

commented Nov 7, 2018

Hi, had a chat with Andreas today about "TimeoutEntity_EndpointIdx" index column validation error on the TimeoutEntity table. Because my schema contains braces when provided to the NHibernate config because otherwise it would not be recognized as a good identifier due to the use of a hyphen, the query to determine the columns used in the index does not return any results.

nHibernateConfig.SetProperty(NHibernate.Cfg.Environment.DefaultSchema, "[IOCDS-Async_NServiceBus_Scheduling]");

As a result the following log entries are created:

2018-11-07 14:58:38,212 [10] DEBUG NServiceBus.TimeoutPersisters.NHibernate.Installer.IncorrectIndexDetector - Detected TimeoutEntity_EndpointIdx (, )

2018-11-07 14:58:38,213 [10] WARN NServiceBus.TimeoutPersisters.NHibernate.Installer.IncorrectIndexDetector - The TimeoutEntity_EndpointIdx index has incorrect column order. This may cause significant performance degradation of message deferral. Consult NServiceBus NHibernate persistence documentation for details on how to create this index.

Possibly this issue can be fixed here within the GetIndex method:
https://github.com/Particular/NServiceBus.NHibernate/blob/21b64e933de12f05486384ab27558bca083564f6/src/NServiceBus.NHibernate/TimeoutPersisters/IncorrectIndexDetector.cs

By changing the GetIndex code as follows (only showing a snippet of the entire body):

if (typeof(MsSql2005Dialect).IsAssignableFrom(dialect.GetType())) 
{ 
    var restrictions = new string[5] 
    { 
        entity.Table.Catalog, 
        entity.Table.Schema
                            .TrimStart('[')
                            .TrimEnd(']'), 
        entity.Table.Name, 
        indexName, 
        null 
    }; 
    return new SqlServerIndex(connection.GetSchema("IndexColumns", restrictions)); 
} 

This fix targets the use of braces with the schema specifically, perhaps the other properties should also be checked in a similar way?

Regards,
Roel

@DavidBoike

This comment has been minimized.

Copy link
Member

commented Nov 7, 2018

Paging @andreasohlund & @SzymonPobiega.

@roel-charita can I clarify what the impact of this is? Is the result just a misleading/wrong warning message, or does this also affect runtime behavior?

I assume the scope is limited to only when using bracket-delimited schema names.

Also, what version of NServiceBus.NHibernate are you currently using?

@andreasohlund

This comment has been minimized.

Copy link
Member

commented Nov 7, 2018

It generates an incorrect WARN log statement at startup, no effetcts on runtime behaviour

@andreasohlund

This comment has been minimized.

Copy link
Member

commented Nov 7, 2018

Sidenote: Escaped tablenames is exposed to the same issue

@DavidBoike

This comment has been minimized.

Copy link
Member

commented Nov 7, 2018

In that case I marked it as Bug and candidate-for-next-release for consideration for the next maintenance release.

@roel-charita

This comment has been minimized.

Copy link
Author

commented Nov 8, 2018

@DavidBoike

  1. Runtime behavior is not directly affected but one may falsily assume his/her index is correct while in fact it is not and blame the reception of this validation error on this bug - no way for them to know. If the index would indeed be incorrect, this would affect runtime behavior.
  2. Version of NServiceBus.NHibernate is 7.2.4 at the moment.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.