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

Parsing compressors from the URI doesn't support snappy

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.9.2
    • Component/s: Wire Protocol
    • None

      Setting snappy explicitly in the MongoClientSettings works, but parsing from the URI does not

      Steps to repro:

      1. mongod --networkMessageCompressors zlib,snappy --dbpath data
      2. mongo --eval "db.setLogLevel(5,'network')"
      3. Run the following in .NET Core 2.1 using the 2.9.2 driver:

      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
      [TestMethod]
      public void TestDotNetCoreAndSnappyNetworkCompressor()
      {
          var m = new MongoClient("mongodb://localhost:27017/?compressors=zlib&appName=zlibFromURI");
          var n = new MongoClient("mongodb://localhost:27017/?compressors=snappy&appName=snappyFromURI");
          var o = new MongoClient(new MongoClientSettings
          {
              Server = new MongoServerAddress("localhost", 27017),
              Compressors = new List<CompressorConfiguration> { new CompressorConfiguration(MongoDB.Driver.Core.Compression.CompressorType.Snappy) },
              ApplicationName = "snappyFromMongoClientSettings"
          });
          var coll = o.GetDatabase("test").GetCollection<BsonDocument>("foo");
          coll.InsertOne(BsonDocument.Parse("{x:1}"));
      }
      

      When reviewing the logs :

      2019-10-16T15:10:24.633-0400 I CONTROL  [initandlisten] MongoDB starting : pid=19504 port=27017 dbpath=data 64-bit host=MEDIA-DESKTOP
      2019-10-16T15:10:24.633-0400 I CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
      2019-10-16T15:10:24.633-0400 I CONTROL  [initandlisten] db version v4.0.11
      2019-10-16T15:10:24.633-0400 I CONTROL  [initandlisten] git version: 417d1a712e9f040d54beca8e4943edce218e9a8c
      2019-10-16T15:10:24.633-0400 I CONTROL  [initandlisten] allocator: tcmalloc
      2019-10-16T15:10:24.634-0400 I CONTROL  [initandlisten] modules: none
      2019-10-16T15:10:24.634-0400 I CONTROL  [initandlisten] build environment:
      2019-10-16T15:10:24.634-0400 I CONTROL  [initandlisten]     distmod: 2008plus-ssl
      2019-10-16T15:10:24.634-0400 I CONTROL  [initandlisten]     distarch: x86_64
      2019-10-16T15:10:24.634-0400 I CONTROL  [initandlisten]     target_arch: x86_64
      2019-10-16T15:10:24.634-0400 I CONTROL  [initandlisten] options: { net: { compression: { compressors: "zlib,snappy" } }, storage: { dbPath: "data" } }
      2019-10-16T15:10:24.636-0400 I STORAGE  [initandlisten] Detected data files in data created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
      2019-10-16T15:10:24.637-0400 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=7650M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),statistics_log=(wait=0),verbose=(recovery_progress),
      2019-10-16T15:38:26.278-0400 I NETWORK  [conn13] received client metadata from 127.0.0.1:51831 conn13: { application: { name: "snappyFromURI" }, driver: { name: "mongo-csharp-driver", version: "2.9.2.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.18362", architecture: "x86_64", version: "10.0.18362" }, platform: ".NET Core 4.6.28008.01" }
      2019-10-16T15:38:26.278-0400 I NETWORK  [conn14] received client metadata from 127.0.0.1:51830 conn14: { application: { name: "snappyFromMongoClientSettings" }, driver: { name: "mongo-csharp-driver", version: "2.9.2.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.18362", architecture: "x86_64", version: "10.0.18362" }, platform: ".NET Core 4.6.28008.01" }
      2019-10-16T15:38:26.278-0400 I NETWORK  [conn15] received client metadata from 127.0.0.1:51832 conn15: { application: { name: "zlibFromURI" }, driver: { name: "mongo-csharp-driver", version: "2.9.2.0" }, os: { type: "Windows", name: "Microsoft Windows 10.0.18362", architecture: "x86_64", version: "10.0.18362" }, platform: ".NET Core 4.6.28008.01" }
      2019-10-16T15:38:26.279-0400 D NETWORK  [conn13] Starting server-side compression negotiation
      2019-10-16T15:38:26.279-0400 D NETWORK  [conn14] Starting server-side compression negotiation
      2019-10-16T15:38:26.279-0400 D NETWORK  [conn15] Starting server-side compression negotiation
      2019-10-16T15:38:26.280-0400 D NETWORK  [conn13] No compressors provided
      2019-10-16T15:38:26.280-0400 D NETWORK  [conn14] snappy is supported
      2019-10-16T15:38:26.280-0400 D NETWORK  [conn15] zlib is supported
      

      When the Compressor is explicitely added as a new CompressorConfiguration is shows in the mongod log as supported, however as soon as you attempt an operation against it the connection will fail:

          System.TimeoutException: A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : "1", ConnectionMode : "Automatic", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/localhost:28017" }", EndPoint: "Unspecified/localhost:28017", State: "Disconnected", Type: "Unknown", HeartbeatException: "System.NotSupportedException: Specified method is not supported.
             at MongoDB.Driver.Core.Compression.SnappyCompressor.Compress(Stream input, Stream output)
             at MongoDB.Driver.Core.WireProtocol.Messages.Encoders.BinaryEncoders.CompressedMessageBinaryEncoder.WriteMessage(CompressedMessage message)
             at MongoDB.Driver.Core.Connections.BinaryConnection.CompressMessages(IEnumerable`1 messages, IByteBuffer uncompressedBuffer, MessageEncoderSettings messageEncoderSettings)
             at MongoDB.Driver.Core.Connections.BinaryConnection.SendMessagesAsync(IEnumerable`1 messages, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
             at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.ExecuteAsync(IConnection connection, CancellationToken cancellationToken)
             at MongoDB.Driver.Core.Servers.ServerMonitor.GetHeartbeatInfoAsync(IConnection connection, CancellationToken cancellationToken)
             at MongoDB.Driver.Core.Servers.ServerMonitor.HeartbeatAsync(CancellationToken cancellationToken)", LastUpdateTimestamp: "2019-10-17T09:51:45.2500008Z" }] }.
        Stack Trace: 
          Cluster.ThrowTimeoutException(IServerSelector selector, ClusterDescription description)
          WaitForDescriptionChangedHelper.HandleCompletedTask(Task completedTask)
          Cluster.WaitForDescriptionChanged(IServerSelector selector, ClusterDescription description, Task descriptionChangedTask, TimeSpan timeout, CancellationToken cancellationToken)
          Cluster.SelectServer(IServerSelector selector, CancellationToken cancellationToken)
          MongoClient.AreSessionsSupportedAfterServerSelection(CancellationToken cancellationToken)
          MongoClient.AreSessionsSupported(CancellationToken cancellationToken)
          OperationExecutor.StartImplicitSession(CancellationToken cancellationToken)
          MongoCollectionImpl`1.UsingImplicitSession[TResult](Func`2 func, CancellationToken cancellationToken)
          MongoCollectionImpl`1.BulkWrite(IEnumerable`1 requests, BulkWriteOptions options, CancellationToken cancellationToken)
          <>c__DisplayClass64_0.<InsertOne>b__0(IEnumerable`1 requests, BulkWriteOptions bulkWriteOptions)
          MongoCollectionBase`1.InsertOne(TDocument document, InsertOneOptions options, Action`2 bulkWrite)
          MongoCollectionBase`1.InsertOne(TDocument document, InsertOneOptions options, CancellationToken cancellationToken)
          UnitTest1.TestDotNetCoreAndSnappyNetworkCompressor() line 41
      

      The above was from a standalone (which makes the HeartbeatException odd) and the following from a replicaset:

      System.TimeoutException: 'A timeout occured after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }. Client view of cluster state is { ClusterId : "1", ConnectionMode : "ReplicaSet", Type : "ReplicaSet", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "Unspecified/localhost:27017" }", EndPoint: "Unspecified/localhost:27017", State: "Disconnected", Type: "Unknown", HeartbeatException: "System.NotSupportedException: Specified method is not supported.
         at MongoDB.Driver.Core.Compression.SnappyCompressor.Compress(Stream input, Stream output)
         at MongoDB.Driver.Core.WireProtocol.Messages.Encoders.BinaryEncoders.CompressedMessageBinaryEncoder.WriteMessage(CompressedMessage message)
         at MongoDB.Driver.Core.Connections.BinaryConnection.CompressMessages(IEnumerable`1 messages, IByteBuffer uncompressedBuffer, MessageEncoderSettings messageEncoderSettings)
         at MongoDB.Driver.Core.Connections.BinaryConnection.SendMessagesAsync(IEnumerable`1 messages, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
         at MongoDB.Driver.Core.WireProtocol.CommandUsingCommandMessageWireProtocol`1.ExecuteAsync(IConnection connection, CancellationToken cancellationToken)
         at MongoDB.Driver.Core.Servers.ServerMonitor.GetHeartbeatInfoAsync(IConnection connection, CancellationToken cancellationToken)
      

            Assignee:
            vincent.kam@mongodb.com Vincent Kam (Inactive)
            Reporter:
            alex.bevilacqua@mongodb.com Alex Bevilacqua
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: