Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2646

ChangeStreamDocument missing _id information on delete operation

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.6.0
    • Component/s: None
    • None

      mongo-java-driver version 3.6.0-beta2

      Following the draft tutorial from
      http://mongodb.github.io/mongo-java-driver/3.6/driver/tutorials/change-streams/

      It can be observed that ChangeStreamDocument is missing the value of _id information for delete operation.

      An example output using MongoDB Java driver when watching for a delete action:

      ChangeStreamOutput{resumeToken={ "_data" : { "$binary" : "glnyzgsAAAABRmRfaWQAZFnyx9Kt2EoTEfEpngBaEATdDjimqgNN+5iz/fXo8WsLBA==", "$type" : "00" } }, namespace=test.restaurants, fullDocument=null, operationType=OperationType{value='delete'}, updateDescription=null}
      

      The same output in mongo shell:

      {
      	"_id" : {
      		"_data" : BinData(0,"glnyzgsAAAABRmRfaWQAZFnyx9Kt2EoTEfEpngBaEATdDjimqgNN+5iz/fXo8WsLBA==")
      	},
      	"operationType" : "delete",
      	"ns" : {
      		"db" : "test",
      		"coll" : "restaurants"
      	},
      	"documentKey" : {
      		"_id" : ObjectId("59f2c7d2add84a1311f1299e")
      	}
      }
      

      Using MongoDB Python driver (master/unreleased)

       
      {u'documentKey': {u'_id': ObjectId('59f2c7d2add84a1311f1299e')}, u'_id': RawBSONDocument('B\x00\x00\x00\x05_data\x001\x00\x00\x00\x00\x82Y\xf2\xce\x0b\x00\x00\x00\x01Fd_id\x00dY\xf2\xc7\xd2\xad\xd8J\x13\x11\xf1)\x9e\x00Z\x10\x04\xdd\x0e8\xa6\xaa\x03M\xfb\x98\xb3\xfd\xf5\xe8\xf1k\x0b\x04\x00', codec_options=CodecOptions(document_class=<class 'bson.raw_bson.RawBSONDocument'>, tz_aware=False, uuid_representation=PYTHON_LEGACY, unicode_decode_error_handler='strict', tzinfo=None)), u'ns': {u'coll': u'restaurants', u'db': u'test'}, u'operationType': u'delete'}
      

      Perhaps this is because _id information is included in fullDocument section for insert, update, replace but for delete fullDocument is null. Adding documentKey as a property of ChangeStreamDocument may solve this issue.

            Assignee:
            Unassigned Unassigned
            Reporter:
            wan.bachtiar@mongodb.com Wan Bachtiar
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: