We are leaving Russia. We are against aggression and war with Ukraine. It is a tragedy for our nations, it is a nightmare

Batches are not initialized

Once in a while, Hangfire stops working on our test environment, and tasks fail with the error message “Batches are not initialized”. An app pool recycle fixes the problem.

For some reason, this does not seem to happen in our production environment.

Does anybody have a clue what’s going on? Searching for this issue brings up nothing.

I think we faced similar issue, “Batches are not initialized. Please use the GlobalConfiguration.Configuration.UseBatches method first.”
Investigated and found that such an issue happens at the very moment when K8S autoscaling is working: there are recurring jobs, and the new POD is starting up. For some reason, it didn’t wait the Initialization to be completed and trying to take and process the background Job, something like this.
As far as I see this message comes from GlobalBatchFilters class. We are using job filters so far, so currently I’m trying to investigate if we are doing it in the right way.
In your situation I guess it could be also connected to the number of servers/workers/instances per environment.