[CDRIVER-1235] Don't log username during auth Created: 18/May/16 Updated: 11/Sep/19 Resolved: 19/May/16 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | auth |
| Affects Version/s: | 1.3.5 |
| Fix Version/s: | 1.4.0 |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Judy Han [X] | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Linux xxx 2.6.32-573.18.1.el6.x86_64 #1 SMP Wed Jan 6 11:20:49 EST 2016 x86_64 x86_64 x86_64 GNU/Linux |
||
| Description |
|
with new C++11 driver, right after retrieving the first doc from first query, following message are prompt to stdout:
Looks like it's some debug message that should not be kept in the library. I would like to suppress these information which is directly dumped to stdout. I expect mongocxx library not dump messages directly to stdout. Please let me know if I misunderstood. Please advice if this can be done without redirecting stdout with current library, or is there a plan to fix this soon. Thanks! |
| Comments |
| Comment by Judy Han [X] [ 24/Jun/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Andrew, | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 23/Jun/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Judy.Han - I don't think that valgrind report suggests the sort of memory corruption I had thought might be in play. I find the behavior you are observing very puzzling. Is it possible that _mongoc_do_init is being called more than once in the lifetime of your process? It appears that you are dynamically opening the mongocxx library (in a mode where it is statically linked to libmongoc). This is a highly unusual way to use the library, and certainly not one that we are testing. Can you explain in more detail what is going on here? Can you set a breakpoint in _mongoc_do_init and count how many times it is invoked? | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Judy Han [X] [ 22/Jun/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
problem reproduced with valgrind ("bar" is reported 2 times while I have 3 threads.)
Is there anything special I need to do regarding unload the library, maybe? | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 21/Jun/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
I recommend running your program under address sanitizer or valgrind. I suspect memory corruption. | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Judy Han [X] [ 20/Jun/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
an update: | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Judy Han [X] [ 20/Jun/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Andrew, In my code I called following in each thread: However, when I revert back to the original library, the above "bar" is not logged. (I think it got logged one time but I can not reproduced it). The auth related logs are not logged in all tests, even though a stand alone test shows the log related message in the log: suggestions? | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 13/Jun/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Judy.Han - Could you try pulling the latest code from master and working with that? I've added a line that is always logged when the logger is configured: https://github.com/mongodb/mongo-cxx-driver/blob/master/src/mongocxx/instance.cpp#L75 That should help determine whether your logger is just not logging because there is nothing to log (as now there always will be), or something else is going wrong. Also, please be aware that I'm expecting to make some changes to how the 'instance' object is managed, per | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Judy Han [X] [ 07/Jun/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Andrew, | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 04/Jun/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Judy.Han - This ticket is resolved, but I notice that you have an open question on it. Do you still need help enabling logging? | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Judy Han [X] [ 25/May/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Andrew, | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 25/May/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Judy.Han - If you build with CMake and then make, the object files should be there unless you removed the build directory. You can regenerate them by rebuilding and re-installing. | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Judy Han [X] [ 22/May/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
ah, looks that I am not able to break in src/mongocxx/instance.cpp:59 because there is no object file for it (not sure why, I followed the build instructions), how do I regenerate the object files? | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Judy Han [X] [ 22/May/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
btw, not sure if this information is helpful - when I was not calling mongocxx::instance, the authentication message showed up in stdout 3 times, one for each thread. Also I tried to add:
But still fail to break in src/mongocxx/instance.cpp:59 | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Judy Han [X] [ 22/May/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Andrew, However, in my multi-threaded app, with the same code, nothing is written to the log file. following calls:
are called before the threads are spawned and I have a new connection for each thread:
Would that be a problem? Thanks! | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 22/May/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
HI Judy.Han - That looks pretty good, I don't see anything immediately wrong that would explain why it does not appear to be getting called. Two suggestions:
I think those steps should help reveal where things are going wrong. | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Judy Han [X] [ 20/May/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Andrew,
And here is my caller:
It looks like the operator() is not called because I tried to print some random info to stdout in operator() and they did not get printed out. | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 20/May/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi - Can you provide the implementation of your logger (should be a subclass of mongocxx:logger) and how you created the instance object? Is your implementation of mongocxx::logger::operator() being called? Thanks, | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Judy Han [X] [ 20/May/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Andrew, Thanks for the update and the link. Sorry, my original code did not call mongocxx::instance object. After I added mongocxx::instance there is no messages popping to stdout any more. Thanks, | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Githook User [ 19/May/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Author: {u'username': u'ajdavis', u'name': u'A. Jesse Jiryu Davis', u'email': u'jesse@mongodb.com'}Message: Remove username from log messages, lower auth error messages from | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Andrew Morrow (Inactive) [ 19/May/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Judy.Han - If you are using the C++11 driver, you should not make any direct calls to libmongoc functions, especially ones related to initialization and termination. The fact that the C-++11 driver uses the C driver is an implementation detail that is, at least in theory, subject to change. The correct way to change the logging setup when using the C++11 driver is to provide an object implementing the mongocxx::logger interface when constructing your mongocxx::instance object. Your injected implementation of mongocxx::logger will then be called back with each log message, and can decide what to do with the message. Please note that we are expecting to make some changes around management of the mongocxx::instance object for the upcoming 3.0.2 release, please see | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by A. Jesse Jiryu Davis [ 19/May/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sorry, I missed the fact that you're using the C++11 driver. No, don't add init/cleanup calls. I'll wait for a member of the C++ driver team to comment on how to deal with logging and errors in C++. The C Driver 1.4.0 will be released in the next few months, and the logging interface won't change. The only change will be that these messages from the authentication system will be changed from INFO to DEBUG level, and the username won't be included in the log messages any more. | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Judy Han [X] [ 19/May/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Jesse, 1. I assume in case of error, error code will be passed back to the caller(s)? 2. My current code does not have direct call to mongoc, is it recommended to call mongoc_init() and mongoc_cleanup() regardless if I call mongoc_log_set_handler()? 3. my application is multi-threaded and each thread has it's own client connection, should I call mongoc_init()/mongoc_cleanup() per thread or should I call them only once for the whole program at the entrance of main() before I spawn the threads(for mongoc_init()) and right before exit point in main (for mongoc_cleanup)? Also I am not sure if any mongocxx libraries calls mongoc_init()/cleanup(), what are the rules for calling mongoc_init/cleanup()? 4. Do you know when version 1.4.0 will be available? and What the interface will be like and what impact to apps code? Do I need to remove the mongoc_init()/cleanup() and mongoc_log_default_handler() code? Thanks in advance! | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by A. Jesse Jiryu Davis [ 19/May/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Judy, you can suppress INFO-level log messages, and allow more important log messages through, like this:
We'll fix this logging in version 1.4.0. | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Judy Han [X] [ 19/May/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi David, | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by David Golden [ 18/May/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
Judy, could you please tell us what version of libmongoc you're compiling against? | |||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by David Golden [ 18/May/16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||
|
That's coming from libmongoc. I'll move this ticket to that queue. |