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

Script: Deprecate script context cache #79508

Merged

Conversation

stu-elastic
Copy link
Contributor

@stu-elastic stu-elastic commented Oct 19, 2021

Deprecate the script context cache in favor of the general cache.

Users should use the following settings:
script.max_compilations_rate to set the max compilation rate
for user scripts such as filter scripts. Certain script contexts
that submit scripts outside of the control of the user are
exempted from this rate limit. Examples include runtime fields,
ingest and watcher.

script.cache.max_size to set the max size of the cache.

script.cache.expire to set the expiration time for entries in
the cache.

Whats deprecated?
script.max_compilations_rate: use-context. This special
setting value was used to turn on the script context-specific caches.

script.context.$CONTEXT.cache_max_size, use script.cache.max_size
instead.

script.context.$CONTEXT.cache_expire, use script.cache.expire
instead.

script.context.$CONTEXT.max_compilations_rate, use
script.max_compilations_rate instead.

The default cache size was increased from 100 to 3000, which
was approximately the max cache size when using context-specific caches.

The default compilation rate limit was increased from 75/5m to
150/5m to account for increasing uses of scripts.

Refs: #62899

Deprecate the script context cache in favor of the general cache.

Users should use the following settings:
`script.max_compilations_rate` to set the max compilation rate
  for user scripts such as filter scripts.  Certain script contexts
  that submit scripts outside of the control of the user are
  exempted from this rate limit.  Examples include runtime fields,
  ingest and watcher.

`script.cache.max_size` to set the max size of the cache.

`script.cache.expire` to set the expiration time for entries in
the cache.

Whats deprecated?
`script.max_compilations_rate: use-context`.  This special
setting value was used to turn on the script context-specific caches.

`script.context.$CONTEXT.cache_max_size`, use `script.cache.max_size`
instead.

`script.context.$CONTEXT.cache_expire`, use `script.cache.expire`
instead.

`script.context.$CONTEXT.max_compilations_rate`, use
`script.max_compilations_rate` instead.

The default cache size was increased from `100` to `3000`, which
was approximately the max cache size when using context-specific caches.

The default compilation rate limit was increased from `75/5m` to
`150/5m` to account for increasing uses of scripts.

Refs: elastic#62899
@stu-elastic stu-elastic added >breaking :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache v7.16.0 labels Oct 19, 2021
@stu-elastic stu-elastic requested a review from rjernst October 19, 2021 18:59
@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Oct 19, 2021
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

A few quick comments

@@ -321,4 +321,77 @@ avoid deprecation warnings and opt into the future behaviour, include the query
parameter `?return_200_for_cluster_health_timeout` in your request.
====

[[script-context-cache-removed]]
.The `script.max_compilations_rate` setting cannot be `use-context`.
Copy link
Member

Choose a reason for hiding this comment

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

The value is deprecated, not removed right? The wording seems to imply it won't work, but it will, it should just be migrated away from.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to "is a deprecated value".

compilation rate limits and to compensate for an undersized general script
cache.
Now, system scripts are exempt from compilation rate limiting and
the general script cache size is dynamically with a higher default
Copy link
Member

Choose a reason for hiding this comment

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

"size is dynamically with a higher default"? I'm not sure what this is supposed to mean.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to "is able to be set dynamically"

`200/10m`, which allows 200 compilations for every 10 minute period.

*Impact* +
Discontinue use of the removed setting value. Specifying the setting value
Copy link
Member

Choose a reason for hiding this comment

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

This wording looks like a breakage, but it's just a deprecation. We should model it after other deprecation docs. For example, look at deprecate-transient-cluster-settings in this file. Ditto for all the other sections added in this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to To avoid deprecation warnings, discontinue use of the deprecated setting value.

