gortiz commented on code in PR #16728:
URL: https://github.com/apache/pinot/pull/16728#discussion_r2359126666
##########
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/MultiStageBrokerRequestHandler.java:
##########
@@ -304,23 +294,34 @@ protected BrokerResponse handleRequestThrowing(long
requestId, String query, Sql
throws QueryException, WebApplicationException {
_queryLogger.log(requestId, query);
+ String cid = extractClientRequestId(sqlNodeAndOptions);
+ if (cid == null) {
+ cid = Long.toString(requestId);
+ }
Map<String, String> options = sqlNodeAndOptions.getOptions();
- long queryTimeoutMs = getTimeout(options);
- QueryThreadContext.setActiveDeadlineMs(System.currentTimeMillis() +
queryTimeoutMs);
- QueryThreadContext.setPassiveDeadlineMs(System.currentTimeMillis() +
queryTimeoutMs + getPassiveTimeout(options));
-
- Timer queryTimer = new Timer(queryTimeoutMs, TimeUnit.MILLISECONDS);
-
- try (QueryEnvironment.CompiledQuery compiledQuery =
- compileQuery(requestId, query, sqlNodeAndOptions, httpHeaders,
queryTimer)) {
- AtomicBoolean rlsFiltersApplied = new AtomicBoolean(false);
- checkAuthorization(requesterIdentity, requestContext, httpHeaders,
compiledQuery, rlsFiltersApplied);
-
- if (sqlNodeAndOptions.getSqlNode().getKind() == SqlKind.EXPLAIN) {
- return explain(compiledQuery, requestId, requestContext, queryTimer);
- } else {
- return query(compiledQuery, requestId, requesterIdentity,
requestContext, httpHeaders, queryTimer,
- rlsFiltersApplied.get());
+ String workloadName =
QueryOptionsUtils.getWorkloadName(sqlNodeAndOptions.getOptions());
+ long startTimeMs = requestContext.getRequestArrivalTimeMillis();
+ long timeoutMs = getTimeoutMs(options);
+ Timer queryTimer = new Timer(timeoutMs, TimeUnit.MILLISECONDS);
+ long activeDeadlineMs = startTimeMs + timeoutMs;
+ long passiveDeadlineMs = activeDeadlineMs +
getExtraPassiveTimeoutMs(options);
+
+ QueryExecutionContext executionContext =
+ new QueryExecutionContext(QueryExecutionContext.QueryType.MSE,
requestId, cid, workloadName, startTimeMs,
+ activeDeadlineMs, passiveDeadlineMs, _brokerId, _brokerId);
+ QueryThreadContext.MseWorkerInfo mseWorkerInfo = new
QueryThreadContext.MseWorkerInfo(0, 0);
+ try (QueryThreadContext ignore = QueryThreadContext.open(executionContext,
mseWorkerInfo, _threadAccountant)) {
+ try (QueryEnvironment.CompiledQuery compiledQuery =
compileQuery(requestId, query, sqlNodeAndOptions, httpHeaders,
+ queryTimer)) {
Review Comment:
Why these two trys? couldn't we do something like:
```java
try (QueryThreadContext ignore = QueryThreadContext.open(...);
QueryEnvironment.CompiledQuery compiledQuery = compileQuery(...)) {
...
}
```
##########
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/MultiStageBrokerRequestHandler.java:
##########
@@ -458,15 +447,14 @@ private BrokerResponse
explain(QueryEnvironment.CompiledQuery query, long reques
throws WebApplicationException, QueryException {
Map<String, String> queryOptions = query.getOptions();
- boolean askServers = QueryOptionsUtils.isExplainAskingServers(queryOptions)
- .orElse(_explainAskingServerDefault);
+ boolean askServers =
QueryOptionsUtils.isExplainAskingServers(queryOptions).orElse(_explainAskingServerDefault);
@Nullable
- AskingServerStageExplainer.OnServerExplainer fragmentToPlanNode =
askServers
- ? fragment -> requestPhysicalPlan(fragment, requestContext,
timer.getRemainingTimeMs(), queryOptions)
- : null;
+ AskingServerStageExplainer.OnServerExplainer fragmentToPlanNode =
+ askServers ? fragment -> requestPhysicalPlan(fragment, requestContext,
timer.getRemainingTimeMs(), queryOptions)
Review Comment:
All these code style changes are unnecessary for the PR and very
opinionated. Could we revert them?
##########
pinot-broker/src/main/java/org/apache/pinot/broker/requesthandler/MultiStageBrokerRequestHandler.java:
##########
@@ -379,43 +379,32 @@ private void checkAuthorization(RequesterIdentity
requesterIdentity, RequestCont
private ImmutableQueryEnvironment.Config getQueryEnvConf(HttpHeaders
httpHeaders, Map<String, String> queryOptions,
long requestId) {
String database =
DatabaseUtils.extractDatabaseFromQueryRequest(queryOptions, httpHeaders);
- boolean inferPartitionHint =
_config.getProperty(CommonConstants.Broker.CONFIG_OF_INFER_PARTITION_HINT,
- CommonConstants.Broker.DEFAULT_INFER_PARTITION_HINT);
- boolean defaultUseSpool =
_config.getProperty(CommonConstants.Broker.CONFIG_OF_SPOOLS,
- CommonConstants.Broker.DEFAULT_OF_SPOOLS);
- boolean defaultUseLeafServerForIntermediateStage = _config.getProperty(
-
CommonConstants.Broker.CONFIG_OF_USE_LEAF_SERVER_FOR_INTERMEDIATE_STAGE,
- CommonConstants.Broker.DEFAULT_USE_LEAF_SERVER_FOR_INTERMEDIATE_STAGE);
- boolean defaultEnableGroupTrim =
_config.getProperty(CommonConstants.Broker.CONFIG_OF_MSE_ENABLE_GROUP_TRIM,
- CommonConstants.Broker.DEFAULT_MSE_ENABLE_GROUP_TRIM);
- boolean defaultEnableDynamicFilteringSemiJoin = _config.getProperty(
-
CommonConstants.Broker.CONFIG_OF_BROKER_ENABLE_DYNAMIC_FILTERING_SEMI_JOIN,
- CommonConstants.Broker.DEFAULT_ENABLE_DYNAMIC_FILTERING_SEMI_JOIN);
- boolean defaultUsePhysicalOptimizer = _config.getProperty(
- CommonConstants.Broker.CONFIG_OF_USE_PHYSICAL_OPTIMIZER,
- CommonConstants.Broker.DEFAULT_USE_PHYSICAL_OPTIMIZER);
- boolean defaultUseLiteMode = _config.getProperty(
- CommonConstants.Broker.CONFIG_OF_USE_LITE_MODE,
- CommonConstants.Broker.DEFAULT_USE_LITE_MODE);
- boolean defaultRunInBroker = _config.getProperty(
- CommonConstants.Broker.CONFIG_OF_RUN_IN_BROKER,
- CommonConstants.Broker.DEFAULT_RUN_IN_BROKER);
- boolean defaultUseBrokerPruning = _config.getProperty(
- CommonConstants.Broker.CONFIG_OF_USE_BROKER_PRUNING,
- CommonConstants.Broker.DEFAULT_USE_BROKER_PRUNING);
- int defaultLiteModeLeafStageLimit = _config.getProperty(
- CommonConstants.Broker.CONFIG_OF_LITE_MODE_LEAF_STAGE_LIMIT,
- CommonConstants.Broker.DEFAULT_LITE_MODE_LEAF_STAGE_LIMIT);
- int defaultLiteModeFanoutAdjustedLimit = _config.getProperty(
-
CommonConstants.Broker.CONFIG_OF_LITE_MODE_LEAF_STAGE_FANOUT_ADJUSTED_LIMIT,
-
CommonConstants.Broker.DEFAULT_LITE_MODE_LEAF_STAGE_FAN_OUT_ADJUSTED_LIMIT);
- String defaultHashFunction = _config.getProperty(
- CommonConstants.Broker.CONFIG_OF_BROKER_DEFAULT_HASH_FUNCTION,
- CommonConstants.Broker.DEFAULT_BROKER_DEFAULT_HASH_FUNCTION);
- boolean caseSensitive = !_config.getProperty(
- CommonConstants.Helix.ENABLE_CASE_INSENSITIVE_KEY,
- CommonConstants.Helix.DEFAULT_ENABLE_CASE_INSENSITIVE
- );
+ boolean inferPartitionHint =
+ _config.getProperty(Broker.CONFIG_OF_INFER_PARTITION_HINT,
Broker.DEFAULT_INFER_PARTITION_HINT);
+ boolean defaultUseSpool = _config.getProperty(Broker.CONFIG_OF_SPOOLS,
Broker.DEFAULT_OF_SPOOLS);
+ boolean defaultUseLeafServerForIntermediateStage =
+
_config.getProperty(Broker.CONFIG_OF_USE_LEAF_SERVER_FOR_INTERMEDIATE_STAGE,
+ Broker.DEFAULT_USE_LEAF_SERVER_FOR_INTERMEDIATE_STAGE);
+ boolean defaultEnableGroupTrim =
+ _config.getProperty(Broker.CONFIG_OF_MSE_ENABLE_GROUP_TRIM,
Broker.DEFAULT_MSE_ENABLE_GROUP_TRIM);
+ boolean defaultEnableDynamicFilteringSemiJoin =
+
_config.getProperty(Broker.CONFIG_OF_BROKER_ENABLE_DYNAMIC_FILTERING_SEMI_JOIN,
+ Broker.DEFAULT_ENABLE_DYNAMIC_FILTERING_SEMI_JOIN);
+ boolean defaultUsePhysicalOptimizer =
+ _config.getProperty(Broker.CONFIG_OF_USE_PHYSICAL_OPTIMIZER,
Broker.DEFAULT_USE_PHYSICAL_OPTIMIZER);
+ boolean defaultUseLiteMode =
_config.getProperty(Broker.CONFIG_OF_USE_LITE_MODE,
Broker.DEFAULT_USE_LITE_MODE);
+ boolean defaultRunInBroker =
_config.getProperty(Broker.CONFIG_OF_RUN_IN_BROKER,
Broker.DEFAULT_RUN_IN_BROKER);
+ boolean defaultUseBrokerPruning =
+ _config.getProperty(Broker.CONFIG_OF_USE_BROKER_PRUNING,
Broker.DEFAULT_USE_BROKER_PRUNING);
+ int defaultLiteModeLeafStageLimit =
+ _config.getProperty(Broker.CONFIG_OF_LITE_MODE_LEAF_STAGE_LIMIT,
Broker.DEFAULT_LITE_MODE_LEAF_STAGE_LIMIT);
+ int defaultLiteModeFanoutAdjustedLimit =
+
_config.getProperty(Broker.CONFIG_OF_LITE_MODE_LEAF_STAGE_FANOUT_ADJUSTED_LIMIT,
+ Broker.DEFAULT_LITE_MODE_LEAF_STAGE_FAN_OUT_ADJUSTED_LIMIT);
+ String defaultHashFunction =
+ _config.getProperty(Broker.CONFIG_OF_BROKER_DEFAULT_HASH_FUNCTION,
Broker.DEFAULT_BROKER_DEFAULT_HASH_FUNCTION);
+ boolean caseSensitive =
+ !_config.getProperty(Helix.ENABLE_CASE_INSENSITIVE_KEY,
Helix.DEFAULT_ENABLE_CASE_INSENSITIVE);
Review Comment:
I think the previous code was quite easier to read.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]