[SERVER-46258] Fix possible race in failWithErrorCodeInRuncommand failpoint Created: 19/Feb/20  Updated: 29/Oct/23  Resolved: 21/Feb/20

Status: Closed
Project: Core Server
Component/s: Replication
Affects Version/s: None
Fix Version/s: 4.3.4

Type: Bug Priority: Major - P3
Reporter: Jason Chan Assignee: Jason Chan
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Repl 2020-02-24
Participants:

 Description   

The way that the failWithErrorCodeInRunCommand failpoint is currently implemented is possibly racey.

The check against shouldFail only indicates the failpoint was active at that particular instant and it is possible that the failpoint gets turned off immediately after, meaning the following call to 'getData' will fassert.

We should instead do something along the lines of

if (MONGO_UNLIKELY(failWithErrorCodeInRunCommand.scopedIf([&](const BSONObj& data){
  return data.hasField(...) ...;
}.isActive())) {
  // build error reply.
}



 Comments   
Comment by Githook User [ 21/Feb/20 ]

Author:

{'username': 'jasonjhchan', 'name': 'Jason Chan', 'email': 'jason.chan@mongodb.com'}

Message: SERVER-46258 Fix possible race in failWithErrorCodeInRuncommand failpoint
Branch: master
https://github.com/mongodb/mongo/commit/3463ea25afcbf2c07b96f043904961b5c0f04474

Generated at Thu Feb 08 05:10:57 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.