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

JsonSerialisation is unable to process changes from sharded collections with composite sharding key

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 2.5.0.Beta1
    • 2.5.0.Alpha2
    • mongodb-connector
    • None
    • False
    • None
    • False

      Originally discussed at https://debezium.zulipchat.com/#narrow/stream/348106-community-mongodb/topic/JsonSerialization.20getDocumentId.20for.20sharded.20deletes/near/402337403

      As per documentation of ChangeStreamDocument#getDocumentKey()

      /**
           * Returns a document containing just the _id of the changed document.
           * <p>
           * For unsharded collections this contains a single field, _id, with the
           * value of the _id of the document updated.  For sharded collections,
           * this will contain all the components of the shard key in order,
           * followed by the _id if the _id isn’t part of the shard key.
           * </p>
           *
           * @return the document key, or null if the event is not associated with a single document (e.g. a collection rename event)
           */
      

      The return document will contain all fields used as a sharding key and id field for events from sharded collection. However the code in _JsonSerialization#getDocumentIdChangeStream(BsonDocument document) assumes that only the _id field will be present.

      Additionally the separate existence of getDocumentIdChangeStream() and getDocumentIdSnapshot seems to be obsolete a the methods could be merged

            jcechace@redhat.com Jakub Čecháček
            jcechace@redhat.com Jakub Čecháček
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: