Skip to content

Add missing unref implementations for replset, mongos #1455

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

Merged
merged 1 commit into from
Jan 23, 2017
Merged

Add missing unref implementations for replset, mongos #1455

merged 1 commit into from
Jan 23, 2017

Conversation

zbjornson
Copy link
Contributor

Fixes NODE-728 (this.s.topology.unref is not a function when calling db.unref())

@zbjornson
Copy link
Contributor Author

@christkv have you had a chance to review this? We're using a patch in our code to add these missing methods right now.

@christkv
Copy link
Contributor

I'm planning too, however it's not trivial to check if it works correctly due to the replicaset and mongos topologies so it will take a little before this potentially is in. But I hope to have it out in the next minor release end of month.

@christkv
Copy link
Contributor

If your goal is to just exit when the pool of operations in progress is done then you should call close as the pools themselves will drain all operations before closing. Unref does not really work correctly with topologies other than a single instance.

@zbjornson
Copy link
Contributor Author

The goal is to let the process exit but still let new mongo operations be performed (e.g. there may be an HTTP server socket keeping the process alive that needs to perform queries, so we can't call close on the db). We've been using a patch I made to unref a replset in production for about a month and it's working perfectly. Could you elaborate on how it doesn't work correctly?

@christkv
Copy link
Contributor

The problem is caused by the monitoring process for replicasets, they will keep opening new sockets potentially and that means there will be sockets that are not unreffed alive and thus the process will never exit.

@christkv christkv closed this Jan 20, 2017
@christkv christkv reopened this Jan 20, 2017
@zbjornson
Copy link
Contributor Author

Ah. The same dynamic connection behavior exists for single servers too, right? Guess that particular situation hasn't occurred for us or we haven't noticed.

Maybe this could be amped up, so that once unref is called, all new connections are also unref'ed?

@christkv
Copy link
Contributor

Yes it would have to be a new state in the server.js and the driver needs to shut down monitoring. Then move to destroyed state once the connection pool is empty. I'll have a look at this next week and see if it can make the next 2.2.22 release.

@christkv christkv merged commit a83efd6 into mongodb:2.2 Jan 23, 2017
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

Successfully merging this pull request may close these issues.

2 participants