Skip to content

Commit 4fc899d

Browse files
authored
Scripting: Deprecate scripts.max_compilation_per_minute setting (#26402)
This setting will be replaced with script.max_compilation_rate in Elasticsearch 6.0, thus it can be marked as deprecated in 5.6.
1 parent 00aeaf5 commit 4fc899d

16 files changed

Lines changed: 90 additions & 22 deletions

File tree

core/src/main/java/org/elasticsearch/script/ScriptService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public class ScriptService extends AbstractComponent implements Closeable, Clust
9090
public static final Setting<Integer> SCRIPT_MAX_SIZE_IN_BYTES =
9191
Setting.intSetting("script.max_size_in_bytes", 65535, Property.NodeScope);
9292
public static final Setting<Integer> SCRIPT_MAX_COMPILATIONS_PER_MINUTE =
93-
Setting.intSetting("script.max_compilations_per_minute", 15, 0, Property.Dynamic, Property.NodeScope);
93+
Setting.intSetting("script.max_compilations_per_minute", 15, 0, Property.Dynamic, Property.NodeScope, Property.Deprecated);
9494

9595
private final Collection<ScriptEngineService> scriptEngines;
9696
private final Map<String, ScriptEngineService> scriptEnginesByLang;

core/src/test/java/org/elasticsearch/script/ScriptServiceTests.java

Lines changed: 53 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ public void testCompilationCircuitBreaking() throws Exception {
151151
for (int i = 0; i < largeLimit; i++) {
152152
scriptService.checkCompilationLimit();
153153
}
154+
assertScriptCompilationWarning();
154155
}
155156

156157
public void testNotSupportedDisableDynamicSetting() throws IOException {
@@ -184,7 +185,9 @@ public void testScriptsWithoutExtensions() throws IOException {
184185
} catch (IllegalArgumentException ex) {
185186
assertThat(ex.getMessage(), containsString("unable to find file script [test_script] using lang [test]"));
186187
}
187-
assertWarnings("File scripts are deprecated. Use stored or inline scripts instead.");
188+
assertWarnings("File scripts are deprecated. Use stored or inline scripts instead.", "[script.max_compilations_per_minute] " +
189+
"setting was deprecated in Elasticsearch and will be removed in a future " +
190+
"release! See the breaking changes documentation for the next major version.");
188191
}
189192

190193
public void testScriptCompiledOnceHiddenFileDetected() throws IOException {
@@ -204,7 +207,9 @@ public void testScriptCompiledOnceHiddenFileDetected() throws IOException {
204207
Files.delete(testHiddenFile);
205208
Files.delete(testFileScript);
206209
resourceWatcherService.notifyNow();
207-
assertWarnings("File scripts are deprecated. Use stored or inline scripts instead.");
210+
assertWarnings("File scripts are deprecated. Use stored or inline scripts instead.", "[script.max_compilations_per_minute] " +
211+
"setting was deprecated in Elasticsearch and will be removed in a future " +
212+
"release! See the breaking changes documentation for the next major version.");
208213
}
209214

210215
public void testInlineScriptCompiledOnceCache() throws IOException {
@@ -214,13 +219,15 @@ public void testInlineScriptCompiledOnceCache() throws IOException {
214219
CompiledScript compiledScript2 = scriptService.compile(new Script(ScriptType.INLINE, "test", "1+1", Collections.emptyMap()),
215220
randomFrom(scriptContexts));
216221
assertThat(compiledScript1.compiled(), sameInstance(compiledScript2.compiled()));
222+
assertScriptCompilationWarning();
217223
}
218224

219225
public void testAllowAllScriptTypeSettings() throws IOException {
220226
buildScriptService(Settings.EMPTY);
221227

222228
assertCompileAccepted("painless", "script", ScriptType.INLINE, ScriptContext.Standard.SEARCH);
223229
assertCompileAccepted("painless", "script", ScriptType.STORED, ScriptContext.Standard.SEARCH);
230+
assertScriptCompilationWarning();
224231
}
225232

226233
public void testAllowAllScriptContextSettings() throws IOException {
@@ -230,6 +237,7 @@ public void testAllowAllScriptContextSettings() throws IOException {
230237
assertCompileAccepted("painless", "script", ScriptType.INLINE, ScriptContext.Standard.AGGS);
231238
assertCompileAccepted("painless", "script", ScriptType.INLINE, ScriptContext.Standard.UPDATE);
232239
assertCompileAccepted("painless", "script", ScriptType.INLINE, ScriptContext.Standard.INGEST);
240+
assertScriptCompilationWarning();
233241
}
234242

235243
public void testAllowSomeScriptTypeSettings() throws IOException {
@@ -242,7 +250,9 @@ public void testAllowSomeScriptTypeSettings() throws IOException {
242250
assertCompileRejected("painless", "script", ScriptType.STORED, ScriptContext.Standard.SEARCH);
243251

244252
assertSettingDeprecationsAndWarnings(
245-
ScriptSettingsTests.buildDeprecatedSettingsArray(scriptSettings, "script.engine.painless.stored"));
253+
ScriptSettingsTests.buildDeprecatedSettingsArray(scriptSettings, "script.engine.painless.stored"),
254+
"[script.max_compilations_per_minute] setting was deprecated in Elasticsearch and will be removed in a " +
255+
"future release! See the breaking changes documentation for the next major version.");
246256
}
247257

248258
public void testAllowSomeScriptContextSettings() throws IOException {
@@ -256,7 +266,9 @@ public void testAllowSomeScriptContextSettings() throws IOException {
256266
assertCompileRejected("painless", "script", ScriptType.INLINE, ScriptContext.Standard.UPDATE);
257267

258268
assertSettingDeprecationsAndWarnings(
259-
ScriptSettingsTests.buildDeprecatedSettingsArray(scriptSettings, "script.update"));
269+
ScriptSettingsTests.buildDeprecatedSettingsArray(scriptSettings, "script.update"),
270+
"[script.max_compilations_per_minute] setting was deprecated in Elasticsearch and will be removed in a " +
271+
"future release! See the breaking changes documentation for the next major version.");
260272
}
261273

262274
public void testAllowNoScriptTypeSettings() throws IOException {
@@ -266,6 +278,7 @@ public void testAllowNoScriptTypeSettings() throws IOException {
266278

267279
assertCompileRejected("painless", "script", ScriptType.INLINE, ScriptContext.Standard.SEARCH);
268280
assertCompileRejected("painless", "script", ScriptType.STORED, ScriptContext.Standard.SEARCH);
281+
assertScriptCompilationWarning();
269282
}
270283

271284
public void testAllowNoScriptContextSettings() throws IOException {
@@ -277,6 +290,7 @@ public void testAllowNoScriptContextSettings() throws IOException {
277290
assertCompileRejected("painless", "script", ScriptType.INLINE, ScriptContext.Standard.AGGS);
278291
assertCompileRejected("painless", "script", ScriptType.INLINE, ScriptContext.Standard.UPDATE);
279292
assertCompileRejected("painless", "script", ScriptType.INLINE, ScriptContext.Standard.INGEST);
293+
assertScriptCompilationWarning();
280294
}
281295

282296
public void testDefaultBehaviourFineGrainedSettings() throws IOException {
@@ -298,9 +312,13 @@ public void testDefaultBehaviourFineGrainedSettings() throws IOException {
298312
}
299313
if (deprecate) {
300314
assertSettingDeprecationsAndWarnings(ScriptSettingsTests.buildDeprecatedSettingsArray(scriptSettings, "script.file"),
301-
"File scripts are deprecated. Use stored or inline scripts instead.");
315+
"File scripts are deprecated. Use stored or inline scripts instead.", "[script.max_compilations_per_minute] " +
316+
"setting was deprecated in Elasticsearch and will be removed in a future " +
317+
"release! See the breaking changes documentation for the next major version.");
302318
} else {
303-
assertWarnings("File scripts are deprecated. Use stored or inline scripts instead.");
319+
assertWarnings("File scripts are deprecated. Use stored or inline scripts instead.", "[script.max_compilations_per_minute] " +
320+
"setting was deprecated in Elasticsearch and will be removed in a future " +
321+
"release! See the breaking changes documentation for the next major version.");
304322
}
305323
}
306324

@@ -398,7 +416,9 @@ public void testFineGrainedSettings() throws IOException {
398416
}
399417
assertSettingDeprecationsAndWarnings(
400418
ScriptSettingsTests.buildDeprecatedSettingsArray(scriptSettings, deprecated.toArray(new String[] {})),
401-
"File scripts are deprecated. Use stored or inline scripts instead.");
419+
"File scripts are deprecated. Use stored or inline scripts instead.", "[script.max_compilations_per_minute] setting was " +
420+
"deprecated in Elasticsearch and will be removed in a future " +
421+
"release! See the breaking changes documentation for the next major version.");
402422
}
403423

404424
public void testCompileNonRegisteredContext() throws IOException {
@@ -418,12 +438,14 @@ public void testCompileNonRegisteredContext() throws IOException {
418438
} catch(IllegalArgumentException e) {
419439
assertThat(e.getMessage(), containsString("script context [" + pluginName + "_" + unknownContext + "] not supported"));
420440
}
441+
assertScriptCompilationWarning();
421442
}
422443

423444
public void testCompileCountedInCompilationStats() throws IOException {
424445
buildScriptService(Settings.EMPTY);
425446
scriptService.compile(new Script(ScriptType.INLINE, "test", "1+1", Collections.emptyMap()), randomFrom(scriptContexts));
426447
assertEquals(1L, scriptService.stats().getCompilations());
448+
assertScriptCompilationWarning();
427449
}
428450

429451
public void testExecutableCountedInCompilationStats() throws IOException {
@@ -432,12 +454,14 @@ public void testExecutableCountedInCompilationStats() throws IOException {
432454
CompiledScript compiledScript = scriptService.compile(script, randomFrom(scriptContexts));
433455
scriptService.executable(compiledScript, script.getParams());
434456
assertEquals(1L, scriptService.stats().getCompilations());
457+
assertScriptCompilationWarning();
435458
}
436459

437460
public void testSearchCountedInCompilationStats() throws IOException {
438461
buildScriptService(Settings.EMPTY);
439462
scriptService.search(null, new Script(ScriptType.INLINE, "test", "1+1", Collections.emptyMap()), randomFrom(scriptContexts));
440463
assertEquals(1L, scriptService.stats().getCompilations());
464+
assertScriptCompilationWarning();
441465
}
442466

443467
public void testMultipleCompilationsCountedInCompilationStats() throws IOException {
@@ -448,6 +472,7 @@ public void testMultipleCompilationsCountedInCompilationStats() throws IOExcepti
448472
.compile(new Script(ScriptType.INLINE, "test", i + " + " + i, Collections.emptyMap()), randomFrom(scriptContexts));
449473
}
450474
assertEquals(numberOfCompilations, scriptService.stats().getCompilations());
475+
assertScriptCompilationWarning();
451476
}
452477

453478
public void testCompilationStatsOnCacheHit() throws IOException {
@@ -460,21 +485,26 @@ public void testCompilationStatsOnCacheHit() throws IOException {
460485
scriptService.compile(script, randomFrom(scriptContexts));
461486
assertEquals(1L, scriptService.stats().getCompilations());
462487
assertSettingDeprecationsAndWarnings(
463-
ScriptSettingsTests.buildDeprecatedSettingsArray(scriptSettings, "script.inline"));
488+
ScriptSettingsTests.buildDeprecatedSettingsArray(scriptSettings, "script.inline"), "[script.max_compilations_per_minute] " +
489+
"setting was deprecated in Elasticsearch and will be removed in a future " +
490+
"release! See the breaking changes documentation for the next major version.");
464491
}
465492

466493
public void testFileScriptCountedInCompilationStats() throws IOException {
467494
buildScriptService(Settings.EMPTY);
468495
createFileScripts("test");
469496
scriptService.compile(new Script(ScriptType.FILE, "test", "file_script", Collections.emptyMap()), randomFrom(scriptContexts));
470497
assertEquals(1L, scriptService.stats().getCompilations());
471-
assertWarnings("File scripts are deprecated. Use stored or inline scripts instead.");
498+
assertWarnings("File scripts are deprecated. Use stored or inline scripts instead.", "[script.max_compilations_per_minute] " +
499+
"setting was deprecated in Elasticsearch and will be removed in a future " +
500+
"release! See the breaking changes documentation for the next major version.");
472501
}
473502

474503
public void testIndexedScriptCountedInCompilationStats() throws IOException {
475504
buildScriptService(Settings.EMPTY);
476505
scriptService.compile(new Script(ScriptType.STORED, "test", "script", Collections.emptyMap()), randomFrom(scriptContexts));
477506
assertEquals(1L, scriptService.stats().getCompilations());
507+
assertScriptCompilationWarning();
478508
}
479509

480510
public void testCacheEvictionCountedInCacheEvictionsStats() throws IOException {
@@ -487,7 +517,10 @@ public void testCacheEvictionCountedInCacheEvictionsStats() throws IOException {
487517
assertEquals(2L, scriptService.stats().getCompilations());
488518
assertEquals(1L, scriptService.stats().getCacheEvictions());
489519
assertSettingDeprecationsAndWarnings(
490-
ScriptSettingsTests.buildDeprecatedSettingsArray(scriptSettings, "script.inline"));
520+
ScriptSettingsTests.buildDeprecatedSettingsArray(scriptSettings, "script.inline"), "[script.max_compilations_per_minute] " +
521+
"setting was deprecated in Elasticsearch and will be removed in a future " +
522+
"release! See the breaking changes documentation for the next major version."
523+
);
491524
}
492525

493526
public void testDefaultLanguage() throws IOException {
@@ -498,7 +531,10 @@ public void testDefaultLanguage() throws IOException {
498531
new Script(ScriptType.INLINE, Script.DEFAULT_SCRIPT_LANG, "1 + 1", Collections.emptyMap()), randomFrom(scriptContexts));
499532
assertEquals(script.lang(), Script.DEFAULT_SCRIPT_LANG);
500533
assertSettingDeprecationsAndWarnings(
501-
ScriptSettingsTests.buildDeprecatedSettingsArray(scriptSettings, "script.inline"));
534+
ScriptSettingsTests.buildDeprecatedSettingsArray(scriptSettings, "script.inline"), "[script.max_compilations_per_minute] " +
535+
"setting was deprecated in Elasticsearch and will be removed in a future " +
536+
"release! See the breaking changes documentation for the next major version.");
537+
502538
}
503539

504540
public void testStoreScript() throws Exception {
@@ -540,6 +576,7 @@ public void testGetStoredScript() throws Exception {
540576

541577
cs = ClusterState.builder(new ClusterName("_name")).build();
542578
assertNull(scriptService.getStoredScript(cs, new GetStoredScriptRequest("_id", "_lang")));
579+
assertScriptCompilationWarning();
543580
}
544581

545582
private void createFileScripts(String... langs) throws IOException {
@@ -566,6 +603,11 @@ private void assertCompileAccepted(String lang, String script, ScriptType script
566603
);
567604
}
568605

606+
private void assertScriptCompilationWarning() {
607+
assertWarnings("[script.max_compilations_per_minute] setting was deprecated in Elasticsearch and will be removed in a " +
608+
"future release! See the breaking changes documentation for the next major version.");
609+
}
610+
569611
public static class TestEngineService implements ScriptEngineService {
570612

571613
public static final String NAME = "test";

docs/reference/cluster/update-settings.asciidoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ PUT /_cluster/settings
1515
}
1616
--------------------------------------------------
1717
// CONSOLE
18+
// TEST[warning:[script.max_compilations_per_minute] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.]
1819

1920
Or:
2021

@@ -28,6 +29,7 @@ PUT /_cluster/settings?flat_settings=true
2829
}
2930
--------------------------------------------------
3031
// CONSOLE
32+
// TEST[warning:[script.max_compilations_per_minute] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.]
3133

3234
The cluster responds with the settings updated. So the response for the
3335
last example will be:
@@ -87,6 +89,7 @@ PUT /_cluster/settings
8789
}
8890
--------------------------------------------------
8991
// CONSOLE
92+
// TEST[warning:[script.max_compilations_per_minute] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.]
9093

9194
Cluster wide settings can be returned using:
9295

docs/reference/modules/cluster/allocation_filtering.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ PUT _cluster/settings
2222
}
2323
--------------------------------------------------
2424
// CONSOLE
25+
// TEST[warning:[script.max_compilations_per_minute] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.]
2526

2627
NOTE: Shards will only be relocated if it is possible to do so without
2728
breaking another routing constraint, such as never allocating a primary and

docs/reference/modules/cluster/disk_allocator.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ PUT _cluster/settings
6666
}
6767
--------------------------------------------------
6868
// CONSOLE
69+
// TEST[warning:[script.max_compilations_per_minute] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.]
6970

7071
NOTE: Prior to 2.0.0, when using multiple data paths, the disk threshold
7172
decider only factored in the usage across all data paths (if you had two

docs/reference/modules/cluster/misc.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[[misc-cluster]]
1+
[misc-cluster]]
22
=== Miscellaneous cluster settings
33

44
[[cluster-read-only]]
@@ -56,3 +56,4 @@ PUT /_cluster/settings
5656
}
5757
-------------------------------
5858
// CONSOLE
59+
// TEST[warning:[script.max_compilations_per_minute] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.]

docs/reference/modules/cross-cluster-search.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ PUT _cluster/settings
7878
}
7979
--------------------------------
8080
// CONSOLE
81+
// TEST[warning:[script.max_compilations_per_minute] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.]
8182

8283
A remote cluster can be deleted from the cluster settings by setting its seeds to `null`:
8384

docs/reference/modules/indices/circuit_breaker.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,5 @@ documentation for more information.
8787

