Skip to content

Commit

Permalink
[8.x] [Session management] update cleanup to allow partial search res…
Browse files Browse the repository at this point in the history
…ults for PIT query (elastic#200912) (elastic#201205)

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Session management] update cleanup to allow partial search results
for PIT query (elastic#200912)](elastic#200912)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT
[{"author":{"name":"Sid","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-21T14:14:54Z","message":"[Session
management] update cleanup to allow partial search results for PIT query
(elastic#200912)\n\nCloses
https://github.com/elastic/kibana/issues/200008\r\n\r\n##
Summary\r\nThis PR updates the session cleanup task to allow partial
results in the\r\npoint in time query used to delete any invalid
sessions.\r\n\r\n\r\n### Notes\r\nUsing a [recently introduced option
by\r\nES](elastic/elasticsearch#111516), the
session\r\ncleanup now allows the PIT to run over partial results. This
should\r\nreduce the noise we see around session_cleanup errors in our
logs.\r\n\r\n\r\n### Release notes\r\nFixes error with opening point in
time query for session deletion by now\r\naccounting for partial
results.\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies following
conditions. \r\n\r\nReviewers should verify this PR satisfies this list
as well.\r\n\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] The PR
description includes the appropriate Release Notes section,\r\nand the
correct `release_node:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"8f12714219ca4b4c8e58678d42e9978c3defa40b","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","release_note:fix","Team:Security","v9.0.0","Feature:Security/Session
Management","backport:prev-major"],"title":"[Session management] update
cleanup to allow partial search results for PIT
query","number":200912,"url":"https://github.com/elastic/kibana/pull/200912","mergeCommit":{"message":"[Session
management] update cleanup to allow partial search results for PIT query
(elastic#200912)\n\nCloses
https://github.com/elastic/kibana/issues/200008\r\n\r\n##
Summary\r\nThis PR updates the session cleanup task to allow partial
results in the\r\npoint in time query used to delete any invalid
sessions.\r\n\r\n\r\n### Notes\r\nUsing a [recently introduced option
by\r\nES](elastic/elasticsearch#111516), the
session\r\ncleanup now allows the PIT to run over partial results. This
should\r\nreduce the noise we see around session_cleanup errors in our
logs.\r\n\r\n\r\n### Release notes\r\nFixes error with opening point in
time query for session deletion by now\r\naccounting for partial
results.\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies following
conditions. \r\n\r\nReviewers should verify this PR satisfies this list
as well.\r\n\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] The PR
description includes the appropriate Release Notes section,\r\nand the
correct `release_node:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"8f12714219ca4b4c8e58678d42e9978c3defa40b"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/200912","number":200912,"mergeCommit":{"message":"[Session
management] update cleanup to allow partial search results for PIT query
(elastic#200912)\n\nCloses
https://github.com/elastic/kibana/issues/200008\r\n\r\n##
Summary\r\nThis PR updates the session cleanup task to allow partial
results in the\r\npoint in time query used to delete any invalid
sessions.\r\n\r\n\r\n### Notes\r\nUsing a [recently introduced option
by\r\nES](elastic/elasticsearch#111516), the
session\r\ncleanup now allows the PIT to run over partial results. This
should\r\nreduce the noise we see around session_cleanup errors in our
logs.\r\n\r\n\r\n### Release notes\r\nFixes error with opening point in
time query for session deletion by now\r\naccounting for partial
results.\r\n\r\n### Checklist\r\n\r\nCheck the PR satisfies following
conditions. \r\n\r\nReviewers should verify this PR satisfies this list
as well.\r\n\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n- [x] The PR
description includes the appropriate Release Notes section,\r\nand the
correct `release_node:*` label is applied per
the\r\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"8f12714219ca4b4c8e58678d42e9978c3defa40b"}}]}]
BACKPORT-->

Co-authored-by: Sid <[email protected]>
  • Loading branch information
kibanamachine and SiddharthMantri authored Nov 21, 2024
1 parent c832adb commit 690bd06
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,7 @@ describe('Session index', () => {
expect(mockElasticsearchClient.search).toHaveBeenCalledTimes(1);
expect(mockElasticsearchClient.search).toHaveBeenCalledWith({
_source_includes: 'usernameHash,provider',
allow_partial_search_results: true,
sort: '_shard_doc',
track_total_hits: false,
search_after: undefined,
Expand Down Expand Up @@ -555,6 +556,7 @@ describe('Session index', () => {
expect(mockElasticsearchClient.search).toHaveBeenCalledTimes(1);
expect(mockElasticsearchClient.search).toHaveBeenCalledWith({
_source_includes: 'usernameHash,provider',
allow_partial_search_results: true,
sort: '_shard_doc',
track_total_hits: false,
search_after: undefined,
Expand Down Expand Up @@ -649,6 +651,7 @@ describe('Session index', () => {
expect(mockElasticsearchClient.search).toHaveBeenCalledTimes(1);
expect(mockElasticsearchClient.search).toHaveBeenCalledWith({
_source_includes: 'usernameHash,provider',
allow_partial_search_results: true,
sort: '_shard_doc',
track_total_hits: false,
search_after: undefined,
Expand Down Expand Up @@ -737,6 +740,7 @@ describe('Session index', () => {
expect(mockElasticsearchClient.search).toHaveBeenCalledTimes(1);
expect(mockElasticsearchClient.search).toHaveBeenCalledWith({
_source_includes: 'usernameHash,provider',
allow_partial_search_results: true,
sort: '_shard_doc',
track_total_hits: false,
search_after: undefined,
Expand Down Expand Up @@ -850,6 +854,7 @@ describe('Session index', () => {
expect(mockElasticsearchClient.search).toHaveBeenCalledTimes(1);
expect(mockElasticsearchClient.search).toHaveBeenCalledWith({
_source_includes: 'usernameHash,provider',
allow_partial_search_results: true,
sort: '_shard_doc',
track_total_hits: false,
search_after: undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,7 @@ export class SessionIndex {
size: SESSION_INDEX_CLEANUP_BATCH_SIZE,
sort: '_shard_doc',
track_total_hits: false, // for performance
allow_partial_search_results: true,
});
const { hits } = searchResponse.hits;
if (hits.length > 0) {
Expand Down

0 comments on commit 690bd06

Please sign in to comment.