Jackie-Jiang commented on code in PR #18784:
URL: https://github.com/apache/pinot/pull/18784#discussion_r3431041270
##########
pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerMeter.java:
##########
@@ -45,6 +45,8 @@ public enum ServerMeter implements AbstractMetrics.Meter {
REALTIME_ROWS_SANITIZED("rows", true),
REALTIME_ROWS_FETCHED("rows", false),
REALTIME_ROWS_FILTERED("rows", false),
+ REALTIME_INGESTION_OOM_PROTECTION_THROTTLED("count", false,
Review Comment:
Given we already have a gauge, do you see this useful?
We should control the per table metrics. We already observe issues when a
cluster has a lot of tables
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/RealtimeSegmentDataManager.java:
##########
@@ -566,6 +577,8 @@ protected boolean consumeLoop()
}
}
+ // Release the fetched batch before the next iteration can wait under
ingestion OOM protection.
+ messageBatch = null;
Review Comment:
This seems unnecessary. It is already a local variable within the loop
##########
pinot-common/src/main/java/org/apache/pinot/common/metrics/ServerGauge.java:
##########
@@ -94,6 +94,10 @@ public enum ServerGauge implements AbstractMetrics.Gauge {
UPSERT_QUERYABLE_DOCS_IN_SNAPSHOT_COUNT("upsertQueryableDocIdsInSnapshot",
false),
REALTIME_INGESTION_OFFSET_LAG("offsetLag", false,
"The difference between latest message offset and the last consumed
message offset."),
+ REALTIME_INGESTION_OOM_PROTECTION_ACTIVE("boolean", false,
+ "Binary indicator (1 or 0) for whether realtime ingestion is currently
blocked by server OOM protection."),
+ REALTIME_INGESTION_OOM_PROTECTION_HEAP_USAGE_PERCENT("percentage", false,
Review Comment:
This shouldn't be emitted under the scope of real-time ingestion. I think it
is a useful gauge. Can we emit it as one global gauge?
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/ServerIngestionOomProtectionManager.java:
##########
@@ -0,0 +1,323 @@
+/**
+ * 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.core.data.manager.realtime;
+
+import com.google.common.annotations.VisibleForTesting;
+import java.util.Locale;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.function.BooleanSupplier;
+import java.util.function.LongSupplier;
+import java.util.function.Supplier;
+import javax.annotation.Nullable;
+import org.apache.pinot.common.metrics.ServerGauge;
+import org.apache.pinot.common.metrics.ServerMeter;
+import org.apache.pinot.common.metrics.ServerMetrics;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.config.table.ingestion.IngestionConfig;
+import
org.apache.pinot.spi.config.table.ingestion.ServerIngestionOomProtectionConfig;
+import org.apache.pinot.spi.config.table.ingestion.StreamIngestionConfig;
+import org.apache.pinot.spi.env.PinotConfiguration;
+import org.apache.pinot.spi.utils.CommonConstants;
+import org.apache.pinot.spi.utils.ResourceUsageUtils;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/// Applies server-local backpressure to realtime ingestion while JVM heap
usage is above a configured threshold.
+public class ServerIngestionOomProtectionManager {
+ private static final Logger LOGGER =
LoggerFactory.getLogger(ServerIngestionOomProtectionManager.class);
+ private static final long ACTIVE_LOG_INTERVAL_MS =
TimeUnit.MINUTES.toMillis(1);
Review Comment:
We should probably just log at check interval. One log line per 3 seconds is
fine across all tables given the severity of ingestion stall
--
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]