プロジェクト

全般

プロフィール

QA #725

奈良 裕記 さんが6年以上前に更新

h3. ■現象/要望 

 親子階層が複雑なチケットを更新すると、チケットの親子階層表示が異常になる場合がある。 
 (親チケット以外の子チケットとして表示される。) 

 現象発生時、issueテーブル上のlft,rgt項目が異常になっていた。 
 parent_idの値は、編集前の正しい親チケットIDが設定されていた。 

 修復手順を確認したい。 

 h3. ■解決策 

 Rails Console上から、チケット階層構造を修正する下記メソッドを実行することで修復できる。 
 但し、データ修復対応であり、現象発生を防止するものではない。 

 下記、rebuild_treeでチケット全部の階層構造を修復するが、件数が多い場合は時間が掛かる。 
 rebuild_single_treeで親チケットを指定すれば、短時間で修復可能。(Redmine3.4以降) 

 <pre><code class="ruby"> 
 [root redmine]# pwd 
 /var/lib/redmine 
 [root redmine]# bundle exec rails console production 

 Loading production environment (Rails 4.2.8) 
 irb(main):001:0> 
 irb(main):002:0* Issue.rebuild_tree! 
 => [] 
 irb(main):004:0> Issue.rebuild_single_tree(1)! 

 </code></pre> 

 ワンライナーの対応(Redmineのルートから実行とする) 

 <pre><code class="ruby"> 
  RAILS_ENV=production rails runner 'Issue.rebuild_single_tree!(1)' 
  
  RAILS_ENV=production bundle exec ruby bin/rails runner 'Issue.rebuild_single_tree!(1)' 
 </code></pre> 

 h3. ■対応状況 

 Rails Console上から、チケット階層構造を修正する下記メソッドを実行することで修復できる。 
 但し、データ修復対応であり、現象発生を防止するものではない。 

 h3. ■補足 

 関連情報 

 ProjectもIssueと同様に階層構造を持つため、同様な修復作業が必要になる場合がある。 
 Project.rebuild_tree! の様に実行する。 

 詳細不明だが、Redmine3.3以降で発生頻度が増加したかもしれない。(Redmine本体以外が関連する可能性含) 

 Rebuild a single nested set with nested_set plugin 
 http://www.redmine.org/issues/24167 

 issue parents is wrong 
 http://www.redmine.org/issues/27066 

 直近2年間のnested_set.rb変更内容 
 http://www.redmine.org/projects/redmine/repository/show/trunk/lib/redmine/nested_set 

戻る