【问题标题】:How to deal with version conflict engine exception in elasticserachelasticsearch中版本冲突引擎异常如何处理
【发布时间】:2021-08-19 07:44:24
【问题描述】:

我使用了 PHP Elasticsearch 客户端,但总是遇到这样的异常

{
    "took": 17,
    "timed_out": false,
    "total": 3,
    "updated": 2,
    "deleted": 0,
    "batches": 1,
    "version_conflicts": 1,
    "noops": 0,
    "retries": {
        "bulk": 0,
        "search": 0
    },
    "throttled_millis": 0,
    "requests_per_second": -1.0,
    "throttled_until_millis": 0,
    "failures": [{
        "index": "questions_statistics",
        "type": "_doc",
        "id": "IwSmq3kB2OehDv3R2YeP",
        "cause": {
            "type": "version_conflict_engine_exception",
            "reason": "[IwSmq3kB2OehDv3R2YeP]: version conflict, required seqNo [1927448], primary term [1]. current document has seqNo [1927450] and primary term [1]",
            "index_uuid": "HW9XMxZtTLi2_Iv_Ryl01w",
            "shard": "0",
            "index": "questions_statistics"
        },
        "status": 409
    }]
}

似乎是乐观锁定导致的版本冲突。我认为不应该处理这种类型的异常。我应该抓住并写下日志吗?或者有没有其他的处理方法?

【问题讨论】:

    标签: php elasticsearch elastic-stack


    【解决方案1】:

    这取决于您将如何处理应用程序中的版本冲突,如果您使用 Last Write Win 冲突解决方案,您可以通过在 Elasticsearch 中提供手动版本来省略版本冲突,但如果您愿意确保您正在写入 Elasticsearch 的文档已经有最新的字段值版本冲突帮助您避免更新之前更新的文档。 关于日志记录,最好将所有类型的失败操作保留在系统中。

    【讨论】:

      猜你喜欢
      • 2017-06-28
      • 2020-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-25
      相关资源
      最近更新 更多