Skip to content

PHPC-1274: Do not allow forked children to affect parent resources #1059

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 13, 2020

Conversation

jmikola
Copy link
Member

@jmikola jmikola commented Nov 12, 2019

https://jira.mongodb.org/browse/PHPC-1274

This PR will supersede both #941 and #1027

@alcaeus
Copy link
Member

alcaeus commented Nov 15, 2019

@jmikola #1060 has been merged, so you can rebase this PR on top of master once you continue working on it.

@@ -0,0 +1,102 @@
--TEST--
PHPC-1274: Session destruct should not end session from parent process
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently not functioning as a regression test, as I'm having trouble getting the child process to actually kill the session when it exits if I disable the call to mongoc_client_reset() in the Session's free_object handler.

I think this may be because the session pool is really only destroyed during the call to mongoc_client_destroy(), and PHPC purposefully avoids calling that due to 600db56 (PHPC-912). If that's the case, perhaps we can't implement a regression test for this at all and will have to make do with the "does not abort" test.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to leave this test in place despite my last comment, as it could become more relevant when we get to PHPC-1522. And even if we can't implement that (i.e. allow children to call mongoc_client_destroy() on clients created by parents), this may still be useful as our only test to demonstrate that child processes don't kill active sessions of a parent process.

@jmikola jmikola changed the title [WIP] Do not allow forked children to affect parent resources PHPC-1274: Do not allow forked children to affect parent resources Dec 17, 2019
@jmikola jmikola changed the title PHPC-1274: Do not allow forked children to affect parent resources [WIP] PHPC-1274: Do not allow forked children to affect parent resources Dec 17, 2019
@jmikola jmikola changed the title [WIP] PHPC-1274: Do not allow forked children to affect parent resources PHPC-1274: Do not allow forked children to affect parent resources Jan 3, 2020
@jmikola jmikola force-pushed the phpc-1274 branch 4 times, most recently from 6d05ac6 to 58fc57c Compare January 8, 2020 05:05
@alcaeus
Copy link
Member

alcaeus commented Jan 9, 2020

Reset logic looks sound to me. LGTM once mongoc_client_session_get_client calls have been refactored.

Check PID before creating/freeing a session or cursor to avoid interfering with resources owned by a parent process. Additionally, prohibit resetting a client multiple times to avoid cases where child resources may not be cleaned up.
jmikola added a commit that referenced this pull request Jan 13, 2020
@jmikola jmikola merged commit 9ecb50a into mongodb:master Jan 13, 2020
@jmikola jmikola deleted the phpc-1274 branch January 31, 2020 21:29
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