Close gaps left by the regex breaker charging #166954
🔍 Preview links for changed docs
This PR only changes snippets or data files. No direct page links are available.
Browse the full preview
✅ Elastic Docs Style Checker (Vale)
No issues found on modified lines!
---
The Vale linter checks documentation changes against the Elastic Docs style guide. To use Vale locally or report issues, refer to Elastic style guide for Vale.
<!-- Sticky Pull Request Commentelastic-vale-results -->
ℹ️ Important: Docs version tagging
👋 Thanks for updating the docs! Elastic docs cover multiple versions and deployment types on the same page. applies_to tags help readers understand which information applies to them.
⚠️ Don't remove or replace information that applies to an older version.
Need help with applies_to?
applies_to metadata, with syntax examples.The automated docs review also checks for tagging issues on your PR, where enabled.
Pinging @elastic/es-analytical-engine (Team:Analytics)
Severity: P3 (Low)
The partial-results caveat also applies to aggregation regex complexity errors and request-breaker trips during compilation. Those errors are reported as shard failures too, so a search can return HTTP 200 with _shards.failures rather than the HTTP 400 or 429 promised here. Scope those status codes to searches that fail outright.
<sub>Generated by Libra. React with 👍 or 👎 to give feedback on this comment.</sub>
Severity: P3 (Low)
The limit is 1,000 UTF-16 code units, not 1,000 Unicode characters. Supplementary characters count twice, so a matcher can be rejected even when its pattern is under the documented character limit. Clarify the unit here and in the changelog.
<sub>Generated by Libra. React with 👍 or 👎 to give feedback on this comment.</sub>
Severity: P3 (Low)
This test would still pass if the successful shard's buckets were discarded: the only value in test_default_regex is bar, which the include pattern does not match. Index a matching value there and assert its bucket and count so the test verifies that the successful shard's aggregation data survives the other shard's rejection.
<sub>Generated by Libra. React with 👍 or 👎 to give feedback on this comment.</sub>
Severity: P2 (Medium)
Keep the compiled version automaton charged after construction. reservingCompile drops the entire reservation, but a compound query keeps the returned automaton alive while it builds subsequent clauses. The query visitor's running estimate is not on the breaker yet, so a later compile can pass its breaker check even when its reservation plus the earlier live automata exceeds the limit. Swap the build reservation for the query's retained size and mark it precharged, as the regexp builder does.
<sub>Generated by Libra. React with 👍 or 👎 to give feedback on this comment.</sub>
Severity: P3 (Low)
Keep a nonmatching value in test_default_regex alongside the new matching one. With only a matching value on the successful side, the mixed-index assertions also pass if the short-limit shard rejects the pattern correctly but the successful shard ignores include and returns unfiltered buckets.
<sub>Generated by Libra. React with 👍 or 👎 to give feedback on this comment.</sub>
Resolved by cbbb309b7c0819cd5b9c0c399a38b8247e117aec
nit: let's thousands separator, as in the other PromQL pages:
{applies_to}`stack: ga 9.7+` {applies_to}`serverless: ga` The pattern of a `=~` or `!~` matcher can be at most 1,000 characters long.
Resolved by 02710cd0818cae0df966c848874b1d1738f0d9a9
Resolved by af39f181d6bfeb03256eddb137394271ab0e7ab9
Resolved by e00fdfbf6c49726e4ac192044e81a0a20679ab89
⚒️ Zug zug. _(Claude, the author's peon)_
Not changing this one. It is true for a pattern with supplementary characters: the check is String.length(), as it is for index.max_regex_length. The regexp query page states that limit in characters too, so this line keeps the same word.
<!-- zugzug:reply-to=4741794779 -->
The implementation confirms the distinction rather than resolving it: it rejects when regex.length() > maxRegexLength and reports that same length (LabelMatcher.java lines 213–223). In Java, String.length() counts UTF-16 code units, so a supplementary character contributes two; a pattern with fewer than 1,000 Unicode code points can therefore exceed this limit. The regexp page uses the same “characters” wording (lines 43–47), but matching that wording does not make the unit clearer. I’d describe the limit as 1,000 UTF-16 code units here (and in the changelog), or explicitly qualify what “characters” means.
<sub>Generated by Libra. React with 👍 or 👎 to give feedback on this comment.</sub>
kosabogi
alighahramani-alig
Follow-up to #158570, from the review comments left on its last commit.
constant_keyword. Aregexporwildcardquery compiled its pattern into aCharacterRunAutomatonto test the field's one value. That is a table with an entry for every state and every character class of the pattern, built after the charged build had released its reservation. The value is now stepped through the DFA, so no table is built.version. Itsregexpquery charged the NFA and DFA builds and then constructed anAutomatonQuery, which compiles the DFA into its UTF-8 run form with nothing reserved. The estimate the keyword field reserves for that step is now held while the query is constructed, and what the finished query keeps is charged as it is built, not when the query tree is walked._shards.failures, unless partial results are disallowed. The entry now says so, and30_limits.ymlpins it for the length check across two indices with different limits. The entry and the Prometheus compatibility page also state the 1,000-character limit on the pattern of a PromQL=~or!~label matcher.Each new unit test fails without its fix. No changelog entry of its own: #158570 is in no stack release yet, so its entry is the one edited here. The backports of #158570 that carry the breaker charging should carry these commits too.
Left for later, from the same review: the include/exclude work limit does not count the ranges it scans, and a multi-value exact label matcher builds its literals before the first budget check.
Assisted by Claude.