[SERVER-9929] audit code for unprotected ScopedDbConnection and ShardConnection constructor calls Created: 13/Jun/13  Updated: 06/Dec/22  Resolved: 12/Jul/18

Status: Closed
Project: Core Server
Component/s: Internal Client, Sharding
Affects Version/s: 2.5.1
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Greg Studer Assignee: [DO NOT USE] Backlog - Sharding Team
Resolution: Done Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Sharding
Participants:

 Description   

... since these calls can fail with a DBException on failure to connect, failure to auth (in authenticated systems), or failure to initShardVersion (for ShardConnections). Need to be careful about unintended exception codepaths, and these are hard to catch during testing since the failure depends on conn pooling.

For example:

ScopedDbConn conn(...);
Type result;
try {
   result = conn->doSomething();
}
catch( const DBException& ex ){
   ...
}
done();

is not exception-safe. Should be:

Type result;
try { 
  ScopedDbConn conn(...);
  result = conn.doSomething();
  conn.done();
}
catch( const DBException& ex ) {
   ...
}



 Comments   
Comment by Gregory McKeon (Inactive) [ 12/Jul/18 ]

We've thrown out a lot of these, and won't be auditing for more.

Comment by Mathias Stearn [ 10/Oct/13 ]

The above two commits were supposed to be on SERVER-9927

Comment by auto [ 10/Oct/13 ]

Author:

{u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}

Message: SERVER-9929 Add socket_poll.cpp to libmongoclient
Branch: master
https://github.com/mongodb/mongo/commit/bf312205b5e5c9f6bdf1d0968c3fe601430f8a38

Comment by auto [ 10/Oct/13 ]

Author:

{u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}

Message: SERVER-9929 Pull in WSAPoll from dll on windows

It is only available in Vista+

This commit also reverts f3ebed0f3ab8e1cf0df752fb9e44875ed1e3849d to reenable
jstests/sharding/shard_kill_and_pooling.js
Branch: master
https://github.com/mongodb/mongo/commit/3b33315ab3dedf8314eb3da126dd0fc56555deb9

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