Use of $csharpnull when serializing a BsonNull whose value is C# null halts replication (and in 2.2 the secondaries crash)

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Minor - P4
    • 1.6
    • Affects Version/s: 1.5
    • Component/s: None
    • None
    • None
    • Minor Change
    • None
    • None
    • None
    • None
    • None
    • None

      The C# driver uses

      { $csharpnull : true }

      to represent a BsonNull property whose value is C# null. For example:

      public class C
      {
          public BsonNull a;
          public BsonNull b;
      }
      
      var c = new C { a = BsonNull.Value, b = null };
      Console.WriteLine(c.ToJson());
      

      results in:

      { "a" : null, "b" : { "$csharpnull" : true } }
      

      The C# driver needs to use some other representation for BsonNull values of C# null because this representation either causes replication to halt (prior to server 2.2) or the secondaries to crash (in server 2.2 rc0 and rc1).

      This is also a server bug, in the sense that no value that a client driver provides should be allowed to halt replication or crash secondaries. If the server considers this representation to be invalid then it should have been rejected outright by the primary.

              Assignee:
              Robert Stam
              Reporter:
              Robert Stam
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Created:
                Updated:
                Resolved: