Uploaded image for project: 'Couchbase .NET client library'
  1. Couchbase .NET client library
  2. NCBC-2017

Subsequent calls to MutateInBuilders cause fields to be set to null

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • Critical
    • 2.7.9
    • 2.7.8
    • library
    • None
    • 1

    Description

      From a brief test, it seems that subsequent execute calls to the same MutateInBuilder cause all of the fields being mutated in the MutateIn to be set to null.

      Example code:

      var document = new Document<dynamic>
      {
          Id = "Test",
          Content = new
          {
              name = "Couchbase"
          }
      };
       
      bucket.Upsert(document);
      var mutator = bucket.MutateIn<dynamic>("Test").Upsert("name", "Matt");
      mutator.Execute();
      Console.WriteLine(bucket.Get<dynamic>("Test"));
      mutator.Execute();
      Console.WriteLine(bucket.Get<dynamic>("Test"));
      

      Expected Results:

      {"id":"Test","cas":1562171798187409408,"token":"mt{bRef=, vbID= -1, vbUUID=-1, seqno=-1}","content":"{\"name\":\"Matt\"}"}
      {"id":"Test","cas":1562171798210478080,"token":"mt{bRef=, vbID= -1, vbUUID=-1, seqno=-1}","content":"{\"name\":\"Matt\"}"}
      

      Actual Results:

      {"id":"Test","cas":1562171798187409408,"token":"mt{bRef=, vbID= -1, vbUUID=-1, seqno=-1}","content":"{\"name\":\"Matt\"}"}
      {"id":"Test","cas":1562171798210478080,"token":"mt{bRef=, vbID= -1, vbUUID=-1, seqno=-1}","content":"{\"name\":null}"}
      

      This behavior essentially amounts to dataloss when calling the same mutateIn object multiple times.
      It should be possible to do this for error retry reasons, you can imagine that if you had a timeout you would want to check if the operation was successful and if not then run Execute() again, for example:

      var result = mutator.Execute();
      if (!result.Success) {
          mutator.Execute();
      }
      

      For reference, in Java this works as expected.

      Code:

      JsonObject arthur = JsonObject.create()
              .put("name", "Arthur")
              .put("email", "kingarthur@couchbase.com")
              .put("interests", JsonArray.from("Holy Grail", "African Swallows"));
       
      bucket.upsert(JsonDocument.create("u:king_arthur", arthur));
      MutateInBuilder build = bucket.mutateIn("u:king_arthur").upsert("name", "foo");
      build.execute();
      System.out.println(bucket.get("u:king_arthur"));
      build.execute();
      System.out.println(bucket.get("u:king_arthur"));
      

      Results:

      JsonDocument{id='u:king_arthur', cas=1562172075359141888, expiry=0, content={"name":"foo","interests":["Holy Grail","African Swallows"],"email":"kingarthur@couchbase.com"}, mutationToken=null}
      JsonDocument{id='u:king_arthur', cas=1562172075371397120, expiry=0, content={"name":"foo","interests":["Holy Grail","African Swallows"],"email":"kingarthur@couchbase.com"}, mutationToken=null}
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            jmorris Jeff Morris
            matt.carabine Matt Carabine (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes

                PagerDuty