You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/08/18 21:16:46 UTC
[GitHub] [pinot] jadami10 opened a new pull request, #9244: add a freshness based consumption status checker
jadami10 opened a new pull request, #9244:
URL: https://github.com/apache/pinot/pull/9244
This is a new `feature` to allow setting a freshness threshold for servers to catch up to before going healthy and serving queries.
- This will supercede the offset based checker if that is set
- This will wait until:
- your current offset is within 1 of the latest offset
- your latest ingested timestamp is non negative and within the desired threshold
- will not work if you set a 0 or negative freshness
This still requires and respects the overall realtime "wait" variable so we never get stuck forever.
This was tested in an internal QA cluster. We actually hit all cases:
- partitions with 0 offset with no messages were caught up
- partitions in error state waited the full time until going healthy
- partitions that were not fresh but then caught up
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] jadami10 commented on pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
jadami10 commented on PR #9244:
URL: https://github.com/apache/pinot/pull/9244#issuecomment-1227531622
@mcvsubbu and @sajjad-moradi, are you ok to accept this PR as is?
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] jadami10 commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
jadami10 commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r952070577
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/LLRealtimeSegmentDataManager.java:
##########
@@ -308,9 +308,9 @@ private boolean endCriteriaReached() {
_consumeEndTime += TimeUnit.HOURS.toMillis(TIME_EXTENSION_ON_EMPTY_SEGMENT_HOURS);
return false;
}
- _segmentLogger
- .info("Stopping consumption due to time limit start={} now={} numRowsConsumed={} numRowsIndexed={}",
- _startTimeMs, now, _numRowsConsumed, _numRowsIndexed);
+ _segmentLogger.info(
Review Comment:
sorry for all the changes here. `Reformat Code` in the IDE did all this. happy to undo it if prefered
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] sajjad-moradi commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
sajjad-moradi commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r955466762
##########
pinot-server/src/main/java/org/apache/pinot/server/starter/helix/IngestionBasedConsumptionStatusChecker.java:
##########
@@ -0,0 +1,97 @@
+/**
+ * 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.server.starter.helix;
+
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.pinot.common.utils.LLCSegmentName;
+import org.apache.pinot.core.data.manager.InstanceDataManager;
+import org.apache.pinot.core.data.manager.realtime.LLRealtimeSegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.SegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.TableDataManager;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public abstract class IngestionBasedConsumptionStatusChecker {
+ protected final Logger _logger = LoggerFactory.getLogger(getClass());
+
+ // constructor parameters
+ protected final InstanceDataManager _instanceDataManager;
+ protected final Set<String> _consumingSegments;
+
+ // helper variable
+ private final Set<String> _caughtUpSegments = new HashSet<>();
+
+ public IngestionBasedConsumptionStatusChecker(InstanceDataManager instanceDataManager,
+ Set<String> consumingSegments) {
+ _instanceDataManager = instanceDataManager;
+ _consumingSegments = consumingSegments;
+ }
+
+ public int getNumConsumingSegmentsNotReachedIngestionCriteria() {
+ for (String segName : _consumingSegments) {
+ if (_caughtUpSegments.contains(segName)) {
+ continue;
+ }
+ TableDataManager tableDataManager = getTableDataManager(segName);
+ if (tableDataManager == null) {
+ _logger.info("TableDataManager is not yet setup for segment {}. Will check consumption status later", segName);
+ continue;
+ }
+ SegmentDataManager segmentDataManager = null;
+ try {
+ segmentDataManager = tableDataManager.acquireSegment(segName);
+ if (segmentDataManager == null) {
+ _logger.info("SegmentDataManager is not yet setup for segment {}. Will check consumption status later",
+ segName);
+ continue;
+ }
+ if (!(segmentDataManager instanceof LLRealtimeSegmentDataManager)) {
+ // There's a possibility that a consuming segment has converted to a committed segment. If that's the case,
+ // segment data manager will not be of type LLRealtime.
+ _logger.info("Segment {} is already committed and is considered caught up.", segName);
+ _caughtUpSegments.add(segName);
+ continue;
+ }
+
+ if (isSegmentCaughtUp(segName, segmentDataManager)) {
Review Comment:
You can change the type of segmentDataManager passed into the `isSegmentCaughtUp` to `LLRealtimeSegmentDataManager` so there's no need to cast it in each subclass.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] mcvsubbu commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
mcvsubbu commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r953236039
##########
pinot-server/src/main/java/org/apache/pinot/server/starter/helix/FreshnessBasedConsumptionStatusChecker.java:
##########
@@ -0,0 +1,102 @@
+/**
+ * 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.server.starter.helix;
+
+import java.util.Set;
+import org.apache.pinot.core.data.manager.InstanceDataManager;
+import org.apache.pinot.core.data.manager.realtime.LLRealtimeSegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.SegmentDataManager;
+import org.apache.pinot.spi.stream.LongMsgOffset;
+import org.apache.pinot.spi.stream.StreamPartitionMsgOffset;
+
+
+/**
+ * This class is used at startup time to have a more accurate estimate of the catchup period in which no query
+ * execution happens and consumers try to catch up to the latest messages available in streams.
+ * To achieve this, every time status check is called - {@link #getNumConsumingSegmentsNotReachedIngestionCriteria} -
+ * for each consuming segment, we check if either:
+ * - the segment's latest ingested offset has reached the current stream offset that's
+ * - the last ingested message is within {@link #_minFreshnessMs} of the current system time
+ */
+public class FreshnessBasedConsumptionStatusChecker extends IngestionBasedConsumptionStatusChecker {
+ private final long _minFreshnessMs;
+
+ public FreshnessBasedConsumptionStatusChecker(InstanceDataManager instanceDataManager, Set<String> consumingSegments,
+ long minFreshnessMs) {
+ super(instanceDataManager, consumingSegments);
+ _minFreshnessMs = minFreshnessMs;
+ }
+
+ private boolean isOffsetCaughtUp(StreamPartitionMsgOffset currentOffset, StreamPartitionMsgOffset latestOffset) {
+ if (currentOffset != null && latestOffset != null) {
+ if (currentOffset.compareTo(latestOffset) == 0) {
+ return true;
+ }
+ if (currentOffset instanceof LongMsgOffset && latestOffset instanceof LongMsgOffset) {
Review Comment:
Please change the interface to do this. We don't want any Kafka specific code in the pinot. It is not too hard to change the interface to add a comparator, with a default method.
Please, let us keep it clean.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] Jackie-Jiang commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r953358783
##########
pinot-server/src/main/java/org/apache/pinot/server/starter/helix/FreshnessBasedConsumptionStatusChecker.java:
##########
@@ -0,0 +1,102 @@
+/**
+ * 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.server.starter.helix;
+
+import java.util.Set;
+import org.apache.pinot.core.data.manager.InstanceDataManager;
+import org.apache.pinot.core.data.manager.realtime.LLRealtimeSegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.SegmentDataManager;
+import org.apache.pinot.spi.stream.LongMsgOffset;
+import org.apache.pinot.spi.stream.StreamPartitionMsgOffset;
+
+
+/**
+ * This class is used at startup time to have a more accurate estimate of the catchup period in which no query
+ * execution happens and consumers try to catch up to the latest messages available in streams.
+ * To achieve this, every time status check is called - {@link #getNumConsumingSegmentsNotReachedIngestionCriteria} -
+ * for each consuming segment, we check if either:
+ * - the segment's latest ingested offset has reached the current stream offset that's
+ * - the last ingested message is within {@link #_minFreshnessMs} of the current system time
+ */
+public class FreshnessBasedConsumptionStatusChecker extends IngestionBasedConsumptionStatusChecker {
+ private final long _minFreshnessMs;
+
+ public FreshnessBasedConsumptionStatusChecker(InstanceDataManager instanceDataManager, Set<String> consumingSegments,
+ long minFreshnessMs) {
+ super(instanceDataManager, consumingSegments);
+ _minFreshnessMs = minFreshnessMs;
+ }
+
+ private boolean isOffsetCaughtUp(StreamPartitionMsgOffset currentOffset, StreamPartitionMsgOffset latestOffset) {
+ if (currentOffset != null && latestOffset != null) {
+ if (currentOffset.compareTo(latestOffset) == 0) {
+ return true;
+ }
+ if (currentOffset instanceof LongMsgOffset && latestOffset instanceof LongMsgOffset) {
Review Comment:
@sajjad-moradi Seems we will have the same problem in the offset based status checker when the ingestion rate is very low? If we never consume anything since the server restarts, it will never reach the latest offset since it is exclusive.
I feel we run into this issue because of the `fetchStreamPartitionOffset()` implementation for kafka 2.0. For all other implementations, it will return the last available offset, but for kafka 2.0 it returns the next offset after the last available offset. We should fix the contract for this method.
IMO we should have a way to get the last available offset, and return `null` if there is no message available in the stream. That's the only way to ensure the consumption already catches up
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] jadami10 commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
jadami10 commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r955472142
##########
pinot-server/src/main/java/org/apache/pinot/server/starter/helix/IngestionBasedConsumptionStatusChecker.java:
##########
@@ -0,0 +1,97 @@
+/**
+ * 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.server.starter.helix;
+
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.pinot.common.utils.LLCSegmentName;
+import org.apache.pinot.core.data.manager.InstanceDataManager;
+import org.apache.pinot.core.data.manager.realtime.LLRealtimeSegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.SegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.TableDataManager;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+public abstract class IngestionBasedConsumptionStatusChecker {
+ protected final Logger _logger = LoggerFactory.getLogger(getClass());
+
+ // constructor parameters
+ protected final InstanceDataManager _instanceDataManager;
+ protected final Set<String> _consumingSegments;
+
+ // helper variable
+ private final Set<String> _caughtUpSegments = new HashSet<>();
+
+ public IngestionBasedConsumptionStatusChecker(InstanceDataManager instanceDataManager,
+ Set<String> consumingSegments) {
+ _instanceDataManager = instanceDataManager;
+ _consumingSegments = consumingSegments;
+ }
+
+ public int getNumConsumingSegmentsNotReachedIngestionCriteria() {
+ for (String segName : _consumingSegments) {
+ if (_caughtUpSegments.contains(segName)) {
+ continue;
+ }
+ TableDataManager tableDataManager = getTableDataManager(segName);
+ if (tableDataManager == null) {
+ _logger.info("TableDataManager is not yet setup for segment {}. Will check consumption status later", segName);
+ continue;
+ }
+ SegmentDataManager segmentDataManager = null;
+ try {
+ segmentDataManager = tableDataManager.acquireSegment(segName);
+ if (segmentDataManager == null) {
+ _logger.info("SegmentDataManager is not yet setup for segment {}. Will check consumption status later",
+ segName);
+ continue;
+ }
+ if (!(segmentDataManager instanceof LLRealtimeSegmentDataManager)) {
+ // There's a possibility that a consuming segment has converted to a committed segment. If that's the case,
+ // segment data manager will not be of type LLRealtime.
+ _logger.info("Segment {} is already committed and is considered caught up.", segName);
+ _caughtUpSegments.add(segName);
+ continue;
+ }
+
+ if (isSegmentCaughtUp(segName, segmentDataManager)) {
Review Comment:
good catch. done
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] jadami-stripe commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
jadami-stripe commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r955458900
##########
pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java:
##########
@@ -386,6 +386,15 @@ public static class Server {
"pinot.server.starter.enableRealtimeOffsetBasedConsumptionStatusChecker";
public static final boolean DEFAULT_ENABLE_REALTIME_OFFSET_BASED_CONSUMPTION_STATUS_CHECKER = false;
+ public static final String CONFIG_OF_ENABLE_REALTIME_FRESHNESS_BASED_CONSUMPTION_STATUS_CHECKER =
Review Comment:
I had it this way in a previous iteration but went back for a few reasons:
- @navina suggested this approach
- the behaviors here aren't orthogonal. The freshness checker is strictly more robust than the offset checker. If you enable both, getting the more robust one is perfectly acceptable from an operational standpoint (in my opinion)
- both of these are disabled by default. anyone running pinot today is at most using the offset based checker. so they would be taking a tangible action to enable the freshness checker meaning it's what they wanted enabled anyway. Having the server fail at startup because of this seems like poor UX
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] jadami10 commented on pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
jadami10 commented on PR #9244:
URL: https://github.com/apache/pinot/pull/9244#issuecomment-1220771563
Hey @navina, thank you for looking!
I agree that this would likely be better as a table level check and maybe even happen continuously through the lifecycle of the server so the broker is aware what servers are fresh enough to server data (I think Kafka does something similar with its brokers).
That said, I think Pinot currently lacks some of the protection needed to do something like that. I know at the scale of our events, even 1 table catching up utilizes a large amount of CPU for example. And while tables can have their consumption rate limited, it's up to the user to make sure that's tuned correctly rather than being able to rely on Pinot to ensure there's always enough CPU to serve queries quickly.
This was also much easier to implement as a starting point. Kudos to whoever wrote the Offset based startup checker because I was able to follow that pattern to easily do this as well. I realize the description also lacked some motivation. But we've seen cases where the Offset based checker take 10-15 minutes to catchup to that offset at server start, the server starts serving queries, but then we are 10-15 minutes behind still and the server is slow to serve queries until it actually finishes catching up.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] sajjad-moradi commented on pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
sajjad-moradi commented on PR #9244:
URL: https://github.com/apache/pinot/pull/9244#issuecomment-1225016104
> > I thought your requirement is to not have many uningested messages in the topic because ingestion interferes with query execution:
>
> Both are a concern, but the ingestion lag is much more of a problem than the slow execution. For a topic with ~4,000 events/second, it takes us ~1-2 minutes per hour of ingestion lag to catch up when a server is restarted. Our segment seal threshold is 6 hours, so each restart takes ~3-6 minutes to reach the offset at startup. That brief period where we're then serving queries at 3-6 minutes behind is a bigger issue than the latency. Using freshness as the threshold happens to help with both. Even if we start serving queries at 15 seconds behind, that's relatively few remaining events to consume, so I don't expect query latency to be impacted any longer.
Makes sense. Even in the case of a huge spike in the latest 15s, consumption rate limiter doesn't allow immediate consumption which in turns prevents latency in query execution.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] jadami-stripe commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
jadami-stripe commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r955456966
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/LLRealtimeSegmentDataManager.java:
##########
@@ -1429,15 +1429,17 @@ private void setConsumeEndTime(SegmentZKMetadata segmentZKMetadata, long now) {
}
}
- private void fetchLatestStreamOffset() {
- try (StreamMetadataProvider metadataProvider = _streamConsumerFactory
- .createPartitionMetadataProvider(_clientId, _partitionGroupId)) {
- _latestStreamOffsetAtStartupTime =
- metadataProvider.fetchStreamPartitionOffset(OffsetCriteria.LARGEST_OFFSET_CRITERIA, /*maxWaitTimeMs*/5000);
+ public StreamPartitionMsgOffset fetchLatestStreamOffset() {
+ long maxWaitTimeMs = 5000;
Review Comment:
I'd prefer to leave as is for now since this is how it was working. It's a minimal change if/when anyone else needs it configurable.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] mcvsubbu commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
mcvsubbu commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r956363110
##########
pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java:
##########
@@ -386,6 +386,15 @@ public static class Server {
"pinot.server.starter.enableRealtimeOffsetBasedConsumptionStatusChecker";
public static final boolean DEFAULT_ENABLE_REALTIME_OFFSET_BASED_CONSUMPTION_STATUS_CHECKER = false;
+ public static final String CONFIG_OF_ENABLE_REALTIME_FRESHNESS_BASED_CONSUMPTION_STATUS_CHECKER =
Review Comment:
What happens if/when someone comes up with yet another way of doing this?
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] Jackie-Jiang merged pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
Jackie-Jiang merged PR #9244:
URL: https://github.com/apache/pinot/pull/9244
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] sajjad-moradi commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
sajjad-moradi commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r950995089
##########
pinot-server/src/main/java/org/apache/pinot/server/starter/helix/FreshnessBasedConsumptionStatusChecker.java:
##########
@@ -0,0 +1,154 @@
+/**
+ * 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.server.starter.helix;
+
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.pinot.common.utils.LLCSegmentName;
+import org.apache.pinot.core.data.manager.InstanceDataManager;
+import org.apache.pinot.core.data.manager.realtime.LLRealtimeSegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.SegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.TableDataManager;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.stream.LongMsgOffset;
+import org.apache.pinot.spi.stream.StreamPartitionMsgOffset;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class is used at startup time to have a more accurate estimate of the catchup period in which no query execution
+ * happens and consumers try to catch up to the latest messages available in streams.
+ * To achieve this, every time status check is called - {@link #getNumConsumingSegmentsNotReachedMinFreshness} -
+ * for each consuming segment, we check if either:
+ * - the segment's latest ingested offset has reached the current stream offset that's
+ * - the last ingested message is within {@link #_minFreshnessMs} of the current system time
+ */
+public class FreshnessBasedConsumptionStatusChecker {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FreshnessBasedConsumptionStatusChecker.class);
+
+ // constructor parameters
+ private final InstanceDataManager _instanceDataManager;
+ private final Set<String> _consumingSegments;
+ private final Long _minFreshnessMs;
+
+ // helper variable
+ private final Set<String> _caughtUpSegments = new HashSet<>();
+
+ public FreshnessBasedConsumptionStatusChecker(InstanceDataManager instanceDataManager, Set<String> consumingSegments,
+ Long minFreshnessMs) {
+ _instanceDataManager = instanceDataManager;
+ _consumingSegments = consumingSegments;
+ _minFreshnessMs = minFreshnessMs;
+ }
+
+ private boolean isOffsetCaughtUp(StreamPartitionMsgOffset currentOffset, StreamPartitionMsgOffset latestOffset) {
+ if (currentOffset != null && latestOffset != null) {
+ if (currentOffset.compareTo(latestOffset) == 0) {
+ return true;
+ }
+ long currentOffsetLong = ((LongMsgOffset) currentOffset).getOffset();
+ long latestOffsetLong = ((LongMsgOffset) latestOffset).getOffset();
Review Comment:
This we can't do. Not all streams have long offsets like Kafka does.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] jadami10 commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
jadami10 commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r954230103
##########
pinot-server/src/main/java/org/apache/pinot/server/starter/helix/FreshnessBasedConsumptionStatusChecker.java:
##########
@@ -0,0 +1,102 @@
+/**
+ * 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.server.starter.helix;
+
+import java.util.Set;
+import org.apache.pinot.core.data.manager.InstanceDataManager;
+import org.apache.pinot.core.data.manager.realtime.LLRealtimeSegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.SegmentDataManager;
+import org.apache.pinot.spi.stream.LongMsgOffset;
+import org.apache.pinot.spi.stream.StreamPartitionMsgOffset;
+
+
+/**
+ * This class is used at startup time to have a more accurate estimate of the catchup period in which no query
+ * execution happens and consumers try to catch up to the latest messages available in streams.
+ * To achieve this, every time status check is called - {@link #getNumConsumingSegmentsNotReachedIngestionCriteria} -
+ * for each consuming segment, we check if either:
+ * - the segment's latest ingested offset has reached the current stream offset that's
+ * - the last ingested message is within {@link #_minFreshnessMs} of the current system time
+ */
+public class FreshnessBasedConsumptionStatusChecker extends IngestionBasedConsumptionStatusChecker {
+ private final long _minFreshnessMs;
+
+ public FreshnessBasedConsumptionStatusChecker(InstanceDataManager instanceDataManager, Set<String> consumingSegments,
+ long minFreshnessMs) {
+ super(instanceDataManager, consumingSegments);
+ _minFreshnessMs = minFreshnessMs;
+ }
+
+ private boolean isOffsetCaughtUp(StreamPartitionMsgOffset currentOffset, StreamPartitionMsgOffset latestOffset) {
+ if (currentOffset != null && latestOffset != null) {
+ if (currentOffset.compareTo(latestOffset) == 0) {
+ return true;
+ }
+ if (currentOffset instanceof LongMsgOffset && latestOffset instanceof LongMsgOffset) {
Review Comment:
This feels like a bigger issue than I want to tackle in this PR. I've removed the kafka specific code for now. We have our own stream ingestion plugin where I will update the `fetchStreamPartitionOffset` to return `- 1`.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] mcvsubbu commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
mcvsubbu commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r955303504
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/LLRealtimeSegmentDataManager.java:
##########
@@ -1429,15 +1429,17 @@ private void setConsumeEndTime(SegmentZKMetadata segmentZKMetadata, long now) {
}
}
- private void fetchLatestStreamOffset() {
- try (StreamMetadataProvider metadataProvider = _streamConsumerFactory
- .createPartitionMetadataProvider(_clientId, _partitionGroupId)) {
- _latestStreamOffsetAtStartupTime =
- metadataProvider.fetchStreamPartitionOffset(OffsetCriteria.LARGEST_OFFSET_CRITERIA, /*maxWaitTimeMs*/5000);
+ public StreamPartitionMsgOffset fetchLatestStreamOffset() {
+ long maxWaitTimeMs = 5000;
Review Comment:
can we move this waitTime to be an argument `maxWaitTimeMillis`, since we seem to be calling it from different places and each may want to set their own wait time
##########
pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java:
##########
@@ -386,6 +386,15 @@ public static class Server {
"pinot.server.starter.enableRealtimeOffsetBasedConsumptionStatusChecker";
public static final boolean DEFAULT_ENABLE_REALTIME_OFFSET_BASED_CONSUMPTION_STATUS_CHECKER = false;
+ public static final String CONFIG_OF_ENABLE_REALTIME_FRESHNESS_BASED_CONSUMPTION_STATUS_CHECKER =
Review Comment:
can we ensure that exactly one of the config is set (maybe in the starter), and throw exception if not?
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] jadami10 commented on pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
jadami10 commented on PR #9244:
URL: https://github.com/apache/pinot/pull/9244#issuecomment-1223418588
> The issue with offset based status checker is that we don't know how many events from the stream we're behind. That's because the StreamPartitionMsgOffset interface only tells us if we're caught up or we're behind, but it it doesn't tell us by how many events we are behind. That was the reason we couldn't define a threshold for catchup when offset based status checker was added.
Even if we had this, I'm not sure it would help. I feel most folks set their SLAs based on time freshness, not "number of events". So even if we knew we were 10,000 events behind, that might be fine if you have 1,000 events per second but not fine if you have 10 events per seconds.
> Anyways, the current PR has duplicate code between OffsetBasedStatusChecker and FreshnessBasedStatusChecker. I think by making a small change to the OffsetBasedStatusChecker, we can achieve the goal of this PR. We can pass in a config for freshness threshold to OffsetBasedStatusChecker and where we get the stream latest offset at startup, if the config is provided, we can get stream latest offset at the current moment and check the freshness then.
Fair feedback. I opted to use a parent class to keep the functionality separate rather than try to merge them. I feel like this is a better approach at the moment to keep things more easily testable and singularly responsible.
> Good point. Can we enhance the stream interface to decide the lag and then emit a metric ?
I'd really prefer not to make such a big change in this PR if it's not necessary.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] mcvsubbu commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
mcvsubbu commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r953288940
##########
pinot-server/src/main/java/org/apache/pinot/server/starter/helix/FreshnessBasedConsumptionStatusChecker.java:
##########
@@ -0,0 +1,102 @@
+/**
+ * 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.server.starter.helix;
+
+import java.util.Set;
+import org.apache.pinot.core.data.manager.InstanceDataManager;
+import org.apache.pinot.core.data.manager.realtime.LLRealtimeSegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.SegmentDataManager;
+import org.apache.pinot.spi.stream.LongMsgOffset;
+import org.apache.pinot.spi.stream.StreamPartitionMsgOffset;
+
+
+/**
+ * This class is used at startup time to have a more accurate estimate of the catchup period in which no query
+ * execution happens and consumers try to catch up to the latest messages available in streams.
+ * To achieve this, every time status check is called - {@link #getNumConsumingSegmentsNotReachedIngestionCriteria} -
+ * for each consuming segment, we check if either:
+ * - the segment's latest ingested offset has reached the current stream offset that's
+ * - the last ingested message is within {@link #_minFreshnessMs} of the current system time
+ */
+public class FreshnessBasedConsumptionStatusChecker extends IngestionBasedConsumptionStatusChecker {
+ private final long _minFreshnessMs;
+
+ public FreshnessBasedConsumptionStatusChecker(InstanceDataManager instanceDataManager, Set<String> consumingSegments,
+ long minFreshnessMs) {
+ super(instanceDataManager, consumingSegments);
+ _minFreshnessMs = minFreshnessMs;
+ }
+
+ private boolean isOffsetCaughtUp(StreamPartitionMsgOffset currentOffset, StreamPartitionMsgOffset latestOffset) {
+ if (currentOffset != null && latestOffset != null) {
+ if (currentOffset.compareTo(latestOffset) == 0) {
+ return true;
+ }
+ if (currentOffset instanceof LongMsgOffset && latestOffset instanceof LongMsgOffset) {
Review Comment:
Here is one option: add a method called `isNextOffset(streamMsgOffset)` you can also add a method (if need be) like `isNextOffsetSupported()` or some such, so that you can make sure you call it only if it is supported. the default can throw exceptions
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] jadami10 commented on pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
jadami10 commented on PR #9244:
URL: https://github.com/apache/pinot/pull/9244#issuecomment-1224964658
> I thought your requirement is to not have many uningested messages in the topic because ingestion interferes with query execution:
Both are a concern, but the ingestion lag is much more of a problem than the slow execution. For a topic with ~4,000 events/second, it takes us ~1-2 minutes per hour of ingestion lag to catch up when a server is restarted. Our segment seal threshold is 6 hours, so each restart takes ~3-6 minutes to reach the offset at startup. That brief period where we're then serving queries at 3-6 minutes behind is a bigger issue than the latency. Using freshness as the threshold happens to help with both. Even if we start serving queries at 15 seconds behind, that's relatively few remaining events to consume, so I don't expect query latency to be impacted any longer.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] sajjad-moradi commented on pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
sajjad-moradi commented on PR #9244:
URL: https://github.com/apache/pinot/pull/9244#issuecomment-1224960209
> Others can chime in here as well about their SLAs/use cases. But for our use case, we promise an internal freshness SLA, not anything else based on number of events. So if there's thousands of events that are < N seconds old, we are fine starting the system up. I assumed this was generic enough of a streaming system SLA to provide as a feature in Pinot.
I thought your requirement is to not have many uningested messages in the topic because ingestion interferes with query execution:
> we've seen cases where the Offset based checker take 10-15 minutes to catchup to that offset at server start, the server starts serving queries, but then we are 10-15 minutes behind still and the server is slow to serve queries until it actually finishes catching up
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] sajjad-moradi commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
sajjad-moradi commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r953206251
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/LLRealtimeSegmentDataManager.java:
##########
@@ -308,9 +308,9 @@ private boolean endCriteriaReached() {
_consumeEndTime += TimeUnit.HOURS.toMillis(TIME_EXTENSION_ON_EMPTY_SEGMENT_HOURS);
return false;
}
- _segmentLogger
- .info("Stopping consumption due to time limit start={} now={} numRowsConsumed={} numRowsIndexed={}",
- _startTimeMs, now, _numRowsConsumed, _numRowsIndexed);
+ _segmentLogger.info(
Review Comment:
Could you please undo the reformatting? It's a bit hard to follow the code change.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] jadami10 commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
jadami10 commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r956374673
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/LLRealtimeSegmentDataManager.java:
##########
@@ -1429,15 +1429,17 @@ private void setConsumeEndTime(SegmentZKMetadata segmentZKMetadata, long now) {
}
}
- private void fetchLatestStreamOffset() {
- try (StreamMetadataProvider metadataProvider = _streamConsumerFactory
- .createPartitionMetadataProvider(_clientId, _partitionGroupId)) {
- _latestStreamOffsetAtStartupTime =
- metadataProvider.fetchStreamPartitionOffset(OffsetCriteria.LARGEST_OFFSET_CRITERIA, /*maxWaitTimeMs*/5000);
+ public StreamPartitionMsgOffset fetchLatestStreamOffset() {
+ long maxWaitTimeMs = 5000;
Review Comment:
fair, updated to make it a function parameter
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] jadami10 commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
jadami10 commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r952057238
##########
pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java:
##########
@@ -385,6 +385,13 @@ public static class Server {
"pinot.server.starter.enableRealtimeOffsetBasedConsumptionStatusChecker";
public static final boolean DEFAULT_ENABLE_REALTIME_OFFSET_BASED_CONSUMPTION_STATUS_CHECKER = false;
+ public static final String CONFIG_OF_ENABLE_REALTIME_FRESHNESS_BASED_CONSUMPTION_STATUS_CHECKER =
+ "pinot.server.starter.enableRealtimeFreshnessBasedConsumptionStatusChecker";
+ public static final boolean DEFAULT_ENABLE_REALTIME_FRESHNESS_BASED_CONSUMPTION_STATUS_CHECKER = false;
+ public static final String CONFIG_OF_STARTUP_REALTIME_MIN_FRESHNESS_MS =
+ "pinot.server.starter.realtimeMinFreshnessMs";
+ public static final int DEFAULT_STARTUP_REALTIME_MIN_FRESHNESS_MS = 0;
Review Comment:
the default of 0 is actually "off". but given the feedback above, i've set this to 10s, and this will get used if a user misconfigures this
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/LLRealtimeSegmentDataManager.java:
##########
@@ -1440,6 +1440,17 @@ private void fetchLatestStreamOffset() {
}
}
+ public StreamPartitionMsgOffset fetchLatestStreamOffset(Long maxWaitTimeMs) {
Review Comment:
agreed on making it public
##########
pinot-server/src/main/java/org/apache/pinot/server/starter/helix/FreshnessBasedConsumptionStatusChecker.java:
##########
@@ -0,0 +1,154 @@
+/**
+ * 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.server.starter.helix;
+
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.pinot.common.utils.LLCSegmentName;
+import org.apache.pinot.core.data.manager.InstanceDataManager;
+import org.apache.pinot.core.data.manager.realtime.LLRealtimeSegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.SegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.TableDataManager;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.stream.LongMsgOffset;
+import org.apache.pinot.spi.stream.StreamPartitionMsgOffset;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class is used at startup time to have a more accurate estimate of the catchup period in which no query execution
+ * happens and consumers try to catch up to the latest messages available in streams.
+ * To achieve this, every time status check is called - {@link #getNumConsumingSegmentsNotReachedMinFreshness} -
+ * for each consuming segment, we check if either:
+ * - the segment's latest ingested offset has reached the current stream offset that's
+ * - the last ingested message is within {@link #_minFreshnessMs} of the current system time
+ */
+public class FreshnessBasedConsumptionStatusChecker {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FreshnessBasedConsumptionStatusChecker.class);
+
+ // constructor parameters
+ private final InstanceDataManager _instanceDataManager;
+ private final Set<String> _consumingSegments;
+ private final Long _minFreshnessMs;
+
+ // helper variable
+ private final Set<String> _caughtUpSegments = new HashSet<>();
+
+ public FreshnessBasedConsumptionStatusChecker(InstanceDataManager instanceDataManager, Set<String> consumingSegments,
+ Long minFreshnessMs) {
+ _instanceDataManager = instanceDataManager;
+ _consumingSegments = consumingSegments;
+ _minFreshnessMs = minFreshnessMs;
+ }
+
+ private boolean isOffsetCaughtUp(StreamPartitionMsgOffset currentOffset, StreamPartitionMsgOffset latestOffset) {
+ if (currentOffset != null && latestOffset != null) {
+ if (currentOffset.compareTo(latestOffset) == 0) {
+ return true;
+ }
+ long currentOffsetLong = ((LongMsgOffset) currentOffset).getOffset();
+ long latestOffsetLong = ((LongMsgOffset) latestOffset).getOffset();
Review Comment:
my bad, i missed the type checking before it. We already do this in `LLRealtimeSegmentDataManager`, and I'd prefer to avoid changing the `StreamPartitionMsgOffset` interface in this PR
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/LLRealtimeSegmentDataManager.java:
##########
@@ -1440,6 +1440,17 @@ private void fetchLatestStreamOffset() {
}
}
+ public StreamPartitionMsgOffset fetchLatestStreamOffset(Long maxWaitTimeMs) {
+ try (StreamMetadataProvider metadataProvider = _streamConsumerFactory
+ .createPartitionMetadataProvider(_clientId, _partitionGroupId)) {
+ return metadataProvider.fetchStreamPartitionOffset(OffsetCriteria.LARGEST_OFFSET_CRITERIA, maxWaitTimeMs);
+ } catch (Exception e) {
+ _segmentLogger.warn("Cannot fetch latest stream offset for clientId {} and partitionGroupId {}", _clientId,
Review Comment:
done
##########
pinot-server/src/main/java/org/apache/pinot/server/starter/helix/BaseServerStarter.java:
##########
@@ -236,12 +236,24 @@ private void registerServiceStatusHandler() {
boolean isOffsetBasedConsumptionStatusCheckerEnabled =
_serverConf.getProperty(Server.CONFIG_OF_ENABLE_REALTIME_OFFSET_BASED_CONSUMPTION_STATUS_CHECKER,
Server.DEFAULT_ENABLE_REALTIME_OFFSET_BASED_CONSUMPTION_STATUS_CHECKER);
+ boolean isFreshnessStatusCheckerEnabled =
+ _serverConf.getProperty(Server.CONFIG_OF_ENABLE_REALTIME_FRESHNESS_BASED_CONSUMPTION_STATUS_CHECKER,
+ Server.DEFAULT_ENABLE_REALTIME_FRESHNESS_BASED_CONSUMPTION_STATUS_CHECKER);
+ int realtimeMinFreshnessMs = _serverConf.getProperty(Server.CONFIG_OF_STARTUP_REALTIME_MIN_FRESHNESS_MS,
+ Server.DEFAULT_STARTUP_REALTIME_MIN_FRESHNESS_MS);
// collect all resources which have this instance in the ideal state
List<String> resourcesToMonitor = new ArrayList<>();
Set<String> consumingSegments = new HashSet<>();
boolean checkRealtime = realtimeConsumptionCatchupWaitMs > 0;
+ if (isFreshnessStatusCheckerEnabled && realtimeMinFreshnessMs <= 0) {
+ LOGGER.warn("Realtime min freshness {} must be > 0. Will not setup freshness based checker.", realtimeMinFreshnessMs);
+ }
+ if (isFreshnessStatusCheckerEnabled && isOffsetBasedConsumptionStatusCheckerEnabled) {
+ LOGGER.warn("Offset and Freshness checkers both enabled. Will only setup freshness based checker.");
+ }
+ boolean checkRealtimeFreshness = realtimeMinFreshnessMs > 0;
Review Comment:
good call, it's definitely confusing. I've changed this to
- use the default freshness setting if it's not set correctly
- to always use the freshness checker regardless of other configs
##########
pinot-server/src/main/java/org/apache/pinot/server/starter/helix/FreshnessBasedConsumptionStatusChecker.java:
##########
@@ -0,0 +1,154 @@
+/**
+ * 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.server.starter.helix;
+
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.pinot.common.utils.LLCSegmentName;
+import org.apache.pinot.core.data.manager.InstanceDataManager;
+import org.apache.pinot.core.data.manager.realtime.LLRealtimeSegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.SegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.TableDataManager;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.stream.LongMsgOffset;
+import org.apache.pinot.spi.stream.StreamPartitionMsgOffset;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class is used at startup time to have a more accurate estimate of the catchup period in which no query execution
+ * happens and consumers try to catch up to the latest messages available in streams.
+ * To achieve this, every time status check is called - {@link #getNumConsumingSegmentsNotReachedMinFreshness} -
+ * for each consuming segment, we check if either:
+ * - the segment's latest ingested offset has reached the current stream offset that's
+ * - the last ingested message is within {@link #_minFreshnessMs} of the current system time
+ */
+public class FreshnessBasedConsumptionStatusChecker {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FreshnessBasedConsumptionStatusChecker.class);
+
+ // constructor parameters
+ private final InstanceDataManager _instanceDataManager;
+ private final Set<String> _consumingSegments;
+ private final Long _minFreshnessMs;
+
+ // helper variable
+ private final Set<String> _caughtUpSegments = new HashSet<>();
+
+ public FreshnessBasedConsumptionStatusChecker(InstanceDataManager instanceDataManager, Set<String> consumingSegments,
+ Long minFreshnessMs) {
+ _instanceDataManager = instanceDataManager;
+ _consumingSegments = consumingSegments;
+ _minFreshnessMs = minFreshnessMs;
+ }
+
+ private boolean isOffsetCaughtUp(StreamPartitionMsgOffset currentOffset, StreamPartitionMsgOffset latestOffset) {
+ if (currentOffset != null && latestOffset != null) {
+ if (currentOffset.compareTo(latestOffset) == 0) {
+ return true;
+ }
+ long currentOffsetLong = ((LongMsgOffset) currentOffset).getOffset();
+ long latestOffsetLong = ((LongMsgOffset) latestOffset).getOffset();
+ // Kafka's "latest" offset is actually the next available offset. Therefore it will be 1 ahead of the
+ // current offset in the case we are caught up.
+ // We expect currentOffset == latestOffset if no messages have ever been published. Both will be 0.
+ // Otherwise, we never expect currentOffset > latestOffset, but we allow this to be caught up in case
+ // it ever happens so we're not stuck starting up.
+ return currentOffsetLong >= latestOffsetLong - 1;
+ }
+ return false;
+ }
+
+ protected Long now() {
+ return System.currentTimeMillis();
+ }
+
+ public int getNumConsumingSegmentsNotReachedMinFreshness() {
+ for (String segName : _consumingSegments) {
+ if (_caughtUpSegments.contains(segName)) {
+ continue;
+ }
+ TableDataManager tableDataManager = getTableDataManager(segName);
+ if (tableDataManager == null) {
+ LOGGER.info("TableDataManager is not yet setup for segment {}. Will check consumption status later", segName);
+ continue;
+ }
+ SegmentDataManager segmentDataManager = null;
+ try {
+ segmentDataManager = tableDataManager.acquireSegment(segName);
+ if (segmentDataManager == null) {
+ LOGGER.info("SegmentDataManager is not yet setup for segment {}. Will check consumption status later",
+ segName);
+ continue;
+ }
+ if (!(segmentDataManager instanceof LLRealtimeSegmentDataManager)) {
+ // There's a possibility that a consuming segment has converted to a committed segment. If that's the case,
+ // segment data manager will not be of type LLRealtime.
+ LOGGER.info("Segment {} is already committed and is considered caught up.", segName);
+ _caughtUpSegments.add(segName);
+ continue;
+ }
+ LLRealtimeSegmentDataManager rtSegmentDataManager = (LLRealtimeSegmentDataManager) segmentDataManager;
+ Long now = now();
Review Comment:
good catch, done
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] mcvsubbu commented on pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
mcvsubbu commented on PR #9244:
URL: https://github.com/apache/pinot/pull/9244#issuecomment-1222550398
> The issue with offset based status checker is that we don't know how many events from the stream we're behind. That's because the StreamPartitionMsgOffset interface only tells us if we're caught up or we're behind, but it it doesn't tell us by how many events we are behind. That was the reason we couldn't define a threshold for catchup when offset based status checker was added.
>
> Anyways, the current PR has duplicate code between OffsetBasedStatusChecker and FreshnessBasedStatusChecker. I think by making a small change to the OffsetBasedStatusChecker, we can achieve the goal of this PR. We can pass in a config for freshness threshold to OffsetBasedStatusChecker and where we get the stream latest offset at startup, if the config is provided, we can get stream latest offset at the current moment and check the freshness then.
Good point. Can we enhance the stream interface to decide the lag and then emit a metric ?
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] navina commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
navina commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r950603573
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/LLRealtimeSegmentDataManager.java:
##########
@@ -1440,6 +1440,17 @@ private void fetchLatestStreamOffset() {
}
}
+ public StreamPartitionMsgOffset fetchLatestStreamOffset(Long maxWaitTimeMs) {
Review Comment:
Looks like there is already a public method called `getLatestStreamOffsetAtStartupTime` in `LLRealtimeSegmentDataManager`. This is also used by the offset checker. I think it is the same information that you are looking for.
##########
pinot-server/src/main/java/org/apache/pinot/server/starter/helix/BaseServerStarter.java:
##########
@@ -236,12 +236,24 @@ private void registerServiceStatusHandler() {
boolean isOffsetBasedConsumptionStatusCheckerEnabled =
_serverConf.getProperty(Server.CONFIG_OF_ENABLE_REALTIME_OFFSET_BASED_CONSUMPTION_STATUS_CHECKER,
Server.DEFAULT_ENABLE_REALTIME_OFFSET_BASED_CONSUMPTION_STATUS_CHECKER);
+ boolean isFreshnessStatusCheckerEnabled =
+ _serverConf.getProperty(Server.CONFIG_OF_ENABLE_REALTIME_FRESHNESS_BASED_CONSUMPTION_STATUS_CHECKER,
+ Server.DEFAULT_ENABLE_REALTIME_FRESHNESS_BASED_CONSUMPTION_STATUS_CHECKER);
+ int realtimeMinFreshnessMs = _serverConf.getProperty(Server.CONFIG_OF_STARTUP_REALTIME_MIN_FRESHNESS_MS,
+ Server.DEFAULT_STARTUP_REALTIME_MIN_FRESHNESS_MS);
// collect all resources which have this instance in the ideal state
List<String> resourcesToMonitor = new ArrayList<>();
Set<String> consumingSegments = new HashSet<>();
boolean checkRealtime = realtimeConsumptionCatchupWaitMs > 0;
+ if (isFreshnessStatusCheckerEnabled && realtimeMinFreshnessMs <= 0) {
+ LOGGER.warn("Realtime min freshness {} must be > 0. Will not setup freshness based checker.", realtimeMinFreshnessMs);
+ }
+ if (isFreshnessStatusCheckerEnabled && isOffsetBasedConsumptionStatusCheckerEnabled) {
+ LOGGER.warn("Offset and Freshness checkers both enabled. Will only setup freshness based checker.");
+ }
+ boolean checkRealtimeFreshness = realtimeMinFreshnessMs > 0;
Review Comment:
This condition checks are confusing.
The first condition checks if a valid realtimeFreshness is set or not. The second condition checks if both checks are enabled and warns saying it will choose freshness based checker over offset based checker.
so, if my config has offsetBasedConsumptionStatusChecker = true, freshnessBasedConsumptionStatusCheckerEnabled = true and realtimeMinFreshness = -50, the logs will be very confusing.
It seems simpler to do this: if both are setup, choose freshness based check and use default freshness value if the minFreshness is not configured correctly. Also, the check for the correct config value can be moved further down Line 298 `if (isFreshnessStatusCheckerEnabled) { `
nit: the boolean `checkRealtimeFreshness` is unused
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] sajjad-moradi commented on pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
sajjad-moradi commented on PR #9244:
URL: https://github.com/apache/pinot/pull/9244#issuecomment-1224918965
> I feel most folks set their SLAs based on time freshness, not "number of events". So even if we knew we were 10,000 events behind, that might be fine if you have 1,000 events per second but not fine if you have 10 events per seconds.
The purpose of this status checker is to consume as many events as possible before enabling query execution. We shouldn't care if the messages are fresh or not. For example, let's say the freshness threshold is 15s and assume there's a huge spike in the topic in last 15s and there are thousands of events available in the topic. The ingestion time for these events is less than the threshold so the status checker announces the consumption has caught up while there are a lot of messages available in the topic to be consumed.
> > Anyways, the current PR has duplicate code between OffsetBasedStatusChecker and FreshnessBasedStatusChecker. I think by making a small change to the OffsetBasedStatusChecker, we can achieve the goal of this PR. We can pass in a config for freshness threshold to OffsetBasedStatusChecker and where we get the stream latest offset at startup, if the config is provided, we can get stream latest offset at the current moment and check the freshness then.
>
> Fair feedback. I opted to use a parent class to keep the functionality separate rather than try to merge them. I feel like this is a better approach at the moment to keep things more easily testable and singularly responsible.
>
I agree it's easier to develop and test this way, but in the long run duplicated code has a high maintenance cost. Let's iron out the issues and consolidate the two classes into one.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] jadami10 commented on pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
jadami10 commented on PR #9244:
URL: https://github.com/apache/pinot/pull/9244#issuecomment-1224930629
> The purpose of this status checker is to consume as many events as possible before enabling query execution. We shouldn't care if the messages are fresh or not. For example, let's say the freshness threshold is 15s and assume there's a huge spike in the topic in last 15s and there are thousands of events available in the topic. The ingestion time for these events is less than the threshold so the status checker announces the consumption has caught up while there are a lot of messages available in the topic to be consumed.
Others can chime in here as well about their SLAs/use cases. But for our use case, we promise an internal freshness SLA, not anything else based on number of events. So if there's thousands of events that are < N seconds old, we are fine starting the system up. I assumed this was generic enough of a streaming system SLA to provide as a feature in Pinot.
> I agree it's easier to develop and test this way, but in the long run duplicated code has a high maintenance cost. Let's iron out the issues and consolidate the two classes into one.
There's no longer any duplicated code as it's in a parent class, so I don't see the value in merging the classes when they'll be controlled by separate config values anyway.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] codecov-commenter commented on pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #9244:
URL: https://github.com/apache/pinot/pull/9244#issuecomment-1225125451
# [Codecov](https://codecov.io/gh/apache/pinot/pull/9244?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#9244](https://codecov.io/gh/apache/pinot/pull/9244?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (39f74d0) into [master](https://codecov.io/gh/apache/pinot/commit/0adf5efe6742699080b4f39c76ad50e0e23da50f?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (0adf5ef) will **decrease** coverage by `0.05%`.
> The diff coverage is `66.66%`.
```diff
@@ Coverage Diff @@
## master #9244 +/- ##
============================================
- Coverage 63.64% 63.59% -0.06%
- Complexity 4984 4985 +1
============================================
Files 1809 1809
Lines 96993 96991 -2
Branches 14832 14832
============================================
- Hits 61735 61684 -51
- Misses 30707 30750 +43
- Partials 4551 4557 +6
```
| Flag | Coverage Δ | |
|---|---|---|
| unittests1 | `67.08% <66.66%> (-0.03%)` | :arrow_down: |
| unittests2 | `15.35% <0.00%> (-0.04%)` | :arrow_down: |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/pinot/pull/9244?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...va/org/apache/pinot/spi/utils/CommonConstants.java](https://codecov.io/gh/apache/pinot/pull/9244/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvdXRpbHMvQ29tbW9uQ29uc3RhbnRzLmphdmE=) | `27.69% <ø> (ø)` | |
| [...manager/realtime/LLRealtimeSegmentDataManager.java](https://codecov.io/gh/apache/pinot/pull/9244/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9kYXRhL21hbmFnZXIvcmVhbHRpbWUvTExSZWFsdGltZVNlZ21lbnREYXRhTWFuYWdlci5qYXZh) | `53.14% <66.66%> (-0.25%)` | :arrow_down: |
| [...ller/validation/OfflineSegmentIntervalChecker.java](https://codecov.io/gh/apache/pinot/pull/9244/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci92YWxpZGF0aW9uL09mZmxpbmVTZWdtZW50SW50ZXJ2YWxDaGVja2VyLmphdmE=) | `25.84% <0.00%> (-33.71%)` | :arrow_down: |
| [...cheduler/resources/PolicyBasedResourceManager.java](https://codecov.io/gh/apache/pinot/pull/9244/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9zY2hlZHVsZXIvcmVzb3VyY2VzL1BvbGljeUJhc2VkUmVzb3VyY2VNYW5hZ2VyLmphdmE=) | `75.00% <0.00%> (-18.75%)` | :arrow_down: |
| [...ore/query/scheduler/resources/ResourceManager.java](https://codecov.io/gh/apache/pinot/pull/9244/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9zY2hlZHVsZXIvcmVzb3VyY2VzL1Jlc291cmNlTWFuYWdlci5qYXZh) | `84.00% <0.00%> (-12.00%)` | :arrow_down: |
| [.../pinot/core/query/scheduler/PriorityScheduler.java](https://codecov.io/gh/apache/pinot/pull/9244/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9zY2hlZHVsZXIvUHJpb3JpdHlTY2hlZHVsZXIuamF2YQ==) | `77.77% <0.00%> (-5.56%)` | :arrow_down: |
| [.../helix/core/minion/MinionInstancesCleanupTask.java](https://codecov.io/gh/apache/pinot/pull/9244/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9oZWxpeC9jb3JlL21pbmlvbi9NaW5pb25JbnN0YW5jZXNDbGVhbnVwVGFzay5qYXZh) | `77.27% <0.00%> (-4.55%)` | :arrow_down: |
| [...lix/core/realtime/PinotRealtimeSegmentManager.java](https://codecov.io/gh/apache/pinot/pull/9244/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9oZWxpeC9jb3JlL3JlYWx0aW1lL1Bpbm90UmVhbHRpbWVTZWdtZW50TWFuYWdlci5qYXZh) | `72.25% <0.00%> (-3.67%)` | :arrow_down: |
| [...gregation/function/StUnionAggregationFunction.java](https://codecov.io/gh/apache/pinot/pull/9244/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9hZ2dyZWdhdGlvbi9mdW5jdGlvbi9TdFVuaW9uQWdncmVnYXRpb25GdW5jdGlvbi5qYXZh) | `73.52% <0.00%> (-2.95%)` | :arrow_down: |
| [.../java/org/apache/pinot/spi/data/TimeFieldSpec.java](https://codecov.io/gh/apache/pinot/pull/9244/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvZGF0YS9UaW1lRmllbGRTcGVjLmphdmE=) | `88.63% <0.00%> (-2.28%)` | :arrow_down: |
| ... and [8 more](https://codecov.io/gh/apache/pinot/pull/9244/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] jadami10 commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
jadami10 commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r953257958
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/LLRealtimeSegmentDataManager.java:
##########
@@ -308,9 +308,9 @@ private boolean endCriteriaReached() {
_consumeEndTime += TimeUnit.HOURS.toMillis(TIME_EXTENSION_ON_EMPTY_SEGMENT_HOURS);
return false;
}
- _segmentLogger
- .info("Stopping consumption due to time limit start={} now={} numRowsConsumed={} numRowsIndexed={}",
- _startTimeMs, now, _numRowsConsumed, _numRowsIndexed);
+ _segmentLogger.info(
Review Comment:
done
##########
pinot-server/src/main/java/org/apache/pinot/server/starter/helix/FreshnessBasedConsumptionStatusChecker.java:
##########
@@ -0,0 +1,102 @@
+/**
+ * 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.server.starter.helix;
+
+import java.util.Set;
+import org.apache.pinot.core.data.manager.InstanceDataManager;
+import org.apache.pinot.core.data.manager.realtime.LLRealtimeSegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.SegmentDataManager;
+import org.apache.pinot.spi.stream.LongMsgOffset;
+import org.apache.pinot.spi.stream.StreamPartitionMsgOffset;
+
+
+/**
+ * This class is used at startup time to have a more accurate estimate of the catchup period in which no query
+ * execution happens and consumers try to catch up to the latest messages available in streams.
+ * To achieve this, every time status check is called - {@link #getNumConsumingSegmentsNotReachedIngestionCriteria} -
+ * for each consuming segment, we check if either:
+ * - the segment's latest ingested offset has reached the current stream offset that's
+ * - the last ingested message is within {@link #_minFreshnessMs} of the current system time
+ */
+public class FreshnessBasedConsumptionStatusChecker extends IngestionBasedConsumptionStatusChecker {
+ private final long _minFreshnessMs;
+
+ public FreshnessBasedConsumptionStatusChecker(InstanceDataManager instanceDataManager, Set<String> consumingSegments,
+ long minFreshnessMs) {
+ super(instanceDataManager, consumingSegments);
+ _minFreshnessMs = minFreshnessMs;
+ }
+
+ private boolean isOffsetCaughtUp(StreamPartitionMsgOffset currentOffset, StreamPartitionMsgOffset latestOffset) {
+ if (currentOffset != null && latestOffset != null) {
+ if (currentOffset.compareTo(latestOffset) == 0) {
+ return true;
+ }
+ if (currentOffset instanceof LongMsgOffset && latestOffset instanceof LongMsgOffset) {
Review Comment:
I can't think of how else to do this even in the interface. This issue only arises with Kafka because "latest offset" there is actually +1 of whatever your current offset is. The kinesis and pulsar implementations use a string and MessageId respectively to store the offset.
I can make a `getPreviousOffset` method in the `LLRealtimeSegmentDataManager`, but then I just move this logic there.
I can put a `fetchPreviousOffset` in `StreamMetadataProvider`, but then I'll just have to raise a `NotImplementedException` by default and later go update our own custom `StreamMetadataProvider`.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] mcvsubbu commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
mcvsubbu commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r956364550
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/LLRealtimeSegmentDataManager.java:
##########
@@ -1429,15 +1429,17 @@ private void setConsumeEndTime(SegmentZKMetadata segmentZKMetadata, long now) {
}
}
- private void fetchLatestStreamOffset() {
- try (StreamMetadataProvider metadataProvider = _streamConsumerFactory
- .createPartitionMetadataProvider(_clientId, _partitionGroupId)) {
- _latestStreamOffsetAtStartupTime =
- metadataProvider.fetchStreamPartitionOffset(OffsetCriteria.LARGEST_OFFSET_CRITERIA, /*maxWaitTimeMs*/5000);
+ public StreamPartitionMsgOffset fetchLatestStreamOffset() {
+ long maxWaitTimeMs = 5000;
Review Comment:
I am not worried about the minimal change afterwards. We have turned what was a private method in a class an changed it to a public method. At the minimum, the javadoc could indicate that there is 5s wait. At best, take a timeout parameter so that any other class that calls it does it knowingly.
What we don't want is another class calling this method without knowing that there could be a 5s delay and get surprised when there is
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] jadami10 commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
jadami10 commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r956377783
##########
pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java:
##########
@@ -386,6 +386,15 @@ public static class Server {
"pinot.server.starter.enableRealtimeOffsetBasedConsumptionStatusChecker";
public static final boolean DEFAULT_ENABLE_REALTIME_OFFSET_BASED_CONSUMPTION_STATUS_CHECKER = false;
+ public static final String CONFIG_OF_ENABLE_REALTIME_FRESHNESS_BASED_CONSUMPTION_STATUS_CHECKER =
Review Comment:
If someone wants an orthogonal way to do this, then it's worth further discussion there. The previous code was already doing something like this:
- if nothing is set, just start
- if realtime wait is set, wait a static amount of time before starting
- if offset is set, do nothing
- if offset and realtime wait is set, do the offset checker
At this point we've somewhat exhausted the "am I caught up" methods with either freshness or offset based. If someone eventually wants something more complex like "freshness and offset based together", we can migrate this config to dynamically point to the class name of the offset checker they want.
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] sajjad-moradi commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
sajjad-moradi commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r956842659
##########
pinot-server/src/main/java/org/apache/pinot/server/starter/helix/FreshnessBasedConsumptionStatusChecker.java:
##########
@@ -0,0 +1,102 @@
+/**
+ * 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.server.starter.helix;
+
+import java.util.Set;
+import org.apache.pinot.core.data.manager.InstanceDataManager;
+import org.apache.pinot.core.data.manager.realtime.LLRealtimeSegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.SegmentDataManager;
+import org.apache.pinot.spi.stream.LongMsgOffset;
+import org.apache.pinot.spi.stream.StreamPartitionMsgOffset;
+
+
+/**
+ * This class is used at startup time to have a more accurate estimate of the catchup period in which no query
+ * execution happens and consumers try to catch up to the latest messages available in streams.
+ * To achieve this, every time status check is called - {@link #getNumConsumingSegmentsNotReachedIngestionCriteria} -
+ * for each consuming segment, we check if either:
+ * - the segment's latest ingested offset has reached the current stream offset that's
+ * - the last ingested message is within {@link #_minFreshnessMs} of the current system time
+ */
+public class FreshnessBasedConsumptionStatusChecker extends IngestionBasedConsumptionStatusChecker {
+ private final long _minFreshnessMs;
+
+ public FreshnessBasedConsumptionStatusChecker(InstanceDataManager instanceDataManager, Set<String> consumingSegments,
+ long minFreshnessMs) {
+ super(instanceDataManager, consumingSegments);
+ _minFreshnessMs = minFreshnessMs;
+ }
+
+ private boolean isOffsetCaughtUp(StreamPartitionMsgOffset currentOffset, StreamPartitionMsgOffset latestOffset) {
+ if (currentOffset != null && latestOffset != null) {
+ if (currentOffset.compareTo(latestOffset) == 0) {
+ return true;
+ }
+ if (currentOffset instanceof LongMsgOffset && latestOffset instanceof LongMsgOffset) {
Review Comment:
> @sajjad-moradi Seems we will have the same problem in the offset based status checker when the ingestion rate is very low? If we never consume anything since the server restarts, it will never reach the latest offset since it is exclusive.
>
> I feel we run into this issue because of the `fetchStreamPartitionOffset()` implementation for kafka 2.0. For all other implementations, it will return the last available offset, but for kafka 2.0 it returns the next offset after the last available offset. We should fix the contract for this method.
>
> IMO we should have a way to get the last available offset, and return `null` if there is no message available in the stream. That's the only way to ensure the consumption already catches up
That's correct. I created this issue for it: https://github.com/apache/pinot/issues/9291
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] navina commented on pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
navina commented on PR #9244:
URL: https://github.com/apache/pinot/pull/9244#issuecomment-1220985810
> I agree that this would likely be better as a table level check and maybe even happen continuously through the lifecycle of the server so the broker is aware what servers are fresh enough to server data (I think Kafka does something similar with its brokers).
Hmm.. I didn't know Kafka does something like this. I know that it tries to load the active partitions. However, a while back , it was made asynchronous. Perhaps I need to go back and see the latest code.
> That said, I think Pinot currently lacks some of the protection needed to do something like that. I know at the scale of our events, even 1 table catching up utilizes a large amount of CPU for example. And while tables can have their consumption rate limited, it's up to the user to make sure that's tuned correctly rather than being able to rely on Pinot to ensure there's always enough CPU to serve queries quickly.
Thanks for explain. I see where you are coming from. Basically, the user ends up tuning per-table level rate limit according to steady state and not peak / catchup traffic. I see the imbalance that can happen during startup on a cluster with multiple tables.
> But we've seen cases where the Offset based checker take 10-15 minutes to catchup to that offset at server start, the server starts serving queries, but then we are 10-15 minutes behind still and the server is slow to serve queries until it actually finishes catching up.
I see. My concern was around this checker not allowing the server to start during the startup timeout. I have noticed cases where sometimes a segment doesn't load and the status checker just hangs while the consumer is going full throttle to catchup. Eventually, the server times-out and reboots. That's why I felt it is better to de-couple the start-up validation from server health.
We can tackle this in a separate PR. But thanks for the context!
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] Jackie-Jiang commented on a diff in pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on code in PR #9244:
URL: https://github.com/apache/pinot/pull/9244#discussion_r950412090
##########
pinot-spi/src/main/java/org/apache/pinot/spi/utils/CommonConstants.java:
##########
@@ -385,6 +385,13 @@ public static class Server {
"pinot.server.starter.enableRealtimeOffsetBasedConsumptionStatusChecker";
public static final boolean DEFAULT_ENABLE_REALTIME_OFFSET_BASED_CONSUMPTION_STATUS_CHECKER = false;
+ public static final String CONFIG_OF_ENABLE_REALTIME_FRESHNESS_BASED_CONSUMPTION_STATUS_CHECKER =
+ "pinot.server.starter.enableRealtimeFreshnessBasedConsumptionStatusChecker";
+ public static final boolean DEFAULT_ENABLE_REALTIME_FRESHNESS_BASED_CONSUMPTION_STATUS_CHECKER = false;
+ public static final String CONFIG_OF_STARTUP_REALTIME_MIN_FRESHNESS_MS =
+ "pinot.server.starter.realtimeMinFreshnessMs";
+ public static final int DEFAULT_STARTUP_REALTIME_MIN_FRESHNESS_MS = 0;
Review Comment:
For a stream with high throughput, can this make it never able to catch up? I think a higher default is better, e.g. 10s
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/LLRealtimeSegmentDataManager.java:
##########
@@ -1440,6 +1440,17 @@ private void fetchLatestStreamOffset() {
}
}
+ public StreamPartitionMsgOffset fetchLatestStreamOffset(Long maxWaitTimeMs) {
Review Comment:
(minor)
```suggestion
public StreamPartitionMsgOffset fetchLatestStreamOffset(long maxWaitTimeMs) {
```
##########
pinot-server/src/main/java/org/apache/pinot/server/starter/helix/FreshnessBasedConsumptionStatusChecker.java:
##########
@@ -0,0 +1,154 @@
+/**
+ * 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.server.starter.helix;
+
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.pinot.common.utils.LLCSegmentName;
+import org.apache.pinot.core.data.manager.InstanceDataManager;
+import org.apache.pinot.core.data.manager.realtime.LLRealtimeSegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.SegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.TableDataManager;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.stream.LongMsgOffset;
+import org.apache.pinot.spi.stream.StreamPartitionMsgOffset;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class is used at startup time to have a more accurate estimate of the catchup period in which no query execution
+ * happens and consumers try to catch up to the latest messages available in streams.
+ * To achieve this, every time status check is called - {@link #getNumConsumingSegmentsNotReachedMinFreshness} -
+ * for each consuming segment, we check if either:
+ * - the segment's latest ingested offset has reached the current stream offset that's
+ * - the last ingested message is within {@link #_minFreshnessMs} of the current system time
+ */
+public class FreshnessBasedConsumptionStatusChecker {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FreshnessBasedConsumptionStatusChecker.class);
+
+ // constructor parameters
+ private final InstanceDataManager _instanceDataManager;
+ private final Set<String> _consumingSegments;
+ private final Long _minFreshnessMs;
Review Comment:
(minor) Same for other boxed `Long`
```suggestion
private final long _minFreshnessMs;
```
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/LLRealtimeSegmentDataManager.java:
##########
@@ -1440,6 +1440,17 @@ private void fetchLatestStreamOffset() {
}
}
+ public StreamPartitionMsgOffset fetchLatestStreamOffset(Long maxWaitTimeMs) {
+ try (StreamMetadataProvider metadataProvider = _streamConsumerFactory
+ .createPartitionMetadataProvider(_clientId, _partitionGroupId)) {
+ return metadataProvider.fetchStreamPartitionOffset(OffsetCriteria.LARGEST_OFFSET_CRITERIA, maxWaitTimeMs);
+ } catch (Exception e) {
+ _segmentLogger.warn("Cannot fetch latest stream offset for clientId {} and partitionGroupId {}", _clientId,
Review Comment:
Let's also log the `maxWaitTime`
##########
pinot-core/src/main/java/org/apache/pinot/core/data/manager/realtime/LLRealtimeSegmentDataManager.java:
##########
@@ -1440,6 +1440,17 @@ private void fetchLatestStreamOffset() {
}
}
+ public StreamPartitionMsgOffset fetchLatestStreamOffset(Long maxWaitTimeMs) {
Review Comment:
Seems we are always using 5s as the wait time. So we should either:
1. Make `fetchLatestStreamOffset()` public and use it
2. Remove `fetchLatestStreamOffset()`, and add a `DEFAULT_MAX_WAIT_TIME_MS` constant
##########
pinot-server/src/main/java/org/apache/pinot/server/starter/helix/FreshnessBasedConsumptionStatusChecker.java:
##########
@@ -0,0 +1,154 @@
+/**
+ * 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.server.starter.helix;
+
+import java.util.HashSet;
+import java.util.Set;
+import org.apache.pinot.common.utils.LLCSegmentName;
+import org.apache.pinot.core.data.manager.InstanceDataManager;
+import org.apache.pinot.core.data.manager.realtime.LLRealtimeSegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.SegmentDataManager;
+import org.apache.pinot.segment.local.data.manager.TableDataManager;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.stream.LongMsgOffset;
+import org.apache.pinot.spi.stream.StreamPartitionMsgOffset;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+/**
+ * This class is used at startup time to have a more accurate estimate of the catchup period in which no query execution
+ * happens and consumers try to catch up to the latest messages available in streams.
+ * To achieve this, every time status check is called - {@link #getNumConsumingSegmentsNotReachedMinFreshness} -
+ * for each consuming segment, we check if either:
+ * - the segment's latest ingested offset has reached the current stream offset that's
+ * - the last ingested message is within {@link #_minFreshnessMs} of the current system time
+ */
+public class FreshnessBasedConsumptionStatusChecker {
+ private static final Logger LOGGER = LoggerFactory.getLogger(FreshnessBasedConsumptionStatusChecker.class);
+
+ // constructor parameters
+ private final InstanceDataManager _instanceDataManager;
+ private final Set<String> _consumingSegments;
+ private final Long _minFreshnessMs;
+
+ // helper variable
+ private final Set<String> _caughtUpSegments = new HashSet<>();
+
+ public FreshnessBasedConsumptionStatusChecker(InstanceDataManager instanceDataManager, Set<String> consumingSegments,
+ Long minFreshnessMs) {
+ _instanceDataManager = instanceDataManager;
+ _consumingSegments = consumingSegments;
+ _minFreshnessMs = minFreshnessMs;
+ }
+
+ private boolean isOffsetCaughtUp(StreamPartitionMsgOffset currentOffset, StreamPartitionMsgOffset latestOffset) {
+ if (currentOffset != null && latestOffset != null) {
+ if (currentOffset.compareTo(latestOffset) == 0) {
+ return true;
+ }
+ long currentOffsetLong = ((LongMsgOffset) currentOffset).getOffset();
+ long latestOffsetLong = ((LongMsgOffset) latestOffset).getOffset();
+ // Kafka's "latest" offset is actually the next available offset. Therefore it will be 1 ahead of the
+ // current offset in the case we are caught up.
+ // We expect currentOffset == latestOffset if no messages have ever been published. Both will be 0.
+ // Otherwise, we never expect currentOffset > latestOffset, but we allow this to be caught up in case
+ // it ever happens so we're not stuck starting up.
+ return currentOffsetLong >= latestOffsetLong - 1;
+ }
+ return false;
+ }
+
+ protected Long now() {
+ return System.currentTimeMillis();
+ }
+
+ public int getNumConsumingSegmentsNotReachedMinFreshness() {
+ for (String segName : _consumingSegments) {
+ if (_caughtUpSegments.contains(segName)) {
+ continue;
+ }
+ TableDataManager tableDataManager = getTableDataManager(segName);
+ if (tableDataManager == null) {
+ LOGGER.info("TableDataManager is not yet setup for segment {}. Will check consumption status later", segName);
+ continue;
+ }
+ SegmentDataManager segmentDataManager = null;
+ try {
+ segmentDataManager = tableDataManager.acquireSegment(segName);
+ if (segmentDataManager == null) {
+ LOGGER.info("SegmentDataManager is not yet setup for segment {}. Will check consumption status later",
+ segName);
+ continue;
+ }
+ if (!(segmentDataManager instanceof LLRealtimeSegmentDataManager)) {
+ // There's a possibility that a consuming segment has converted to a committed segment. If that's the case,
+ // segment data manager will not be of type LLRealtime.
+ LOGGER.info("Segment {} is already committed and is considered caught up.", segName);
+ _caughtUpSegments.add(segName);
+ continue;
+ }
+ LLRealtimeSegmentDataManager rtSegmentDataManager = (LLRealtimeSegmentDataManager) segmentDataManager;
+ Long now = now();
Review Comment:
(minor) Change boxed `Long` to primitive, same for other places
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org
[GitHub] [pinot] navina commented on pull request #9244: add a freshness based consumption status checker
Posted by GitBox <gi...@apache.org>.
navina commented on PR #9244:
URL: https://github.com/apache/pinot/pull/9244#issuecomment-1220074413
@jadami10 Iiuc, this check basically happens during server startup, but pertains to a table catching up with some point in its source. This approach tightly couples table query readiness and server liveness. Is there a reason why this "freshness based consumption catch-up" can't be done at a per table-level?
--
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: commits-unsubscribe@pinot.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org