We have MongoDB replica set running on 6.0 version. One of our services listens to change streams for specific collections. The command looks like this:
db.watch([ {"$addFields":{"namespace":{"$concat":["$ns.db",".","$ns.coll"]}}}, {"$match":{"$and":[{"$and":[{"ns.db":{"$regex":"db_name1|db_name2","$options":"i"}},{"$or":[{"namespace":"collection1"},{"namespace":{"$regex":"collection1|collection2","$options":"i"}}]}]}, {"operationType":{"$in":["insert","update","replace","delete"]}}]}}, {"$addFields":{"namespace":"$$REMOVE"}}], {"resumeAfter":{"_data":"resume_token"}});
Then we have an error:
Aggregate command executor error","attr":{"error":{"code":280,"codeName":"ChangeStreamFatalError","errmsg":"cannot resume stream; the resume token was not found....
The resume_token was created at 9.00AM.
We also executed rs.printReplicationInfo cmd and found out, that the first oplog event was at 7.00AM! So the oplog must contains the resume_token!
So, then why did the error happen? Why the resume_token was not found?
Thank you in advance.