[CDRIVER-2857] Provide a reset method to be called on clients after forking Created: 16/Oct/18 Updated: 28/Oct/23 Resolved: 04/Jan/19 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | libmongoc |
| Affects Version/s: | None |
| Fix Version/s: | 1.14.0 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Rathi Gnanasekaran | Assignee: | Samantha Ritter (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||
| Epic Link: | FY2019Q4 Quick Wins (C and CXX) | ||||||||||||||||||||||||||||||||||||||||
| Description |
|
When user code forks, various resources in the client need to be protected against parallel use in both the parent and the child code. These include the following: sessions:
cursors:
connections:
See |
| Comments |
| Comment by Samantha Ritter (Inactive) [ 04/Jan/19 ] | ||||||||||||||||||||||||||||||||||||||||||||
|
After some discussion, we have decided not to implement a reset method for pooled clients. We cannot imagine a likely usage scenario for users who have a pooled client in multithreaded applications, and are still choosing to fork(). This article has convinced us that fork()ing in multithreaded programs is dangerous, and that we should not support it. Closing this ticket as 'Fixed', since the single client reset method was implemented. | ||||||||||||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 07/Dec/18 ] | ||||||||||||||||||||||||||||||||||||||||||||
|
Author: {'name': 'samantharitter', 'email': 'samantha.ritter@10gen.com', 'username': 'samantharitter'}Message: | ||||||||||||||||||||||||||||||||||||||||||||
| Comment by Jeremy Mikola [ 16/Nov/18 ] | ||||||||||||||||||||||||||||||||||||||||||||
|
jesse: I've re-purposed | ||||||||||||||||||||||||||||||||||||||||||||
| Comment by A. Jesse Jiryu Davis [ 16/Nov/18 ] | ||||||||||||||||||||||||||||||||||||||||||||
|
I think the right logic for the PHP driver is to cache a PID on a PHP-level client object when the client is created. Whenever it creates / destroys a session or cursor with a client, it should check if the current PID is the same as it was the last time it created / destroyed a session or cursor with the same client. If the PID is different, the PHP driver updates the PID cached on the client, and then calls mongoc_client_reset, and then proceeds to create / destroy the session or cursor.
Consider some sequences:
| ||||||||||||||||||||||||||||||||||||||||||||
| Comment by Kevin Albertson [ 25/Oct/18 ] | ||||||||||||||||||||||||||||||||||||||||||||
|
Similar to PERL-1012, let's create a function like mongoc_client_reset/mongoc_client_pool_reset which users can call after forking. This would clear the session pool without sending endSessions. This could also potentially solve the issue described in |