Scheduled job fails when run from the interface, but works when run inline.

Vote:
 

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();
job.Execute();

    

It appears to work fine this way, every time.  I cannot get it to throw an error any longer.

Why would this be?

#54783
Nov 02, 2011 16:48
Vote:
 

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

#54785
Nov 02, 2011 17:29
Vote:
 

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.

#54786
Nov 02, 2011 17:31
Vote:
 

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.

#54787
Nov 02, 2011 17:40
Vote:
 

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)? 

#54791
Nov 03, 2011 8:42
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.