-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
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
Labels
No labels