I have an Azure Worker Role that is processing messages off of a service bus queue. A specific message that I am receiving is causing a corrupted heap exception which I cannot catch and handle. This is causing my system to enter an Unknown/ Unhealthy state:
Status: Unknown (Role has reported itself as unhealthy.)
I'm trying to protect the worker role from entering this state but in the off-chance that this occurs again, I want the worker role to restart, but it's just sitting there until I manually restart it.
Does anyone have any ideas on what I can do to force a restart if the heap gets corrupted?
I know I can force a role recycle by exiting the Run()
loop but how can I check to see if the heap is corrupted? Is there a setting in the worker role that can help?
It turns out you cannot catch a corrupted heap and the only way to handle this scenario is to have a process running in your worker role that you monitor and restarts if it crashes. The issue was the worker role was never crashing.