Project

General

Profile

new & copied projects appear nested under the wrong sub-project... cannot rebuild projects

Added by Justin Walker about 11 years ago

Hey guys,

We have an ongoing issue where any new projects or copied projects nest under this one project that is 3 levels deep. We're able to relocate them to other sub-projects but not to the root. Everytime we try to relocate anything to the root it goes back to the original project. It's similar to this forum post http://www.redmine.org/boards/2/topics/24012 .

I have looked in the projects table at the lft, rgt, and it was quite tedious but they all appear to be normal.

I am running the Bitnami Redmine Stack so my versions are as follows:

OS: Windows Server Web 2008R2
Redmine version: 2.0.3.stable
Ruby version: 1.8.7 (i386-mingw32)
Rails version: 3.2.6
MySQL: 5.0.83-community for Win32 on ia32

Here is the log from when I tried to move the project that thinks it's the root back to the actual root, my log file when set to debug (note: I've removed the project name for client privacy):

Started PUT "/redmine/projects/client-victoria" for 127.0.0.1 at Tue Mar 05 18:52:15 +1100 2013
Processing by ProjectsController#update as HTML
  Parameters: {"id"=>"client-victoria", "project"=>{"is_public"=>"0", "name"=>"client Victoria Web Site - Corporate", "homepage"=>"", "issue_custom_field_ids"=>["4", ""], "description"=>"client Vic - client", "parent_id"=>"", "tracker_ids"=>["1", "2", "3", "5", "6", "9", "10", "11", ""]}, "utf8"=>"✓", "commit"=>"Save", "authenticity_token"=>"VQRCsKhNMt1EM08Uev9ssy7ZJls6zawjpgRb8WFOSik="}
  [1m[35m (0.0ms)[0m  SELECT MAX(`settings`.`updated_on`) AS max_id FROM `settings` 
  [1m[36mUser Load (0.0ms)[0m  [1mSELECT `users`.* FROM `users` WHERE `users`.`type` IN ('User', 'AnonymousUser') AND `users`.`id` = 18 AND (users.status = 1) LIMIT 1[0m
  [1m[35mProject Load (0.0ms)[0m  SELECT `projects`.* FROM `projects` WHERE `projects`.`identifier` = 'client-victoria' LIMIT 1
  [1m[36mEnabledModule Load (0.0ms)[0m  [1mSELECT name FROM `enabled_modules` WHERE `enabled_modules`.`project_id` = 68[0m
  [1m[35mIssueCustomField Load (0.0ms)[0m  SELECT `custom_fields`.* FROM `custom_fields` WHERE `custom_fields`.`type` IN ('IssueCustomField') AND `custom_fields`.`id` = 4 LIMIT 1
  [1m[36mIssueCustomField Load (0.0ms)[0m  [1mSELECT `custom_fields`.* FROM `custom_fields` INNER JOIN `custom_fields_projects` ON `custom_fields`.`id` = `custom_fields_projects`.`custom_field_id` WHERE `custom_fields`.`type` IN ('IssueCustomField') AND `custom_fields_projects`.`project_id` = 68 ORDER BY custom_fields.position[0m
  [1m[35m (0.0ms)[0m  BEGIN
  [1m[36m (0.0ms)[0m  [1mCOMMIT[0m
  [1m[35mTracker Load (0.0ms)[0m  SELECT `trackers`.* FROM `trackers` WHERE `trackers`.`id` IN (1, 2, 3, 5, 6, 9, 10, 11)
  [1m[36mTracker Load (0.0ms)[0m  [1mSELECT `trackers`.* FROM `trackers` INNER JOIN `projects_trackers` ON `trackers`.`id` = `projects_trackers`.`tracker_id` WHERE `projects_trackers`.`project_id` = 68 ORDER BY trackers.position[0m
  [1m[35m (0.0ms)[0m  BEGIN
  [1m[36m (0.0ms)[0m  [1mCOMMIT[0m
  [1m[35m (0.0ms)[0m  BEGIN
  [1m[36mProject Exists (0.0ms)[0m  [1mSELECT 1 AS one FROM `projects` WHERE (`projects`.`identifier` = BINARY 'client-victoria' AND `projects`.`id` != 68) LIMIT 1[0m
  [1m[35mRepository Load (0.0ms)[0m  SELECT `repositories`.* FROM `repositories` WHERE `repositories`.`project_id` = 68 AND (is_default = 1) LIMIT 1
  [1m[36mWiki Load (0.0ms)[0m  [1mSELECT `wikis`.* FROM `wikis` WHERE `wikis`.`project_id` = 68 LIMIT 1[0m
  [1m[35mCustomField Load (0.0ms)[0m  SELECT `custom_fields`.* FROM `custom_fields` WHERE (type = 'ProjectCustomField') ORDER BY position
  [1m[36mSQL (0.0ms)[0m  [1mSELECT `custom_values`.`id` AS t0_r0, `custom_values`.`customized_type` AS t0_r1, `custom_values`.`customized_id` AS t0_r2, `custom_values`.`custom_field_id` AS t0_r3, `custom_values`.`value` AS t0_r4, `custom_fields`.`id` AS t1_r0, `custom_fields`.`type` AS t1_r1, `custom_fields`.`name` AS t1_r2, `custom_fields`.`field_format` AS t1_r3, `custom_fields`.`possible_values` AS t1_r4, `custom_fields`.`regexp` AS t1_r5, `custom_fields`.`min_length` AS t1_r6, `custom_fields`.`max_length` AS t1_r7, `custom_fields`.`is_required` AS t1_r8, `custom_fields`.`is_for_all` AS t1_r9, `custom_fields`.`is_filter` AS t1_r10, `custom_fields`.`position` AS t1_r11, `custom_fields`.`searchable` AS t1_r12, `custom_fields`.`default_value` AS t1_r13, `custom_fields`.`editable` AS t1_r14, `custom_fields`.`visible` AS t1_r15, `custom_fields`.`multiple` AS t1_r16 FROM `custom_values` LEFT OUTER JOIN `custom_fields` ON `custom_fields`.`id` = `custom_values`.`custom_field_id` WHERE `custom_values`.`customized_id` = 68 AND `custom_values`.`customized_type` = 'Project' ORDER BY custom_fields.position[0m
  [1m[35m (0.0ms)[0m  COMMIT
  [1m[36mProject Load (15.6ms)[0m  [1mSELECT `projects`.* FROM `projects` WHERE (projects.status=1)[0m
  [1m[35mProject Load (0.0ms)[0m  SELECT `projects`.* FROM `projects` WHERE (`projects`.`lft` >= 350 AND `projects`.`rgt` <= 453) ORDER BY `projects`.`lft`
  [1m[36mProject Load (0.0ms)[0m  [1mSELECT `projects`.* FROM `projects` WHERE `projects`.`id` = 280 LIMIT 1[0m
  [1m[35mProject Load (0.0ms)[0m  SELECT `projects`.* FROM `projects` WHERE `projects`.`parent_id` IS NULL ORDER BY `lft`
  [1m[36m (0.0ms)[0m  [1mBEGIN[0m
  [1m[35mProject Load (0.0ms)[0m  SELECT `lft`, `rgt`, `parent_id` FROM `projects` WHERE `projects`.`id` = 92 LIMIT 1 FOR UPDATE
  [1m[36mProject Load (0.0ms)[0m  [1mSELECT `lft`, `rgt`, `parent_id` FROM `projects` WHERE `projects`.`id` = 68 LIMIT 1 FOR UPDATE[0m
  [1m[35m (0.0ms)[0m  ROLLBACK
Completed 500 Internal Server Error in 391ms

ActiveRecord::ActiveRecordError (Impossible move, target node cannot be inside moved tree.):
  lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:502:in `move_to'
  lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:426:in `in_tenacious_transaction'
  lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:492:in `move_to'
  lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:491:in `move_to'
  lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:351:in `move_to_left_of'
  app/models/project.rb:382:in `set_parent!'
  app/models/project.rb:360:in `set_allowed_parent!'
  app/controllers/projects_controller.rb:188:in `update'

When I took Redmine offline and tried to zero the lft and rgt columns and do a rebuild here is what came back from the command-line:

C:\Program Files\BitNami Redmine Stack\apps\redmine\htdocs>ruby script/rails runner -e production 'Project.rebuild!'
C:/Program Files/BitNami Redmine Stack/ruby/lib/ruby/gems/1.8/gems/railties-3.2.6/lib/rails/commands/runner.rb:53: C:/Program Files/BitNami Redmine Stack/ruby/lib/ruby/gems/1.8/gems/activerecord-3.2.6/lib/active_record/validations.rb:56:in`save!': Validation failed: Identifier has already been taken (ActiveRecord::RecordInvalid)
        from C:/Program Files/BitNami Redmine Stack/ruby/lib/ruby/gems/1.8/gems/activerecord-3.2.6/lib/active_record/attribute_methods/dirty.rb:33:in `save!'
        from C:/Program Files/BitNami Redmine Stack/ruby/lib/ruby/gems/1.8/gems/activerecord-3.2.6/lib/active_record/transactions.rb:246:in `save!'
        from C:/Program Files/BitNami Redmine Stack/ruby/lib/ruby/gems/1.8/gems/activerecord-3.2.6/lib/active_record/transactions.rb:295:in `with_transaction_returning_status'
        from C:/Program Files/BitNami Redmine Stack/ruby/lib/ruby/gems/1.8/gems/activerecord-3.2.6/lib/active_record/connection_adapters/abstract/database_statements.rb:192:in `transaction'
        from C:/Program Files/BitNami Redmine Stack/ruby/lib/ruby/gems/1.8/gems/activerecord-3.2.6/lib/active_record/transactions.rb:208:in `transaction'
        from C:/Program Files/BitNami Redmine Stack/ruby/lib/ruby/gems/1.8/gems/activerecord-3.2.6/lib/active_record/transactions.rb:293:in `with_transaction_returning_status'
        from C:/Program Files/BitNami Redmine Stack/ruby/lib/ruby/gems/1.8/gems/activerecord-3.2.6/lib/active_record/transactions.rb:246:in `save!'
        from C:/Program Files/BitNami Redmine Stack/apps/redmine/htdocs/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:185:in `rebuild!'
        from C:/Program Files/BitNami Redmine Stack/apps/redmine/htdocs/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:182:in `call'
        from C:/Program Files/BitNami Redmine Stack/apps/redmine/htdocs/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:182:in `rebuild!'
        from C:0:in `each'
        from C:0:in `__send__'
        from C:0:in `each'
        from C:/Program Files/BitNami Redmine Stack/apps/redmine/htdocs/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:182:in `rebuild!'
        from C:/Program Files/BitNami Redmine Stack/apps/redmine/htdocs/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:182:in `call'
        from C:/Program Files/BitNami Redmine Stack/apps/redmine/htdocs/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:182:in `rebuild!'
        from C:0:in `each'
        from C:0:in `__send__'
        from C:0:in `each'
        from C:/Program Files/BitNami Redmine Stack/apps/redmine/htdocs/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:182:in `rebuild!'
        from C:/Program Files/BitNami Redmine Stack/apps/redmine/htdocs/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:182:in `call'
        from C:/Program Files/BitNami Redmine Stack/apps/redmine/htdocs/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:182:in `rebuild!'
        from C:0:in `each'
        from C:0:in `__send__'
        from C:0:in `each'
        from C:/Program Files/BitNami Redmine Stack/apps/redmine/htdocs/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:182:in `rebuild!'
        from C:/Program Files/BitNami Redmine Stack/apps/redmine/htdocs/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:192:in `call'
        from C:/Program Files/BitNami Redmine Stack/apps/redmine/htdocs/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:192:in `rebuild!'
        from C:0:in `each'
        from C:0:in `__send__'
        from C:0:in `each'
        from C:/Program Files/BitNami Redmine Stack/apps/redmine/htdocs/lib/plugins/awesome_nested_set/lib/awesome_nested_set/awesome_nested_set.rb:189:in `rebuild!'
        from (eval):1
        from C:/Program Files/BitNami Redmine Stack/ruby/lib/ruby/gems/1.8/gems/railties-3.2.6/lib/rails/commands.rb:64:in `eval'
        from C:/Program Files/BitNami Redmine Stack/ruby/lib/ruby/gems/1.8/gems/railties-3.2.6/lib/rails/commands/runner.rb:53
        from C:/Program Files/BitNami Redmine Stack/ruby/lib/ruby/gems/1.8/gems/railties-3.2.6/lib/rails/commands.rb:64:in `require'
        from C:/Program Files/BitNami Redmine Stack/ruby/lib/ruby/gems/1.8/gems/railties-3.2.6/lib/rails/commands.rb:64
        from script/rails:6:in `require'
        from script/rails:6

This left all of the projects underneath that project with 0 values still for lft and rgt. However if I restored back to original, deleted that project and did the rebuild it came back with no error but again left the orphened projects underneath it with zero values for lft and rgt.

I think there's some sort of circular reference going on here but I can't pick it, I'm hoping someone out there can give me some tips.

Regards,
Justin