Ask Your Question
0

Preventing stale reads

asked 2011-12-14 18:57:57 -0500

david-kranz gravatar image

I am trying to understand what prevents the following from happening:

  1. Overwrite an existing object to swift. Two replicas are written but the the third's storage node is unreachable so the write returns but only two copies of the new file exist.
  2. Read the file, but the unreachable node is now reachable and the proxy chooses it to get the data before replication can update the third copy of the file. The read returns the old data.

I looked at the proxy code for PUT/GET but could not figure this out. Is there an easy answer?

edit retag flag offensive close merge delete

4 answers

Sort by ยป oldest newest most voted
0

answered 2011-12-14 19:05:23 -0500

notmyname gravatar image

Nothing prevents that from happening. That is part of the eventual consistency model of swift. Understanding this is very important to writing good clients for swift (or any eventually consistent system).

However, if you ABSOLUTELY MUST HAVE the very newest data every time, you can add an "X-Newest: true" header to your request, and the proxy will query all three replicas and return the one with the newest timestamp. Note, however, that this will cause the result to be slower that if the x-newest header is not used.

edit flag offensive delete link more

Comments

Your reply at https://ask.openstack.org/en/question/26403/does-x-newest-apply-to-getting-container-lists-and-object-lists-also-dlo/ (link text) says "X-Newest: true" does not return the very newest data every time.

Jim Freeman gravatar imageJim Freeman ( 2015-03-11 18:41:28 -0500 )edit
0

answered 2011-12-14 19:30:47 -0500

notmyname gravatar image

If the etag doesn't match the hash of the data, the object is quarantined and replication replaces it. A hash mismatch means that the data has been corrupted on disk (filesystem corruption or bit rot).

On Dec 14, 2011, at 1:20 PM, David Kranz wrote:

Question #181905 on OpenStack Object Storage (swift) changed: https://answers.launchpad.net/swift/+...

David Kranz posted a new comment: I remember there being some kind of 'etag' that can be provided with a read to make sure the data is OK. Would it be possible for the proxy to know what the tag is for an object and check it when doing the read from the object server? It could then try other replicas if the tag was wrong before bailing with an error. That would seem to give the attributes of your X-Newest suggestion but usually not have the overhead of checking multiple copies.


You received this question notification because you are a member of Swift Core, which is an answer contact for OpenStack Object Storage (swift).

edit flag offensive delete link more
0

answered 2011-12-14 19:19:11 -0500

david-kranz gravatar image

I remember there being some kind of 'etag' that can be provided with a read to make sure the data is OK. Would it be possible for the proxy to know what the tag is for an object and check it when doing the read from the object server? It could then try other replicas if the tag was wrong before bailing with an error. That would seem to give the attributes of your X-Newest suggestion but usually not have the overhead of checking multiple copies.

edit flag offensive delete link more
0

answered 2011-12-14 19:10:01 -0500

david-kranz gravatar image

Thanks John Dickinson, that solved my question.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2011-12-14 18:57:57 -0500

Seen: 35 times

Last updated: Dec 14 '11