Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excessive number of open cursors #28

Open
piotrlg9 opened this issue Jan 3, 2024 · 0 comments
Open

Excessive number of open cursors #28

piotrlg9 opened this issue Jan 3, 2024 · 0 comments

Comments

@piotrlg9
Copy link
Contributor

piotrlg9 commented Jan 3, 2024

Current change event loop probably leads to many cursor objects being created and left for GC - this can lead to performance issues (it's not a memory leak per se, but it generates unwanted objects).

Example:

  • after few minues number of MongoChangeStreamCursorImpl objects is 1274 (this should be equal to number of partitions)

Current loop scheme (MongoChangeStreamWorker.run):

        do {
            try (var cursor = changeStream.cursor()) { // constant re-creation of cursor
                ChangeStreamDocument<Document> document = cursor.tryNext();
                if (document != null) {
                //... section A
                }
       } while (true);

This code in "section A" handles just one document and then worker re-creates the cursor.

Cursor re-creation may be required but should be limited by some integer counter or time limit (e.g. re-create after n nulls returned by tryNext calls or after m milliseconds whatever goes first.

meehaws added a commit that referenced this issue Aug 1, 2024
…connection

#28 Add reusing of cursor, fix potential memory leak with MongoConnection
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant