couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From faust 1111 <faust...@gmail.com>
Subject Re: About denormalization and keep consistent
Date Fri, 09 Apr 2010 06:55:52 GMT
Yes i understand that listen _changes is better to get round race conditions.

Cannot get your suggesting about
how i can track that all contents related to author was updated not 5
of 50 but all.

Thats ok.
I don't understand if listen feed _chenges, feed give me info only
about id & rev of changed doc, how i can get that author name is
changed?


2010/4/9 Nicholas Orr <nicholas.orr@zxgen.net>:
> i don't think you are getting what the above people are suggesting...
>
> Go read up on the _changes API :)
>
> The basics are, every single change in the database is pushed into this
> feed. All race conditions that are caused by your ruby way (via the filter)
> are averted :)
>
> Nick
>
> On Fri, Apr 9, 2010 at 4:34 AM, faust 1111 <faust451@gmail.com> wrote:
>
>> i means
>> when i do
>> Content.by_author(self).each {|content|
>>          content.author_name = self.name;
>>          content.save(bulk=true)
>>       }
>>
>> i don't sure that all contents will updated may be only 5 and then
>> process crushed.
>>
>> 2010/4/8 Andrew Melo <andrew.melo@gmail.com>:
>> > On Thu, Apr 8, 2010 at 12:53 PM, faust 1111 <faust451@gmail.com> wrote:
>> >> What difference?
>> >> if do
>> >> Author
>> >>  after_save
>> >>     if name_changed?
>> >>        Content.by_author(self).each {|content|
>> >>           content.author_name = self.name;
>> >>           content.save(bulk=true)
>> >>       }
>> >>
>> >> or i start backend process to track Author _changes.
>> >>
>> >> This code not guarantee that all contents will updated.
>> >
>> > I don't get your question. You asked how to make sure that you could
>> > change a number of documents consistently, we suggested that you watch
>> > _changes to catch any silly race conditions. Then, you told us you
>> > didn't need to use _changes, but you were worried that things would be
>> > inconsistent.
>> >
>> > Even with your code above, you get a race condition (if I understand
>> > your ruby right, I don't know ruby much at all). Something could
>> > happen between when you check to see if a document needs to be changed
>> > and the actual change occurs. Then, you're gonna get a conflict and
>> > have to write up the logic to handle that intelligently.
>> >
>> > best,
>> > Andrew
>> >
>> >
>> >>
>> >> 2010/4/8 Andrew Melo <andrew.melo@gmail.com>:
>> >>> On Thu, Apr 8, 2010 at 12:29 PM, faust 1111 <faust451@gmail.com>
>> wrote:
>> >>>> I can catch changes in my app before save author, may be backend
>> >>>> process is surplus in my case.
>> >>>> i need consistent, when i update author name i must know that all
>> >>>> contents with author was updated success.
>> >>>
>> >>> Then their suggestion of watching _changes works for you. Start
>> >>> watching _changes. Make all your changes to the documents' authors.
>> >>> Any changes that come through on _changes, make sure they have the
>> >>> proper author. Keep watching _changes until you're sure that nobody
>> >>> has stale data they're waiting submit.
>> >>>
>> >>>
>> >>>>
>> >>>>
>> >>>> 2010/4/8 Zachary Zolton <zachary.zolton@gmail.com>:
>> >>>>> I suggest you check out the _changes API:
>> >>>>> http://books.couchdb.org/relax/reference/change-notifications
>> >>>>>
>> >>>>> Basically, if you have doc types A & B, where B maintains
a denormed
>> >>>>> bit of A, then you can watch the _changes feed in a backend
process.
>> >>>>> When an A gets updated, hit a view of all B's related to that
>> >>>>> particular A, and update the dernomed data.
>> >>>>>
>> >>>>> On Thu, Apr 8, 2010 at 10:20 AM, faust 1111 <faust451@gmail.com>
>> wrote:
>> >>>>>> Hi guy's
>> >>>>>> I return back to my problem with denormalization.
>> >>>>>>
>> >>>>>> is it possible to keep consistent when apply denormalization?
>> >>>>>> For example
>> >>>>>> Content
>> >>>>>>   have author (we store author name and id in Content)
>> >>>>>>
>> >>>>>> When author name changed(that's happens not frequently)
>> >>>>>> i need find all content belong to this author and update
author name
>> >>>>>> but what if this operation not finished (not all docs was
updated)
>> >>>>>>
>> >>>>>> What i can do in this case?
>> >>>>>> Thanks.
>> >>>>>>
>> >>>>>
>> >>>>
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> --
>> >>> Andrew Melo
>> >>>
>> >>
>> >
>> >
>> >
>> > --
>> > --
>> > Andrew Melo
>> >
>>
>

Mime
View raw message