Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "add freshness lag when there are no consuming segments (#8911)" #1

Open
wants to merge 1 commit into
base: bugFix-GcsIssue-9555-release-0.11.0
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.apache.pinot.core.common.datatable.DataTableFactory;
import org.apache.pinot.core.common.datatable.DataTableUtils;
import org.apache.pinot.core.data.manager.InstanceDataManager;
import org.apache.pinot.core.data.manager.realtime.RealtimeTableDataManager;
import org.apache.pinot.core.operator.filter.EmptyFilterOperator;
import org.apache.pinot.core.operator.filter.MatchAllFilterOperator;
import org.apache.pinot.core.plan.Plan;
Expand All @@ -70,15 +69,13 @@
import org.apache.pinot.segment.local.data.manager.SegmentDataManager;
import org.apache.pinot.segment.local.data.manager.TableDataManager;
import org.apache.pinot.segment.spi.AggregationFunctionType;
import org.apache.pinot.segment.spi.ImmutableSegment;
import org.apache.pinot.segment.spi.IndexSegment;
import org.apache.pinot.segment.spi.MutableSegment;
import org.apache.pinot.segment.spi.SegmentMetadata;
import org.apache.pinot.spi.env.PinotConfiguration;
import org.apache.pinot.spi.exception.BadQueryRequestException;
import org.apache.pinot.spi.trace.Tracing;
import org.apache.pinot.spi.utils.CommonConstants;
import org.joda.time.Interval;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -200,41 +197,19 @@ private DataTable processQueryInternal(ServerQueryRequest queryRequest, Executor

// Gather stats for realtime consuming segments
int numConsumingSegmentsQueried = 0;
int numOnlineSegments = 0;
long minIndexTimeMs = 0;
long minIngestionTimeMs = 0;
long maxEndTimeMs = 0;
if (tableDataManager instanceof RealtimeTableDataManager) {
numConsumingSegmentsQueried = 0;
numOnlineSegments = 0;
minIndexTimeMs = Long.MAX_VALUE;
minIngestionTimeMs = Long.MAX_VALUE;
maxEndTimeMs = Long.MIN_VALUE;
for (IndexSegment indexSegment : indexSegments) {
if (indexSegment instanceof MutableSegment) {
numConsumingSegmentsQueried += 1;
SegmentMetadata segmentMetadata = indexSegment.getSegmentMetadata();
long indexTimeMs = segmentMetadata.getLastIndexedTimestamp();
if (indexTimeMs != Long.MIN_VALUE && indexTimeMs < minIndexTimeMs) {
minIndexTimeMs = indexTimeMs;
}
long ingestionTimeMs = segmentMetadata.getLatestIngestionTimestamp();
if (ingestionTimeMs != Long.MIN_VALUE && ingestionTimeMs < minIngestionTimeMs) {
minIngestionTimeMs = ingestionTimeMs;
}
} else if (indexSegment instanceof ImmutableSegment) {
SegmentMetadata segmentMetadata = indexSegment.getSegmentMetadata();
long indexCreationTime = segmentMetadata.getIndexCreationTime();
numOnlineSegments++;
if (indexCreationTime != Long.MIN_VALUE) {
maxEndTimeMs = Math.max(maxEndTimeMs, indexCreationTime);
} else {
// NOTE: the endTime may be totally inaccurate based on the value added in the timeColumn
Interval timeInterval = segmentMetadata.getTimeInterval();
if (timeInterval != null) {
maxEndTimeMs = Math.max(maxEndTimeMs, timeInterval.getEndMillis());
}
}
long minIndexTimeMs = Long.MAX_VALUE;
long minIngestionTimeMs = Long.MAX_VALUE;
for (IndexSegment indexSegment : indexSegments) {
if (indexSegment instanceof MutableSegment) {
numConsumingSegmentsQueried += 1;
SegmentMetadata segmentMetadata = indexSegment.getSegmentMetadata();
long indexTimeMs = segmentMetadata.getLastIndexedTimestamp();
if (indexTimeMs != Long.MIN_VALUE && indexTimeMs < minIndexTimeMs) {
minIndexTimeMs = indexTimeMs;
}
long ingestionTimeMs = segmentMetadata.getLatestIngestionTimestamp();
if (ingestionTimeMs != Long.MIN_VALUE && ingestionTimeMs < minIngestionTimeMs) {
minIngestionTimeMs = ingestionTimeMs;
}
}
}
Expand Down Expand Up @@ -288,21 +263,12 @@ private DataTable processQueryInternal(ServerQueryRequest queryRequest, Executor
_serverMetrics.addMeteredTableValue(tableNameWithType, ServerMeter.NUM_MISSING_SEGMENTS, numMissingSegments);
}

if (tableDataManager instanceof RealtimeTableDataManager) {
long minConsumingFreshnessTimeMs = Long.MAX_VALUE;
if (numConsumingSegmentsQueried > 0) {
minConsumingFreshnessTimeMs = minIngestionTimeMs != Long.MAX_VALUE ? minIngestionTimeMs : minIndexTimeMs;
metadata.put(MetadataKey.NUM_CONSUMING_SEGMENTS_QUERIED.getName(),
Integer.toString(numConsumingSegmentsQueried));
metadata.put(MetadataKey.MIN_CONSUMING_FRESHNESS_TIME_MS.getName(), Long.toString(minConsumingFreshnessTimeMs));
LOGGER.debug("Request {} queried {} consuming segments with minConsumingFreshnessTimeMs: {}", requestId,
numConsumingSegmentsQueried, minConsumingFreshnessTimeMs);
} else if (numConsumingSegmentsQueried == 0 && maxEndTimeMs != Long.MIN_VALUE) {
minConsumingFreshnessTimeMs = maxEndTimeMs;
metadata.put(MetadataKey.MIN_CONSUMING_FRESHNESS_TIME_MS.getName(), Long.toString(maxEndTimeMs));
LOGGER.debug("Request {} queried {} consuming segments with minConsumingFreshnessTimeMs: {}", requestId,
numConsumingSegmentsQueried, minConsumingFreshnessTimeMs);
}
if (numConsumingSegmentsQueried > 0) {
long minConsumingFreshnessTimeMs = minIngestionTimeMs != Long.MAX_VALUE ? minIngestionTimeMs : minIndexTimeMs;
LOGGER.debug("Request {} queried {} consuming segments with minConsumingFreshnessTimeMs: {}", requestId,
numConsumingSegmentsQueried, minConsumingFreshnessTimeMs);
metadata.put(MetadataKey.NUM_CONSUMING_SEGMENTS_QUERIED.getName(), Integer.toString(numConsumingSegmentsQueried));
metadata.put(MetadataKey.MIN_CONSUMING_FRESHNESS_TIME_MS.getName(), Long.toString(minConsumingFreshnessTimeMs));
}

LOGGER.debug("Query processing time for request Id - {}: {}", requestId, queryProcessingTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,8 +310,6 @@ protected void setStats(String rawTableName, BrokerResponseNative brokerResponse
brokerResponseNative.setExplainPlanNumMatchAllFilterSegments(_explainPlanNumMatchAllFilterSegments);
if (_numConsumingSegmentsQueried > 0) {
brokerResponseNative.setNumConsumingSegmentsQueried(_numConsumingSegmentsQueried);
}
if (_minConsumingFreshnessTimeMs != Long.MAX_VALUE) {
brokerResponseNative.setMinConsumingFreshnessTimeMs(_minConsumingFreshnessTimeMs);
}
brokerResponseNative.setNumConsumingSegmentsProcessed(_numConsumingSegmentsProcessed);
Expand Down Expand Up @@ -342,7 +340,7 @@ protected void setStats(String rawTableName, BrokerResponseNative brokerResponse
brokerMetrics.addTimedTableValue(rawTableName, BrokerTimer.REALTIME_TOTAL_CPU_TIME_NS, _realtimeTotalCpuTimeNs,
TimeUnit.NANOSECONDS);

if (_minConsumingFreshnessTimeMs != Long.MAX_VALUE) {
if (_numConsumingSegmentsQueried > 0 && _minConsumingFreshnessTimeMs > 0) {
brokerMetrics.addTimedTableValue(rawTableName, BrokerTimer.FRESHNESS_LAG_MS,
System.currentTimeMillis() - _minConsumingFreshnessTimeMs, TimeUnit.MILLISECONDS);
}
Expand Down