Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When is mongodb change stream events cleared from the stream

I understand that when any watched entity of mongo is altered/added , mongo logs these changes in change streams, to which applications can listen to.

When is a single change stream event cleared , what is the maximum capacity of change stream. Are there any negative scenarios wherein log is deleted from change stream before it was notified to the subscribers due to maximum capacity restrictions.

I could not find any such data in their official page: https://docs.mongodb.com/manual/changeStreams/

like image 282
Manas Saxena Avatar asked Mar 04 '23 21:03

Manas Saxena


1 Answers

Change streams are using the oplog as the basis of its data. Thus the "maximum capacity" is based on the size of your oplog (see SERVER-13932).

As long as you're following the change stream, you should be notified of changes in real time. The size of the oplog is not an issue in this case, since you're consuming the change as it happens.

However, a change stream can be resumed using a resume token that points to a specific timestamp in the oplog. When the oplog has rolled over, this resume token is now invalid. Attempting to resume a change stream using an invalid resume token will result in an error:

resume of change stream was not possible, as the resume token was not found. {_data: <the invalid resume token>}

At this point, it's up to the application on how to proceed.

like image 97
kevinadi Avatar answered May 14 '23 17:05

kevinadi