8888
Limit for the number of unique dynamic scripts within a minute that are
8989
allowed to be compiled. Defaults to 15.
90+
91+
deprecated[5.6.0 This parameter is deprecated and will be replaced with `script.max_compilation_rate` in Elasticsearch 6.0]

docs/reference/modules/node.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ PUT _cluster/settings
168168
----------------------------
169169
// CONSOLE
170170
// TEST[catch:/cannot set discovery.zen.minimum_master_nodes to more than the current master nodes/]
171+
// TEST[warning:[script.max_compilations_per_minute] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.]
171172

172173
TIP: An advantage of splitting the master and data roles between dedicated
173174
nodes is that you can have just three master-eligible nodes and set

docs/reference/modules/transport.asciidoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ PUT _cluster/settings
9696
}
9797
--------------------------------------------------
9898
// CONSOLE
99+
// TEST[warning:[script.max_compilations_per_minute] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.]
99100

100101
You can also control which actions will be traced, using a set of include and exclude wildcard patterns. By default every request will be traced
101102
except for fault detection pings:
@@ -111,5 +112,6 @@ PUT _cluster/settings
111112
}
112113
--------------------------------------------------
113114
// CONSOLE
115+
// TEST[warning:[script.max_compilations_per_minute] setting was deprecated in Elasticsearch and will be removed in a future release! See the breaking changes documentation for the next major version.]
114116

115117

0 commit comments

Comments
 (0)