Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-66808

Remove undocumented fields from the change stream error

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 6.0.1, 6.1.0-rc0
    • Affects Version/s: 6.0.0-rc7
    • Component/s: Change streams
    • None
    • Fully Compatible
    • ALL
    • v6.0
    • QE 2022-06-27, QE 2022-07-11

      When change stream errors because pre-image is not available it returns `preImageId` and `rawOplogUpdateSpec`.

      Open a change stream with pre or post image required on a collection that doesn't have pre-images enabled

      watch = db.col.aggregate([{ $changeStream: { fullDocument: "required"} }]) 

      Make an update to collection

      db.col.insertOne({a:1})
      db.col.updateOne({}, {$set: {a:2}})

      Read the change stream

      watch.tryNext() 

      For update event it produces an error like this if you requested post-image:

      MongoServerError: Executor error during getMore :: caused by :: Change stream was configured to require a post-image for all update, delete and replace events, but the post-image was not found for event: {rawOplogUpdateSpec: {$v: 2, diff: {u: {a: 2}}}, _id: {_data: "82628FB979000000012B022C0100296E5A1004EC71121BA6E44B5D97FB01ED73D7A21046645F69640064628FB966D440719E7C9887A00004"}, operationType: "update", clusterTime: Timestamp(1653586297, 1), wallTime: 2022-05-26T17:31:37.351Z, preImageId: {nsUUID: BinData(4, "EC71121BA6E44B5D97FB01ED73D7A210"), ts: Timestamp(1653586297, 1), applyOpsIndex: 0}, ns: {db: "test", coll: "col"}, documentKey: {_id: 628fb966d440719e7c9887a0}, updateDescription: {updatedFields: {a: 2}, removedFields: [], truncatedArrays: []}}

      Or like this if pre-image was requested:

      MongoServerError: Executor error during getMore :: caused by :: Change stream was configured to require a pre-image for all update, delete and replace events, but the pre-image was not found for event: {rawOplogUpdateSpec: {$v: 2, diff: {u: {a: 2}}}, _id: {_data: "82628FB90E000000012B022C0100296E5A1004E544309D04C54ACDA8D747782D1ADB5446645F69640064628FB908D440719E7C98879F0004"}, operationType: "update", clusterTime: Timestamp(1653586190, 1), wallTime: 2022-05-26T17:29:50.395Z, preImageId: {nsUUID: BinData(4, "E544309D04C54ACDA8D747782D1ADB54"), ts: Timestamp(1653586190, 1), applyOpsIndex: 0}, ns: {db: "test", coll: "col"}, documentKey: {_id: 628fb908d440719e7c98879f}, updateDescription: {updatedFields: {a: 2}, removedFields: [], truncatedArrays: []}}

       

            Assignee:
            catalin.sumanaru@mongodb.com Catalin Sumanaru
            Reporter:
            kateryna.kamenieva@mongodb.com Katya Kamenieva
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: