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

NullReferenceException in ServerMonitor

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.11.6
    • Component/s: Internal

      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:

      Unable to find source-code formatter for language: csharp. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      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.

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

              Created:
              Updated:
              Resolved: