[CSHARP-1953] ObjectDisposedException when performing database operations Created: 28/Mar/17  Updated: 13/Jul/20  Resolved: 13/Jul/20

Status: Closed
Project: C# Driver
Component/s: Error Handling
Affects Version/s: 2.4.2
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Aristarkh Zagorodnikov Assignee: Robert Stam
Resolution: Cannot Reproduce Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Windows 10 64-bit, .NET Framework 4.6



 Description   

System.ObjectDisposedException: Cannot access a disposed object.
System.Threading.TimerQueueTimer.Change(UInt32 dueTime, UInt32 period)
System.Threading.Timer.Change(TimeSpan dueTime, TimeSpan period)
MongoDB.Driver.Core.Servers.HeartbeatDelay.RequestHeartbeat()
MongoDB.Driver.Core.Servers.ServerMonitor.RequestHeartbeat()
MongoDB.Driver.Core.Servers.Server.HandleChannelException(IConnection connection, Exception ex)
MongoDB.Driver.Core.Servers.Server.ServerChannel.ExecuteProtocol[TResult](IWireProtocol`1 protocol, CancellationToken cancellationToken)
MongoDB.Driver.Core.Servers.Server.ServerChannel.Command[TResult](DatabaseNamespace databaseNamespace, BsonDocument command, IElementNameValidator commandValidator, Func`1 responseHandling, Boolean slaveOk, IBsonSerializer`1 resultSerializer, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
MongoDB.Driver.Core.Operations.CommandOperationBase`1.ExecuteProtocol(IChannelHandle channel, ServerDescription serverDescription, ReadPreference readPreference, CancellationToken cancellationToken)
MongoDB.Driver.Core.Operations.CommandOperationBase`1.ExecuteProtocol(IChannelSource channelSource, ReadPreference readPreference, CancellationToken cancellationToken)
MongoDB.Driver.Core.Operations.WriteCommandOperation`1.Execute(IWriteBinding binding, CancellationToken cancellationToken)
MongoDB.Driver.Core.Operations.CreateCollectionOperation.Execute(IWriteBinding binding, CancellationToken cancellationToken)
MongoDB.Driver.OperationExecutor.ExecuteWriteOperation[TResult](IWriteBinding binding, IWriteOperation`1 operation, CancellationToken cancellationToken)
MongoDB.Driver.MongoDatabaseImpl.ExecuteWriteOperation[T](IWriteOperation`1 operation, CancellationToken cancellationToken)
MongoDB.Driver.MongoDatabaseImpl.CreateCollectionHelper[TDocument](String name, CreateCollectionOptions`1 options, CancellationToken cancellationToken)
MongoDB.Driver.MongoDatabaseImpl.CreateCollection(String name, CreateCollectionOptions options, CancellationToken cancellationToken)



 Comments   
Comment by Aristarkh Zagorodnikov [ 28/Mar/17 ]

No solid reproduction case, sorry, it only occured twice (both cases in last month, so it might be something done between 2.2 and 2.4.2, because we upgraded only a month ago).

Comment by Robert Stam [ 28/Mar/17 ]

Thanks. That's helpful to know. Even if we can't reproduce it that tells us where to look.

Comment by Aristarkh Zagorodnikov [ 28/Mar/17 ]

Please excuse me, I forgot to state that this occurs very rarely and only when the replica set has topology changes (i.e. failover) or connectivity issues.

Comment by Robert Stam [ 28/Mar/17 ]

onyxmaster do you have a way to reproduce this?

Comment by Robert Stam [ 28/Mar/17 ]

An attempt to reproduce using this simple program did not throw an exception:

var client = new MongoClient("mongodb://localhost");
var database = client.GetDatabase("test");
database.DropCollection("test");
 
database.CreateCollection("test");

I'm guessing that something went wrong with the CreateCollection command and the exception was thrown while handling the error (that's what the stack trace looks like).

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