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

Add search backpressure cancellation at the coordinator level #5605

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
1402ced
Cancellation of in-flight search requests at coordinator level
PritLadani Dec 19, 2022
9ccdae5
Cancellation of in-flight search requests at coordinator level
PritLadani Dec 19, 2022
253fc61
Merge branch 'searchbackpressure/search-task-cancellation' of github.…
PritLadani Dec 19, 2022
5817770
Fixing test failures
PritLadani Dec 20, 2022
dee7efb
Merge branch 'opensearch-project:main' into searchbackpressure/search…
PritLadani Dec 20, 2022
1f188a3
java code formatting
PritLadani Dec 20, 2022
64c6ed0
Adding unit tests and integration tests
PritLadani Dec 21, 2022
5b846a2
Introducing separate thresholds for different task types
PritLadani Jan 5, 2023
4778162
Adding java docs
PritLadani Jan 6, 2023
5b0bf15
Moving cancellation settings to task specific settings
PritLadani Jan 18, 2023
ac0688f
Moving cancellation settings to task specific settings
PritLadani Jan 18, 2023
663e4ee
Merge branch 'searchbackpressure/search-task-cancellation' of github.…
PritLadani Jan 18, 2023
53609a7
Separating SearchTaskStats and SearchShardTaskStats
PritLadani Jan 19, 2023
102cfd5
Cancellation of in-flight search requests at coordinator level
PritLadani Dec 19, 2022
474be6c
Fixing test failures
PritLadani Dec 20, 2022
72c5d87
java code formatting
PritLadani Dec 20, 2022
0192d6c
Adding unit tests and integration tests
PritLadani Dec 21, 2022
b31b876
Introducing separate thresholds for different task types
PritLadani Jan 5, 2023
6f75c23
Adding java docs
PritLadani Jan 6, 2023
2f299ce
Moving cancellation settings to task specific settings
PritLadani Jan 18, 2023
339a746
Separating SearchTaskStats and SearchShardTaskStats
PritLadani Jan 19, 2023
b2c2062
Merge branch 'searchbackpressure/search-task-cancellation' of github.…
PritLadani Jan 19, 2023
d2bcb88
Merge branch 'searchbackpressure/search-task-cancellation' of github.…
PritLadani Jan 19, 2023
bcc6483
Merge branch 'searchbackpressure/search-task-cancellation' of github.…
PritLadani Jan 20, 2023
7d52b52
Changing default values for SearchTaskSettings
PritLadani Jan 20, 2023
5933c2d
Adding version checks for SearchTaskStats
PritLadani Jan 23, 2023
d933936
Avoiding heap usage cancellation in case of undefined maximum heap me…
PritLadani Jan 29, 2023
e80e79d
Merge branch 'main' into searchbackpressure/search-task-cancellation
PritLadani Jan 29, 2023
31f3f07
Moving limiters in SearchBackpressureState
PritLadani Jan 29, 2023
26d19a0
code formatting
PritLadani Jan 29, 2023
156225a
Merge branch 'main' into searchbackpressure/search-task-cancellation
PritLadani Jan 30, 2023
dd10073
Adding TaskManager#cancelTaskAndDescendants for task cancellation
PritLadani Jan 30, 2023
9e0fa78
Removing heap usage tracker if heap size is undefined
PritLadani Jan 30, 2023
3ff7116
Merge branch 'main' into searchbackpressure/search-task-cancellation
PritLadani Jan 31, 2023
1f17964
Extracting CancellationListener
PritLadani Jan 31, 2023
7d06d91
Extracting CancellationListener
PritLadani Jan 31, 2023
950248d
Defining cancellation settings as volatile variables
PritLadani Jan 31, 2023
d9c113d
Separating SearchTaskStats and SearchShardTaskStats to avoid BWC issues
PritLadani Feb 1, 2023
8e09787
Moving getTrackers to SearchBackpressureService
PritLadani Feb 1, 2023
0732c74
Updating UTs
PritLadani Feb 2, 2023
97533cb
Merge branch 'opensearch-project:main' into searchbackpressure/search…
PritLadani Feb 2, 2023
4ee781c
Re-adding deprecated settings to address BWC issues
PritLadani Feb 3, 2023
d28cda6
Merge branch 'searchbackpressure/search-task-cancellation' of github.…
PritLadani Feb 3, 2023
9cb6c6b
Merge branch 'opensearch-project:main' into searchbackpressure/search…
PritLadani Feb 3, 2023
874cd97
Adding method to check if heap usage tracking is enabled
PritLadani Feb 3, 2023
e8df261
Merge branch 'searchbackpressure/search-task-cancellation' of github.…
PritLadani Feb 3, 2023
881bdee
Isolating HEAP_SIZE_BYTES value
PritLadani Feb 3, 2023
5da5817
Moving changelog to unreleased 2.x section
PritLadani Feb 3, 2023
bf19bf7
Merge branch 'main' into searchbackpressure/search-task-cancellation
Bukhtawar Feb 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
- Added support to apply index create block ([#4603](https://github.com/opensearch-project/OpenSearch/issues/4603))
- Adds support for minimum compatible version for extensions ([#6003](https://github.com/opensearch-project/OpenSearch/pull/6003))
- Add a guardrail to limit maximum number of shard on the cluster ([#6143](https://github.com/opensearch-project/OpenSearch/pull/6143))
- Add cancellation of in-flight SearchTasks based on resource consumption ([#5606](https://github.com/opensearch-project/OpenSearch/pull/5605))

### Dependencies
- Update nebula-publishing-plugin to 19.2.0 ([#5704](https://github.com/opensearch-project/OpenSearch/pull/5704))
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import org.opensearch.search.fetch.ShardFetchSearchRequest;
import org.opensearch.search.internal.ShardSearchRequest;
import org.opensearch.tasks.CancellableTask;
import org.opensearch.tasks.SearchBackpressureTask;
import org.opensearch.tasks.TaskId;

import java.util.Map;
Expand All @@ -47,7 +48,7 @@
*
* @opensearch.internal
*/
public class SearchShardTask extends CancellableTask {
public class SearchShardTask extends CancellableTask implements SearchBackpressureTask {
// generating metadata in a lazy way since source can be quite big
private final MemoizedSupplier<String> metadataSupplier;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import org.opensearch.common.unit.TimeValue;
import org.opensearch.tasks.CancellableTask;
import org.opensearch.tasks.SearchBackpressureTask;
import org.opensearch.tasks.TaskId;

import java.util.Map;
Expand All @@ -46,7 +47,7 @@
*
* @opensearch.internal
*/
public class SearchTask extends CancellableTask {
public class SearchTask extends CancellableTask implements SearchBackpressureTask {
// generating description in a lazy way since source can be quite big
private final Supplier<String> descriptionSupplier;
private SearchProgressListener progressListener = SearchProgressListener.NOOP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@
import org.opensearch.search.backpressure.settings.NodeDuressSettings;
import org.opensearch.search.backpressure.settings.SearchBackpressureSettings;
import org.opensearch.search.backpressure.settings.SearchShardTaskSettings;
import org.opensearch.search.backpressure.trackers.CpuUsageTracker;
import org.opensearch.search.backpressure.trackers.ElapsedTimeTracker;
import org.opensearch.search.backpressure.trackers.HeapUsageTracker;
import org.opensearch.search.backpressure.settings.SearchTaskSettings;
import org.opensearch.tasks.TaskManager;
import org.opensearch.tasks.TaskResourceTrackingService;
import org.opensearch.watcher.ResourceWatcherService;
Expand Down Expand Up @@ -600,18 +598,31 @@ public void apply(Settings value, Settings current, Settings previous) {

// Settings related to search backpressure
SearchBackpressureSettings.SETTING_MODE,
SearchBackpressureSettings.SETTING_CANCELLATION_RATIO,
SearchBackpressureSettings.SETTING_CANCELLATION_RATE,
SearchBackpressureSettings.SETTING_CANCELLATION_BURST,

NodeDuressSettings.SETTING_NUM_SUCCESSIVE_BREACHES,
NodeDuressSettings.SETTING_CPU_THRESHOLD,
NodeDuressSettings.SETTING_HEAP_THRESHOLD,
SearchTaskSettings.SETTING_CANCELLATION_RATIO,
SearchTaskSettings.SETTING_CANCELLATION_RATE,
SearchTaskSettings.SETTING_CANCELLATION_BURST,
SearchTaskSettings.SETTING_HEAP_PERCENT_THRESHOLD,
SearchTaskSettings.SETTING_HEAP_VARIANCE_THRESHOLD,
SearchTaskSettings.SETTING_HEAP_MOVING_AVERAGE_WINDOW_SIZE,
SearchTaskSettings.SETTING_CPU_TIME_MILLIS_THRESHOLD,
SearchTaskSettings.SETTING_ELAPSED_TIME_MILLIS_THRESHOLD,
SearchTaskSettings.SETTING_TOTAL_HEAP_PERCENT_THRESHOLD,
SearchShardTaskSettings.SETTING_CANCELLATION_RATIO,
SearchShardTaskSettings.SETTING_CANCELLATION_RATE,
SearchShardTaskSettings.SETTING_CANCELLATION_BURST,
SearchShardTaskSettings.SETTING_HEAP_PERCENT_THRESHOLD,
SearchShardTaskSettings.SETTING_HEAP_VARIANCE_THRESHOLD,
SearchShardTaskSettings.SETTING_HEAP_MOVING_AVERAGE_WINDOW_SIZE,
SearchShardTaskSettings.SETTING_CPU_TIME_MILLIS_THRESHOLD,
SearchShardTaskSettings.SETTING_ELAPSED_TIME_MILLIS_THRESHOLD,
SearchShardTaskSettings.SETTING_TOTAL_HEAP_PERCENT_THRESHOLD,
HeapUsageTracker.SETTING_HEAP_PERCENT_THRESHOLD,
HeapUsageTracker.SETTING_HEAP_VARIANCE_THRESHOLD,
HeapUsageTracker.SETTING_HEAP_MOVING_AVERAGE_WINDOW_SIZE,
CpuUsageTracker.SETTING_CPU_TIME_MILLIS_THRESHOLD,
ElapsedTimeTracker.SETTING_ELAPSED_TIME_MILLIS_THRESHOLD
SearchBackpressureSettings.SETTING_CANCELLATION_RATIO, // deprecated
SearchBackpressureSettings.SETTING_CANCELLATION_RATE, // deprecated
SearchBackpressureSettings.SETTING_CANCELLATION_BURST // deprecated
)
)
);
Expand Down
3 changes: 2 additions & 1 deletion server/src/main/java/org/opensearch/node/Node.java
Original file line number Diff line number Diff line change
Expand Up @@ -867,7 +867,8 @@ protected Node(
final SearchBackpressureService searchBackpressureService = new SearchBackpressureService(
searchBackpressureSettings,
taskResourceTrackingService,
threadPool
threadPool,
transportService.getTaskManager()
);

final RecoverySettings recoverySettings = new RecoverySettings(settings, settingsModule.getClusterSettings());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* The OpenSearch Contributors require contributions made to
* this file be licensed under the Apache-2.0 license or a
* compatible open source license.
*/

package org.opensearch.search.backpressure;

/**
* Listener for callbacks related to cancellation settings
*/
public interface CancellationSettingsListener {

void onRatioChanged(double ratio);

void onRateChanged(double rate);

void onBurstChanged(double burst);
}
Loading