ThreadAbortException - how to diagnose/solve?

1,891 views
Skip to first unread message

Mark Hansen

unread,
Sep 24, 2012, 7:11:25 PM9/24/12
to mongod...@googlegroups.com
During a long-running Collection.MapReduce, I'm getting a ThreadAbortException.  How might I diagnose the cause of this and solve the problem?





System.Threading.ThreadAbortException: Thread was being aborted.
   at System.Net.UnsafeNclNativeMethods.OSSOCK.recv(IntPtr socketHandle, Byte*
pinnedBuffer, Int32 len, SocketFlags socketFlags)
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32
size, SocketFlags socketFlags, SocketError& errorCode)
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32
size)
   at MongoDB.Bson.IO.BsonBuffer.LoadFrom(Stream stream, Int32 count) in
C:\work\10gen\mongodb\mongo-csharp-driver\Bson\IO\BsonBuffer.cs:line 295
   at MongoDB.Bson.IO.BsonBuffer.LoadFrom(Stream stream) in
C:\work\10gen\mongodb\mongo-csharp-driver\Bson\IO\BsonBuffer.cs:line 268
   at
MongoDB.Driver.Internal.MongoConnection.ReceiveMessage[TDocument](BsonBinaryReaderSettings
readerSettings, IBsonSerializationOptions serializationOptions) in
C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Internal\MongoConnection.cs:line
445
   at MongoDB.Driver.MongoCursorEnumerator`1.GetReply(MongoConnection
connection, MongoRequestMessage message) in
C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoCursorEnumerator.cs:line
296
   at MongoDB.Driver.MongoCursorEnumerator`1.GetFirst() in
C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoCursorEnumerator.cs:line
253
   at MongoDB.Driver.MongoCursorEnumerator`1.MoveNext() in
C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoCursorEnumerator.cs:line
141
   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
   at MongoDB.Driver.MongoDatabase.RunCommandAs(Type commandResultType,
IMongoCommand command) in
C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoDatabase.cs:line 965
   at MongoDB.Driver.MongoDatabase.RunCommandAs[TCommandResult](IMongoCommand
command) in
C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoDatabase.cs:line 942
   at MongoDB.Driver.MongoCollection.MapReduce(BsonJavaScript map,
BsonJavaScript reduce, IMongoMapReduceOptions options) in
C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoCollection.cs:line
1144
   at
com.digitalbrandmine.download.db.GoogleAnalyticsDateRangeMacroDatasetBuilder.LoadDataTable(DataTable
dt) in C:\Users\Administrator\Documents\Visual Studio
2010\Projects\WorkbookService\WorkbookService\source\com\digitalbrandmine\download\db\GoogleAnalyticsDateRangeMacroDatasetBuilder.cs:line
109

Louisa Berger

unread,
Sep 25, 2012, 11:25:11 AM9/25/12
to mongod...@googlegroups.com
A ThreadAbortException is thrown when a call is made to the Abort method (documentation: http://msdn.microsoft.com/en-us/library/system.threading.thread.abort.aspx) on a thread. This is often called by the  Response.EndResponse.Redirect, or Server.Transfer methods, does your code use any of these methods? Here's some workarounds for those methods : 

Here's some Stack Overflow questions that deal with the ThreadAbortException. Looking at these can help you diagnose some simliar trouble spots in your own code:


General resource for troubelshooting mapreduce:

Mark Hansen

unread,
Sep 25, 2012, 2:31:03 PM9/25/12
to mongod...@googlegroups.com
Thanks Louisa.  I have examined the links you provided, and none of those situations seem to apply.  

It seems like a long-running map-reduce is exceeding the wait time of a thread, and IIS is throwing the ThreadAbortException - killing the thread before it gets the map-reduce results.

How can I figure out which wait-time is being exceeded, so I can correct it in the configuration?
Reply all
Reply to author
Forward
0 new messages