[SERVER-16375] Replication log message about vetoing can be truncated. Created: 01/Dec/14  Updated: 04/Dec/14  Resolved: 03/Dec/14

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: None
Fix Version/s: 2.8.0-rc2

Type: Bug Priority: Major - P3
Reporter: Eric Milkie Assignee: Spencer Brody (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

Because BSONElement::toString() on a String-type element have a limit of 160 unless you explicitly tell it not to:

        case mongo::String:
            s << '"';
            if ( !full &&  valuestrsize() > 160 ) {
                s.write(valuestr(), 150);
                s << "...\"";
            }

You can end up with log messages like this:

 m31000| 2014-12-01T21:09:54.978+0000 I REPL     [ReplicationExecutor] not electing self, WIN-LPG54MQP00S:31004 would veto with 'errmsg: "I don't think WIN-LPG54MQP00S:31006 is electable because the member is not currently a secondary; member is more than 10 seconds behind the most up-to..."'



 Comments   
Comment by Githook User [ 03/Dec/14 ]

Author:

{u'username': u'stbrody', u'name': u'Spencer T Brody', u'email': u'spencer@mongodb.com'}

Message: SERVER-16375 Prevent truncating of log message about remote node vetoing us
Branch: master
https://github.com/mongodb/mongo/commit/4b3cae88318ada78ccb6e195e8aa85b61069cbb8

Comment by Andy Schwerin [ 01/Dec/14 ]

The problem here is that it's rarely appropriate to just serialize a BSONElement to a LogStreamBuilder or to a std::ostream, regardless of type and not by serializing its enclosing BSONObj. I recommend spot fixing this, by explicitly checking the "errmsg" field's type, and only logging if it's a known string. In that case, you can call msg.String() and send that to the log.

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