[SERVER-14527] MongoDB servers processes should only setLastError when wire writes or write commands fail. Created: 10/Jul/14  Updated: 11/Sep/14  Resolved: 14/Jul/14

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: 2.7.4

Type: Improvement Priority: Major - P3
Reporter: Andy Schwerin Assignee: Andy Schwerin
Resolution: Done Votes: 1
Labels: cap-ticket-needed
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to RUBY-789 Update test to expect new server erro... Closed
Tested
Backwards Compatibility: Minor Change
Participants:

 Description   

MongoDB servers only promise that getLastError returns meaningful information about errors in wire-protocol writes or write commands. For finds, getmores and all other commands, the error component of getLastError has unspecified meaning. By setting the lastError information higher in the call stack, when we know they won't be swallowed, we can make lastError more sensible, and also break the triangle dependency between the lasterror, network and foundation libraries.

This changes the behavior from prior versions of MongoDB, in which servers occasionally set the last error information in non-write commands and failed find operations. However, the servers were not consistent about the conditions in which they would set the information, as drivers were not expected to consult it.



 Comments   
Comment by Andy Schwerin [ 14/Jul/14 ]

The change effected in this ticket alters the error-checking behavior of getLastError only in cases where its behavior is unspecified (after non-write commands and regular finds and getmores).

Comment by Githook User [ 14/Jul/14 ]

Author:

{u'username': u'andy10gen', u'name': u'Andy Schwerin', u'email': u'schwerin@mongodb.com'}

Message: SERVER-14527 Do not setLastError in assert_util.

MongoD and MongoS set it explicitly for write commands and wire writes, and in the
forceerror command, which is better than invoking it every time an assertion is
thrown. It prevents swallowed exceptions from being reported, and obviates the
LastError::Disabled type and "last error disabled" functionality in general.
Branch: master
https://github.com/mongodb/mongo/commit/1d2bba92453e709ed62cfb21bb084edf4f754dd3

Comment by Githook User [ 14/Jul/14 ]

Author:

{u'username': u'andy10gen', u'name': u'Andy Schwerin', u'email': u'schwerin@mongodb.com'}

Message: SERVER-14527 Call setLastError explicitly on wire write failures in mongod.

Also in the forceerror command. These are the only places where we promise to set
last error information.
Branch: master
https://github.com/mongodb/mongo/commit/d7d72deffcbe47d486715e56df72fa470738bc69

Comment by Githook User [ 14/Jul/14 ]

Author:

{u'username': u'andy10gen', u'name': u'Andy Schwerin', u'email': u'schwerin@mongodb.com'}

Message: SERVER-14527 Remove erroenous expectations about setting of last error from dbtests.

Commands are not guaranteed to set last error, except for the write commands and forceerror.
This patch fixes up dbtests to not expect it.
Branch: master
https://github.com/mongodb/mongo/commit/4a81cb9824987b0e4e534091d3f3dd4a01149d98

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