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

System.IO.EndOfStreamException when iterating change stream cursor

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.5
    • None

      I got following exception when tried to resume watching changes in collection with new change stream feature in MongoDB 3.6.

      This error happened on 2 out of 6 collections I watched. It started occurring after 6-12 hours and it worked normally before. To resolve it I needed to restart watching for the events without resume token which is unfortunate because it can cause loss of information in my system.

      System.IO.EndOfStreamException: Attempted to read past the end of the stream.
      at void MongoDB.Bson.IO.BsonStreamExtensions.ReadBytes(BsonStream stream, byte[] buffer, int offset, int count)
      at int MongoDB.Bson.IO.BsonStreamAdapter.ReadInt32()
      at int MongoDB.Bson.IO.BsonBinaryReader.ReadSize()
      at void MongoDB.Bson.IO.BsonBinaryReader.ReadStartDocument()
      at BsonDocument MongoDB.Bson.Serialization.Serializers.BsonDocumentSerializer.DeserializeValue(BsonDeserializationContext context, BsonDeserializationArgs args)
      at TBsonValue MongoDB.Bson.Serialization.Serializers.BsonValueSerializerBase<TBsonValue>.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
      at TValue MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize<TValue>(IBsonSerializer<TValue> serializer, BsonDeserializationContext context)
      at BsonValue MongoDB.Bson.Serialization.Serializers.BsonValueSerializer.DeserializeValue(BsonDeserializationContext context, BsonDeserializationArgs args)
      at TBsonValue MongoDB.Bson.Serialization.Serializers.BsonValueSerializerBase<TBsonValue>.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
      at TValue MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize<TValue>(IBsonSerializer<TValue> serializer, BsonDeserializationContext context)
      at BsonDocument MongoDB.Bson.Serialization.Serializers.BsonDocumentSerializer.DeserializeValue(BsonDeserializationContext context, BsonDeserializationArgs args)
      at TBsonValue MongoDB.Bson.Serialization.Serializers.BsonValueSerializerBase<TBsonValue>.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
      at TValue MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize<TValue>(IBsonSerializer<TValue> serializer, BsonDeserializationContext context)
      at BsonValue MongoDB.Bson.Serialization.Serializers.BsonValueSerializer.DeserializeValue(BsonDeserializationContext context, BsonDeserializationArgs args)
      at TBsonValue MongoDB.Bson.Serialization.Serializers.BsonValueSerializerBase<TBsonValue>.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
      at TValue MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize<TValue>(IBsonSerializer<TValue> serializer, BsonDeserializationContext context)
      at BsonDocument MongoDB.Bson.Serialization.Serializers.BsonDocumentSerializer.DeserializeValue(BsonDeserializationContext context, BsonDeserializationArgs args)
      at TBsonValue MongoDB.Bson.Serialization.Serializers.BsonValueSerializerBase<TBsonValue>.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
      at TValue MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize<TValue>(IBsonSerializer<TValue> serializer, BsonDeserializationContext context)
      at ChangeStreamDocument<TDocument> MongoDB.Driver.ChangeStreamDocumentSerializer<TDocument>.DeserializeValue(BsonDeserializationContext context, BsonDeserializationArgs args)
      at TValue MongoDB.Bson.Serialization.Serializers.SealedClassSerializerBase<TValue>.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
      at TValue MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize<TValue>(IBsonSerializer<TValue> serializer, BsonDeserializationContext context)
      at TDocument MongoDB.Driver.Core.Operations.ChangeStreamCursor<TDocument>.DeserializeDocument(RawBsonDocument rawDocument)
      at IEnumerable<TDocument> MongoDB.Driver.Core.Operations.ChangeStreamCursor<TDocument>.DeserializeDocuments(IEnumerable<RawBsonDocument> rawDocuments)
      at void MongoDB.Driver.Core.Operations.ChangeStreamCursor<TDocument>.ProcessBatch(bool hasMore)
      at async Task<bool> MongoDB.Driver.Core.Operations.ChangeStreamCursor<TDocument>.MoveNextAsync(CancellationToken cancellationToken)

            Assignee:
            wan.bachtiar@mongodb.com Wan Bachtiar
            Reporter:
            andrii.litvinov@gmail.com Andrii Litvinov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: