I have a scheduled job that does a Lucene re-index of my own custom Lucene implementation.
The job was failing constantly with "Thread was being aborted." At one point I trapped a low-level Lucene merge exception, but otherwise, it failed silently, without logging anything. It would sometimes fail two minutes into its run, sometimes five seconds. Every once in a great while, it would complete (say, one out of every 20 times).
Here's where it gets interesting --
Our of despseration and a desire to see if I could get the exception to throw interactively, I created an ASPX page and put this in the code-behind:
var job = new ReindexJob();
It appears to work fine this way, every time. I cannot get it to throw an error any longer.
Why would this be?
Quess there is a reference to HttpContext.Current or User inside the Execute method
The trick is to do a try catch around all code inside the Execute method. and log any errors
This is no such code. I have checked for this, and, also, if this code existed, there would be no way for the job to randomly complete every 20th run or so. Existence of that code would ensure consistent failure, every time.
Also, I have a try...catch around the entire Execute method, with logging. It never hits the catch. I have no idea why.
It could be some code like that inside a page property, and you dont feed all pages all the time, only the new ones?
The only thing that don't hit the catch is as far as I know only a recursive well.
I guess that this is not the issue but could a possible cause can be that IIS is recycling the application (due to some settings in IIS, like memory consumtion, or not answering ping request)?