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

Connector crashes on attempting retrieve or update functions on the database for big-endian processor machines.

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 2.21.0
    • Affects Version/s: 2.19.2
    • Component/s: BSON
    • None
    • Needed
    • Hide

      Not sure whether to mention this in documentation or not...

      Show
      Not sure whether to mention this in documentation or not...

      Summary

      The MongoDB.Driver connects to the database on Big-endian machines (s390x in my case) and operations like collection create and delete work as expected but the connector crashes when attempting an insert or update operation.

      How to Reproduce

      using System;using MongoDB.Bson;using MongoDB.Driver;
      namespace Program
      {
          class Program
          {
              static void Main(string[] args)
              {
                  MongoClient dbClient = new MongoClient("mongodb://127.0.0.1:27017/");
                  var database = dbClient.GetDatabase("sample_training");
                  var collection = database.GetCollection<BsonDocument>("grades");
                  var document = new BsonDocument
                  {
                      { "student_id", 1 },
                      { "scores", new BsonArray
                          {
                          new BsonDocument{ {"type", "exam"}, {"score", 88.12334193287023 } },
                          new BsonDocument\{ {"type", "quiz"}, {"score", 74.92381029342834 } },
                          new BsonDocument\{ {"type", "homework"}, {"score", 89.97929384290324 } },
                          new BsonDocument\{ {"type", "homework"}, {"score", 82.12931030513218 } }
                          }
                      },
                      { "class_id", 480}
                  };           
                 collection.InsertOne(document);      
             }
          }
      }

       

      Additional Background

      Error message:

      Unhandled Exception:
      System.TimeoutException: A timeout occurred after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector }. Client view of cluster state is { ClusterId : "1", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 1, EndPoint : "127.0.0.1:27017" }", EndPoint: "127.0.0.1:27017", ReasonChanged: "Heartbeat", State: "Disconnected", ServerVersion: , TopologyVersion: , Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server.
       ---> MongoDB.Driver.MongoConnectionException: An exception occurred while receiving a message from the server.
       ---> System.FormatException: The size of the message is invalid.
         at MongoDB.Driver.Core.Connections.BinaryConnection.EnsureMessageSizeIsValid(Int32 messageSize)
         at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer(CancellationToken cancellationToken)
         --- End of inner exception stack trace ---
         at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer(CancellationToken cancellationToken)
         at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer(Int32 responseTo, CancellationToken cancellationToken)
      --- End of stack trace from previous location ---
         at MongoDB.Driver.Core.Connections.BinaryConnection.Dropbox.RemoveMessage(Int32 responseTo)
         at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveBuffer(Int32 responseTo, CancellationToken cancellationToken)
         at MongoDB.Driver.Core.Connections.BinaryConnection.ReceiveMessage(Int32 responseTo, IMessageEncoderSelector encoderSelector, MessageEncoderSettings messageEncoderSettings, CancellationToken cancellationToken)
         at MongoDB.Driver.Core.WireProtocol.CommandUsingQueryMessageWireProtocol`1[[MongoDB.Bson.BsonDocument, MongoDB.Bson, Version=2.19.2.0, Culture=neutral, PublicKeyToken=null]].Execute(IConnection connection, CancellationToken cancellationToken)
         at MongoDB.Driver.Core.WireProtocol.CommandWireProtocol`1[[MongoDB.Bson.BsonDocument, MongoDB.Bson, Version=2.19.2.0, Culture=neutral, PublicKeyToken=null]].Execute(IConnection connection, CancellationToken cancellationToken)
         at MongoDB.Driver.Core.Connections.HelloHelper.GetResult(IConnection connection, CommandWireProtocol`1 helloProtocol, CancellationToken cancellationToken)
         at MongoDB.Driver.Core.Connections.ConnectionInitializer.SendHello(IConnection connection, CancellationToken cancellationToken)
         at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelper(CancellationToken cancellationToken)
         --- End of inner exception stack trace ---
         at MongoDB.Driver.Core.Connections.BinaryConnection.OpenHelper(CancellationToken cancellationToken)
         at MongoDB.Driver.Core.Connections.BinaryConnection.Open(CancellationToken cancellationToken)
         at MongoDB.Driver.Core.Servers.ServerMonitor.InitializeConnection(CancellationToken cancellationToken)
         at MongoDB.Driver.Core.Servers.ServerMonitor.Heartbeat(CancellationToken cancellationToken)", LastHeartbeatTimestamp: "2023-06-12T14:03:57.6330997Z", LastUpdateTimestamp: "2023-06-12T14:03:57.6331002Z" }] }.
         at MongoDB.Driver.Core.Clusters.Cluster.ThrowTimeoutException(IServerSelector selector, ClusterDescription description)
         at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChangedHelper.HandleCompletedTask(Task completedTask)
         at MongoDB.Driver.Core.Clusters.Cluster.WaitForDescriptionChanged(IServerSelector selector, ClusterDescription description, Task descriptionChangedTask, TimeSpan timeout, CancellationToken cancellationToken)
         at MongoDB.Driver.Core.Clusters.Cluster.SelectServer(IServerSelector selector, CancellationToken cancellationToken)
         at MongoDB.Driver.MongoClient.AreSessionsSupportedAfterServerSelection(CancellationToken cancellationToken)
         at MongoDB.Driver.MongoClient.AreSessionsSupported(CancellationToken cancellationToken)
         at MongoDB.Driver.MongoClient.StartImplicitSession(CancellationToken cancellationToken)
         at MongoDB.Driver.OperationExecutor.StartImplicitSession(CancellationToken cancellationToken)
         at MongoDB.Driver.MongoCollectionImpl`1[[MongoDB.Bson.BsonDocument, MongoDB.Bson, Version=2.19.2.0, Culture=neutral, PublicKeyToken=null]].UsingImplicitSession[BulkWriteResult`1](Func`2 func, CancellationToken cancellationToken)
         at MongoDB.Driver.MongoCollectionImpl`1[[MongoDB.Bson.BsonDocument, MongoDB.Bson, Version=2.19.2.0, Culture=neutral, PublicKeyToken=null]].BulkWrite(IEnumerable`1 requests, BulkWriteOptions options, CancellationToken cancellationToken)
         at MongoDB.Driver.MongoCollectionBase`1.<>c__DisplayClass68_0[[MongoDB.Bson.BsonDocument, MongoDB.Bson, Version=2.19.2.0, Culture=neutral, PublicKeyToken=null]].<InsertOne>b__0(IEnumerable`1 requests, BulkWriteOptions bulkWriteOptions)
         at MongoDB.Driver.MongoCollectionBase`1[[MongoDB.Bson.BsonDocument, MongoDB.Bson, Version=2.19.2.0, Culture=neutral, PublicKeyToken=null]].InsertOne(BsonDocument document, InsertOneOptions options, Action`2 bulkWrite)
         at MongoDB.Driver.MongoCollectionBase`1[[MongoDB.Bson.BsonDocument, MongoDB.Bson, Version=2.19.2.0, Culture=neutral, PublicKeyToken=null]].InsertOne(BsonDocument document, InsertOneOptions options, CancellationToken cancellationToken)
         at MongoDBCRUDExample.Program.Main(String[] args)

      I have a fix ready for the bug.

            Assignee:
            robert@mongodb.com Robert Stam
            Reporter:
            manas.sahu.212@gmail.com Manas Sahu
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: