Skip to content

Deprecating _primary preference makes getting consistent results impossible(?) #31929

Closed
@bra-fsn

Description

@bra-fsn

Elasticsearch up to 6.x has a preference setting (for eg. get and search operations) named _primary.
According to the docs this makes the query to run on the primary shard:
" The operation will go and be executed only on the primary shards. "

On master (7.x) this setting has disappeared (on 6.x it's deprecated) and for the doc API only _local remained.

This makes it impossible to use the doc (and search) API to get consistent results. A subsequent query could return stale data, which may be even true if a custom preference value is used, because it just hashes the client to a given shard, which may be yet to be updated (while asking the primary would return correct result). Two different clients could get two different results for the same query in the same time this way (or given that all clients use the same custom preference could all see the same stale data).

One could argue that using wait_for_active_shards is the solution here, but even if it's working correctly in this manner (ie: all replicas and the primary are updated atomically from the PoV of the client, which I guess is not true), it would require that all of the shards are always available for writes, which makes replication somewhat useless, or at least much less useful.

Given all of these, I would like to ask you to restore the _primary option for preference.

Metadata

Metadata

Assignees

Labels

:Distributed Indexing/DistributedA catch all label for anything in the Distributed Indexing Area. Please avoid if you can.>docsGeneral docs changesteam-discuss

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions