-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
feat(feature-flagged-query-cache): Added a feature flagged query cache #19072
Conversation
public componentWillUnmount() { | ||
this.props.resetCachedQueryResults() |
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.
doesn't this need to called if the flag is disabled?
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.
Not since the file has been removed and we're no longer caching things. Even if the feature flag is implemented the previous caching system has been ripped out in this PR
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.
that's what i'm trying to call attention to. doesn't that mean that we have interface changes being deployed that aren't captured / contained by the feature flag?
@@ -101,10 +110,6 @@ const mstp = (state: AppState) => { | |||
} | |||
} | |||
|
|||
const mdtp = { | |||
resetCachedQueryResults: resetCachedQueryResults, |
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.
and this added back
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.
Not unless we want to integrate the old system back in before we end up removing it later?
ui/src/shared/apis/queryCache.ts
Outdated
hashedVariables: string, | ||
values: RunQueryResult | ||
): void => { | ||
event('query_cache_miss', {context: 'queryCache'}) |
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.
what's the context for?
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.
🤷 I just went based off of what was going on in the other usages. Is there a doc somewhere on event reporting that we should stick to?
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.
we might want to add the queryID
into that object so that we can separate parallelized queries
orgID: string, | ||
query: string, | ||
state: AppState | ||
): CancelBox<RunQueryResult> => { |
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.
throw an event up here too so that we can split questions like "how many queries did the cache save?" and it'd be queries requested
vs query cache set
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.
i think this should be taken care of already in the sense that we already report events for the executeQueries (and TimeSeries.tsx) which this inevitably call this
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.
i dont understand this. feels like an gap between intent vs implementation. explicitly defining the event at the intent (as opposed to using a proxy event rooted in implementation to estimate the intent) helps keep a consistent history to the event, even through implementation changes. if we rewrite all of executeQueries, and forget to put in the eventing, or change the definition of the submodule's eventing structure, our dashboards for cache hits vs missus shouldn't change right? isn't the event you're planning on proxying already invalid because we don't use executeQueries for dashboards?
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're right in that the TimeSeries component does not depend on the executeQueries thunk to run a query, it does, however, a duplicate event. I do see what you're saying though. I'll add it in
const windowVars = getWindowVars(query, allVars) | ||
|
||
// otherwise query & set results | ||
const extern = buildVarsOption([...variableAssignments, ...windowVars]) |
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.
flagging this for the thread's sake as the fix for the outage... generating a windowPeriod
variable from the query and adding it to the AST partial for the query
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.
👍
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.
it looks good to me..
…tion and restructured the way that Cached data was being stored Still need to: - create a filterUnusedVars without a view context to pass into the query - explicitly reset & set the query when the VEO is submitted
… is submitted filtering out unused vars before setting them to query cache
…ta sets used in other tests
…ay funcs were being imported and updated a few comments
…y & removed comments from tests to reduce confusion
…ry and added a comment to TIME_INVALIDATION const
…rence from executeQueries call to cache
…r windowPeriod based on query
6b5bebd
to
aeb14b9
Compare
Closes #18791
NOTE
This is a preliminary version of the query cache that has a feature flag wrapped around every place where it's being invoked so that we can work off of it. It resolves the windowPeriod issue that created the incident on Friday. This issue was resolved by specifically getting the windowPeriod variable from the query text, a pattern that we use here:
https://github.com/influxdata/influxdb/pull/19072/files#diff-4399ae26b73db6259e86e2dea60efd3dR224-R225
This was added here before running the query:
https://github.com/influxdata/influxdb/pull/19072/files?file-filters%5B%5D=.go&file-filters%5B%5D=.ts&file-filters%5B%5D=.tsx#diff-0be90b2f69a877941cc79979e2747aadR177-R180
What
This PR introduces the concept of a QueryCache to dashboards in order to reduce the number of API requests generated by the UI when toggling between the Cell Configuration Overlay (known as VEO), and the cells on a dashboard.
How
Before each cells runs its respective query, it checks for a matching hashed version of that query in the local cache instance. If one is found, then the data from the cache is returned as promise and runQuery is never run. If one is not found (or if there is a mismatch in variables, or the data is stale), then the operation will continue to runQuery.
Similarly, when the VEO is toggled open, the same operation will occur.
When the cache is instantiated, a watch dog is triggered to clean up any stale data that is currently in the cache.