This is an automated email from the ASF dual-hosted git repository.
xiangfu0 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 9f6f5ca10df Fix duplicate QueryErrorCode id 429 so quota rejections
decode as TOO_MANY_REQUESTS (#19676)
9f6f5ca10df is described below
commit 9f6f5ca10df5d9d3af49217d7b5b009675b3f481
Author: Samuel Papin <[email protected]>
AuthorDate: Mon Sep 28 14:09:21 2026 -0400
Fix duplicate QueryErrorCode id 429 so quota rejections decode as
TOO_MANY_REQUESTS (#19676)
TOO_MANY_REQUESTS and WORKLOAD_BUDGET_EXCEEDED both used id 429. BY_ID is
filled in declaration order, so fromErrorCode(429) returned
WORKLOAD_BUDGET_EXCEEDED. The broker therefore counted its own query-quota
rejections under the QUERY_ERROR_WORKLOAD_BUDGET_EXCEEDED meter, and a
decoded 429 was not a client error.
Nothing sends WORKLOAD_BUDGET_EXCEEDED today, so give it the unused id 430
instead of removing it from the public SPI.
Co-authored-by: spapin <[email protected]>
---
.../src/main/resources/app/pages/Query.tsx | 1 +
.../apache/pinot/spi/exception/QueryErrorCode.java | 2 +-
.../pinot/spi/exception/QueryErrorCodeTest.java | 56 ++++++++++++++++++++++
3 files changed, 58 insertions(+), 1 deletion(-)
diff --git a/pinot-controller/src/main/resources/app/pages/Query.tsx
b/pinot-controller/src/main/resources/app/pages/Query.tsx
index 42795fc8aa5..38ff5ee93bc 100644
--- a/pinot-controller/src/main/resources/app/pages/Query.tsx
+++ b/pinot-controller/src/main/resources/app/pages/Query.tsx
@@ -188,6 +188,7 @@ const queryErrorCodeMap = {
425: "BrokerRequestSend",
427: "ServerNotResponding",
429: "TooManyRequests",
+ 430: "WorkloadBudgetExceededError",
450: "InternalError",
500: "MergeResponseError",
503: "QueryCancellationError",
diff --git
a/pinot-spi/src/main/java/org/apache/pinot/spi/exception/QueryErrorCode.java
b/pinot-spi/src/main/java/org/apache/pinot/spi/exception/QueryErrorCode.java
index 78286d4f44f..a304a7d3fd9 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/exception/QueryErrorCode.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/exception/QueryErrorCode.java
@@ -56,7 +56,7 @@ public enum QueryErrorCode {
BROKER_REQUEST_SEND(425, "BrokerRequestSend",
Response.Status.SERVICE_UNAVAILABLE),
SERVER_NOT_RESPONDING(427, "ServerNotResponding",
Response.Status.SERVICE_UNAVAILABLE),
TOO_MANY_REQUESTS(429, "TooManyRequests", Response.Status.TOO_MANY_REQUESTS),
- WORKLOAD_BUDGET_EXCEEDED(429, "WorkloadBudgetExceededError",
Response.Status.TOO_MANY_REQUESTS),
+ WORKLOAD_BUDGET_EXCEEDED(430, "WorkloadBudgetExceededError",
Response.Status.TOO_MANY_REQUESTS),
INTERNAL(450, "InternalError", Response.Status.INTERNAL_SERVER_ERROR),
MERGE_RESPONSE(500, "MergeResponseError",
Response.Status.INTERNAL_SERVER_ERROR),
QUERY_CANCELLATION(503, "QueryCancellationError",
Response.Status.SERVICE_UNAVAILABLE),
diff --git
a/pinot-spi/src/test/java/org/apache/pinot/spi/exception/QueryErrorCodeTest.java
b/pinot-spi/src/test/java/org/apache/pinot/spi/exception/QueryErrorCodeTest.java
new file mode 100644
index 00000000000..dbb77f9faa1
--- /dev/null
+++
b/pinot-spi/src/test/java/org/apache/pinot/spi/exception/QueryErrorCodeTest.java
@@ -0,0 +1,56 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pinot.spi.exception;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
+
+
+/// Tests that every [QueryErrorCode] has its own id, so that
[QueryErrorCode#fromErrorCode(int)] decodes each id back
+/// to the constant that sent it.
+public class QueryErrorCodeTest {
+
+ @Test
+ public void testIdsAreUnique() {
+ Map<Integer, QueryErrorCode> codesById = new HashMap<>();
+ for (QueryErrorCode code : QueryErrorCode.values()) {
+ QueryErrorCode previous = codesById.put(code.getId(), code);
+ assertNull(previous, "Error code id " + code.getId() + " is shared by "
+ previous + " and " + code);
+ }
+ }
+
+ @Test
+ public void testFromErrorCodeReturnsConstantWithThatId() {
+ for (QueryErrorCode code : QueryErrorCode.values()) {
+ assertSame(QueryErrorCode.fromErrorCode(code.getId()), code);
+ }
+ }
+
+ @Test
+ public void testTooManyRequestsDecodesAsClientError() {
+ QueryErrorCode code = QueryErrorCode.fromErrorCode(429);
+ assertSame(code, QueryErrorCode.TOO_MANY_REQUESTS);
+ assertTrue(code.isClientError());
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]