Skip to content

Excessive number of open cursors #28

@piotrlg9

Description

@piotrlg9

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions