Skip to content

Commit 385a511

Browse files
authored
[9.0] Fix exceptions in index pattern conflict checks (#134231) (#134292)
* Fix exceptions in index pattern conflict checks (#134231) We already fixed an issue with this in #128362 but apparently another instance of the unnecessary determinization was hiding elsewhere and in its current state throws exceptions starting with Lucene 10 on complext patterns. This change adds the same fix as #128362 and adds a test that would have triggered this. Closes #133652 * Fix test compilation
1 parent 734fa3e commit 385a511

File tree

3 files changed

+79
-53
lines changed

3 files changed

+79
-53
lines changed

docs/changelog/134231.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
pr: 134231
2+
summary: Fix unnecessary determinization in index pattern conflict checks
3+
area: Indices APIs
4+
type: bug
5+
issues:
6+
- 133652

server/src/main/java/org/elasticsearch/cluster/metadata/MetadataIndexTemplateService.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -953,12 +953,16 @@ static Map<String, List<String>> findConflictingV2Templates(
953953
boolean checkPriority,
954954
long priority
955955
) {
956-
Automaton v1automaton = Regex.simpleMatchToAutomaton(indexPatterns.toArray(Strings.EMPTY_ARRAY));
956+
// No need to determinize the automaton, as it is only used to check for intersection with another automaton.
957+
// Determinization is avoided because it can fail or become very costly due to state explosion.
958+
Automaton v1automaton = Regex.simpleMatchToNonDeterminizedAutomaton(indexPatterns.toArray(Strings.EMPTY_ARRAY));
957959
Map<String, List<String>> overlappingTemplates = new TreeMap<>();
958960
for (Map.Entry<String, ComposableIndexTemplate> entry : state.metadata().templatesV2().entrySet()) {
959961
String name = entry.getKey();
960962
ComposableIndexTemplate template = entry.getValue();
961-
Automaton v2automaton = Regex.simpleMatchToAutomaton(template.indexPatterns().toArray(Strings.EMPTY_ARRAY));
963+
// No need to determinize the automaton, as it is only used to check for intersection with another automaton.
964+
// Determinization is avoided because it can fail or become very costly due to state explosion.
965+
Automaton v2automaton = Regex.simpleMatchToNonDeterminizedAutomaton(template.indexPatterns().toArray(Strings.EMPTY_ARRAY));
962966
if (Operations.isEmpty(Operations.intersection(v1automaton, v2automaton)) == false) {
963967
if (checkPriority == false || priority == template.priorityOrZero()) {
964968
logger.debug(

0 commit comments

Comments
 (0)