[CXX-912] The logic of func DBClientReplicaSet::isFailed() in dbclient_rs.h Created: 18/May/16 Updated: 25/May/16 Resolved: 25/May/16 |
|
| Status: | Closed |
| Project: | C++ Driver |
| Component/s: | None |
| Affects Version/s: | legacy-1.1.0, legacy-1.1.1 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Critical - P2 |
| Reporter: | ethan zhang | Assignee: | Andrew Morrow (Inactive) |
| Resolution: | Done | Votes: | 0 |
| Labels: | legacy-cxx | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Hi! I am using DBClientReplicaSet to querying a mongodb replicaset, and I found a bug in this class. In my project, I use client connection as a long keep alive connection. And everytime I reuse this client again, I must check this client whether it is ok. So I use func DBClientReplicaSet::isFailed() to check the client whether it is ok or not. But I found it always return true. I check the code below in dbclient_rs.h
In my project, I always query mongodb with the secondary node using the method DBClientReplicaSet::slaveConn(), so the client did not have the chance to init the _master member. thanks. |
| Comments |
| Comment by Andrew Morrow (Inactive) [ 24/May/16 ] | ||||||||||
|
Hi -
Please understand that the Legacy C++ driver is just that - legacy. It is headed for end-of-life in the near future. It is very unlikely to support any new MongoDB features after those features incorporated in the lergacy-1.1.0 release to support MongoDB 3.2. The arguments in favor of making any change must be extraordinarily compelling: the driver has a wide install base that relies on its existing semantics (whatever those are and however broken they may be), so changing those semantics in a stable release is very risky, and we also have new stable drivers in C and C++11 that offer much better APIs with unified semantics and high quality implementations. The legacy C++ driver has none of these things. If you want a stable driver with proper semantics, continued support, and which will reflect ongoing development in MongoDB server releases, you should use either the MongoDB C driver, or the new C++11 driver. | ||||||||||
| Comment by ethan zhang [ 24/May/16 ] | ||||||||||
Andrew, If you really want to close this issue, please do have someone else have read this issue first, Thankx. | ||||||||||
| Comment by Andrew Morrow (Inactive) [ 22/May/16 ] | ||||||||||
|
Several comments:
Alternatively, writing it with isFailed:
From the perspective of the driver maintainer, there is no documentation for the isFailed function, so its intended semantics are unclear. It is possible that the implementation for DBClientReplicaSet is in fact broken. However, I'm reluctant to change it at this point - the driver is stable, and whatever semantics that function has had, it has had for a long time. Changing it risks breaking those semantics in the case that the function is being used in the wild, no matter how odd the semantics or misguided such usage may be. So, I'm inclined to close this ticket as Wont Fix, but please let me know if you have any additional comments or questions. If you do disagree with the above analysis, it would be very helpful if you could post some code showing how you are connecting to the server, and how and why you are using isFailed. | ||||||||||
| Comment by ethan zhang [ 20/May/16 ] | ||||||||||
|
Hi, Andrew. Is it not welcomed to fix some some bugs with the old legacy driver in the mongodb community? I wish to fix the bugs in the driver, so that other develop will not be face the same question. My English written is not so much, So Which part is not clear please point to me~ | ||||||||||
| Comment by Andrew Morrow (Inactive) [ 18/May/16 ] | ||||||||||
|
You should not be making direct use of the DBClientReplicaSet class. Instead, the correct way to connect to a replica set is via the following procedure:
Could you please try connecting this way, via ConnectionString::parse and ConnectionString::connect? Also, is there a particular reason you are using the old legacy driver? I can't recommend strongly enough that you switch to the new C++11 driver if at all possible. It offers a greatly improved API and much higher quality of implementation. |