【问题标题】:Elasticsearch error resource_already_exists_exception when index doesn't exist for sure当索引确定不存在时,Elasticsearch 错误 resource_already_exists_exception
【发布时间】:2022-07-13 01:24:47
【问题描述】:

我对新索引使用随机索引名称:

async import_index(alias_name, mappings, loadFn) {
    const index = `${alias_name}_${+new Date()}`
    console.log('creating new index: ', index)
    await this.esService.indices.create({
        index: index,
        body: {
            "settings": this.index_settings(),
            "mappings": mappings
        }
    }).then(res => {
        console.log('index created: ', index)
    }).catch(async (err) => {
        console.error(alias_name, ": creating new index", JSON.stringify(err.meta, null, 2))
        throw err
    });

我认为不存在同名的索引,但 ES 向我返回此错误

"error": {
      "root_cause": [
        {
          "type": "resource_already_exists_exception",
          "reason": "index [brands_1637707367610/bvY5O_NjTm6mU3nQVx7QiA] already exists",
          "index_uuid": "bvY5O_NjTm6mU3nQVx7QiA",
          "index": "brands_1637707367610"
        }
      ],
      "type": "resource_already_exists_exception",
      "reason": "index [brands_1637707367610/bvY5O_NjTm6mU3nQVx7QiA] already exists",
      "index_uuid": "bvY5O_NjTm6mU3nQVx7QiA",
      "index": "brands_1637707367610"
    },
    "status": 400
  }

使用 bitnami helm chart 在 k8s 中安装 ES,运行 3 个主节点。客户端连接到主服务 url。我的想法:客户端同时向所有节点发送请求,但我无法证明。

请帮忙

【问题讨论】:

  • 我面临同样的问题。你是怎么解决的?
  • 我增加了容器的内存堆,它开始运行良好。

标签: elasticsearch nestjs


【解决方案1】:

我们在使用 python 客户端时遇到了同样的错误。但据我所知,javascript 客户端是用类似的方式编写的。

客户端中有一个retry 选项。

在您的情况下,这很可能设置为 true(可以重新配置)。然后你将一个大的映射传递给this.esService.indices.create。操作耗时过长,超时,然后重试,但在集群上创建了索引。

您需要向 elasticsearch index create api 发送更大的超时时间(默认 30 秒)。并且还为 http 连接设置了相同的超时时间。至少在 python 上,这些是 2 个单独的设置 https://github.com/elastic/elasticsearch-py/issues/1569 我在 js 客户端中看到了类似的选项。 https://github.com/elastic/elasticsearch-js/blob/v7.17.0/lib/Transport.js#L435

【讨论】:

    猜你喜欢
    • 2021-01-02
    • 1970-01-01
    • 1970-01-01
    • 2019-03-04
    • 2018-02-22
    • 1970-01-01
    • 2021-09-11
    • 1970-01-01
    • 2021-02-02
    相关资源
    最近更新 更多