Uploaded image for project: 'Debezium'
  1. Debezium
  2. DBZ-989

UnwrapFromMongoDbEnvelope fails when encountering Tombstone messages

    XMLWordPrintable

Details

    Description

      Context

      When a document is deleted on a MongoDB Collection 2 messages will appear:

      • First being a delete operation as in the oplog
        SourceRecord{sourcePartition={rs=rs0, server_id=mongo}, sourceOffset={sec=1542546121, ord=3, h=8008529886791156268}} ConnectRecord{topic='mongo.transform.source', kafkaPartition=null, key=Struct{id=1}, value=Struct{source=Struct{version=0.9.0-SNAPSHOT,connector=mongodb,name=mongo,rs=rs0,ns=transform.source,sec=1542546121,ord=3,h=8008529886791156268},op=d,ts_ms=1542546121897}, timestamp=null, headers=ConnectHeaders(headers=)}
        
      • Second a Tombstone message which value is null
        SourceRecord{sourcePartition={rs=rs0, server_id=mongo}, sourceOffset={sec=1542546121, ord=3, h=8008529886791156268}} ConnectRecord{topic='mongo.transform.source', kafkaPartition=null, key=Struct{id=1}, value=null, timestamp=null, headers=ConnectHeaders(headers=)}
        

      How to reproduce

      In a connector with UnwrapFromMongoDbEnvelope enabled, delete a document within the collection.

      The result is as follows:

      java.lang.NullPointerException
      	at io.debezium.connector.mongodb.transforms.UnwrapFromMongoDbEnvelope.apply(UnwrapFromMongoDbEnvelope.java:125)
      	at io.debezium.connector.mongodb.transforms.UnwrapFromMongoDbEnvelopeTestIT.shouldTransformEvents(UnwrapFromMongoDbEnvelopeTestIT.java:148)
      

      Reason

      It happens because the Tombstone message has no value nor valueSchema, this part of the transformer UnwrapFromMongoDbEnvelopeTestIT.java:148 depends on the valueSchema to exist which isn't true for the tombstone

      Attachments

        Issue Links

          Activity

            People

              renatomefi Renato Mefi (Inactive)
              renatomefi Renato Mefi (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: