Skip to content

Instantly share code, notes, and snippets.

@kelseyhightower
Created February 9, 2015 23:15
Show Gist options
  • Select an option

  • Save kelseyhightower/9af2dd9ccb671eacbf26 to your computer and use it in GitHub Desktop.

Select an option

Save kelseyhightower/9af2dd9ccb671eacbf26 to your computer and use it in GitHub Desktop.

Key-Value API

Read consistency

Starting with etcd 2.0.0 read operations provide the following consistency guarantees:

The consistent read guarantees the sequential consistency within one client that talks to one etcd server. Read/Write from one client to one etcd member should be observed in order. If one client write a value to a etcd server successfully, it should be able to get the value out of the server immediately.

Each etcd member will proxy the request to leader and only return the result to user after the result is applied on the local member. Thus after the write succeed, the user is guaranteed to see the value on the member it sent the request to.

Reads do not provide linearizability. If you want linearizabilable read, you need to set quorum option to true.

As a result of this change the consistent flag for read is removed.

Previous behavior

We added an option for a consistent read in the old version of etcd since etcd 0.x redirects the write request to the leader. When the user get back the result from the leader, the member it sent the request to originally might not apply the write request yet. With the consistent flag set to true, the client will always send read request to the leader. So one client should be able to see its last write when consistent=true is enabled. There is no order guarantees among different clients.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment