[SERVER-35083] Extend failCommand to return write concern errors Created: 18/May/18  Updated: 29/Oct/23  Resolved: 31/May/18

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

Type: Task Priority: Major - P3
Reporter: Kevin Albertson Assignee: Mathias Stearn
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Depends
depends on SERVER-35270 StringMap::count() Closed
Related
related to SERVER-35004 Add functionality to only fail specif... Closed
is related to SERVER-34551 Add failpoint to fail commands with n... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v4.0
Sprint: Platforms 2018-06-04
Participants:

 Description   

Retryable writes now retries upon receiving a write concern error. It'd be nice to add tests to check this in our spec tests.

Currently (per SERVER-34551) we can specify arbitrary error codes like the following shows:

> db.adminCommand({"configureFailPoint":  "failCommand", mode: {times:1}, data:{errorCode:11601, closeConnection:false}});
> db.runCommand('serverStatus')
db.runCommand('serverStatus');
{
	"operationTime" : Timestamp(1525994518, 1),
	"ok" : 0,
	"errmsg" : "Failing command due to 'failCommand' failpoint",
	"code" : 11601,
	"codeName" : "Interrupted",
	"$clusterTime" : {
		"clusterTime" : Timestamp(1525994518, 1),
		"signature" : {
			"hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
			"keyId" : NumberLong(0)
		}
	}
}

Can we extend the failCommand failpoint to return write concern errors? Something like the following:

> db.adminCommand({configureFailPoint:  "failCommand", mode: {times:1}, data:{errorReply: {ok: 1, writeConcernError: {code:91}}, closeConnection:false}});
> db.runCommand('serverStatus')
{
    "operationTime" : Timestamp(1525994518, 1),
    "ok" : 1,
    "writeConcernError": { "code": 91,  "codeName": "ShutdownInProgress" }
    "$clusterTime" : {
        "clusterTime" : Timestamp(1525994518, 1),
        "signature" : {
            "hash" : BinData(0,"AAAAAAAAAAAAAAAAAAAAAAAAAAA="),
            "keyId" : NumberLong(0)
        }
    }
}



 Comments   
Comment by Githook User [ 31/May/18 ]

Author:

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

Message: SERVER-35083 Add writeConcernError option to failCommand failpoint

It replaces the waitForWriteConcern logic with just adding the supplied
writeConcernError to the reply. Since it happens where we would be waiting for
write concern, it is only done for commands that support writeConcern and
happens after the command finishes (regardless of success or failure).

(cherry picked from commit 8fcb4e1bbc38f2c87ff6b63bf305e2695218f103)
Branch: v4.0
https://github.com/mongodb/mongo/commit/8c0665a4e1f6716067cb1f6120dde8ef046205e2

Comment by Githook User [ 31/May/18 ]

Author:

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

Message: SERVER-35083 Add writeConcernError option to failCommand failpoint

It replaces the waitForWriteConcern logic with just adding the supplied
writeConcernError to the reply. Since it happens where we would be waiting for
write concern, it is only done for commands that support writeConcern and
happens after the command finishes (regardless of success or failure).
Branch: master
https://github.com/mongodb/mongo/commit/8fcb4e1bbc38f2c87ff6b63bf305e2695218f103

Generated at Thu Feb 08 04:38:47 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.