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

Exception when switching selected failed message with a retry in progress #571

Closed
ramonsmits opened this issue Mar 21, 2016 · 2 comments
Closed
Assignees
Labels
Milestone

Comments

@ramonsmits
Copy link
Member

By clicking rapidly between messages it seems that an InvalidCastException can be raised.

Exception:

System.InvalidCastException: Unable to cast object of type ServiceInsight.ServiceControl.PresentationBody' to type 'System.Tuple`2[System.String,ServiceInsight.ServiceControl.PresentationBody]'

Exception details:

System.InvalidCastException: Unable to cast object of type  ServiceInsight.ServiceControl.PresentationBody' to type 'System.Tuple`2[System.String,ServiceInsight.ServiceControl.PresentationBody]'.
at ServiceInsight.ServiceControl.DefaultServiceControl.Execute[T](RestRequestWithCache request, Func`2 selector, String baseUrl) in C:\BuildAgent\work\7540559e45164f93\src\ServiceInsight\ServiceControl\DefaultServiceControl.cs:line 280
at ServiceInsight.ServiceControl.DefaultServiceControl.LoadBody(StoredMessage message) in C:\BuildAgent\work\7540559e45164f93\src\ServiceInsight\ServiceControl\DefaultServiceControl.cs:line 168
at ServiceInsight.MessageViewers.MessageBodyViewModel.LoadMessageBody() in C:\BuildAgent\work\7540559e45164f93\src\ServiceInsight\MessageViewers\MessageBodyViewModel.cs:line 160

Location in source code:

It seems that

  • When CacheStyle.Immutable then the cache should contain that item directly and it its CacheStyle.IfNotModified than the type should be wrapped in a Tuple<string,T>.
  • The CacheStyle can be different for different instance of the same type (PresentationBody).
  • In this issue it is assumed that PresentationBody has cache style IfNotModified but seems to have been added as Immutable.

Versions:

  • ServiceInsight: 1.5.4
  • ServiceControl: 1.11.1

References

@HEskandari
Copy link
Contributor

@ramonsmits regarding your observations after going through the code in more depth:

  • The PresentationBody which is what's rendered on the screen in the Body tab is only loaded through LoadBody method and it has specified CacheStyle.Immutable as can be seen here.
  • The reason we have both CacheStyle.Immutable and CacheStyle.IfNotModified for PresentationBody is because of messages in error queue. The messages in Success state are not going to change, hence they are CacheStyle.Immutable but error messages could be retires that's why they have CacheStyle.IfNotModified. I don't think this makes sense, since the Body of the message won't change, even if we retry it.

I still couldn't reproduce it by clicking quickly through the messages (or even by keeping arrow keys up/down). The reason this could happen is that the SI user is browsing the messages, message gets cached, then the message status changes (by either manual or automatic retrying process) and we try to pull it out of the cache with the wrong key.

I'm proposing to just stick to CacheStyle.Immutable when we load the message body (if the above makes sense).

@HEskandari HEskandari added this to the 1.5.6 milestone Mar 23, 2016
@HEskandari
Copy link
Contributor

Closed with #573

@HEskandari HEskandari changed the title Unable to cast object of type 'ServiceInsight.ServiceControl.PresentationBody' to type 'System.Tuple`2[System.String,ServiceInsight.ServiceControl.PresentationBody]'. Bug: Exception when switching selected failed message with a retry in progress Mar 23, 2016
@HEskandari HEskandari changed the title Bug: Exception when switching selected failed message with a retry in progress Exception when switching selected failed message with a retry in progress Mar 23, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants