mongo-java-server icon indicating copy to clipboard operation
mongo-java-server copied to clipboard

Fix 100% CPU usage when starting multiple ChangeStreams

Open jmoghisi opened this issue 4 years ago • 3 comments

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.

jmoghisi avatar Mar 24 '21 12:03 jmoghisi

@bwaldvogel please can you check this pull request.

jmoghisi avatar Apr 07 '21 06:04 jmoghisi

@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…

bwaldvogel avatar Apr 07 '21 16:04 bwaldvogel

Apologies, I missed that. Thanks for checking.

jmoghisi avatar Apr 07 '21 19:04 jmoghisi