U4-9595 - Improve ThreadAbortedException message

Created by Stephan 03 Mar 2017, 13:28:36 Updated by Shannon Deminick 20 Mar 2017, 03:16:22

Relates to: U4-9606

Subtask of: U4-9609

Whenever we log a ThreadAbortedException message... it's usually because the application is going down (eg when building models) but the message is scary ... in most cases there's nothing wrong with a thread abort and nothing can be done about it ... so we could detect (in the logger) that it's a ThreadAbortException and log a nicer message.


Sebastiaan Janssen 03 Mar 2017, 13:29:56

Example message:

2017-03-03 11:31:43,279 [P20152/D7/T8] ERROR Umbraco.ModelsBuilder.Umbraco.PureLiveModelFactory - Failed to build models. System.Threading.ThreadAbortException: Thread was being aborted.

Stephan 07 Mar 2017, 15:14:29

This is a 7.5.12 task not 7.5.11 and we should not do it until we understand what is going on in U4-9606 as we have reports of ThreadAbortException while the site is definitively not going down.

Stephan 09 Mar 2017, 10:22:20

It is highly probable that the exception we are seeing is due to a timeout. And, using (very little) reflection, we can actually tell if that's the case. Going to make sure we try and are a bit more explicit.

Stephan 09 Mar 2017, 11:05:35

PR: https://github.com/umbraco/Umbraco-CMS/pull/1787

Test: you have to edit eg ContentFinderByNiceUrl and insert the following code at the top of the TryFindContent method:

try { System.Threading.Thread.Sleep(240*1000); } catch (Exception e) { LogHelper.Error("oops!", e); }

Make sure the sleep is long enough (here, 240s = 2mins) and that you are running with compilation debug="false" (else timeouts don't work) and try to hit any page on the site. It should YSOD with a timeout exception.

But looking into Umbraco's log, you should see:

2017-03-09 11:48:58,176 [P47808/D15/T51] ERROR Umbraco.Web.Routing.ContentFinderByNiceUrl - oops! The thread has been aborted, because the request has timed out. System.Threading.ThreadAbortException: Thread was being aborted. at System.Threading.Thread.SleepInternal(Int32 millisecondsTimeout) at System.Threading.Thread.Sleep(Int32 millisecondsTimeout) at Umbraco.Web.Routing.ContentFinderByNiceUrl.TryFindContent(PublishedContentRequest docRequest)

So basically the same error message we got before, plus an extra line that tells you whether the abort is due to a "normal" timeout (not all aborts are).

Priority: Normal

Type: Task

State: Fixed


Difficulty: Normal


Backwards Compatible: True

Fix Submitted:

Affected versions:

Due in version: 7.5.12

Sprint: Sprint 54

Story Points: 1