SERVER-113311 Attach NoWritesPerformed error label to IngressRequestRateLimiter rejections (#45805)
GitOrigin-RevId: 8763ea147e9b0e359bf6d5d1209cdabc669544ca
This commit is contained in:
parent
9d1682cb70
commit
e142ec7e13
@ -20,6 +20,8 @@ import {
|
||||
runTestStandalone,
|
||||
} from "jstests/noPassthrough/admission/libs/ingress_request_rate_limiter_helper.js";
|
||||
|
||||
const kExpectedErrorLabels = ["SystemOverloadedError", "RetryableError", "NoWritesPerformed"];
|
||||
|
||||
/**
|
||||
* Runs the set parameter commands with some arbitrary value to ensure invalid values are rejected.
|
||||
*/
|
||||
@ -114,7 +116,7 @@ function testRateLimiterMetrics(conn, exemptConn) {
|
||||
for (let i = 0; i < requestAmount; ++i) {
|
||||
const assertContainsExpectedErrorLabels = (res) => {
|
||||
assert(res.hasOwnProperty("errorLabels"), res);
|
||||
assert.sameMembers(["SystemOverloadedError", "RetryableError"], res.errorLabels);
|
||||
assert.sameMembers(kExpectedErrorLabels, res.errorLabels);
|
||||
};
|
||||
|
||||
const collName = `${jsTest.name()}_coll`;
|
||||
@ -282,7 +284,7 @@ function runTestCompressed() {
|
||||
const compressionArgs = ["--networkMessageCompressors", kCompressor];
|
||||
const shell = startParallelShell(
|
||||
funWithArgs(
|
||||
(host, params, exemptAppName, requestAmount) => {
|
||||
(host, params, exemptAppName, requestAmount, expectedLabels) => {
|
||||
const exemptConn = new Mongo(`mongodb://${host}/?appName=${exemptAppName}`);
|
||||
exemptConn.getDB("admin").auth("admin", "pwd");
|
||||
assert.commandWorked(
|
||||
@ -293,8 +295,7 @@ function runTestCompressed() {
|
||||
for (let i = 0; i < requestAmount; ++i) {
|
||||
const assertContainSystemOverloadedErrorLabel = (res) => {
|
||||
assert(res.hasOwnProperty("errorLabels"), res);
|
||||
assert.sameMembers(["SystemOverloadedError", "RetryableError"],
|
||||
res.errorLabels);
|
||||
assert.sameMembers(expectedLabels, res.errorLabels);
|
||||
};
|
||||
|
||||
const collName = `${jsTest.name()}_coll`;
|
||||
@ -313,7 +314,9 @@ function runTestCompressed() {
|
||||
mongod.host,
|
||||
JSON.stringify(kParams),
|
||||
kRateLimiterExemptAppName,
|
||||
requestAmount),
|
||||
requestAmount,
|
||||
kExpectedErrorLabels,
|
||||
),
|
||||
mongod.port,
|
||||
false,
|
||||
...compressionArgs);
|
||||
|
||||
@ -215,6 +215,7 @@ void ErrorLabelBuilder::build(BSONArrayBuilder& labels) const {
|
||||
labels << ErrorLabel::kNoWritesPerformed;
|
||||
}
|
||||
} else if (isOperationIdempotent()) {
|
||||
// TODO SERVER-108898: apply the NoWritesPerformed error label here too, if appropriate.
|
||||
labels << ErrorLabel::kRetryableError;
|
||||
}
|
||||
}
|
||||
|
||||
@ -744,6 +744,9 @@ DbResponse makeDbResponseErrorForRateLimiting(const Message& message, const Stat
|
||||
BSONArrayBuilder arrayBuilder(commandBodyBob.subarrayStart(kErrorLabelsFieldName));
|
||||
arrayBuilder.append(ErrorLabel::kSystemOverloadedError);
|
||||
arrayBuilder.append(ErrorLabel::kRetryableError);
|
||||
// It can't be determined whether the request being rejected is a write or not without
|
||||
// deserializing it, so we just always append the NoWritesPerformed label.
|
||||
arrayBuilder.append(ErrorLabel::kNoWritesPerformed);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user