Skip to content

Mitigate MongoDB cursor leak: synchronize next() and close() operations#13786

Merged
italojs merged 15 commits intorelease-3.3.1from
fix/infinity-cursor
Jul 17, 2025
Merged

Mitigate MongoDB cursor leak: synchronize next() and close() operations#13786
italojs merged 15 commits intorelease-3.3.1from
fix/infinity-cursor

Conversation

@italojs
Copy link
Copy Markdown
Member

@italojs italojs commented Jun 10, 2025

Note: branch base is devel because release 3.x must to be updated with devel

Description:

This PR addresses the MongoDB cursor leak issue as reported in issue #13783

Key changes:

  • Adds concurrency control to AsynchronousCursor to prevent simultaneous next() and close() calls, avoiding race conditions.
  • Ensures that when closing a cursor, any pending next operation is awaited before the cursor is actually closed.
  • Adjusts the cursor lifecycle in the tail method to guarantee the previous cursor is fully closed before creating a new one.

These changes help ensure that the killCursor command is sent to the MongoDB server before the session ends, preventing the accumulation of open cursors and improving the reliability of OPLog tailing.

@netlify
Copy link
Copy Markdown

netlify bot commented Jun 10, 2025

Deploy Preview for v3-meteor-api-docs canceled.

Name Link
🔨 Latest commit 8a52d75
🔍 Latest deploy log https://app.netlify.com/projects/v3-meteor-api-docs/deploys/6879108ba8867e00084b82d7

@netlify
Copy link
Copy Markdown

netlify bot commented Jun 10, 2025

Deploy Preview for v3-migration-docs canceled.

Name Link
🔨 Latest commit a57cf89
🔍 Latest deploy log https://app.netlify.com/projects/v3-migration-docs/deploys/68595e809489f9000856624a

@StorytellerCZ
Copy link
Copy Markdown
Collaborator

Given the severity I think this should be released standalone package patch.

@nachocodoner
Copy link
Copy Markdown
Member

I’d like to run a meteor/performance runtime check to see if the MongoDB driver upgrade starting in version 3.1.1 caused the regression.

@Grubba27 Grubba27 requested a review from radekmie June 17, 2025 13:21
@italojs italojs marked this pull request as ready for review June 18, 2025 19:49
@italojs italojs changed the base branch from devel to release-3.3.1 June 23, 2025 14:39
@italojs italojs force-pushed the fix/infinity-cursor branch from a57cf89 to 01c1845 Compare June 23, 2025 14:45
@italojs italojs force-pushed the fix/infinity-cursor branch from 01c1845 to e475952 Compare July 2, 2025 14:43
@italojs italojs force-pushed the fix/infinity-cursor branch from e475952 to 55406e5 Compare July 2, 2025 18:53
@meteor meteor deleted a comment from radekmie Jul 2, 2025
@italojs italojs force-pushed the fix/infinity-cursor branch from 929b287 to 9fcb2d6 Compare July 3, 2025 15:16
@italojs italojs force-pushed the fix/infinity-cursor branch from cdde498 to 2ea8219 Compare July 3, 2025 17:24
@italojs italojs requested a review from radekmie July 3, 2025 17:36
@italojs
Copy link
Copy Markdown
Member Author

italojs commented Jul 4, 2025

@radekmie changes addressed

@italojs italojs requested a review from Grubba27 July 4, 2025 15:56
@italojs italojs force-pushed the fix/infinity-cursor branch from acc1f3d to 2ea8219 Compare July 16, 2025 20:46
Co-authored-by: Gabriel Grubba <70247653+Grubba27@users.noreply.github.com>
@italojs italojs merged commit 723c065 into release-3.3.1 Jul 17, 2025
10 checks passed
@nachocodoner nachocodoner deleted the fix/infinity-cursor branch July 21, 2025 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OPLog tailing in Meteor 3.1 and 3.2 results in infinite number of cursors in Mongo database server

5 participants