Defect #28240
openIssue parents are getting set incorrectly
0%
Description
It is same as Defect #27066.  
---
When adding and saving a sub issue under a parent issue, the subtask appear under wrong parent.
----
In our Redmine environment, this occurs pretty often for some root_id issues have over 100 decendent issues.  
We recently start running "Issues#rebuild_tree!" once a month at midnight.
But "once a month" is not enough.
"Issues#rebuild_tree!" takes over 5 hours and lockes all issues meanwhile. So running this script every day is not good.
'Issue.rebuild_single_tree!(1)' needs manual operation by redmine admins at daytime.
So preventing "issue parents is wrong(="lft" and "rgt" values of issues become wrong.)" from happening would be much better.
Environment- Redmine 3.2
- Rails 4
- Ruby 2.3
- Issue number:about 400000
Related issues
       Updated by Tomoko  Shimizu over 7 years ago
      Updated by Tomoko  Shimizu over 7 years ago
      
    
    - Copied from Defect #27066: issue parents is wrong added
       Updated by Mischa The Evil over 7 years ago
      Updated by Mischa The Evil over 7 years ago
      
    
    - Copied from deleted (Defect #27066: issue parents is wrong)
       Updated by Mischa The Evil over 7 years ago
      Updated by Mischa The Evil over 7 years ago
      
    
    - Related to Defect #27066: issue parents is wrong added
       Updated by Mischa The Evil over 7 years ago
      Updated by Mischa The Evil over 7 years ago
      
    
    - Tracker changed from Feature to Defect
- Subject changed from issue parents is wrong to Issue parents are getting set incorrectly
- Category set to Issues
- Affected version set to 3.2.0
Tomoko Shimizu wrote:
- Redmine 3.2
I'd first suggest to update to the current release branch, 3.4.x. As Toshi and Randa both pointed out in #27066, recent release might have changed things in order to fix/mitigate the issue.
Additionally, are you using any plugins? See submissions and for some pointers.
       Updated by Tomoko  Shimizu over 7 years ago
      Updated by Tomoko  Shimizu over 7 years ago
      
    
    Affected version is 3.3.0 (not 3.2), sorry I was wrong.
Environment:
  Redmine version                3.3.0.stable
  Ruby version                   2.3.1-p112 (2016-04-26) [x86_64-linux]
  Rails version                  4.2.6
  Environment                    production
  Database adapter               Mysql2
SCM:
  Subversion                     1.8.13
  Filesystem
Redmine plugins:
  clipboard_image_paste          1.10
  notify_custom_users            1.0.2
  project_overview               1.2.0
  redmine_absolute_dates         0.0.2
  redmine_backlogs               v1.0.6
  redmine_banner                 0.1.1
  redmine_code_review            0.7.0
  redmine_diff_email             0.0.5
       Updated by Tomoko  Shimizu over 7 years ago
      Updated by Tomoko  Shimizu over 7 years ago
      
    
    Thank you Mischa.
I would version up our Redmine Environment to the latest verion.
I have thought "def update_nested_set_attributes" and "def update_nested_set_attributes_on_parent_change" in "app/models/issue.rb" are related to this defect, and If both defs are done under same DB trunsaction , the defect might be fixed.
The recent change about "def update_nested_set_attributes" and "def update_nested_set_attributes_on_parent_change"  is only following one. 
Merged rails-5.1 branch (#23630). r16859.
This change looks different purpose.
http://www.redmine.org/projects/redmine/repository/revisions/16859/diff/trunk/app/models/issue.rb