-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Add user-facing warning when MSE Lite hits implicit query limits #18725
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| /** | ||
| * 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.common.response.broker; | ||
|
|
||
| import com.fasterxml.jackson.databind.JsonNode; | ||
| import org.apache.pinot.common.datatable.StatMap; | ||
| import org.apache.pinot.spi.utils.JsonUtils; | ||
| import org.testng.annotations.Test; | ||
|
|
||
| import static org.testng.Assert.assertEquals; | ||
| import static org.testng.Assert.assertFalse; | ||
| import static org.testng.Assert.assertTrue; | ||
|
|
||
|
|
||
| public class BrokerResponseNativeV2LiteModeTest { | ||
|
|
||
| @Test | ||
| public void testLiteModeLeafStageLimitReachedMarksPartialResult() { | ||
| BrokerResponseNativeV2 brokerResponse = new BrokerResponseNativeV2(); | ||
| assertFalse(brokerResponse.isMseLiteLeafStageLimitReached()); | ||
| assertFalse(brokerResponse.isPartialResult()); | ||
|
|
||
| brokerResponse.mergeMseLiteLeafStageLimitReached(true); | ||
|
|
||
| assertTrue(brokerResponse.isMseLiteLeafStageLimitReached()); | ||
| assertTrue(brokerResponse.isPartialResult()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testLiteModeLeafStageLimitReachedViaStatMap() { | ||
| BrokerResponseNativeV2 brokerResponse = new BrokerResponseNativeV2(); | ||
| brokerResponse.addBrokerStats(new StatMap<>(BrokerResponseNativeV2.StatKey.class) | ||
| .merge(BrokerResponseNativeV2.StatKey.LITE_MODE_LEAF_STAGE_LIMIT_REACHED, true)); | ||
|
|
||
| assertTrue(brokerResponse.isMseLiteLeafStageLimitReached()); | ||
| assertTrue(brokerResponse.isPartialResult()); | ||
| } | ||
|
|
||
| @Test | ||
| public void testLiteModeFieldsInJsonSerialization() | ||
| throws Exception { | ||
| BrokerResponseNativeV2 brokerResponse = new BrokerResponseNativeV2(); | ||
| brokerResponse.mergeMseLiteLeafStageLimitReached(true); | ||
| brokerResponse.setMseLiteLeafStageEffectiveLimit(100); | ||
| brokerResponse.setMseLiteFanOutAdjustedLimitApplied(true); | ||
|
|
||
| JsonNode json = JsonUtils.objectToJsonNode(brokerResponse); | ||
|
|
||
| assertTrue(json.path("mseLiteLeafStageLimitReached").asBoolean(false)); | ||
| assertEquals(json.path("mseLiteLeafStageEffectiveLimit").asInt(), 100); | ||
| assertTrue(json.path("mseLiteFanOutAdjustedLimitApplied").asBoolean(false)); | ||
| assertTrue(json.path("partialResult").asBoolean(false)); | ||
| } | ||
|
|
||
| @Test | ||
| public void testLiteModeFieldsNotSerializedWhenDefault() | ||
| throws Exception { | ||
| BrokerResponseNativeV2 brokerResponse = new BrokerResponseNativeV2(); | ||
|
|
||
| JsonNode json = JsonUtils.objectToJsonNode(brokerResponse); | ||
|
|
||
| assertFalse(json.has("mseLiteLeafStageEffectiveLimit")); | ||
| assertFalse(json.has("mseLiteFanOutAdjustedLimitApplied")); | ||
| } | ||
|
|
||
| @Test | ||
| public void testPartialResultNotSetWhenLimitNotReached() { | ||
| BrokerResponseNativeV2 brokerResponse = new BrokerResponseNativeV2(); | ||
| brokerResponse.setMseLiteLeafStageEffectiveLimit(100); | ||
|
|
||
| assertFalse(brokerResponse.isMseLiteLeafStageLimitReached()); | ||
| assertFalse(brokerResponse.isPartialResult()); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,7 @@ | |
| import java.util.Collections; | ||
| import java.util.List; | ||
| import org.apache.pinot.common.datatable.DataTable.MetadataKey; | ||
| import org.apache.pinot.common.utils.config.QueryOptionsUtils; | ||
| import org.apache.pinot.core.common.Operator; | ||
| import org.apache.pinot.core.operator.blocks.InstanceResponseBlock; | ||
| import org.apache.pinot.core.operator.blocks.results.BaseResultsBlock; | ||
|
|
@@ -29,10 +30,13 @@ | |
| import org.apache.pinot.segment.spi.FetchContext; | ||
| import org.apache.pinot.segment.spi.SegmentContext; | ||
| import org.apache.pinot.spi.accounting.ThreadResourceSnapshot; | ||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
|
|
||
|
|
||
| public class InstanceResponseOperator extends BaseOperator<InstanceResponseBlock> { | ||
| private static final String EXPLAIN_NAME = "INSTANCE_RESPONSE"; | ||
| private static final Logger LOGGER = LoggerFactory.getLogger(InstanceResponseOperator.class); | ||
|
|
||
| protected final BaseCombineOperator<?> _combineOperator; | ||
| protected final List<SegmentContext> _segmentContexts; | ||
|
|
@@ -96,6 +100,13 @@ protected InstanceResponseBlock buildInstanceResponseBlock(BaseResultsBlock base | |
| String.valueOf(_threadMemAllocatedBytes)); | ||
| instanceResponseBlock.addMetadata(MetadataKey.SYSTEM_ACTIVITIES_CPU_TIME_NS.getName(), | ||
| String.valueOf(_systemActivitiesCpuTimeNs)); | ||
| Integer implicitLimit = QueryOptionsUtils.getLiteModeImplicitLeafStageLimit( | ||
| _queryContext.getQueryOptions()); | ||
| // false-positive when table has exactly implicitLimit rows | ||
| if (implicitLimit != null && baseResultsBlock.getNumRows() >= implicitLimit) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is a known and documented limitation (and should be rare in reality) both in code and PR. Will add a note in MSE Lite docs too |
||
| instanceResponseBlock.addMetadata( | ||
| MetadataKey.LITE_MODE_LEAF_STAGE_LIMIT_REACHED.getName(), "true"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. would it better to log also, afair, baseResultsBlock should ideally have at most implicitLimit rows because both selection and group by operators will not allow returning more than that. in that case i guess we can just keep this true
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dont think that's needed. the final response has a |
||
| } | ||
| return instanceResponseBlock; | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you might also want to emit a metric when the limit is reached. also from Cellar PoV, with the current change would you be able to identify exact queries which hit this limit? you might want to ensure that broker event listener captures this flag too
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense.
Added a metric at the end similar to
groupsTrimmed. And added the flag toaugmentStatisticsinBaseBrokerRequestHandler