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

Recurring jobs not being executed when running as part of integration tests using a 'test host' configured with Hangfire per test case #5

Open
bhehe opened this issue Aug 16, 2022 · 0 comments

Comments

@bhehe
Copy link

bhehe commented Aug 16, 2022

I created a related issue with same title on the main Hangfire project's issues tracker, but I believe I've isolated this to being an issue with use of the 'InMemory' storage provider so I'm creating an issue here since this may be the more appropriate place to pursue it.

See: HangfireIO/Hangfire#2082

My Research So Far

On digging into the InMemory provider's code, I was looking for anywhere that had 'static' state management in use. As mentioned on the related issue #2082 above, when running the tests individually 1-by-1 they all work and pass their assertions that verify the job was triggered/executed. When I switched to using a local SQL Server database as the storage provider, they all pass. So now I'm fairly convinced it's due to this provider and something internal to it that relates to the lifetime of the AppDomain running the tests.

What I do see is that in the [InMemoryDispatcherBase] class there is some static state being managed that relates to the queues and it looked at least suspect to what I'm seeing - jobs not getting picked up & executed.

Additionally, that component is called as part of acquiring a distributed lock in the [InMemoryConnection] class which has the following note on it:
// TODO: Track acquired lock at a connection level and release them on dispose

That too leads me to suspect that static state management might be a factor in the issue I'm chasing.

Questions

  • Is there a way (exposed to consumers) to force a 'reset' of all state?
  • If no facility for this exists today, can we get something like that? i.e. InMemoryStorage.Reset() or something exposed on the InMemoryStorageOptions like an options.ForceReset = true or similar.
  • Is there any other trickery I could consider to work around this?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant