Krishna Dole
2007-Aug-15 17:57 UTC
[Betternestedset-talk] New release? (was: Concurrency issues?)
I believe trunk is currently backwards compatible with stable. Since the renumber_full_tree bug is serious for those using virtual roots, I''d like to tag a new release. Any thoughts/objections? Krishna On 8/15/07, Tekin Suleyman <tekin at raid.nu> wrote:> > > Now you''ve got me worried! > > I''m currently using tags/stable and although I''ve had no problems with it, > looking through the repository it looks like trunk has moved on > significantly. Is trunk fully backwards compatible? > > > > -----Original Message----- > From: betternestedset-talk-bounces at rubyforge.org > [mailto:betternestedset-talk-bounces at rubyforge.org] On > Behalf Of Jeremy Nicoll > Sent: 14 August 2007 21:12 > To: betternestedset-talk at rubyforge.org > Subject: Re: [Betternestedset-talk] Concurrency issues? > > Thanks Matt - I''m glad you found this before my app went to production > :). Good luck with yours. > > -- > Jeremy Nicoll > > Krishna Dole wrote: > Hey Matt, > > You were right-- there was a bug in the renumbering when working with > virtual roots. I have fixed it in trunk. You can get the fixed version > with > > script/plugin install > svn://rubyforge.org/var/svn/betternestedset/trunk > > Thanks for reporting this. > > Krishna > > On 8/14/07, Matt Rogish <rogishmn at muohio.edu> wrote: > > > My guess is that there''s a bug in the implementation of > renumber_full_tree/calc_numbers which is causing this problem. The dataset > with overlapping numbers is what resulted from applying renumber_full_tree; > thus something is not quite right with that method... > > I have a copy of SQL for Smarties (2nd ed), so I''ll try and see if the two > algorithms diverge at all and/or provide a patch if I can help it. :) > > Thanks, > > -- > Matt > > > On 8/14/07, Matt Rogish <matt.rogish at gmail.com> wrote: > > > The problem is, as I see it, overlapping left and right columns. Shouldn''t > > the lft/right be one apart, or am I wrong. > > > For example: > mysql> select id, parent_id, lft, rgt from messages where message_board_id > > = 1926 and parent_id is null order by lft; > > > +--------+-----------+------+------+ > | id | parent_id | lft | rgt | > +--------+-----------+------+------+ > | 9472 | NULL | 1 | 2 | > | 9473 | NULL | 2 | 37 | > | 9474 | NULL | 37 | 44 | > | 9475 | NULL | 44 | 45 | > | 9476 | NULL | 45 | 74 | > | 9477 | NULL | 74 | 75 | > | 9478 | NULL | 75 | 114 | > | 9487 | NULL | 114 | 179 | > | 9479 | NULL | 179 | 348 | > | 9488 | NULL | 478 | 515 | > | 9482 | NULL | 515 | 520 | > | 9483 | NULL | 520 | 525 | > | 9484 | NULL | 525 | 526 | > | 9485 | NULL | 526 | 579 | > | 334881 | NULL | 579 | 580 | > | 335201 | NULL | 581 | 584 | > | 335234 | NULL | 585 | 586 | > +--------+-----------+------+------+ > > So the only ones "correct" are id = 335201 and id = 335234? > > I attached the entire dataset. What is happening is that the BETWEEN > > statement that better nested set is executing looks something like this: > > > m = Message.find( 9478 ) > m.all_children.each{ stuff } > > SQL is: > SELECT * FROM messages WHERE (message_board_id = 1926 AND (lft BETWEEN 75 > > AND 114)) ORDER BY lf > > > Since BETWEEN is inclusive, that result pulls all the children correctly > > but incorrectly pulls out the next root, message id = 9487. > > > I''m not sure if that means renumber_entire_tree needs to be fixed, or the > > actual move_to_child does, but something isn''t right. > > > -- > > Matt > > > On 8/14/07, Matt Rogish <rogishmn at muohio.edu> wrote: > > > I''m not writing any SQL, I''m using built-in better-nested-set functions. > > Here''s my save: > def create > @message = Message.new(params[:message]) > > if @message.save > flash[:notice] = ''Message was successfully created.'' > > if params[:message][:parent_id] > @message.move_to_child_of( Message.find > > params[:message][:parent_id] ) > > > > @message.save > end > end > end > > -- > Matt > > > > On 8/14/07, Jeremy Nicoll <jnicoll at goldnoteexpress.com > wrote: > > > I think it would be best if you could post your SQL that is messed > > up as well as the code you are using to save your nodes. Unfortunately we > can''t tell you what is wrong until we actually see the logic behind what you > are doing. > > > > > -- > Jeremy Nicoll > > Matt Rogish wrote: > > How can I repair my tree? > > I have a message board system in which the messages are grouped by > > "message_board_id", thus my model is: > > > > > acts_as_nested_set :scope => :message_board_id > > Somehow the tree is messed up, inasmuch as some roots (parent_id => > null) are being set to the children of some other message, so I cannot > successfully repair it. I''m not sure if I''m performing incorrect operations > or what, but somehow I need to repair my tree where message_board_id = 34 > (or whatever it is). > > > > > It seems as if renumber_full_tree tries to find the virtual root for a > > given node, but since the root itself is a CHILD of another node, the whole > thing fails. My layman''s guess is that the "root" condition is wrong, since > it''s doing WHERE parent_id IS NULL ... AND lft BETWEEN .. AND .. > > > > > Well, if the root is incorrectly between something, then the lft would > > fail, no? Maybe I''m misreading that. Help!! > > > > > Thanks, > > -- > Matt > > > On 8/14/07, Matt Rogish <rogishmn at muohio.edu> wrote: > > > Under heavy load we are getting significantly screwed up data. I > > have to run renumber_full_tree in script/console production order to repair > the thing. > > > > > > Obviously this is a bad thing, but I don''t even know where to start > > to fix it. Any ideas? > > > > > > Thanks, > > -- > Matt > > > ________________________________ > > > > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > > > > > > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > > > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > >