Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-3436

NullReferenceException in ServerMonitor

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 2.11.6
    • Fix Version/s: None
    • Component/s: Internal
    • Security Level: Public
    • Labels:

      Description

      It appears that there is a state management issue in ServerMonitor.
      When the target replicaset is failing over, one of the threads fails with NullReferenceException, see exception callstack below:

      System.NullReferenceException: Object reference not set to an instance of an object.
      void MongoDB.Driver.Core.Servers.ServerMonitor.CancelCurrentCheck()
      void MongoDB.Driver.Core.Servers.Server.HandleBeforeHandshakeCompletesException(IConnection connection, Exception ex)
      IChannelHandle MongoDB.Driver.Core.Servers.Server.GetChannel(CancellationToken cancellationToken)
      IChannelHandle MongoDB.Driver.Core.Bindings.ServerChannelSource.GetChannel(CancellationToken cancellationToken)
      IChannelHandle MongoDB.Driver.Core.Bindings.ChannelSourceHandle.GetChannel(CancellationToken cancellationToken)
      RetryableReadContext MongoDB.Driver.Core.Operations.RetryableReadContext.Create(IReadBinding binding, bool retryRequested, CancellationToken cancellationToken)
      IAsyncCursor<TDocument> MongoDB.Driver.Core.Operations.FindOperation<TDocument>.Execute(IReadBinding binding, CancellationToken cancellationToken)
      TResult MongoDB.Driver.OperationExecutor.ExecuteReadOperation<TResult>(IReadBinding binding, IReadOperation<TResult> operation, CancellationToken cancellationToken)
      TResult MongoDB.Driver.MongoCollectionImpl<TDocument>.ExecuteReadOperation<TResult>(IClientSessionHandle session, IReadOperation<TResult> operation, ReadPreference readPreference, CancellationToken cancellationToken)
      TResult MongoDB.Driver.MongoCollectionImpl<TDocument>.ExecuteReadOperation<TResult>(IClientSessionHandle session, IReadOperation<TResult> operation, CancellationToken cancellationToken)
      IAsyncCursor<TProjection> MongoDB.Driver.MongoCollectionImpl<TDocument>.FindSync<TProjection>(IClientSessionHandle session, FilterDefinition<TDocument> filter, FindOptions<TDocument, TProjection> options, CancellationToken cancellationToken)
      IAsyncCursor<TProjection> MongoDB.Driver.MongoCollectionImpl<TDocument>.FindSync<TProjection>(IClientSessionHandle session, FilterDefinition<TDocument> filter, FindOptions<TDocument, TProjection> options, CancellationToken cancellationToken)+(IClientSessionHandle session) => { }
      TResult MongoDB.Driver.MongoCollectionImpl<TDocument>.UsingImplicitSession<TResult>(Func<IClientSessionHandle, TResult> func, CancellationToken cancellationToken)
      IAsyncCursor<TProjection> MongoDB.Driver.MongoCollectionImpl<TDocument>.FindSync<TProjection>(FilterDefinition<TDocument> filter, FindOptions<TDocument, TProjection> options, CancellationToken cancellationToken)
      

      While I don't have debug symbols with line numbers (and optimized/JITted code would not indicate the target line with 100% certainty), I believe the Dispose call is the culprit here.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned Unassigned
              Reporter:
              onyxmaster Aristarkh Zagorodnikov
              Participants:
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: