Add search API param to specify read consistency level #10150
Labels
enhancement
Enhancement or improvement to existing feature or request
Search:Query Capabilities
Search:Remote Search
Is your feature request related to a problem? Please describe.
Today to achieve strong read consistency the system exposes refresh policies on the write path to guarantee shards have refreshed on newly indexed documents before the requests are ack'd.
Segment replication does not support these policies and as such does not provide a mechanism for guaranteed read/write consistency on the write path. More on this below in additional context.
As a workaround, the current suggestion is to use the prefer primary preference option when performing reads. This works, but is not ideal for clients/plugins in that it requires prior knowledge of the replication strategy used on the index. Further it applies to both replication strategies and is not required for docrep.
Describe the solution you'd like
As an alternative, I propose we add a new expert level parameter that specifies the read consistency requirements.
I am thinking:
where eventual is the default. This would have the following applications:
For segrep indices, we internally route to the primary shard if it is determined that replicas are behind.
For docrep indices there is no change required. Newly indexed documents will already be refreshed on if refresh is pending.Edit - There is a small nuance here and I think we would need to apply a manual refresh for docrep indices when STRONG is used. Today on the read path, DocRep indices will locally refresh only if search idle state is enabled, not if there are pending documents. If scheduled refresh has not yet run, it is possible that documents that have been written with no refresh policy (default) would not be returned. The impact here is that the reads using the STRONG policy would trigger a refresh before serving the request for it to truly be serving a strong read. Otherwise it will return only the latest refreshed on documents.
Describe alternatives you've considered
Do nothing.
Revisit supporting existing write level mechanisms (wait/immediate refresh policies) with segRep with tight constraints.
Blocking the reads until replicas have caught up, significantly impacting read latency.
Additional context
#6045
#8700
The text was updated successfully, but these errors were encountered: