incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Anderson <jch...@apache.org>
Subject Re: Why is CouchDB frequently re-indexing my views from scratch?
Date Fri, 19 Jun 2009 17:06:43 GMT
On Thu, Jun 18, 2009 at 3:08 PM, Jim Puls<jim@nondifferentiable.com> wrote:
> I couldn't figure out how to file a bug (seriously!) but here's how I'm
> testing it. I have a short Ruby file "test_reindexing.rb":
>
> require 'rubygems'
> require 'couchrest'
>
> class SomeModel < CouchRest::ExtendedDocument
>
>  use_database CouchRest.database!('http://localhost:5984/testing')
>
>  def self.load
>    20000.times do |i|
>      some_model = new
>      some_model.type = 'foo'
>      some_model.save
>    end
>  end
>
>  property :type
>
>  view_by :bar, :map => %q{
>      function (event) {
>        if (event.type === 'quux' && event.bar) {
>          emit(event.bar, null);
>        }
>      }
>    }
> end
>
> where I can first populate the database:
> ruby -r test_reindexing -e SomeModel.load
>
> and then I can have it query a view and see the indexing every time:
> ruby -r test_reindexing -e SomeModel.by_bar
>
> To verify that there are no changes other than the revision number and
> ordering of the views, I take the the MD5 hash of the sorted list of
> characters in the view record:
>
> ruby -r test_reindexing -e SomeModel.by_bar && curl
> http://localhost:5984/testing/_design/SomeModel 2>/dev/null | ruby -ne
> '$_.sub! /"_rev":"[^"]+",/, "";puts $_.split(//).sort.join("")' | openssl
> md5
>
> -> jp
>

> On Jun 18, 2009, at 2:20 PM, Damien Katz wrote:
>
>> Hmm, that's a bug in CouchDB IMO. Can you write a bug with a failing test
>> for that?

Damien's suggesting we should sort the views in some deterministic way
internally before taking our hash of them. I'll keep that in mind as
I'm gonna be delving into that code to implement the patch for

https://issues.apache.org/jira/browse/COUCHDB-218

I've added a note to that ticket

>>
>> -Damien
>>
>> On Jun 18, 2009, at 5:07 PM, Jim Puls wrote:
>>
>>> On Jun 18, 2009, at 1:10 PM, Damien Katz wrote:
>>>
>>>> Also, do the order of the views change?
>>>
>>> Indeed, I see when I do a raw HTTP GET of the design document that
>>> CouchRest is changing the order of the views. Futon, of course - actually my
>>> browser parsing the JSON data - was nice enough to alphabetize them for me,
>>> completely obscuring the problem.
>>>
>>> -> jp
>>>
>
>



-- 
Chris Anderson
http://jchrisa.net
http://couch.io

Mime
View raw message