Elasticsearch read and write consistency

后端 未结 2 1649
南笙
南笙 2020-12-25 13:46

Elasticsearch doesn\'t have \"read consistency\" param (like Cassandra). But it has \"write consistency\" and \"read preference\".

Documentation says the following a

相关标签:
2条回答
  • 2020-12-25 14:13

    I think I can answer my own question now :)

    Regarding the first question, by re-re-reading the documentation (this and this) a few times :) I realized that this statement should be right:

    Index operation return when all live/active shards have finished indexing, regardless of consistency param. Consistency param may only prevent the operation to start if there are not enough available shards(nodes).

    So for example, if there are 3 shards (one primary and two replicas), and all shards are available - the operation will be waiting for all 3 (considering that all 3 are live/available), regardless of consistency param (even when consistency=one)
    This makes the system consistent (at least the document-api part); unless there is a network-partition. But, I didn't have a chance to test this yet.

    UPDATE: by consistency here, I don't mean ACID-consistency, it is just the guarantee that all replicas are updated at the moment when request is returned.

    Regarding the second question: The obvious answer is - it is randomized to spread the load; on the other hand, a client can pick a random node to talk to, but probably it is not 100% efficient as a single request may need multiple shards.

    0 讨论(0)
  • 2020-12-25 14:20

    Write: I am not sure if above is true for ES 6.1 https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#index-wait-for-active-shards says that index operation returns if the primary shard is active and can be changed to other values.

    Searches are random so setting wait for active shard field to all will ensure write is successful if it is performed on all shards.

    Read: Preference can still be used but it is marked as deprecated.

    0 讨论(0)
提交回复
热议问题