Skip to content

Commit

Permalink
completely disable query cancellation to see if that is impacting pla…
Browse files Browse the repository at this point in the history
…ywright
  • Loading branch information
pauldambra committed Dec 22, 2022
1 parent b3c5e2f commit 09234ce
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 54 deletions.
52 changes: 25 additions & 27 deletions frontend/src/scenes/dashboard/dashboardLogic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import { insightsModel } from '~/models/insightsModel'
import {
AUTO_REFRESH_DASHBOARD_THRESHOLD_HOURS,
DashboardPrivilegeLevel,
FEATURE_FLAGS,
OrganizationMembershipLevel,
} from 'lib/constants'
import { DashboardEventSource, eventUsageLogic } from 'lib/utils/eventUsageLogic'
Expand Down Expand Up @@ -187,7 +186,6 @@ export const dashboardLogic = kea<dashboardLogicType>([
loadingDashboardItemsStarted: (action: string, dashboardQueryId: string) => ({ action, dashboardQueryId }),
setInitialLoadResponseBytes: (responseBytes: number) => ({ responseBytes }),
abortQuery: (payload: { dashboardQueryId: string; queryId: string; queryStartTime: number }) => payload,
abortAnyRunningQuery: true,
}),

loaders(({ actions, props, values }) => ({
Expand Down Expand Up @@ -226,7 +224,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
return values.allItems
}

actions.abortAnyRunningQuery()
// actions.abortAnyRunningQuery()

try {
return await api.update(`api/projects/${values.currentTeamId}/dashboards/${props.id}`, {
Expand Down Expand Up @@ -924,7 +922,7 @@ export const dashboardLogic = kea<dashboardLogicType>([
)

// we will use one abort controller for all insight queries for this dashboard
actions.abortAnyRunningQuery()
// actions.abortAnyRunningQuery()
cache.abortController = new AbortController()
const methodOptions: ApiMethodOptions = {
signal: cache.abortController.signal,
Expand Down Expand Up @@ -1156,30 +1154,30 @@ export const dashboardLogic = kea<dashboardLogicType>([
}
},
abortAnyRunningQuery: () => {
if (cache.abortController) {
cache.abortController.abort()
cache.abortController = null
}
// if (cache.abortController) {
// cache.abortController.abort()
// cache.abortController = null
// }
},
abortQuery: async ({ dashboardQueryId, queryId, queryStartTime }) => {
const { currentTeamId } = values
if (values.featureFlags[FEATURE_FLAGS.CANCEL_RUNNING_QUERIES]) {
await api.create(`api/projects/${currentTeamId}/insights/cancel`, { client_query_id: dashboardQueryId })

// TRICKY: we cancel just once using the dashboard query id.
// we can record the queryId that happened to capture the AbortError exception
// and request the cancellation, but it is probably not particularly relevant
await captureTimeToSeeData(values.currentTeamId, {
type: 'insight_load',
context: 'dashboard',
dashboard_query_id: dashboardQueryId,
query_id: queryId,
status: 'cancelled',
time_to_see_data_ms: Math.floor(performance.now() - queryStartTime),
insights_fetched: 0,
insights_fetched_cached: 0,
})
}
abortQuery: async () => {
// const { currentTeamId } = values
// if (values.featureFlags[FEATURE_FLAGS.CANCEL_RUNNING_QUERIES]) {
// await api.create(`api/projects/${currentTeamId}/insights/cancel`, { client_query_id: dashboardQueryId })
//
// // TRICKY: we cancel just once using the dashboard query id.
// // we can record the queryId that happened to capture the AbortError exception
// // and request the cancellation, but it is probably not particularly relevant
// await captureTimeToSeeData(values.currentTeamId, {
// type: 'insight_load',
// context: 'dashboard',
// dashboard_query_id: dashboardQueryId,
// query_id: queryId,
// status: 'cancelled',
// time_to_see_data_ms: Math.floor(performance.now() - queryStartTime),
// insights_fetched: 0,
// insights_fetched_cached: 0,
// })
// }
},
})),

Expand Down
53 changes: 26 additions & 27 deletions frontend/src/scenes/insights/insightLogic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import { urls } from 'scenes/urls'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { actionsModel } from '~/models/actionsModel'
import * as Sentry from '@sentry/react'
import { DashboardPrivilegeLevel, FEATURE_FLAGS } from 'lib/constants'
import { DashboardPrivilegeLevel } from 'lib/constants'
import { groupsModel } from '~/models/groupsModel'
import { cohortsModel } from '~/models/cohortsModel'
import { mathsLogic } from 'scenes/trends/mathsLogic'
Expand Down Expand Up @@ -171,7 +171,6 @@ export const insightLogic = kea<insightLogicType>([
toggleVisibility: (index: number) => ({ index }),
setHiddenById: (entry: Record<string, boolean | undefined>) => ({ entry }),
highlightSeries: (seriesIndex: number | null) => ({ seriesIndex }),
abortAnyRunningQuery: true,
}),
loaders(({ actions, cache, values, props }) => ({
insight: [
Expand Down Expand Up @@ -296,7 +295,7 @@ export const insightLogic = kea<insightLogicType>([
// fetch this now, as it might be different when we report below
const scene = sceneLogic.isMounted() ? sceneLogic.values.scene : null

actions.abortAnyRunningQuery()
// actions.abortAnyRunningQuery()
cache.abortController = new AbortController()
const methodOptions: ApiMethodOptions = {
signal: cache.abortController.signal,
Expand Down Expand Up @@ -745,7 +744,7 @@ export const insightLogic = kea<insightLogicType>([
},
],
}),
listeners(({ actions, selectors, values, cache }) => ({
listeners(({ actions, selectors, values }) => ({
setFiltersMerge: ({ filters }) => {
actions.setFilters({ ...values.filters, ...filters })
},
Expand Down Expand Up @@ -859,30 +858,30 @@ export const insightLogic = kea<insightLogicType>([
actions.setIsLoading(true)
},
abortAnyRunningQuery: () => {
if (cache.abortController) {
cache.abortController.abort()
cache.abortController = null
}
// if (cache.abortController) {
// cache.abortController.abort()
// cache.abortController = null
// }
},
abortQuery: async ({ queryId }) => {
const { currentTeamId } = values

if (values.featureFlags[FEATURE_FLAGS.CANCEL_RUNNING_QUERIES]) {
await api.create(`api/projects/${currentTeamId}/insights/cancel`, { client_query_id: queryId })

const duration = performance.now() - values.queryStartTimes[queryId]
await captureTimeToSeeData(values.currentTeamId, {
type: 'insight_load',
context: 'insight',
query_id: queryId,
status: 'cancelled',
time_to_see_data_ms: Math.floor(duration),
insights_fetched: 0,
insights_fetched_cached: 0,
api_response_bytes: 0,
insight: values.activeView,
})
}
abortQuery: async () => {
// const { currentTeamId } = values
//
// if (values.featureFlags[FEATURE_FLAGS.CANCEL_RUNNING_QUERIES]) {
// await api.create(`api/projects/${currentTeamId}/insights/cancel`, { client_query_id: queryId })
//
// const duration = performance.now() - values.queryStartTimes[queryId]
// await captureTimeToSeeData(values.currentTeamId, {
// type: 'insight_load',
// context: 'insight',
// query_id: queryId,
// status: 'cancelled',
// time_to_see_data_ms: Math.floor(duration),
// insights_fetched: 0,
// insights_fetched_cached: 0,
// api_response_bytes: 0,
// insight: values.activeView,
// })
// }
},
endQuery: ({ queryId, view, lastRefresh, scene, exception, response }) => {
if (values.timeout) {
Expand Down

0 comments on commit 09234ce

Please sign in to comment.