You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Behrad Zari <be...@yahoo.com> on 2011/06/29 13:02:10 UTC

View Returns Inconsistent Data on CouchDB 1.1

Dear Couchees,
Consider a view on a CouchDB 1.1 private DB which emits: ( doc._id, 1 )
1) call the view with reduce=false&include_docs=true by your browser!
2) update a document (with futon)
3) recall that view 
You will see a cached-inconsistent document included in view results! (according to _rev and doc data) with a 304 response!
4) recall that view with CTRL+F5 (forces to 'no-cache' and cleaning if-Not-Match)
Now couchdb returns 200 with correct included document version!

The above scenario was not happening in previous CouchDB version and at step 3 we received latest document versions! 
Also this happens when updated document DOES NOT reflect view (key,value) pairs, but when we update an attribute that is emited by a view, Couch returns consistent results. (logically since view hash is changed)
This seems an to be an issue with couchdb's Cache Control.

for more details Request/Response headers are included down below:

View GET Request @step 3:


Request Headers
----------------------
Host192.168.128.11:5984
User-AgentMozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.10) Gecko/20100922 Ubuntu/10.10 (maverick) Firefox/3.6.10
Accepttext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Languageen-us,en;q=0.5
Accept-Encodinggzip,deflate
Accept-CharsetISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive115
Connectionkeep-alive
Cookiesession_id=439173cbd2f955017d8282102a9388a0b92a29c2; AuthSession=YWRtaW46NEUwQUVCNDE6YGCaYBacZ6PweA1xjFoK1U6FwrI
If-None-Match"AI17SB7U17NIG0SL4BRNABYZB"
Cache-Controlmax-age=0

304
-----
ServerCouchDB/1.1.0 (Erlang OTP/R13B03)
Etag"AI17SB7U17NIG0SL4BRNABYZB"
DateWed, 29 Jun 2011 09:07:46 GMT
Content-Typetext/plain;charset=utf-8
Cache-Controlmust-revalidate



AND View GET Request @step 4:

Request Headers
----------------------
Host192.168.128.11:5984
User-AgentMozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.10) Gecko/20100922 Ubuntu/10.10 (maverick) Firefox/3.6.10
Accepttext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Languageen-us,en;q=0.5
Accept-Encodinggzip,deflate
Accept-CharsetISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive115
Connectionkeep-alive
Cookiesession_id=439173cbd2f955017d8282102a9388a0b92a29c2; AuthSession=YWRtaW46NEUwQUVCNDE6YGCaYBacZ6PweA1xjFoK1U6FwrI
Pragmano-cache
Cache-Controlno-cache

200
-----
Transfer-Encodingchunked
ServerCouchDB/1.1.0 (Erlang OTP/R13B03)
Etag"AI17SB7U17NIG0SL4BRNABYZB"
DateWed, 29 Jun 2011 09:09:52 GMT
Content-Typetext/plain;charset=utf-8
Cache-Controlmust-revalidate
 


--Behrad

Re: View Returns Inconsistent Data on CouchDB 1.1

Posted by Jens Alfke <je...@mooseyard.com>.
On Jun 29, 2011, at 11:54 AM, Robert Newson wrote:

> I think the sanest fix is to make view etags for include_docs=true use
> the original algorithm, so that they always change if the database
> changes. If you file a ticket, I can fix this in the morning.

OK! Filed https://issues.apache.org/jira/browse/COUCHDB-1206

—Jens

Re: View Returns Inconsistent Data on CouchDB 1.1

Posted by Paul Davis <pa...@gmail.com>.
Yes, this is a bug in etag generation, not a concerted effort to make them weak.

Sane solution sounds sane.

On Wed, Jun 29, 2011 at 2:54 PM, Robert Newson <rn...@apache.org> wrote:
> I think the sanest fix is to make view etags for include_docs=true use
> the original algorithm, so that they always change if the database
> changes. If you file a ticket, I can fix this in the morning.
>
> B.
>
>
> On 29 June 2011 19:22, Jens Alfke <je...@mooseyard.com> wrote:
>>
>> On Jun 29, 2011, at 11:13 AM, Jens Alfke wrote:
>>
>>> So for example, I do this:
>>>
>>> $ curl -I http://localhost:5984/demo-addresses/_all_docs
>>
>> Sorry, to be a good test the URL should have been like
>>        http://127.0.0.1:5984/demo-addresses/_changes?include_docs=true
>> because without include_docs, the ETag is still a strong validator, as far as I can tell.
>>
>> —Jens
>

Re: View Returns Inconsistent Data on CouchDB 1.1

Posted by Robert Newson <rn...@apache.org>.
I think the sanest fix is to make view etags for include_docs=true use
the original algorithm, so that they always change if the database
changes. If you file a ticket, I can fix this in the morning.

B.


On 29 June 2011 19:22, Jens Alfke <je...@mooseyard.com> wrote:
>
> On Jun 29, 2011, at 11:13 AM, Jens Alfke wrote:
>
>> So for example, I do this:
>>
>> $ curl -I http://localhost:5984/demo-addresses/_all_docs
>
> Sorry, to be a good test the URL should have been like
>        http://127.0.0.1:5984/demo-addresses/_changes?include_docs=true
> because without include_docs, the ETag is still a strong validator, as far as I can tell.
>
> —Jens

Re: View Returns Inconsistent Data on CouchDB 1.1

Posted by Jens Alfke <je...@mooseyard.com>.
On Jun 29, 2011, at 11:13 AM, Jens Alfke wrote:

> So for example, I do this:
> 
> $ curl -I http://localhost:5984/demo-addresses/_all_docs

Sorry, to be a good test the URL should have been like
	http://127.0.0.1:5984/demo-addresses/_changes?include_docs=true
because without include_docs, the ETag is still a strong validator, as far as I can tell.

—Jens

Re: View Returns Inconsistent Data on CouchDB 1.1

Posted by Jens Alfke <je...@mooseyard.com>.
On Jun 29, 2011, at 8:02 AM, Robert Newson wrote:

> This is deliberate ("COUCHDB-799 - More granular ETags for views." --
> "ETags for views now only change when their underlying view index
> changes due to indexing or purges. ETags are also specific to each
> view.")
> 
> The view is updated if and only if the emitted data actually changes.

Interesting. So the implication is that one shouldn’t combine the ?include_docs option with conditional GETs, because it won’t report changes in the document contents.

Unfortunately this means that CouchDB is now returning incorrect Etag: headers. This semantic change means that the view’s ETag is now a “weak validator”, since it may stay the same even though the literal response body changes. That means that it must be preceded with “W/“ according to the HTTP 1.1 spec.

So for example, I do this:

$ curl -I http://localhost:5984/demo-addresses/_all_docs
HTTP/1.1 200 OK
Server: CouchDB/1.2.0a-ed63a4d-git (Erlang OTP/R14B01)
Etag: "9XKYFE3OM8ZSWLNSEI4QPFB9L"
Date: Wed, 29 Jun 2011 18:10:49 GMT
Content-Type: text/plain;charset=utf-8
Content-Length: 0
Cache-Control: must-revalidate

The “Etag:” header should read
	Etag: W/"9XKYFE3OM8ZSWLNSEI4QPFB9L"

—Jens

Re: View Returns Inconsistent Data on CouchDB 1.1

Posted by Robert Newson <rn...@apache.org>.
This is deliberate ("COUCHDB-799 - More granular ETags for views." --
"ETags for views now only change when their underlying view index
changes due to indexing or purges. ETags are also specific to each
view.")

The view is updated if and only if the emitted data actually changes.

B.

On 29 June 2011 13:57, Jan Lehnardt <ja...@apache.org> wrote:
> Hi Behrad,
>
> can you open an issue for this? http://issues.apache.org/jira/browse/COUCHDB
>
> Cheers
> Jan
> --
>
> On 29 Jun 2011, at 13:02, Behrad Zari wrote:
>
>> Dear Couchees,
>> Consider a view on a CouchDB 1.1 private DB which emits: ( doc._id, 1 )
>> 1) call the view with reduce=false&include_docs=true by your browser!
>> 2) update a document (with futon)
>> 3) recall that view
>> You will see a cached-inconsistent document included in view results! (according to _rev and doc data) with a 304 response!
>> 4) recall that view with CTRL+F5 (forces to 'no-cache' and cleaning if-Not-Match)
>> Now couchdb returns 200 with correct included document version!
>>
>> The above scenario was not happening in previous CouchDB version and at step 3 we received latest document versions!
>> Also this happens when updated document DOES NOT reflect view (key,value) pairs, but when we update an attribute that is emited by a view, Couch returns consistent results. (logically since view hash is changed)
>> This seems an to be an issue with couchdb's Cache Control.
>>
>> for more details Request/Response headers are included down below:
>>
>> View GET Request @step 3:
>>
>>
>> Request Headers
>> ----------------------
>> Host192.168.128.11:5984
>> User-AgentMozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.10) Gecko/20100922 Ubuntu/10.10 (maverick) Firefox/3.6.10
>> Accepttext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
>> Accept-Languageen-us,en;q=0.5
>> Accept-Encodinggzip,deflate
>> Accept-CharsetISO-8859-1,utf-8;q=0.7,*;q=0.7
>> Keep-Alive115
>> Connectionkeep-alive
>> Cookiesession_id=439173cbd2f955017d8282102a9388a0b92a29c2; AuthSession=YWRtaW46NEUwQUVCNDE6YGCaYBacZ6PweA1xjFoK1U6FwrI
>> If-None-Match"AI17SB7U17NIG0SL4BRNABYZB"
>> Cache-Controlmax-age=0
>>
>> 304
>> -----
>> ServerCouchDB/1.1.0 (Erlang OTP/R13B03)
>> Etag"AI17SB7U17NIG0SL4BRNABYZB"
>> DateWed, 29 Jun 2011 09:07:46 GMT
>> Content-Typetext/plain;charset=utf-8
>> Cache-Controlmust-revalidate
>>
>>
>>
>> AND View GET Request @step 4:
>>
>> Request Headers
>> ----------------------
>> Host192.168.128.11:5984
>> User-AgentMozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.10) Gecko/20100922 Ubuntu/10.10 (maverick) Firefox/3.6.10
>> Accepttext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
>> Accept-Languageen-us,en;q=0.5
>> Accept-Encodinggzip,deflate
>> Accept-CharsetISO-8859-1,utf-8;q=0.7,*;q=0.7
>> Keep-Alive115
>> Connectionkeep-alive
>> Cookiesession_id=439173cbd2f955017d8282102a9388a0b92a29c2; AuthSession=YWRtaW46NEUwQUVCNDE6YGCaYBacZ6PweA1xjFoK1U6FwrI
>> Pragmano-cache
>> Cache-Controlno-cache
>>
>> 200
>> -----
>> Transfer-Encodingchunked
>> ServerCouchDB/1.1.0 (Erlang OTP/R13B03)
>> Etag"AI17SB7U17NIG0SL4BRNABYZB"
>> DateWed, 29 Jun 2011 09:09:52 GMT
>> Content-Typetext/plain;charset=utf-8
>> Cache-Controlmust-revalidate
>>
>>
>>
>> --Behrad
>
>

