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

InvalidOperationException being thrown from Unleash.Scheduling.SystemTimerScheduledTaskManager.ConfigureTask #211

Closed
dcook-net opened this issue Mar 18, 2024 · 2 comments
Assignees

Comments

@dcook-net
Copy link

Describe the bug
We are seeing the error "Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct." being thrown from Unleash.Scheduling.SystemTimerScheduledTaskManager.ConfigureTask when it calls Dictionary.FindValue.

From looking at the code, I assume this is becuase of the way the SystemTimerScheduledTaskManager mutates the Timers Dictionary.

To Reproduce

We are using v4.1.7
Polling is set to 120 seconds

We are calling client.IsEnabled within a loop for 4 flag names, like so:

client?.IsEnabled(toggleName, unleashContext, defaultValue) ?? defaultValue;

The client is a singleton, as described in the documentation

I'm happy to raise a PR chaning Timers the Dictionary to a ConcurrentDictionary if this is an acceptable solution.

@dcook-net
Copy link
Author

dcook-net commented Mar 18, 2024

Upon closer inspection, it appears that despite the app using an unleash client as a singleton, we have a HealthCheck service that periodially creates a seperate instance, and determines the health of the connection by whether that client was successfully creatd or not (ie, is it null or not)?

I believe all the instances of this error originate from this health check.

For info, there are very few of these. In 10 period, we've only seen 6 instances of this.

@daveleek
Copy link
Collaborator

Thank you for getting back to us on what seems to be the root cause for the issues you've experienced! I'll close this issue for now, but you're welcome to reopen or open a new issue if this didn't address the issue or you experience any new issues!

@github-project-automation github-project-automation bot moved this from New to Done in Issues and PRs Mar 25, 2024
@daveleek daveleek self-assigned this Mar 25, 2024
@daveleek daveleek reopened this Apr 16, 2024
@github-project-automation github-project-automation bot moved this from Done to New in Issues and PRs Apr 16, 2024
@github-project-automation github-project-automation bot moved this from New to Done in Issues and PRs Apr 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants