ChangeStreamDocument.ClusterTime always throws FormatException

1

I am on Windows 7 using MongoDB.Driver 2.7.0 in a net461/netstandard2.0 dll against a local install of community server 4.0.2 with a single replica set configured.

I am listening to a change stream on a collection, but when I simply try to access the ClusterTime property of the resulting ChangeStreamDocument it throws an exception:

    private static DateTime? GetTimeStamp(ChangeStreamDocument<T> csd)
    {
        try
        {
            var clusterTime = csd.ClusterTime; // BOOM
            return clusterTime.ToNullableUniversalTime();
        }
        catch
        {
            return null;
        }
    }

  System.FormatException
  HResult=0x80131537
  Message=Cannot deserialize a 'BsonDocument' from BsonType 'Timestamp'.
  Source=MongoDB.Bson
  StackTrace:
   at MongoDB.Bson.Serialization.Serializers.SerializerBase`1.EnsureBsonTypeEquals(IBsonReader reader, BsonType bsonType)
   at MongoDB.Bson.Serialization.Serializers.BsonValueSerializerBase`1.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
   at MongoDB.Bson.Serialization.Serializers.SerializerBase`1.MongoDB.Bson.Serialization.IBsonSerializer.Deserialize(BsonDeserializationContext context, BsonDeserializationArgs args)
   at MongoDB.Bson.Serialization.IBsonSerializerExtensions.Deserialize(IBsonSerializer serializer, BsonDeserializationContext context)
   at MongoDB.Bson.Serialization.BsonSerializationInfo.DeserializeValue(BsonValue value)
   at MongoDB.Bson.Serialization.BsonDocumentBackedClass.GetValue[T](String memberName, T defaultValue)
   at Foo.GetTimeStamp(ChangeStreamDocument`1 csd) in Foo.cs:line 28

Looking at the backing document, clusterTime is indeed a Timestamp:

{
  "_id": {
    "_data": "825B9102E30000000129295A1004BFB7B7E0A5F648929251FC06F06640A2463C5F6964003C62366332623361352D313965352D343162392D386336322D396565313130393337666634000004"
  },
  "operationType": "insert",
  "clusterTime": Timestamp(1536230115, 1),
  // ... omitted
}

Is this a bug/known issue or a problem with my setup?

c#
.net
mongodb
asked on Stack Overflow Sep 6, 2018 by ultra909 • edited Sep 21, 2018 by ultra909

1 Answer

0

This has been confirmed as a bug by MongoDB.

answered on Stack Overflow Sep 21, 2018 by ultra909

User contributions licensed under CC BY-SA 3.0