@@ -249,6 +263,10 @@ void registerClusterSettingsListeners(ClusterSettings clusterSettings) {
*/
void validateCacheSettings(Settings settings) {
boolean useContext = SCRIPT_GENERAL_MAX_COMPILATIONS_RATE_SETTING.get(settings).equals(USE_CONTEXT_RATE_VALUE);
if (useContext) {
deprecationLogger.critical(DeprecationCategory.SCRIPTING, "scripting-context-cache",
Copy link
Member

Choose a reason for hiding this comment

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

All of these critical should be warnings instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

@stu-elastic
Copy link
Contributor Author

@elasticmachine update branch

@stu-elastic
Copy link
Contributor Author

@elasticmachine update branch

Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

This looks good, but i would like @debadair to look over the migration docs wording/structure.


Previously, you could set this setting to `use-context` to have a
script cache, compilation rate limit settings, cache expiration and
cache size per cluster.
Copy link
Member

Choose a reason for hiding this comment

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

per cluster -> per script context

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed.

Now, system scripts are exempt from compilation rate limiting and
the general script cache size is able to be set dynamically.

Do not use `use-context` as a value for this setting. Instead, remove
Copy link
Member

Choose a reason for hiding this comment

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

This paragraph should be moved/rephrased into the impact below. I would also remove the first sentence.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed first sentence, moved and expanded below.

size.

*Impact* +
To avoid deprecation warnings, discontinue use of the deprecated settings.
Copy link
Member

Choose a reason for hiding this comment

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

The impact should be specific, not the same for every one of these migration notes. Maybe @debadair can provide some suggestions on wording. I'm also not sure if we should have a single note about script.context.$CONTEXT.* or have individual notes as you have here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the impact more specific and recommended mitigation.

I'm also not sure if we should have a single note about script.context.$CONTEXT.* or have individual notes as you have here.

I made them different so the deprecation warnings could point to different sections. Since the deprecation warning URLs can easily be changed after release (they use https://ela.st/), I don't have a strong opinion.

Copy link
Contributor

@debadair debadair Oct 19, 2021

Choose a reason for hiding this comment

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

I'd be inclined to consolidate this into a single entry. I think it can be streamlined quite a bit.

[[script-context-cache-deprecated]]
. The script context cache is deprecated
[%collapsible]
====
Details +
Setting script.max_compilations_rate to use-contextand
configuring context-specific caches is deprecated.
Context-specific caches are no longer needed to prevent system scripts
from triggering rate limits.
Configure the general cache to control the max complication rate, cache size, and
cache expiration for your scripts.

Impact +
Remove script.max_compilations_rate: use-context and the context-specific cache settings: script.context.$CONTEXT.cache_max_size, script.context.$CONTEXT.max_compilations_rate, script.context.$CONTEXT.cache_expire.

The general cache defaults to a max size of 3000 with a rate limit of 150/5m,
which allows 150 compilations per 5 minute period.
To override the defaults, configure the script.cache.max_size, script.max_compilations_rate, and script.cache.expire settings.
====

@@ -277,7 +295,7 @@ void validateCacheSettings(Settings settings) {
String.join(", ", customRates) + "] if compile rates disabled via [" +
SCRIPT_DISABLE_MAX_COMPILATIONS_RATE_SETTING.getKey() + "]");
}
if (useContext == false) {
if (useContext == false && SCRIPT_GENERAL_MAX_COMPILATIONS_RATE_SETTING.exists(settings)) {
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this branch not be an error anymore? The setting is the general one, not per context?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SCRIPT_DISABLE_MAX_COMPILATIONS_RATE_SETTING is used for tests and not compatible with any custom settings. If that is set at all we need to error. I added this due to a test error.

Copy link
Member

Choose a reason for hiding this comment

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

Hrm, but the conditional here is checking SCRIPT_GENERAL_MAX_COMPILATIONS_RATE_SETTING not SCRIPT_DISABLE_MAX_COMPILATIONS_RATE_SETTING?

Copy link
Member

Choose a reason for hiding this comment

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

Oooh, this is inside a block for SCRIPT_DISABLE_MAX_COMPILATIONS_RATE_SETTING, I think I see now.

Copy link
Contributor

@debadair debadair left a comment

Choose a reason for hiding this comment

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

Left some suggestions to streamline the deprecation entry & align the messages with the guidelines. LMK if you have any questions!

size.

*Impact* +
To avoid deprecation warnings, discontinue use of the deprecated settings.
Copy link
Contributor

@debadair debadair Oct 19, 2021

Choose a reason for hiding this comment

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

I'd be inclined to consolidate this into a single entry. I think it can be streamlined quite a bit.

[[script-context-cache-deprecated]]
. The script context cache is deprecated
[%collapsible]
====
Details +
Setting script.max_compilations_rate to use-contextand
configuring context-specific caches is deprecated.
Context-specific caches are no longer needed to prevent system scripts
from triggering rate limits.
Configure the general cache to control the max complication rate, cache size, and
cache expiration for your scripts.

Impact +
Remove script.max_compilations_rate: use-context and the context-specific cache settings: script.context.$CONTEXT.cache_max_size, script.context.$CONTEXT.max_compilations_rate, script.context.$CONTEXT.cache_expire.

The general cache defaults to a max size of 3000 with a rate limit of 150/5m,
which allows 150 compilations per 5 minute period.
To override the defaults, configure the script.cache.max_size, script.max_compilations_rate, and script.cache.expire settings.
====

String.format(Locale.ROOT, "settings [" + maxSettings + "] for context specific rate limits are deprecated and will"
+ " not be available in a future version."
+ " Use [" + ScriptService.SCRIPT_GENERAL_MAX_COMPILATIONS_RATE_SETTING.getKey() + "] to rate limit the compilation"
+ " of user scripts, system scripts are exempt.", maxSettings),
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd edit slightly to align with the other deprecation messages:

Setting context-specific rate limits is deprecated. Use [setting] to rate limit the compilation of user scripts. Context-specific caches are no longer needed to prevent system scripts from triggering rate limits.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Much nicer. Done.

+ " deprecated and will not be available in a future version."
+ " Use [" + ScriptService.SCRIPT_GENERAL_CACHE_SIZE_SETTING.getKey() + "] to size the context cache for all"
+ " scripts.",
cacheSizeSettings),
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly:

Setting a context-specific cache size is deprecated. Use [setting] to configure the size of the general cache for user scripts. Context-specific caches are no longer needed to prevent system scripts from triggering rate limits.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

+ " Use [" + ScriptService.SCRIPT_GENERAL_CACHE_EXPIRE_SETTING.getKey() + "]"
+ " to set the cache expiration all scripts.",
cacheExpireSettings),
"https://ela.st/es-deprecation-7-script-context-expire-deprecated",
Copy link
Contributor

Choose a reason for hiding this comment

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

Similarly:

Setting a context-specific cache expiration is deprecated. Use [setting] to configure the expiration of the general cache. Context-specific caches are no longer needed to prevent system scripts from triggering rate limits.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@stu-elastic stu-elastic merged commit 005d8f0 into elastic:7.x Oct 20, 2021
stu-elastic added a commit to stu-elastic/elasticsearch that referenced this pull request Oct 20, 2021
Deprecate the script context cache in favor of the general cache.

Users should use the following settings:
`script.max_compilations_rate` to set the max compilation rate
  for user scripts such as filter scripts.  Certain script contexts
  that submit scripts outside of the control of the user are
  exempted from this rate limit.  Examples include runtime fields,
  ingest and watcher.

`script.cache.max_size` to set the max size of the cache.

`script.cache.expire` to set the expiration time for entries in
the cache.

Whats deprecated?
`script.max_compilations_rate: use-context`.  This special
setting value was used to turn on the script context-specific caches.

`script.context.$CONTEXT.cache_max_size`, use `script.cache.max_size`
instead.

`script.context.$CONTEXT.cache_expire`, use `script.cache.expire`
instead.

`script.context.$CONTEXT.max_compilations_rate`, use
`script.max_compilations_rate` instead.

The default cache size was increased from `100` to `3000`, which
was approximately the max cache size when using context-specific caches.

The default compilation rate limit was increased from `75/5m` to
`150/5m` to account for increasing uses of scripts.

System script contexts can now opt-out of compilation rate limiting
using a flag rather than a sentinel rate limit value.

7.16: Script: Deprecate script context cache elastic#79508
Refs: elastic#62899

7.16: Script: Opt-out system contexts from script compilation rate limit elastic#79459
Refs: elastic#62899
stu-elastic added a commit to stu-elastic/elasticsearch that referenced this pull request Oct 20, 2021
Deprecate the script context cache in favor of the general cache.

Users should use the following settings:
`script.max_compilations_rate` to set the max compilation rate
  for user scripts such as filter scripts.  Certain script contexts
  that submit scripts outside of the control of the user are
  exempted from this rate limit.  Examples include runtime fields,
  ingest and watcher.

`script.cache.max_size` to set the max size of the cache.

`script.cache.expire` to set the expiration time for entries in
the cache.

Whats deprecated?
`script.max_compilations_rate: use-context`.  This special
setting value was used to turn on the script context-specific caches.

`script.context.$CONTEXT.cache_max_size`, use `script.cache.max_size`
instead.

`script.context.$CONTEXT.cache_expire`, use `script.cache.expire`
instead.

`script.context.$CONTEXT.max_compilations_rate`, use
`script.max_compilations_rate` instead.

The default cache size was increased from `100` to `3000`, which
was approximately the max cache size when using context-specific caches.

The default compilation rate limit was increased from `75/5m` to
`150/5m` to account for increasing uses of scripts.

System script contexts can now opt-out of compilation rate limiting
using a flag rather than a sentinel rate limit value.

7.16: Script: Deprecate script context cache elastic#79508
Refs: elastic#62899

7.16: Script: Opt-out system contexts from script compilation rate limit elastic#79459
Refs: elastic#62899
stu-elastic added a commit that referenced this pull request Oct 21, 2021
Deprecate the script context cache in favor of the general cache.

Users should use the following settings:
`script.max_compilations_rate` to set the max compilation rate
  for user scripts such as filter scripts.  Certain script contexts
  that submit scripts outside of the control of the user are
  exempted from this rate limit.  Examples include runtime fields,
  ingest and watcher.

`script.cache.max_size` to set the max size of the cache.

`script.cache.expire` to set the expiration time for entries in
the cache.

Whats deprecated?
`script.max_compilations_rate: use-context`.  This special
setting value was used to turn on the script context-specific caches.

`script.context.$CONTEXT.cache_max_size`, use `script.cache.max_size`
instead.

`script.context.$CONTEXT.cache_expire`, use `script.cache.expire`
instead.

`script.context.$CONTEXT.max_compilations_rate`, use
`script.max_compilations_rate` instead.

The default cache size was increased from `100` to `3000`, which
was approximately the max cache size when using context-specific caches.

The default compilation rate limit was increased from `75/5m` to
`150/5m` to account for increasing uses of scripts.

System script contexts can now opt-out of compilation rate limiting
using a flag rather than a sentinel rate limit value.

7.16: Script: Deprecate script context cache #79508
Refs: #62899

7.16: Script: Opt-out system contexts from script compilation rate limit #79459
Refs: #62899
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >deprecation Team:Core/Infra Meta label for core/infra team v7.16.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants