I have an application that runs change streams on various collections, against a replica set with 3 nodes that were on 4.0.28, and when upgrading the db deployment from 4.0 => 4.2 => 4.4 (we can’t upgrade directly to 4.4), the application began throwing the following error:
Resume of change stream was not possible, as the resume point may no longer be in the oplog., ‘stack’: MongoError: Resume of change stream was not possible, as the resume point may no longer be in the oplog.
The error is ChangeStreamHistoryLost, code 286.
I’m trying to identify the root cause of the issue but it’s difficult to replicate because:
- Atlas won’'t allow another deployment on 4.0.x
- This issue doesn’t always occur. Another staging environment was upgraded and didn’t experience this.
I don’t believe it’s an incompatibility with our app and our DB deployment, since re-deploying the app fixed the issue.
I noticed that during our version upgrades, the primary was restarted and a secondary replica was elected the new primary. Is it possible that during an election of a new primary, oplogs may be lost?