Skip to content

Improve regex parsing in GET /_alias/ or GET /_alias/prefix #130464

@mayya-sharipova

Description

@mayya-sharipova

Elasticsearch Version

8.14

Installed Plugins

No response

Java Version

bundled

OS Version

Linux

Problem Description

A user has a huge amount of aliases for their indices (could be > 1000 aliases per index), defined like this:

    "cf_index": {
        "aliases": {
            "cf_0001": {
                "filter": {
                    "term": {
                        "cf": "0001"
                    }
                }
            },
            "cf_0002": {
                "filter": {
                    "term": {
                        "cf": 0002"
                    }
                }
            },
            "cf_0003": {
                "filter": {
                    "term": {
                        "cf": "003"
                    }
                }
            },

when GET _alias API is requested (through monitoring or user based? ), there is a lot CPU spent on processing Regex expressions:

   100.4% [cpu=100.4%, other=0.0%] (502.2ms out of 500ms) cpu usage by thread 'elasticsearch[instance-0000000047][management][T#2]'
     10/10 snapshots sharing following 16 elements
       app/org.elasticsearch.server@8.14.1/org.elasticsearch.common.regex.Regex.simpleMatchWithNormalizedStrings(Regex.java:170)
       app/org.elasticsearch.server@8.14.1/org.elasticsearch.common.regex.Regex.simpleMatch(Regex.java:164)
       app/org.elasticsearch.server@8.14.1/org.elasticsearch.common.regex.Regex.simpleMatch(Regex.java:143)
       app/org.elasticsearch.server@8.14.1/org.elasticsearch.cluster.metadata.Metadata.findAliasInfo(Metadata.java:896)
       app/org.elasticsearch.server@8.14.1/org.elasticsearch.cluster.metadata.Metadata.findAliases(Metadata.java:823)
       app/org.elasticsearch.server@8.14.1/org.elasticsearch.action.admin.indices.alias.get.TransportGetAliasesAction.localClusterStateOperation(TransportGetAliasesAction.java:98)
       app/org.elasticsearch.server@8.14.1/org.elasticsearch.action.admin.indices.alias.get.TransportGetAliasesAction.localClusterStateOperation(TransportGetAliasesAction.java:47)
       app/org.elasticsearch.server@8.14.1/org.elasticsearch.action.support.TransportLocalClusterStateAction.lambda$doExecute$0(TransportLocalClusterStateAction.java:60)
       app/org.elasticsearch.server@8.14.1/org.elasticsearch.action.support.TransportLocalClusterStateAction$$Lambda/0x00007f1f2ce2bcc8.accept(Unknown Source)
       app/org.elasticsearch.server@8.14.1/org.elasticsearch.action.ActionRunnable$4.doRun(ActionRunnable.java:100)
       app/org.elasticsearch.server@8.14.1/org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:984)
       app/org.elasticsearch.server@8.14.1/org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:26)
       java.base@22.0.1/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
       java.base@22.0.1/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
       java.base@22.0.1/java.lang.Thread.runWith(Thread.java:1583)
       java.base@22.0.1/java.lang.Thread.run(Thread.java:1570)

Steps to Reproduce

Steps (I have not reproduced myself):

  • Create an index with > 1000 filter aliases
  • Request GET _alias API or GET /_alias/prefix API

Logs (if relevant)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions