[CXX-550] the exception in the mongo-cxx-driver Created: 04/Mar/15 Updated: 06/Mar/15 Resolved: 06/Mar/15 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | API, Release |
| Affects Version/s: | legacy-1.0.0-rc1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Fly.ang | Assignee: | Andrew Morrow (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | driver, exception, legacy-cxx, query | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Attachments: |
|
| Description |
|
The application is used the driver to connect the MongoDB Server. It will failed and throw exception on sometime. I catch the exception, but the next request is failed. |
| Comments |
| Comment by Andrew Morrow (Inactive) [ 06/Mar/15 ] |
|
Hi chen610620 - You are correct: the Connection object is not thread safe, by design. The correct way to manage this is to either give every thread a thread-local connection object, or to write a thread-safe pool of connections, and have threads request and return connections from the pool. Which strategy is best depends heavily on the design of the application. I'm going to close this issue, please feel free to re-open it if you require additional help with this issue. Thanks, |
| Comment by Fly.ang [ 06/Mar/15 ] |
|
Thanks all. |
| Comment by Tyler Brock [ 04/Mar/15 ] |
|
Thank you for reporting the issue. Would it be possible to upgrade the driver to legacy-1.0.0-stable? Is it possible to share the code that is throwing the exception? It is likely that the driver will throw errors which are not shown on the server (for example when it cannot connect or is disconnected – there is a socket exception). Any additional information you could give us about the code in the application (possibly in the form of a small reproducible example or succinct explanation if you cannot provide the code iteself) would help. -Tyler |