You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2021/09/23 19:39:37 UTC
[GitHub] [druid] vogievetsky commented on a change in pull request #11738: Support real query cancelling for web console
vogievetsky commented on a change in pull request #11738:
URL: https://github.com/apache/druid/pull/11738#discussion_r715094949
##########
File path: web-console/src/views/query-view/query-view.tsx
##########
@@ -196,6 +196,10 @@ export class QueryView extends React.PureComponent<QueryViewProps, QueryViewStat
return Api.instance.post(`/druid/v2${isSql ? '/sql' : ''}`, payload, { cancelToken });
});
+ const generateQueryId = (): string => {
Review comment:
I think druid query ids are normally UUID v4 by convention. it would be best to stick to that. Use an off the shelf uuid v4 library like https://www.npmjs.com/package/uuid instead on hand rolling a random number generator here.
##########
File path: web-console/src/views/query-view/query-view.tsx
##########
@@ -205,14 +209,23 @@ export class QueryView extends React.PureComponent<QueryViewProps, QueryViewStat
const query = QueryView.isJsonLike(queryString) ? Hjson.parse(queryString) : queryString;
+ const queryId = generateQueryId();
+
+ const isSql = !QueryView.isJsonLike(queryString);
Review comment:
no need to call `QueryView.isJsonLike(queryString)` twice in 3 lines, call it once up top and then reuse the variable
##########
File path: web-console/src/views/query-view/query-view.tsx
##########
@@ -205,14 +209,23 @@ export class QueryView extends React.PureComponent<QueryViewProps, QueryViewStat
const query = QueryView.isJsonLike(queryString) ? Hjson.parse(queryString) : queryString;
+ const queryId = generateQueryId();
+
+ const isSql = !QueryView.isJsonLike(queryString);
+
let context: Record<string, any> | undefined;
if (!isEmptyContext(queryContext) || wrapQueryLimit || mandatoryQueryContext) {
context = { ...queryContext, ...(mandatoryQueryContext || {}) };
+ context.sqlQueryId = queryId;
if (typeof wrapQueryLimit !== 'undefined') {
context.sqlOuterLimit = wrapQueryLimit + 1;
}
}
+ void cancelToken.promise.then(() => {
+ void Api.instance.delete(`/druid/v2/${isSql ? '/sql' : ''}/${queryId}`);
Review comment:
will `void` here be enough to make sure nothing complains about an unhandled promise rejection (we do not want to trigger https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event)? Can you try this when it fails? Does the error get fully ignored or is there a need for `.catch(() => {})` ? If I was in your place I would add the `.catch(() => {})` just to be sure (and to save time on doing the proper research)
##########
File path: web-console/src/views/query-view/query-view.tsx
##########
@@ -205,14 +209,23 @@ export class QueryView extends React.PureComponent<QueryViewProps, QueryViewStat
const query = QueryView.isJsonLike(queryString) ? Hjson.parse(queryString) : queryString;
+ const queryId = generateQueryId();
+
+ const isSql = !QueryView.isJsonLike(queryString);
+
let context: Record<string, any> | undefined;
if (!isEmptyContext(queryContext) || wrapQueryLimit || mandatoryQueryContext) {
context = { ...queryContext, ...(mandatoryQueryContext || {}) };
+ context.sqlQueryId = queryId;
Review comment:
where are you setting the `context.queryId` if this is not a SQL query?
--
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@druid.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org