Skip to content
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

Refactor search session status on-the-fly calculation and other fixes #136296

Conversation

Dosant
Copy link
Contributor

@Dosant Dosant commented Jul 13, 2022

Summary

  • Refactor initial on-the-fly status implantation:
    • Instead of augmenting status field in a saved object, return it as part of a separate map in find API
    • Instead of new param in get API, use separate status API
  • Mgmt screen changes to prevent overfetching: by default disable auto-refresh and reduce limit of items to 100
    • Also fix sorting of search sessions in API request
    • Fix sorting of options in mgmt filters
  • Better handle edge case with session sharing: Lens and visualize "continue" search sessions to share a client-side search response cache. This functionality already had issues in the past (Separate architecture for client side cache sharing #121543) but with new search/session implementation it gets worse:
      1. When you in editor, we need to make sure we don't keep searches alive because it won't be possible to save. To fix this I added a check when keeping searches alive that this session can be saved by the current app
      1. When you navigate back to dashboard and "continue" the session the client side "trackedSearches" are dropped, so it won't be possible to keep search alive or to add them to a session. To fix this - I started disabling "save" button if session was continued. I think it is better than letting users be wrong that something went wrong than they try to restore a session where we knew it probably didn't have all the searches saved with it.
  • Fix and unskip most of the unit tests, add more functional tests

return options;
}, []),
options: [...new Set(tableData.map((data) => data.appId ?? 'unknown'))]
.sort()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After fixing sort order for the find some UI session tests started failing. They failed because the order of this option has changed. I fixed it by starting sorting the options to make them consistent. Also slightly refactored the function


// initial data load
useEffect(() => {
doRefresh();
searchUsageCollector.trackSessionsListLoaded();
}, [doRefresh, searchUsageCollector]);

useInterval(doRefresh, refreshInterval);
Copy link
Contributor Author

@Dosant Dosant Jul 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improvements to fetching on the management screen:

  • By default disable auto-refresh
  • useInterval was refactored to a setTimeout, so that we had control of scheduling a new timeout only after ongoing refresh completes.
  • Also added a shortcut if (document.visibilityState !== 'hidden') { to skip refresh in case page is not visible.

@@ -141,7 +126,7 @@ export class SearchSessionsMgmtAPI {
page: 1,
perPage: mgmtConfig.maxSessions,
sortField: 'created',
sortOrder: 'asc',
Copy link
Contributor Author

@Dosant Dosant Jul 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this was a mistake. We fetched all sessions and did client-side sorting. Since we changed the default max count from 10000 to 100 we need to properly sort in es


router.get(
{
path: '/internal/session/{id}/status',
Copy link
Contributor Author

@Dosant Dosant Jul 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is used only in api tests. this is instead checkStatus param in get because I think this is clearer and doesn't argument saved object response

@Dosant Dosant added Feature:Search Querying infrastructure in Kibana Team:AppServicesSv labels Jul 18, 2022
@Dosant Dosant requested a review from lukasolson July 18, 2022 13:42
@Dosant Dosant marked this pull request as ready for review July 18, 2022 13:42
@Dosant Dosant requested a review from a team as a code owner July 18, 2022 13:42
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-app-services (Team:AppServicesSv)

@Dosant Dosant changed the title Refactor search session status on-the-fly calculation Refactor search session status on-the-fly calculation and other fixes Jul 19, 2022
public readonly disableSaveAfterSessionCompleteTimedOut$ =
this._disableSaveAfterSessionCompleteTimedOut$.asObservable();

private readonly _disableSaveAfterSessionContinuedFromDifferentApp$ =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See description why I think we have to add this new disable condition

@Dosant
Copy link
Contributor Author

Dosant commented Jul 25, 2022

@elasticmachine merge upstream

kibanamachine and others added 2 commits July 25, 2022 06:53
…astic/kibana into d/2022-07-11-search-sessions-status-refactor
@@ -266,10 +277,27 @@ export class SearchInterceptor {
})
: undefined;

// track if this search's session will be send to background
// if yes, then we don't need to cancel this search when it is aborted
let isSavedToBackground = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While unskipping the remaining tests, I realized that this older implementation from main had some benefits. So I decided to get it back and unskip related tests

@Dosant
Copy link
Contributor Author

Dosant commented Jul 25, 2022

buildlkite, test this

@Dosant
Copy link
Contributor Author

Dosant commented Jul 25, 2022

buildkite, test this

@kibana-ci
Copy link
Collaborator

kibana-ci commented Jul 25, 2022

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] FTR Configs #8 / apps machine learning basic license data visualizer index based with farequote lucene saved search displays index details
  • [job] [logs] FTR Configs #8 / apps machine learning basic license data visualizer index based with view in lens action farequote index pattern loads lens charts

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
data 516 515 -1

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
data 2423 2422 -1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
data 52.4KB 52.2KB -234.0B

Canvas Sharable Runtime

The Canvas "shareable runtime" is an bundle produced to enable running Canvas workpads outside of Kibana. This bundle is included in third-party webpages that embed canvas and therefor should be as slim as possible.

id before after diff
module count 4935 4934 -1

Public APIs missing exports

Total count of every type that is part of your API that should be exported but is not. This will cause broken links in the API documentation system. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats exports for more detailed information.

id before after diff
data 21 22 +1

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
data 429.5KB 430.3KB +764.0B
Unknown metric groups

API count

id before after diff
data 3099 3101 +2

ESLint disabled line counts

id before after diff
data 65 66 +1

Total ESLint disabled count

id before after diff
data 67 68 +1

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

Copy link
Member

@lukasolson lukasolson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for walking me through these changes, LGTM

/**
* Map containing calculated statuses of search sessions from the find response
*/
statuses: Record<string, SearchSessionStatusResponse>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Instead of something like savedObjects: [...], statuses: [...] I think it would be easier to use if it were more like searchSessions: [{savedObject: {...}, status: 'status'}].

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good suggestion 👍

I'll take a look if it is worth update,
I think I didn't go this route initially because we use SavedObjectFindResponse with a bunch of other properties, and instead of just extending it, I'd had to deep update it

@Dosant Dosant merged commit 810428c into elastic:search-sessions-stabilization-stage-1 Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature:Search Querying infrastructure in Kibana
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants