Pruning probes each index with field caps and an index filter, keeping the ones
that come back. An index whose shards cannot be read does not come back either,
and field caps reports no failure for it, so pruning dropped it. The search then
covered every shard it was given, so neither the PARTIAL_RESULT warning nor
search.default_allow_partial_results=false could see the loss. Measured on a
two-node cluster over a 4-shard pattern of 990 documents with one node stopped:
stats count() returned 750 with no warning and no error.
Keep any resolved index that an unfiltered field caps probe cannot read either;
a readable index answers that probe whatever the time range. The search then
reaches the missing shard and reports it. Readability is judged by a probe
rather than the routing table, because cluster state needs
cluster:monitor/state, which an index-scoped role lacks.
- The unfiltered probe is sent alongside the filtered one, so it adds no round
trip. Its answer is read only when pruning would narrow.
- Kept indices are re-resolved first, so an index deleted mid-query is not
named and cannot fail the search with index_not_found.
- An expression naming a remote cluster is no longer pruned: field caps and
resolve both omit an unreachable remote without error.
Known gap: the probe works per index, not per shard. An index readable through a
shard holding nothing in range, while the shard holding in-range documents is
unassigned, still looks prunable. Closing it needs field caps to report the
shards it could not reach.
Signed-off-by: Kai Huang <[email protected]>
Description
Index pruning (#5766) probes each index with
_field_capsplus anindex_filterand keeps the ones that come back. An index whose shards are unavailable can't be probed, and field caps reports no failure for it. The index is just missing from the response, which looks the same as an index proven to hold nothing in range:So the unreachable index was pruned out of the expression (#5808). The search that ran next covered every shard it was given, which means:
PARTIAL_RESULTwarning had nothing to report;search.default_allow_partial_results=falsesaw a complete search and allowed it.Every PPL query from Dashboards sends request-level time bounds, which is what turns pruning on, so this is the main path. Measured on a two-node cluster over a 4-shard pattern of 990 documents, with one node stopped:
750, no warning, no error750+PARTIAL_RESULTwarningallow_partial_search_results=false750, no errorThe fix
Keep any index the probe can't have ruled out. One probe can't tell the two cases apart, but a second
_field_capscall with no index filter can:unsearchable = resolved − unfiltered, thenkeep = candidates ∪ unsearchable. The search then reaches the missing shard, and #5807 reports it.cluster:monitor/state, which an index-scoped role doesn't have. The first version of this fix read the routing table:TimeBoundsPruningSecurityITwent red, and those users would have had pruning silently disabled plus a MISSING_PRIVILEGES audit event on every query. A unit test now asserts no cluster state request is issued.index_not_found, and the old, out-of-range indices are exactly the ones retention deletes._field_capsand_resolve/indexboth omit an unreachable remote without error, solocal-*,remote:*could narrow to local indices and drop the remote silently. This predates this PR (Prune indices by request-level time bounds before the schema is resolved #5766), but it's the same failure.fieldsnever decides which indices come back, and a range on an unmapped field can't match anything, so dropping it is correct.Known gap (raised by @dai-chen in #5807)
The probe works per index, not per shard. Suppose an index has one readable shard with nothing in range and another shard, holding the in-range documents, that is unassigned. The unfiltered probe sees the index and the filtered probe doesn't, so it's still pruned. That requires the in-range documents to sit only on the missing shard. It's unusual under default routing, but possible when the range holds very few documents.
The complete fix is for
_field_capsto report the shards it couldn't reach; today it returnsfailed_indices: null. That belongs in core. This PR closes the index-level case, which covers the observed failure (a node drop leaving a whole index unreadable), and I'm happy to open the core issue alongside it.Testing
IndexPrunerTest(38), including checks that no cluster state request is issued, both probes are sent before either is read, an index deleted after resolving is not named, and a remote expression is not pruned.ShardFailureWarningSecurityITgains an out-of-range index and two cases, run as an index-scoped user:source=shard_sec_* | stats count(), no boundsPARTIAL_RESULT, "1 of 3 shards"source=shard_sec_* | stats count(), with boundsPARTIAL_RESULT, "1 of 2 shards" (the old index is pruned, the unreadable one kept)source=shard_sec_* | fields legacy_only, with boundsField [legacy_only] not found.(the out-of-range index is still pruned)@RequiresCapability(TIME_BOUNDS_PRUNING)and pin pruning on, likeTimeBoundsPruningSecurityIT.executeQueryAsUserWithBoundsand the pruning setting helpers move intoSecurityTestBase, sharing one request helper withexecuteQueryAsUser.Related Issues
Resolves #5808
Check List
--signoff.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.