-
Notifications
You must be signed in to change notification settings - Fork 968
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
[discover] async query and caching #7943
Conversation
❌ Empty Changelog SectionThe Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section. |
this.storage = createStorage({ engine: window.localStorage, prefix: 'opensearchDashboards.' }); | ||
this.sessionStorage = createStorage({ | ||
engine: window.sessionStorage, | ||
prefix: 'opensearchDashboards.', |
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.
this prefix has to be opensearchDashboards.
BWC
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7943 +/- ##
==========================================
+ Coverage 61.03% 61.10% +0.06%
==========================================
Files 3688 3691 +3
Lines 87232 87309 +77
Branches 13425 13433 +8
==========================================
+ Hits 53241 53348 +107
+ Misses 30763 30713 -50
- Partials 3228 3248 +20
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
||
constructor(initializerContext: PluginInitializerContext<ConfigSchema>) { | ||
this.searchService = new SearchService(initializerContext); | ||
this.uiService = new UiService(initializerContext); | ||
this.queryService = new QueryService(); | ||
this.fieldFormatsService = new FieldFormatsService(); | ||
this.autocomplete = new AutocompleteService(initializerContext); | ||
this.storage = createStorage({ engine: window.localStorage, prefix: 'opensearch_dashboards.' }); | ||
this.storage = createStorage({ engine: window.localStorage, prefix: 'opensearchDashboards.' }); |
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.
Lets not change the key. Else users stored cache will be wiped out with a version update
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.
correct, the original prefix was opensearchDashboards.
so this was restoring it back to the older key.
const cacheKey = `${dataType}.${lastPathItem.id}`; | ||
|
||
const cachedDataStructure = this.sessionStorage.get<CachedDataStructure>(cacheKey); | ||
if (cachedDataStructure.children?.length > 0) { |
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 if the datastructure has no children?
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.
should attempt the fetch correct? we could check hasNext
but to me in makes sense to refetch always if no children.
src/plugins/data/public/query/query_string/dataset_service/dataset_service.ts
Show resolved
Hide resolved
const query = this.buildQuery(strategy); | ||
|
||
return fetch(context, query).pipe( | ||
return fetch(context, this.queryService.queryString.getQuery()).pipe( |
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.
doesnt the request object already have the whole query? why ae we fetching the query from the service?
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 are right. this is an existing issue i will need to fix in a subsequent PR.
❌ Empty Changelog SectionThe Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section. |
export const buildQueryStatusConfig = (response: any) => { | ||
return { | ||
queryId: response.data.queryId, | ||
sessionId: response.data.sessionId, |
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.
Can we please make sure the sessionId is stored per - MDS cluster and flint datasource?
Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
@@ -440,11 +440,15 @@ export class SearchSource { | |||
await this.setDataFrame(dataFrameResponse.body as IDataFrame); | |||
return onResponse(searchRequest, convertResult(response as IDataFrameResponse)); | |||
} | |||
if ((response as IDataFrameResponse).type === DATA_FRAME_TYPES.POLLING) { |
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.
nit: Can we combine both the if condition
(response as IDataFrameResponse).type === DATA_FRAME_TYPES.DEFAULT) || (response as IDataFrameResponse).type === DATA_FRAME_TYPES.POLLING)
since the body of the both the condition are same.
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.
yes good catch. i put this here but i'm planning on removing this type
difference
if (temporaryIndexPattern) { | ||
this.indexPatterns?.saveToCache(dataset.id, temporaryIndexPattern); | ||
} | ||
} | ||
} | ||
|
||
public fetchOptions( | ||
public async fetchOptions( |
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.
Do we want to give an option to users to explicitly cache burst fetchOptions
?
Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
try { | ||
const response = await handleQueryStatus({ | ||
fetchStatus: () => | ||
http.fetch('../../api/enhancements/datasource/jobs', { |
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.
why do we need ../../
?
will address the comments in fast follows |
The backport to
To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-7943-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 8c9abe2e32ccf7a47c0998d574c68b2ead111026
# Push it to GitHub
git push --set-upstream origin backport/backport-7943-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x Then, create a pull request where the |
The backport to
To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-7943-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 8c9abe2e32ccf7a47c0998d574c68b2ead111026
# Push it to GitHub
git push --set-upstream origin backport/backport-7943-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.x Then, create a pull request where the |
Async query feature for S3 type on Discover. Due to the time to click and verify I end up implementing the cache to avoid waiting too long per every re-build. What this PR does: Poll for query Cache data structures and refetches them from session storage Poll based on the data type What this PR does NOT do yet: SessionId for search strategy, working fine for selector isCacheable field property Abort signal on server --------- Signed-off-by: Kawika Avilla <kavilla414@gmail.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> (cherry picked from commit 8c9abe2)
Async query feature for S3 type on Discover. Due to the time to click and verify I end up implementing the cache to avoid waiting too long per every re-build. What this PR does: Poll for query Cache data structures and refetches them from session storage Poll based on the data type What this PR does NOT do yet: SessionId for search strategy, working fine for selector isCacheable field property Abort signal on server --------- Signed-off-by: Kawika Avilla <kavilla414@gmail.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> (cherry picked from commit 8c9abe2)
Manually backported to 2.x with #7979 |
Description
Async query feature for S3 type on Discover. Due to the time to click and verify I end up implementing the cache to avoid waiting too long per every re-build.
What this PR does:
What this PR does NOT do yet:
Issues Resolved
n/a
Screenshot
Testing the changes
Changelog
Check List
yarn test:jest
yarn test:jest_integration