diff --git a/client/dbclient.cpp b/client/dbclient.cpp index f2ea3ac4213..fdd1737c675 100644 --- a/client/dbclient.cpp +++ b/client/dbclient.cpp @@ -305,8 +305,6 @@ namespace mongo { b.append( "fsync", 1 ); if ( j ) b.append( "j", 1 ); - if ( wtimeout > 0 ) - b.append( "wtimeout", wtimeout ); // only affects request when greater than one node if ( w >= 1 ) @@ -314,6 +312,9 @@ namespace mongo { else if ( w == -1 ) b.append( "w", "majority" ); + if ( wtimeout > 0 ) + b.append( "wtimeout", wtimeout ); + runCommand("admin", b.obj(), info); return info; diff --git a/client/dbclient.h b/client/dbclient.h index a183f35708f..744de2a1dde 100644 --- a/client/dbclient.h +++ b/client/dbclient.h @@ -472,7 +472,7 @@ namespace mongo { /** Get error result from the last write operation (insert/update/delete) on this connection. @return error message text, or empty string if no error. */ - string getLastError(bool fsync = false, bool j = false, int w = 1, int wtimeout = 0); + string getLastError(bool fsync = false, bool j = false, int w = 0, int wtimeout = 0); /** Get error result from the last write operation (insert/update/delete) on this connection. @return full error object. @@ -480,7 +480,7 @@ namespace mongo { If "w" is -1, wait for propagation to majority of nodes. If "wtimeout" is 0, the operation will block indefinitely if needed. */ - virtual BSONObj getLastErrorDetailed(bool fsync = false, bool j = false, int w = 1, int wtimeout = 0); + virtual BSONObj getLastErrorDetailed(bool fsync = false, bool j = false, int w = 0, int wtimeout = 0); /** Can be called with the returned value from getLastErrorDetailed to extract an error string. If all you need is the string, just call getLastError() instead. diff --git a/client/syncclusterconnection.cpp b/client/syncclusterconnection.cpp index fbcdd139dc8..601cdcbd758 100644 --- a/client/syncclusterconnection.cpp +++ b/client/syncclusterconnection.cpp @@ -135,10 +135,10 @@ namespace mongo { throw UserException( 8001 , (string)"SyncClusterConnection write op failed: " + err.str() ); } - BSONObj SyncClusterConnection::getLastErrorDetailed() { + BSONObj SyncClusterConnection::getLastErrorDetailed(bool fsync, bool j, int w, int wtimeout) { if ( _lastErrors.size() ) return _lastErrors[0]; - return DBClientBase::getLastErrorDetailed(); + return DBClientBase::getLastErrorDetailed(fsync,j,w,wtimeout); } void SyncClusterConnection::_connect( string host ) { diff --git a/client/syncclusterconnection.h b/client/syncclusterconnection.h index 68dd338a408..d2374ddaa45 100644 --- a/client/syncclusterconnection.h +++ b/client/syncclusterconnection.h @@ -85,7 +85,7 @@ namespace mongo { virtual bool isFailed() const { return false; } virtual string toString() { return _toString(); } - virtual BSONObj getLastErrorDetailed(); + virtual BSONObj getLastErrorDetailed(bool fsync=false, bool j=false, int w=0, int wtimeout=0); virtual bool callRead( Message& toSend , Message& response );