Skip to content

Commit

Permalink
Added minimum timeout for transforms search of 10 minutes (opensearch…
Browse files Browse the repository at this point in the history
…-project#1033)

* Added minimum timeout for transforms search of 10 minutes

Signed-off-by: Joshua Au <[email protected]>

* Extracted cancel minimum code to function

Signed-off-by: Joshua Au <[email protected]>

* Fixed transform code to use cluster setting

Signed-off-by: Joshua Au <[email protected]>

* Removed log statements

Signed-off-by: Joshua Au <[email protected]>

* Changed timeout logic

Signed-off-by: Joshua Au <[email protected]>

* Switched to basing off seconds

Signed-off-by: Joshua Au <[email protected]>

* [Feature] Support Transform as an ISM action (opensearch-project#760)

* Initial impl

Signed-off-by: Tanqiu Liu <[email protected]>

* fix style

Signed-off-by: Tanqiu Liu <[email protected]>

* end to end functional

Signed-off-by: Tanqiu Liu <[email protected]>

* ISM transform unit tests & integ tests

Signed-off-by: Tanqiu Liu <[email protected]>

* Fix after core #8157 (opensearch-project#857)

Signed-off-by: bowenlan-amzn <[email protected]>

* Upgrade the backport workflow (opensearch-project#862)

Signed-off-by: Ashish Agrawal <[email protected]>
Signed-off-by: Tanqiu Liu <[email protected]>

* Added 2.9 release notes. (opensearch-project#851)

* Added 2.9 release notes.

Signed-off-by: AWSHurneyt <[email protected]>

* Added 2.9 release notes.

Signed-off-by: AWSHurneyt <[email protected]>

* Added 2.9 release notes.

Signed-off-by: AWSHurneyt <[email protected]>

---------

Signed-off-by: AWSHurneyt <[email protected]>
Signed-off-by: Tanqiu Liu <[email protected]>

* Handle NPE in isRollupIndex (opensearch-project#855)

* Handle NPE in isRollupIndex

`metadata.index()` can return `null`, so handle that case by returning
`false`.

Signed-off-by: Bryce Lampe <[email protected]>

* unit test

Signed-off-by: Bryce Lampe <[email protected]>

---------

Signed-off-by: Bryce Lampe <[email protected]>
Co-authored-by: bowenlan-amzn <[email protected]>
Signed-off-by: Tanqiu Liu <[email protected]>

* Fix core XcontentType refactor (opensearch-project#873)

Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Tanqiu Liu <[email protected]>

* fix for max & min aggregations when no metric property exist (opensearch-project#870)

Signed-off-by: Subhobrata Dey <[email protected]>
Signed-off-by: Tanqiu Liu <[email protected]>

* core refactor change (opensearch-project#884)

Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Tanqiu Liu <[email protected]>

* update backport branch name (opensearch-project#885)

Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Tanqiu Liu <[email protected]>

* core refactor change (opensearch-project#887)

Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Tanqiu Liu <[email protected]>

* Fix breaking change by core refactor (opensearch-project#888)

Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Tanqiu Liu <[email protected]>

* fix core breaking (opensearch-project#906)

Signed-off-by: bowenlan-amzn <[email protected]>
Signed-off-by: Tanqiu Liu <[email protected]>

* Support copy alias in rollover (opensearch-project#907)

* Support copy alias in rollover

Signed-off-by: bowenlan-amzn <[email protected]>

* 2.10

Signed-off-by: bowenlan-amzn <[email protected]>

---------

Signed-off-by: bowenlan-amzn <[email protected]>
Signed-off-by: Tanqiu Liu <[email protected]>

* Set preference to _primary when searching control-center index (opensearch-project#911)

* Set preference to _primary when searching control-center index

Signed-off-by: gaobinlong <[email protected]>

* Use _primary_first instead

Signed-off-by: gaobinlong <[email protected]>

---------

Signed-off-by: gaobinlong <[email protected]>
Signed-off-by: Tanqiu Liu <[email protected]>

* Add primary first preference to all search requests (opensearch-project#912)

Signed-off-by: Tanqiu Liu <[email protected]>

* fix intelliJ IDEA gradle sync error (opensearch-project#916)

Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Tanqiu Liu <[email protected]>

* make control center index as system index (opensearch-project#919)

Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Tanqiu Liu <[email protected]>

* Updates demo certs used in integ tests (opensearch-project#921)

Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: Tanqiu Liu <[email protected]>

* Added 2.10 release notes (opensearch-project#925)

Signed-off-by: Ashish Agrawal <[email protected]>
Signed-off-by: Tanqiu Liu <[email protected]>

* Bump bwc version (opensearch-project#930)

Signed-off-by: bowenlan-amzn <[email protected]>
Signed-off-by: Tanqiu Liu <[email protected]>

* fix integ tests; upgrade mappings versions

Signed-off-by: Tanqiu Liu <[email protected]>

* Fix DCO

Signed-off-by: Tanqiu Liu <[email protected]>

* Addressed pr comments; Add integ test case for re-execute the same transform action

Signed-off-by: Tanqiu Liu <[email protected]>

* Addressed detekt error

Signed-off-by: Tanqiu Liu <[email protected]>

* Added ISMTransform writeable test

Signed-off-by: Tanqiu Liu <[email protected]>

* Addressed comments; Moved updateTransformStartTime to IndexManagementRestTestCase

Signed-off-by: Tanqiu Liu <[email protected]>

---------

Signed-off-by: Tanqiu Liu <[email protected]>
Signed-off-by: bowenlan-amzn <[email protected]>
Signed-off-by: Ashish Agrawal <[email protected]>
Signed-off-by: AWSHurneyt <[email protected]>
Signed-off-by: Bryce Lampe <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Subhobrata Dey <[email protected]>
Signed-off-by: gaobinlong <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Co-authored-by: bowenlan-amzn <[email protected]>
Co-authored-by: Ashish Agrawal <[email protected]>
Co-authored-by: AWSHurneyt <[email protected]>
Co-authored-by: Bryce Lampe <[email protected]>
Co-authored-by: Hailong Cui <[email protected]>
Co-authored-by: Subhobrata Dey <[email protected]>
Co-authored-by: gaobinlong <[email protected]>
Co-authored-by: Darshit Chanpura <[email protected]>
Signed-off-by: Joshua Au <[email protected]>

* [Test] increase the wait time after transform job triggered (opensearch-project#999)

Signed-off-by: bowenlan-amzn <[email protected]>
Signed-off-by: Joshua Au <[email protected]>

* Drafted 2.11 release notes. (opensearch-project#1004)

* Drafted 2.11 release notes.

Signed-off-by: AWSHurneyt <[email protected]>

* Drafted 2.11 release notes.

Signed-off-by: AWSHurneyt <[email protected]>

---------

Signed-off-by: AWSHurneyt <[email protected]>
Signed-off-by: Joshua Au <[email protected]>

* Refactor change policy API and the policy in managed index to be non-null (opensearch-project#967)

* Refactor the policy to be non null in managed index config

Signed-off-by: bowenlan-amzn <[email protected]>

* Update

Signed-off-by: bowenlan-amzn <[email protected]>

* fix bug

Signed-off-by: bowenlan-amzn <[email protected]>

---------

Signed-off-by: bowenlan-amzn <[email protected]>
Signed-off-by: Joshua Au <[email protected]>

* Add more error notification at fail points (opensearch-project#1000)

* Add more error notification at fail points

Signed-off-by: bowenlan-amzn <[email protected]>

* Handle exception gracefully

Signed-off-by: bowenlan-amzn <[email protected]>

* small fix

Signed-off-by: bowenlan-amzn <[email protected]>

---------

Signed-off-by: bowenlan-amzn <[email protected]>
Signed-off-by: Joshua Au <[email protected]>

* fix the race condition in test reset action start time (opensearch-project#1007)

Signed-off-by: bowenlan-amzn <[email protected]>
Signed-off-by: Joshua Au <[email protected]>

* Bump bwc version after 2.11 release (opensearch-project#1015)

Signed-off-by: bowenlan-amzn <[email protected]>
Signed-off-by: Joshua Au <[email protected]>

* added type check for pipeline aggregator types in Transform initialization (opensearch-project#1014)

Signed-off-by: n-dohrmann <[email protected]>
Co-authored-by: Joanne Wang <[email protected]>
Signed-off-by: Joshua Au <[email protected]>

* Improve security plugin enabling check (opensearch-project#1017)

Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Joshua Au <[email protected]>

* Onboard jenkins prod docker images to github actions (opensearch-project#1025)

* Onboard jenkins prod docker images to github actions

Signed-off-by: Peter Zhu <[email protected]>

* Add more

Signed-off-by: Peter Zhu <[email protected]>

* Add more

Signed-off-by: Peter Zhu <[email protected]>

---------

Signed-off-by: Peter Zhu <[email protected]>
Signed-off-by: Joshua Au <[email protected]>

* Support switch aliases in shrink action. (opensearch-project#987)

Signed-off-by: Oleg Kravchuk <[email protected]>
Co-authored-by: ikibo <[email protected]>
Signed-off-by: Joshua Au <[email protected]>

* Transform pipeline aggr test (opensearch-project#1027)

* tester code: pipeline aggr. transform job

Signed-off-by: n-dohrmann <[email protected]>

* made test case for pipeline aggregator in transform job

Signed-off-by: n-dohrmann <[email protected]>

* removed unnec. test lines

Signed-off-by: n-dohrmann <[email protected]>

* re-added method call on Transform obj

Signed-off-by: n-dohrmann <[email protected]>

---------

Signed-off-by: n-dohrmann <[email protected]>
Signed-off-by: Joshua Au <[email protected]>

* Added unit test for switchAliases method. (opensearch-project#1035)

* Added unit test for switchAliases method.

Signed-off-by: Oleg Kravchuk <[email protected]>

* Added unit test for switchAliases method checking the flow when switchAliases is disabled.

Signed-off-by: Oleg Kravchuk <[email protected]>

---------

Signed-off-by: Oleg Kravchuk <[email protected]>
Signed-off-by: Joshua Au <[email protected]>

* Interval schedule should take start time from the request, should not set it to the current time of request execution. (opensearch-project#1036)

Signed-off-by: Oleg Kravchuk <[email protected]>
Signed-off-by: Joshua Au <[email protected]>

* Added minimum for search.cancel_after_time_interval setting for rollups (opensearch-project#1026)

* Added minimum for search.cancel_after_time_interval setting for rollups

Signed-off-by: Joshua Au <[email protected]>

* Added constant for cancel_after_time_interval for rollup search

Signed-off-by: Joshua Au <[email protected]>

* Handled case of default value for cancel interval

Signed-off-by: Joshua Au <[email protected]>

* Added comment explanation for default rollup cancel after time interval

Signed-off-by: Joshua Au <[email protected]>

* Fixed github workflow checks

Signed-off-by: Joshua Au <[email protected]>

---------

Signed-off-by: Joshua Au <[email protected]>
Co-authored-by: bowenlan-amzn <[email protected]>
Signed-off-by: Joshua Au <[email protected]>

* Update 2.11.1 release note (opensearch-project#1042)

Signed-off-by: bowenlan-amzn <[email protected]>
Signed-off-by: Joshua Au <[email protected]>

* Interval schedule should take start time from the request, should not… (opensearch-project#1040)

* Interval schedule should take start time from the request, should not set it to the current time of request execution.

Signed-off-by: Oleg Kravchuk <[email protected]>

* Changed the "delayed continuous execution test" to be more expressive about what it should test.

Signed-off-by: Oleg Kravchuk <[email protected]>

* fixed the NPE if schedule.startTime is NULL

Signed-off-by: Oleg Kravchuk <[email protected]>

* fixed the NPE if schedule.startTime is NULL

Signed-off-by: Oleg Kravchuk <[email protected]>

* fixed styling

Signed-off-by: Oleg Kravchuk <[email protected]>

* - removed null checks from RollUp and Transforms
- fixed comments in the "delayed execution" test

Signed-off-by: Oleg Kravchuk <[email protected]>

---------

Signed-off-by: Oleg Kravchuk <[email protected]>
Signed-off-by: Joshua Au <[email protected]>

* Removed unused imports

Signed-off-by: Joshua Au <[email protected]>

---------

Signed-off-by: Joshua Au <[email protected]>
Signed-off-by: Tanqiu Liu <[email protected]>
Signed-off-by: bowenlan-amzn <[email protected]>
Signed-off-by: Ashish Agrawal <[email protected]>
Signed-off-by: AWSHurneyt <[email protected]>
Signed-off-by: Bryce Lampe <[email protected]>
Signed-off-by: Hailong Cui <[email protected]>
Signed-off-by: Subhobrata Dey <[email protected]>
Signed-off-by: gaobinlong <[email protected]>
Signed-off-by: Darshit Chanpura <[email protected]>
Signed-off-by: n-dohrmann <[email protected]>
Signed-off-by: Peter Zhu <[email protected]>
Signed-off-by: Oleg Kravchuk <[email protected]>
Co-authored-by: Tanqiu Liu <[email protected]>
Co-authored-by: bowenlan-amzn <[email protected]>
Co-authored-by: Ashish Agrawal <[email protected]>
Co-authored-by: AWSHurneyt <[email protected]>
Co-authored-by: Bryce Lampe <[email protected]>
Co-authored-by: Hailong Cui <[email protected]>
Co-authored-by: Subhobrata Dey <[email protected]>
Co-authored-by: gaobinlong <[email protected]>
Co-authored-by: Darshit Chanpura <[email protected]>
Co-authored-by: n-dohrmann <[email protected]>
Co-authored-by: Joanne Wang <[email protected]>
Co-authored-by: Peter Zhu <[email protected]>
Co-authored-by: Oleg Kravchuk <[email protected]>
Co-authored-by: ikibo <[email protected]>
  • Loading branch information
15 people committed Dec 22, 2023
1 parent cbdc3e3 commit fc026ed
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import org.opensearch.action.bulk.BackoffPolicy
import org.opensearch.action.index.IndexRequest
import org.opensearch.action.search.SearchRequest
import org.opensearch.action.search.SearchResponse
import org.opensearch.action.search.TransportSearchAction.SEARCH_CANCEL_AFTER_TIME_INTERVAL_SETTING
import org.opensearch.client.Client
import org.opensearch.cluster.metadata.IndexMetadata
import org.opensearch.cluster.service.ClusterService
Expand Down Expand Up @@ -47,6 +48,7 @@ import org.opensearch.indexmanagement.util.IndexUtils.Companion.LUCENE_MAX_CLAUS
import org.opensearch.indexmanagement.util.IndexUtils.Companion.ODFE_MAGIC_NULL
import org.opensearch.indexmanagement.util.IndexUtils.Companion.hashToFixedSize
import org.opensearch.core.rest.RestStatus
import org.opensearch.indexmanagement.transform.settings.TransformSettings.Companion.MINIMUM_CANCEL_AFTER_TIME_INTERVAL_SECONDS
import org.opensearch.search.aggregations.Aggregation
import org.opensearch.search.aggregations.bucket.composite.CompositeAggregation
import org.opensearch.search.aggregations.bucket.composite.CompositeAggregationBuilder
Expand Down Expand Up @@ -78,11 +80,17 @@ class TransformSearchService(
@Volatile private var backoffPolicy =
BackoffPolicy.constantBackoff(TRANSFORM_JOB_SEARCH_BACKOFF_MILLIS.get(settings), TRANSFORM_JOB_SEARCH_BACKOFF_COUNT.get(settings))

@Volatile private var cancelAfterTimeInterval = SEARCH_CANCEL_AFTER_TIME_INTERVAL_SETTING.get(settings)

init {
clusterService.clusterSettings.addSettingsUpdateConsumer(TRANSFORM_JOB_SEARCH_BACKOFF_MILLIS, TRANSFORM_JOB_SEARCH_BACKOFF_COUNT) {
millis, count ->
backoffPolicy = BackoffPolicy.constantBackoff(millis, count)
}

clusterService.clusterSettings.addSettingsUpdateConsumer(SEARCH_CANCEL_AFTER_TIME_INTERVAL_SETTING) {
cancelAfterTimeInterval = it
}
}

@Suppress("RethrowCaughtException")
Expand Down Expand Up @@ -187,7 +195,11 @@ class TransformSearchService(
val searchStart = Instant.now().epochSecond
val searchResponse = backoffPolicy.retryTransformSearch(logger, transformContext.transformLockManager) {
val pageSizeDecay = 2f.pow(retryAttempt++)
val searchRequestTimeoutInSeconds = transformContext.getMaxRequestTimeoutInSeconds()

var searchRequestTimeoutInSeconds = transformContext.getMaxRequestTimeoutInSeconds()
if (searchRequestTimeoutInSeconds == null) {
searchRequestTimeoutInSeconds = getCancelAfterTimeIntervalSeconds(cancelAfterTimeInterval.seconds)
}

client.suspendUntil { listener: ActionListener<SearchResponse> ->
// If the previous request of the current transform job execution was successful, take the page size of previous request.
Expand Down Expand Up @@ -224,6 +236,16 @@ class TransformSearchService(
}
}

private fun getCancelAfterTimeIntervalSeconds(givenIntervalSeconds: Long): Long {
// The default value for the cancelAfterTimeInterval is -1 and so, in this case
// we should ignore processing on the value
if (givenIntervalSeconds == -1L) {
return -1
}

return max(givenIntervalSeconds, MINIMUM_CANCEL_AFTER_TIME_INTERVAL_SECONDS)
}

companion object {
const val failedSearchErrorMessage = "Failed to search data in source indices"
const val modifiedBucketsErrorMessage = "Failed to get the modified buckets in source indices"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class TransformSettings {
companion object {
const val DEFAULT_RENEW_LOCK_RETRY_COUNT = 3
const val DEFAULT_RENEW_LOCK_RETRY_DELAY = 1000L
const val MINIMUM_CANCEL_AFTER_TIME_INTERVAL_SECONDS = 600L

val TRANSFORM_JOB_SEARCH_BACKOFF_COUNT: Setting<Int> = Setting.intSetting(
"plugins.transform.internal.search.backoff_count",
Expand Down

0 comments on commit fc026ed

Please sign in to comment.