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

InvalidOperationException thrown from ContextBag.Merge #271

Closed
bording opened this Issue Jan 9, 2019 · 0 comments

Comments

Projects
None yet
2 participants
@bording
Copy link
Member

bording commented Jan 9, 2019

When processing messages from the main queue and satellite queues simultaneously, an InvalidOperationException can be thrown in the main pipeline.

System.InvalidOperationException: Collection was modified; enumeration operation may not execute.
   at System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Enumerator.MoveNext()
   at NServiceBus.Extensibility.ContextBag.Merge(ContextBag context)
   at NServiceBus.MainPipelineExecutor.<Invoke>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

This can occur when a satellite message is processed at the same time as a main queue message because the transport is sharing a ContextBag instance.

Who's affected

  • Any user with an endpoint that is processing messages on the main queue and a satellite can potentially be affected.

Symptoms

  • Log entries are seen saying a message is being retried because of the following exception: System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

Backported to

Originally reported in Particular/ServiceControl#1550

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment