Project

General

Profile

Project Hierarchy: Project Rebuild Error

Added by Paul Liao over 13 years ago

We have an issue with the project hierarchy where when we move a project, it didn't go where it suppose to go. I have found a possible solution where preforming the command found in here (http://www.redmine.org/issues/4701) should resolve an issue. We were using Redmine 0.9.1 when we encountered this issue. We now have Redmine 1.1.2. But when we perform the command

ruby script/runner -e production 'Project.rebuild!'
it still didn't work.

I have also looked at the database in the projects table and found anomalies in the lft and rgt columns. There was a sub folder where the rgt value is greater than it's parent which shouldn't be.

Example here:

Parent (lft 1, rgt 10)
   Child 1 (lft 2, rgt 3)
   Child 2 (lft 4, rgt 20)

Note that this is just an example but this is what it looks like in the table. From what I understand the parent's rgt should have the highest number since it's the last one. Basically the value of the root folder is the first and last of the sub-folders it contain. (Correct me if I'm wrong).

I don't want to manually change the lft and rgt values because it's tedious and I'm afraid to break it further. I believe the 'Project.rebuild!' command is my last hope in this.

Additionally, I have viewed the logs for this redmine site. The command actually did something, but rolled back for some reason. Could it be that there's a duplicate that's why I didn't went through the process?

Thanks in advance.

Here is the list of gems we have installed:
  • actionmailer (2.3.8)
  • actionpack (2.3.8)
  • activerecord (2.3.8)
  • activeresource (2.3.8)
  • activesupport (2.3.8)
  • cgi_multipart_eof_fix (2.5.0)
  • daemons (1.1.0)
  • fastthread (1.0.7)
  • gem_plugin (0.2.3)
  • i18n (0.5.0, 0.4.2)
  • mongrel (1.1.5)
  • passenger (2.2.15)
  • postgres (0.7.9.2008.01.28)
  • rack (1.1.0, 1.0.1)
  • rails (2.3.8)
  • rake (0.8.7)
  • rubygems-update (1.3.7)

Here is the error that occurred after performing the command:

The {{key}} interpolation syntax in I18n messages is deprecated and will be removed in Redmine 1.2. Please use %{key} instead, see http://www.redmine.org/issues/7013 for more information.
/home/redmine/redmine-1.1.2/vendor/rails/railties/lib/commands/runner.rb:48: /home/redmine/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/validations.rb:1090:in `save_without_dirty!': Validation failed: Identifier has already been taken (ActiveRecord::RecordInvalid)
from /home/redmine/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/dirty.rb:87:in `save_without_transactions!'
from /home/redmine/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/transactions.rb:200:in `save!'
from /home/redmine/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:136:in `transaction'
from /home/redmine/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/transactions.rb:182:in `transaction'
from /home/redmine/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/transactions.rb:200:in `save!'
from /home/redmine/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/transactions.rb:208:in `rollback_active_record_state!'
from /home/redmine/redmine-1.1.2/vendor/rails/activerecord/lib/active_record/transactions.rb:200:in `save!'
from /home/redmine/redmine-1.1.2/vendor/plugins/awesome_nested_set/lib/awesome_nested_set.rb:186:in `rebuild!'
... 14 levels...
from /home/redmine/redmine-1.1.2/vendor/rails/railties/lib/commands/runner.rb:48
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
from script/runner:3

Logs: last couple of lines before the rollback

  [4;36;1mSQL (0.2ms)[0m   [0;1mCOMMIT[0m
  [4;35;1mProject Load (0.5ms)[0m   [0mSELECT * FROM "projects" WHERE ("parent_id" = 170 ) ORDER BY "lft", "rgt", name[0m
  [4;36;1mSQL (0.2ms)[0m   [0;1mBEGIN[0m
  [4;35;1mProject Load (0.9ms)[0m   [0mSELECT "projects".id FROM "projects" WHERE ("projects"."identifier" = E'procedures' AND "projects".id <> 170) LIMIT 1[0m
  [4;36;1mRepository Load (0.3ms)[0m   [0;1mSELECT * FROM "repositories" WHERE ("repositories".project_id = 170) LIMIT 1[0m
  [4;35;1mWiki Load (0.3ms)[0m   [0mSELECT * FROM "wikis" WHERE ("wikis".project_id = 170) LIMIT 1[0m
  [4;36;1mCustomField Load (0.4ms)[0m   [0;1mSELECT * FROM "custom_fields" WHERE (type = 'ProjectCustomField') ORDER BY position[0m
  [4;35;1mSQL (0.2ms)[0m   [0mCOMMIT[0m
  [4;36;1mProject Load (0.5ms)[0m   [0;1mSELECT * FROM "projects" WHERE ("parent_id" = 509 ) ORDER BY "lft", "rgt", name[0m
  [4;35;1mSQL (0.1ms)[0m   [0mBEGIN[0m
  [4;36;1mProject Load (0.5ms)[0m   [0;1mSELECT "projects".id FROM "projects" WHERE ("projects"."identifier" = E'productinfo' AND "projects".id <> 509) LIMIT 1[0m
  [4;35;1mRepository Load (0.3ms)[0m   [0mSELECT * FROM "repositories" WHERE ("repositories".project_id = 509) LIMIT 1[0m
  [4;36;1mWiki Load (0.3ms)[0m   [0;1mSELECT * FROM "wikis" WHERE ("wikis".project_id = 509) LIMIT 1[0m
  [4;35;1mSQL (0.3ms)[0m   [0mROLLBACK[0m

Replies (3)

RE: Project Hierarchy: Project Rebuild Error - Added by Paul Liao over 13 years ago

Can someone assist me with my problem? I saw that there where duplicates in the 'rgt' and 'lft' columns. So I changed them to a different one which was unique. But still, I have the same issue.

I checked my Redmine log and it is the same. Where it rolls back after it performs the last select statement.

My question now is, what does ruby script/runner -e production 'Project.rebuild!' does?

Why is it that when it goes to the Wiki Load, it performs a rollback?

RE: Project Hierarchy: Project Rebuild Error - Added by Sven Culley over 13 years ago

This is what I did to get the order back to work:

  1. Go to your database
  2. Make a backup of your "projects" table
  3. Set the value for "lft" and "rgt" to "0"
  4. Go to you console and use "ruby script/runner -e production 'Project.rebuild!'" to rebuild the project order

In case anything goes wrong you still have the backup.

RE: Project Hierarchy: Project Rebuild Error - Added by Asif Noor about 9 years ago

I had the same issue, so i have reset all lft and rgt to 0.

And then i tried this command.

Go to your project doc root and execute this

ruby script/rails runner 'Project.rebuild_tree!'

My Redmine version 2.4.2 Stable
This will recalculate all lft and rgt based on the current projects.

    (1-3/3)