-
Notifications
You must be signed in to change notification settings - Fork 266
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
Why using older version of mongodb driver. #3132
Comments
Yes, there is an specific reason for using the legacy driver. In one word: legacy :) When we started CB development (around 2013), the C++11 wasn't available. Now that C++1 is fully available and stable and the legacy driver is no longer recommended (although still working with at least MongoDB 3.4, see this post) we should migrate to C++11 driver. However, migration is not an easy task. Although most of the driver operations are encapsulated in a few places (namelly connectionOperations.cpp/h and safeMongo.cpp/h) we extensibly use BSON-related types that, as far as I remember, are also part of the legacy driver. Migration cannot be done in a single shoot and we need to define a plan, with several intermediate milestones. A first milestone could be to start using the driver in the unit tests code, mostly to gain experience an knowhow on it. Maybe you want to implement a small proof-of-concept with one unit tests file using the database (the shortest file in test/unittest/mongoBackend) so we can see how it looks like and provide feedback? :) You can have a look to hardening/poc_new_mongo_driver branch if it helps... it was an attemp of include the driver in the CMakeList.txt framework, but I wasn't able to put much time on it and at the end it didn't work. |
@fgalan I have started my investigation regarding this. But I need to know How to start with. My few questions are:
|
First of all, thank you very much for your proactivity and your will to help with so needed (and at the same time, so complex) task! :) Let me answer question by question.
I'd suggest to process the way I mention in my previous comment:
First steps would be:
If you refer to documentation, I'd suggest not touching it yet. That would be done when we have some more mature progress. I'd add in a separate comment some instruction I gather about C++11 installation, in the case it helps.
Yes and no :) Most of the interacting with MongoDB driver is encapsulated in src/lib/mongoBackend library. However, BSON stuff (e.g. |
Here it is, in the case it may help: References:
Installation system: Debian 8.10. Install required CMake 3.2 (Debian 8 comes with con CMake 2.8)
Install C driver (pre-requirement):
Install C++11 driver:
|
@fgalan Thanks for the inputs. Currently, I successfully installed latest mongocxx driver on unix system. Tested it, it is working fine. I will update you further once I proceed my work.
|
@fgalan
- Including directories for bsoncxx and mongocxx
After these changes Broker will use cxx11 standards for compiling the program. Also, we can include headers for latest mongo-cxx-driver in mogoBackend/MongoGlobal.cpp file. It won't throw any include directory errors. But as auto_ptr (Used at 14 places in mongoBackend libarary) is deprecated in cxx 11 standards, It'll raise an error while compiling the code. Any of the above will lead to the successful compilation of broker with latest mongo-cxx-driver. But replacing auto_ptr with unique_ptr in code is another problem. Some operations might be different in both smart pointers.
Program is crashing because we are using cxx 11 standards and when we initialize mongo client, it is using auto_ptr. Actually I have not used |
Hello, I'm involved in a smart city platform project using Fiware, for metropolis of Nice, in France. My intuition is many problems regarding Orion crashes with MongoDB >3.4 with some requests (like /v2/types) are mainly due to the use of the old drivers version, may be you already know ;O). We could have been satisfied with using mongo 3.4, but regarding the target production platform , the MongoDB will be in a docker swarm with clustered architecture, which is not possible in 3.4... It's been a long time I put my hands in building C++, but if I can help, tell me how, may be on Docker testing ? I've a ready to test almost complete Fiware docker based environment with a database (the data are compatible between mongo 3.4 and 3.6=>, once you don't use 3.6 new features, or I can start from empty database). Thanks in advance for your feedback on my proposal |
@saurabhjangir with regard to auto_ptr issue, if I'm understand correctly, the alternative of using unique_ptr could cause segfault in some cases. Thus, the other alternative (i.e. to use |
@agaldemas MongoDB 3.6 issues have its separate issue: #3070. I agree... it could be related with driver version. Anyway, I'd recommend you to have a look to that issue because it seems that is some scenarios (in particular, when using MongoDB 3.6 from scratch) Orion works. Thank you for you offer to help with the driver migration :) By the moment, we are in a stage of "initial research" (done mainly thanks to @saurabhjangir ). Once the things get a bit clearer, maybe we can defined specific tasks and you could help with some of them. Please stay tunned to this issue (we will use it to coordinate among ourselves). |
Hi, @fgalan |
Thanks for the report @agaldemas ! I have re-posted on the #3070 issue (the one about MongoDB 3.6 support, which, in principle, it is an independent issue from this one). (Probably migrating to C++11 driver is a sufficient condition to make Orion to work with MongoDB 3.6, but not sure if it is also a necessary condition, i.e. there could be solutions -maybe reformulating the query in the aggregation pipeline for the problematic operations- we could mae legacy driver to work with MongoDB 3.6. Further investigation needed). |
After a fruitful interchange of emails with @saurabhjangir (thanks! :), some feedback to take into account: I think one of the problems of the current codebase is that the usage of the legacy driver is spread around the code, instead of being concentrated in just a single point (or in a small set of points). Although all the DB operations (query, insert, etc.) are isolated in just a couple of modules (connectionOperations.cpp/h and safeMongo.cpp/h) the data structures used by them (BSONObj, BSON, BSONObjBuilder, etc.) are spread around the code. This lack of isolation makes the migration work more complex. So maybe before starting the migration work itself, we should focus on improving isolation in a reduced set of modules. Then replace the implementation of that modules (.cpp part) with the one corresponding to the new driver. I mean, some rough plan like this:
This approach also ensures that if in the future a new migration is needed, it would be easy (just re-implementing again a reduced set of modules but not touching the rest of the code). |
With regards to item 2 this is currently the situation (at master). The following list shows all the source code files in which the string "BSONObj" appears:
(Maybe there is some "false positive", as BSONObj could appear for instance in a comment but I think the list is pretty accurate. In addition, a similar check could be done with other key classes in the legacy driver like BSONArray, etc. but the result would be pretty much the same). At the end of task 2 what I hope to have is a reduced set of direct usages to BSONObj, BSONArray, etc. and so on. Ideally, only bsonStructures.cpp and bsonStructures.h. The current usages should be replaced by invocations to the "wrapper" exposed by bsonStructures.h. |
|
PR #3622 is implementing the actual migration of the driver. |
PR #3622 has been finally merged. Closing issue. |
According to http://fiware-orion.readthedocs.io/en/latest/admin/build_source we are using mongo-cxx-driver-legacy-1.1.2 which is not supported by the community member now. This driver is replaced by C++11 driver. You can refer https://jira.mongodb.org/browse/CXX-1526 for this.
Also, backward compatibility is not supported for MongoDB 3.4 and later releases.
Because of Issue #3119 , I raised this question in mongodb driver Community to which they replied that they are not supporting this version now. so I would like to know if there any specific reason we're still using this older version of MongoDB driver?
The text was updated successfully, but these errors were encountered: