That is correct, primaries are always written to first. They are the
"point of truth" inside the cluster. After a write is finished on a
primary, it is sent out to the replicas to be replicated.
When a primary shard leaves the cluster (because the node disappears, etc),
a replica shard will be promoted to primary. This happens on a per-shard
basis (e.g. promotion of individual shards, not the whole node) and is
nearly instant. The promotion is really just the master updating the
cluster state and informing the other nodes of the changes. The node will
then mark its replica as master and continue business as usual.
If you do happen to index a document while A) the primary is gone and B)
the replica is in the midst of being promoted...elasticsearch will wait
until the promotion is complete before continuing the indexing request. By
default the request will time-out after a minute if the promotion process
takes longer than that.
Replicas and quorums play an overlapping role. A primary/replica
distinction simplifies the process of deciding who can make decisions about
data ("point of truth"). Write consistency quorums help prevent writing to
the wrong side of a split-brain, where a shard thinks it is the primary but
in reality it is sitting in isolation from the rest of the cluster (and
therefore is no longer the true primary, and should not accept indexing
It is important to note that write consistency quorums only checks that the
shards are available...it doesn't actually do a quorum consensus on each
new document. The shards don't all talk to each other and discuss if the
data should be indexed or not. If the quorum rule passes, the primary
shard is still the only shard capable of "officially" accepting the data
into the cluster, then responsible for pushing that data out to replicas.
Phew, that reply got kind of long-winded...does it help clear things up?
On Tuesday, August 27, 2013 10:44:11 PM UTC-4, Mo wrote:
From what I understand writes always go to prmary shard even though you
have 2+ replica copies. It also looks like there is a concept of promoting
other node in the cluster as primary shard when a node fails. Does it mean
clients could potentially see a downtime while this promition is taking
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firstname.lastname@example.org.
For more options, visit https://groups.google.com/groups/opt_out.