[SERVER-21569] Improve sharded error message from majority readConcern without shard support Created: 19/Nov/15  Updated: 06/Dec/22  Resolved: 31/Jul/20

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 3.2.0-rc2
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Hannes Magnusson Assignee: [DO NOT USE] Backlog - Sharding Team
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Assigned Teams:
Sharding
Participants:

 Description   

mongos> db.test.runCommand({count: "test", query: {}, readConcern: {level: "majority"}})
{
	"shards" : {
		
	},
	"cause" : {
		"ok" : 0,
		"errmsg" : "Majority read concern requested, but server was not started with --enableMajorityReadConcern.",
		"code" : 148
	},
	"code" : 148,
	"ok" : 0,
	"errmsg" : "failed on : sh01"
}

Same applies to aggregate and I imagine the others

mongos> db.test.runCommand({count: "aggregate", pipeline: {}, readConcern: {level: "majority"}})
{
	"shards" : {
		
	},
	"cause" : {
		"ok" : 0,
		"errmsg" : "Majority read concern requested, but server was not started with --enableMajorityReadConcern.",
		"code" : 148
	},
	"code" : 148,
	"ok" : 0,
	"errmsg" : "failed on : sh01"
}

Most/all drivers only expose the "errmsg", which results in the cryptic "failed on: sh01" error message being all the users see.

The cause.errmsg should probably overwrite the top-level errmsg similarly to how find does it:

mongos> db.test.runCommand({find: "test", filter: {}, readConcern: {level: "majority"}})
{
	"ok" : 0,
	"errmsg" : "Majority read concern requested, but server was not started with --enableMajorityReadConcern.",
	"code" : 148
}


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