gortiz commented on code in PR #18519:
URL: https://github.com/apache/pinot/pull/18519#discussion_r3266806763


##########
pinot-query-runtime/src/test/java/org/apache/pinot/query/mailbox/GrpcSenderBackpressureReproTest.java:
##########
@@ -0,0 +1,237 @@
+/**
+ * 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.query.mailbox;
+
+import java.util.Locale;
+import java.util.Map;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicLong;
+import org.apache.pinot.common.datatable.StatMap;
+import org.apache.pinot.common.utils.DataSchema;
+import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
+import org.apache.pinot.query.planner.physical.MailboxIdUtils;
+import org.apache.pinot.query.runtime.blocks.RowHeapDataBlock;
+import org.apache.pinot.query.runtime.operator.MailboxSendOperator;
+import org.apache.pinot.query.runtime.operator.OperatorTestUtil;
+import org.apache.pinot.query.testutils.QueryTestUtils;
+import org.apache.pinot.spi.config.instance.InstanceType;
+import org.apache.pinot.spi.env.PinotConfiguration;
+import org.apache.pinot.spi.query.QueryThreadContext;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import static org.testng.Assert.assertTrue;
+
+
+/// Validates the sender-side gRPC back-pressure described in 
`grpc-oom-analysis.md`.
+///
+/// A "fast sender" tries to push the same small data block over and over on 
the
+/// test thread while a "slow reader" thread polls the receiving mailbox at
+/// roughly 50 blocks per second. With back-pressure in place, the sender 
thread
+/// blocks inside [GrpcSendingMailbox.awaitReady] whenever the gRPC outbound
+/// queue fills, so the send rate tracks the polling rate plus a bounded
+/// in-flight pipeline (gRPC HTTP/2 stream window + Netty WriteQueue + the
+/// receiver's bounded mailbox queue).
+///
+/// We assert two complementary properties:
+///  1. `sendCount` is bounded by `polledCount` plus a generous in-flight
+///     allowance — pre-fix the ratio was ~1700x, which would still fail this
+///     check by orders of magnitude.
+///  2. The peak growth of the sender's client allocator stays under a small
+///     constant — pre-fix it reached 50+ MB in 3 s, post-fix we expect at most
+///     one or two Netty pool chunks.
+///
+/// The thresholds are intentionally generous; tightening them would require
+/// per-channel Netty watermark tuning, which is deferred to a follow-up.
+public class GrpcSenderBackpressureReproTest {

Review Comment:
   Added in commit `fc507c23f2` ("Add CI test that the back-pressure 
kill-switch actually disables the gate"). The new 
`GrpcSenderBackpressureDisabledTest` mirrors the enabled-path repro but with 
`pinot.query.runner.grpc.sender.backpressure.enabled=false`, and asserts the 
sender pushes orders of magnitude more blocks than the slow reader polls 
(`sendCount > polledCount * 10` — actual ratio in CI is ~6450×). A refactor 
that broke the `bypassReady || !_backpressureEnabled` short-circuit at 
`GrpcSendingMailbox.java:373` would push that ratio back down toward the 
enabled-test's ~35× and fail loudly. The two tests pin both sides of the 
boolean.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to