Skip to content

Commit 43b1af3

Browse files
authored
Enable index pruning by default (#5759)
The permissions its probes need were added to ppl_full_access in opensearch-project/security#6471. Signed-off-by: Chen Dai <daichen@amazon.com>
1 parent 8d68419 commit 43b1af3

4 files changed

Lines changed: 20 additions & 9 deletions

File tree

docs/user/admin/settings.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,22 +214,22 @@ Version
214214
Description
215215
-----------
216216

217-
Prunes a wildcard index expression down to the concrete indices that can hold data in the query's ``@timestamp`` range, so fewer indices and shards are touched. The primary use currently is to avoid exhausting the open point-in-time (PIT) context limit when a query would otherwise open a reader context over many indices.
217+
Prunes a wildcard index expression down to the concrete indices that can hold data in the query's ``@timestamp`` range, so fewer indices and shards are touched. The primary use currently is to avoid exhausting the open point-in-time (PIT) context limit when a query would otherwise open a reader context over many indices. Enabled by default.
218218

219-
Pruning only applies to a wildcard expression whose query filters on a ``@timestamp`` range; anything else is left untouched, and any failure while probing the cluster falls back to querying the full expression. Weigh these limitations before enabling it:
219+
Pruning only applies to a wildcard expression whose query filters on a ``@timestamp`` range; anything else is left untouched, and any failure while probing the cluster falls back to querying the full expression. Weigh these limitations before turning it off:
220220

221221
1. An index whose shards are all unavailable is pruned rather than reported, because ``_field_caps`` does not surface per-index failures. Such a query returns fewer rows instead of an error.
222222
2. Pruning fixes the list of index names, so an index created or deleted between pruning and PIT creation, by a rollover or retention policy for instance, is missed or fails the query. The interval between the two is short, so this is unlikely in practice.
223223
3. An expression that matches an alias or a data stream is never pruned, because a filtered alias contributes a filter and routing that are resolved from the expression itself and so would be silently dropped.
224-
4. Pruning probes the cluster with the ``indices:admin/resolve/index`` and ``indices:data/read/field_caps`` actions. A principal lacking either permission falls back to querying the full expression silently, so pruning simply never takes effect.
224+
4. Pruning probes the cluster with the ``indices:admin/resolve/index`` and ``indices:data/read/field_caps*`` actions, both granted by the ``ppl_full_access`` role of the security plugin since 3.9. A principal lacking either permission falls back to querying the full expression silently, so pruning simply never takes effect.
225225

226226
Pruning is also skipped when it would not reduce the read, that is when no index is excluded. The query then uses the original wildcard expression and reads exactly the same indices.
227227

228-
Enable it with::
228+
Disable it with::
229229

230230
>> curl -H 'Content-Type: application/json' -X PUT localhost:9200/_plugins/_query/settings -d '{
231231
"transient" : {
232-
"plugins.query.pruning.enabled" : true
232+
"plugins.query.pruning.enabled" : false
233233
}
234234
}'
235235

@@ -242,7 +242,7 @@ Result set::
242242
"plugins" : {
243243
"query" : {
244244
"pruning" : {
245-
"enabled" : "true"
245+
"enabled" : "false"
246246
}
247247
}
248248
}
@@ -251,7 +251,7 @@ Result set::
251251

252252
Settings:
253253

254-
1. The default value is false.
254+
1. The default value is true.
255255
2. This setting is node scope.
256256
3. This setting can be updated dynamically.
257257

integ-test/src/yamlRestTest/resources/rest-api-spec/test/ppl/index_pruning.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ setup:
2121
plugins.calcite.enabled: true
2222
# Without this a Calcite failure is silently answered by the v2 engine, which never prunes.
2323
plugins.calcite.fallback.allowed: false
24-
plugins.query.pruning.enabled: true
2524
- do:
2625
indices.put_index_template:
2726
name: pruning-it

opensearch/src/main/java/org/opensearch/sql/opensearch/setting/OpenSearchSettings.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public class OpenSearchSettings extends Settings {
220220
public static final Setting<?> QUERY_PRUNING_ENABLED_SETTING =
221221
Setting.boolSetting(
222222
Key.QUERY_PRUNING_ENABLED.getKeyValue(),
223-
false,
223+
true,
224224
Setting.Property.NodeScope,
225225
Setting.Property.Dynamic);
226226

opensearch/src/test/java/org/opensearch/sql/opensearch/setting/OpenSearchSettingsTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,18 @@ void testPplValuesMaxLimitSetting() {
125125
assertEquals(5000, newLimit);
126126
}
127127

128+
@Test
129+
void testQueryPruningEnabledSetting() {
130+
when(clusterSettings.get(ClusterName.CLUSTER_NAME_SETTING)).thenReturn(ClusterName.DEFAULT);
131+
when(clusterSettings.get(not((eq(ClusterName.CLUSTER_NAME_SETTING))))).thenReturn(null);
132+
OpenSearchSettings settings = new OpenSearchSettings(clusterSettings);
133+
134+
assertEquals(true, settings.getSettingValue(Settings.Key.QUERY_PRUNING_ENABLED));
135+
136+
settings.new Updater(Settings.Key.QUERY_PRUNING_ENABLED).accept(false);
137+
assertEquals(false, settings.getSettingValue(Settings.Key.QUERY_PRUNING_ENABLED));
138+
}
139+
128140
@Test
129141
void testDeserializationStructuralLimitSettings() {
130142
when(clusterSettings.get(ClusterName.CLUSTER_NAME_SETTING)).thenReturn(ClusterName.DEFAULT);

0 commit comments

Comments
 (0)