Files
mongo/jstests/libs/query/uwe_utils.js
Rui Liu 3c4569fd99 SERVER-114276 Fix shard expected command type in UWE (#44281)
GitOrigin-RevId: 14396d71d112ee1b855e13211482373aca880e50
2025-11-27 14:29:24 +00:00

31 lines
894 B
JavaScript

/**
* Checks whether the unified write executor is used for sharded writes.
*/
export function isUweEnabled(db) {
return !!assert.commandWorkedOrFailedWithCode(
db.adminCommand({
getParameter: 1,
internalQueryUnifiedWriteExecutor: 1,
}),
// Allow the error when the query knob is not present.
ErrorCodes.InvalidOptions,
).internalQueryUnifiedWriteExecutor;
}
/**
* Checks whether the unified write executor uses a different write command name on the shards.
*/
export function isUweShardCmdNameChanged(cmdName) {
return ["insert", "update", "delete", "remove"].includes(cmdName);
}
/**
* Maps the write command name that the unified write executor uses on the shards.
*/
export function mapUweShardCmdName(cmdName) {
if (isUweShardCmdNameChanged(cmdName)) {
return "bulkWrite";
}
return cmdName;
}