Re: View Returns Inconsistent Data on CouchDB 1.1

Posted by Jan Lehnardt <ja...@apache.org>.
Hi Behrad,

can you open an issue for this? http://issues.apache.org/jira/browse/COUCHDB

Cheers
Jan
-- 

On 29 Jun 2011, at 13:02, Behrad Zari wrote:

> Dear Couchees,
> Consider a view on a CouchDB 1.1 private DB which emits: ( doc._id, 1 )
> 1) call the view with reduce=false&include_docs=true by your browser!
> 2) update a document (with futon)
> 3) recall that view 
> You will see a cached-inconsistent document included in view results! (according to _rev and doc data) with a 304 response!
> 4) recall that view with CTRL+F5 (forces to 'no-cache' and cleaning if-Not-Match)
> Now couchdb returns 200 with correct included document version!
> 
> The above scenario was not happening in previous CouchDB version and at step 3 we received latest document versions! 
> Also this happens when updated document DOES NOT reflect view (key,value) pairs, but when we update an attribute that is emited by a view, Couch returns consistent results. (logically since view hash is changed)
> This seems an to be an issue with couchdb's Cache Control.
> 
> for more details Request/Response headers are included down below:
> 
> View GET Request @step 3:
> 
> 
> Request Headers
> ----------------------
> Host192.168.128.11:5984
> User-AgentMozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.10) Gecko/20100922 Ubuntu/10.10 (maverick) Firefox/3.6.10
> Accepttext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> Accept-Languageen-us,en;q=0.5
> Accept-Encodinggzip,deflate
> Accept-CharsetISO-8859-1,utf-8;q=0.7,*;q=0.7
> Keep-Alive115
> Connectionkeep-alive
> Cookiesession_id=439173cbd2f955017d8282102a9388a0b92a29c2; AuthSession=YWRtaW46NEUwQUVCNDE6YGCaYBacZ6PweA1xjFoK1U6FwrI
> If-None-Match"AI17SB7U17NIG0SL4BRNABYZB"
> Cache-Controlmax-age=0
> 
> 304
> -----
> ServerCouchDB/1.1.0 (Erlang OTP/R13B03)
> Etag"AI17SB7U17NIG0SL4BRNABYZB"
> DateWed, 29 Jun 2011 09:07:46 GMT
> Content-Typetext/plain;charset=utf-8
> Cache-Controlmust-revalidate
> 
> 
> 
> AND View GET Request @step 4:
> 
> Request Headers
> ----------------------
> Host192.168.128.11:5984
> User-AgentMozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.10) Gecko/20100922 Ubuntu/10.10 (maverick) Firefox/3.6.10
> Accepttext/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
> Accept-Languageen-us,en;q=0.5
> Accept-Encodinggzip,deflate
> Accept-CharsetISO-8859-1,utf-8;q=0.7,*;q=0.7
> Keep-Alive115
> Connectionkeep-alive
> Cookiesession_id=439173cbd2f955017d8282102a9388a0b92a29c2; AuthSession=YWRtaW46NEUwQUVCNDE6YGCaYBacZ6PweA1xjFoK1U6FwrI
> Pragmano-cache
> Cache-Controlno-cache
> 
> 200
> -----
> Transfer-Encodingchunked
> ServerCouchDB/1.1.0 (Erlang OTP/R13B03)
> Etag"AI17SB7U17NIG0SL4BRNABYZB"
> DateWed, 29 Jun 2011 09:09:52 GMT
> Content-Typetext/plain;charset=utf-8
> Cache-Controlmust-revalidate
>  
> 
> 
> --Behrad