Fix 100% CPU usage when starting multiple ChangeStreams
We have observed a bug with mongo-java-server that causes 100% CPU usage when starting multiple ChangeStreams.
The fix is to introduce a small delay before returning documents from the OpLog Cursor. This also emulates real behaviour in which a ChangeStream cursor returns only after a timeout or once data has been received from all shards.
The change also includes:
- Refactoring ChangeStream-specific behaviour into its own Cursor class.
- Introducing a TailableCursor interface in preparation for supporting Tailable Cursors.
@bwaldvogel please can you check this pull request.
@jmoghisi: Yes, as you probably saw, I’ve started reviewing this PR and I've cherry-picked a couple of commits on master.
I’ll continue when time permits…
Apologies, I missed that. Thanks for checking.