[SERVER-8226] C++ driver fassert 16464 when runGlobalInitializersOrDie is not called Created: 18/Jan/13  Updated: 11/Jul/16  Resolved: 01/Feb/13

Status: Closed
Project: Core Server
Component/s: Internal Client
Affects Version/s: 2.2.2
Fix Version/s: 2.4.0-rc1

Type: Bug Priority: Blocker - P1
Reporter: Pieter Willem Jordaan Assignee: Randolph Tan
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux 3.5.0-21-generic x86_64
mongo 2.2.2
c++ driver latest 2013-01-15 20:02:28
boost 1.49


Issue Links:
Duplicate
duplicates CXX-99 Require driver users to runGlobalInit... Closed
Related
related to CXX-82 runGlobalInitializersOrDie returns Ba... Closed
Operating System: Linux
Steps To Reproduce:

Any C++ program with the above version which calls a find will reproduce this assert

Participants:

 Description   

Trying any find command when a replica set only contains a primary (only one server in the set) an fassert 16464 is raised in _isQueryOkToSecondary.

It must be noted that I am using a ScopedDbConnection.



 Comments   
Comment by Pieter Willem Jordaan [ 01/Feb/13 ]

Randolph thank you I appreciate it!

Comment by Randolph Tan [ 01/Feb/13 ]

climax: We changed the client driver so the user doesn't need to call runGlobalInitializersOrDie.

Comment by auto [ 01/Feb/13 ]

Author:

{u'date': u'2013-01-31T21:19:28Z', u'email': u'randolph@10gen.com', u'name': u'Randolph Tan'}

Message: SERVER-8226 C++ driver fassert 16464 when runGlobalInitializersOrDie is not called

Changed implementation to not rely on the global initialization framework.
Branch: master
https://github.com/mongodb/mongo/commit/51bcc22142234ca1d86d6675b8fe4a83b140a025

Comment by Pieter Willem Jordaan [ 18/Jan/13 ]

Thanks for clarifying. You make an excellent point.

Comment by Randolph Tan [ 18/Jan/13 ]

The main use for runGlobalInitializersOrDie is for initializing all static variables while maintaining the right order (for example, if one variable depends on another to be initialized first). This also makes the initialization more simple because we don't need to worry about protecting the data structure with mutex (which can create unnecessary points of serialization) even though we need to modify it only once in the program life time.

Comment by Pieter Willem Jordaan [ 18/Jan/13 ]

This seems rather sloppy. Can't the main db connection classes ensure that static variables get initialized during first call? Same with cleaning up at the end of the program (mongo::dbexit(mongo::EXIT_CLEAN). These things can be automated surely. At the very least there is a large gap in the documentation regarding this, especially for ScopedDbConnection usage.

Comment by Randolph Tan [ 18/Jan/13 ]

Hi,

You need to call runGlobalInitializersOrDie near the start of your program. This method is used for initializing static variables used by Mongo.

Generated at Thu Feb 08 03:16:52 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.