[CSHARP-824] IIS AppPool crashing due to possible socket exception with MongoDB driver 1.3.1 Created: 17/Sep/13  Updated: 20/Mar/14  Resolved: 19/Sep/13

Status: Closed
Project: C# Driver
Component/s: None
Affects Version/s: 1.3.1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Aaron Atkins Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 2008 R2, IIS 7.5



 Description   

IIS AppPool crashing with the following error.

Exception: System.Net.Sockets.SocketException

Message: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

StackTrace: at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at System.Net.Sockets.TcpClient.Connect(IPEndPoint remoteEP)
at MongoDB.Driver.Internal.MongoConnection.Open() in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Internal\MongoConnection.cs:line 315
at MongoDB.Driver.Internal.MongoConnection.GetNetworkStream() in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Internal\MongoConnection.cs:line 462
at MongoDB.Driver.Internal.MongoConnection.SendMessage(MongoRequestMessage message, SafeMode safeMode) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Internal\MongoConnection.cs:line 430
at MongoDB.Driver.MongoCursorEnumerator`1.GetReply(MongoConnection connection, MongoRequestMessage message) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoCursorEnumerator.cs:line 262
at MongoDB.Driver.MongoCursorEnumerator`1.GetFirst() in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoCursorEnumerator.cs:line 223
at MongoDB.Driver.MongoCursorEnumerator`1.MoveNext() in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoCursorEnumerator.cs:line 126
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)
at MongoDB.Driver.MongoCollection.FindOneAs[TDocument](IMongoQuery query) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoCollection.cs:line 498
at MongoDB.Driver.MongoCollection`1.FindOne(IMongoQuery query) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoCollection.cs:line 1639
at MongoDB.Driver.MongoDatabase.RunCommandAs(Type commandResultType, IMongoCommand command) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoDatabase.cs:line 891
at MongoDB.Driver.MongoDatabase.RunCommandAs[TCommandResult](IMongoCommand command) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoDatabase.cs:line 866
at MongoDB.Driver.MongoDatabase.RunCommand(IMongoCommand command) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoDatabase.cs:line 843
at MongoDB.Driver.MongoCollection.Count(IMongoQuery query) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoCollection.cs:line 112
at MongoDB.Driver.MongoCollection.IndexExistsByName(String indexName) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoCollection.cs:line 847
at MongoDB.Driver.MongoCollection.IndexExists(String[] keyNames) in C:\work\10gen\mongodb\mongo-csharp-driver\Driver\Core\MongoCollection.cs:line 831
at Volusion.Core.Data.Logging.MongoDbBatchAppender.get_LogEventCollection()
at Volusion.Core.Data.Logging.MongoDbBatchAppender.SendBuffer(LoggingEvent[] events)
at log4net.Appender.BufferingAppenderSkeleton.SendFromBuffer(LoggingEvent firstLoggingEvent, CyclicBuffer buffer)
at log4net.Appender.BufferingAppenderSkeleton.Flush(Boolean flushLossyBuffer)
at Volusion.Core.Logging.AppenderFlushTimer.<.ctor>b__0(Object o)
at System.Threading._TimerCallback.TimerCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading._TimerCallback.PerformTimerCallback(Object state)



 Comments   
Comment by Craig Wilson [ 17/Sep/13 ]

1.3.1 is very old and a number of releases have happened since then. If this is an actual bug, then there is a high probability that it has been fixed in more recent releases. We are currently on version 1.8.2.

In general regarding MongoDB, there are going to be exceptions and you need to be prepared to handle them. If a primary goes down and you attempt a write, you're going to get an exception because there isn't anywhere to write to. If this exception gets raised in a background thread (like a timer event as seen in your stacktrace) and isn't caught and handled, then your app pool is going to crash. I'd check into your MongoDbBatchAppender and ensure you are protecting yourself from exceptions.

Generated at Wed Feb 07 21:37:56 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.