[SERVER-72473] Error about $_internalChangeStreamOplogMatch when trying to use $changeStream in a pipeline Created: 03/Jan/23  Updated: 04/Jan/23  Resolved: 04/Jan/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 6.0.3
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Radu D Assignee: Unassigned
Resolution: Done Votes: 0
Labels: changestreams
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:

Watch a collection with $changeStream in the pipeline.

Participants:

 Description   

I'm trying to watch a collection, but whenever $changeStream is part of the pipeline, I get the following error:

Command failed (Location40602): $_internalChangeStreamOplogMatch is only valid as the first stage in a pipeline

It doesn't matter what I set $changeStream to, or if it's alone or with other stages in the pipeline, I always get this error. I tried both with Rust and Node.js and I get the same error. This is the Rust code I'm using:

let stream_pipeline = Some(doc! {
    "$changeStream" : {
        "fullDocument": "updateLookup"
{{    }}}
});
{{}}

let stream = collection.watch(stream_pipeline, None).await?;{}

I'm using the "mongodb" 2.3.1 crate, Rust 1.66.0, MongoDB server 6.0.3, on macOS 13.1, Apple M1 Pro CPU. For Node.js I used the "mongodb" 4.13.0 package with Node.js 16.14.2.



 Comments   
Comment by Yuan Fang [ 04/Jan/23 ]

Hi radu.dineiu@gmail.com,

Thank you for following up and I'm glad to hear your problem has been resolved! I'm closing this ticket.

Regards,
Yuan

Comment by Radu D [ 03/Jan/23 ]

I didn't use this correctly. If I use fullDocument: updateLookup as an option to watch(), it works as expected.

Generated at Thu Feb 08 06:21:54 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.