Defect #26376

Wrong issue counts and spent time on project overview

Added by Serhiy Yefremenko 21 days ago. Updated 3 days ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Projects
Target version:3.4.1
Resolution:Fixed Affected version:3.4.0

Description

After switching to 3.4.0 from 3.3.3 got the problem on project overview page. With non-admin user issue table is empty and total spent time is 0.0, even though "all issues" page and time report show correct data.
I saw related issues posted here but open new one because another version is affected and also because it seems to me that I found the reason.
I was able to trace the bug to the method User#project_ids_by_role, which returned wrong data. The actual reason lives in :visible scope of Project:

scope :visible, lambda {|*args| where(Project.visible_condition(args.shift || User.current, *args)) }

Because of this method chain, any query to Project from User#project_ids_by_role adds condition for parent id. So even if you place break point inside that method and call Project.first, you will get something like
SELECT * FROM Project WHERE project.id = ? LIMIT 1

Looks like it's a bug affecting ActiveRecord 4.2.8, discussed here:
https://github.com/rails/rails/issues/29445
https://github.com/rails/rails/issues/29338

The actual problem with missing issues and time can be solved commenting first line in User#project_ids_by_role (result caching) but it's not a valid solution. Also 3.3.3 and 3.3.4 seem to do same things but the bug is not reproduced on our data so we stick with 3.3.4 for now.


Related issues

Duplicated by Redmine - Defect #26084: In my Overview column didn't show bugs count Closed
Duplicated by Redmine - Defect #26389: summary issue list disappeared from project overview page Closed

Associated revisions

Revision 16766
Added by Jean-Philippe Lang 19 days ago

Fixed that issue counts are 0 on project overview (#26376).

Revision 16767
Added by Jean-Philippe Lang 19 days ago

Fixed User#project_ids_by_role when first called within chained scopes (#26376).

Revision 16768
Added by Jean-Philippe Lang 19 days ago

Reverts change made to ProjectController in r16766 (#26376).

History

#1 Updated by Serhiy Yefremenko 20 days ago

UPD: 3.3.4 is probably fine as it uses rails 4.2.7.1

#2 Updated by Go MAEDA 20 days ago

  • Duplicated by Defect #26084: In my Overview column didn't show bugs count added

#3 Updated by Go MAEDA 20 days ago

Screenshots from #26084:

#4 Updated by Go MAEDA 20 days ago

  • Target version set to 3.4.1

#5 Updated by Jean-Philippe Lang 19 days ago

  • Subject changed from Project/Tracker visibility control fails, presumably because of ActiveRecord bug to Wrong issue counts and spent time on project overview
  • Status changed from New to Resolved
  • Assignee set to Jean-Philippe Lang
  • Resolution set to Fixed

I was able to fix the problem on the project overview by loading visible subprojects (which poisons project_ids cache) at the end. I'll see if we can workaround this Rails bug with a more general solution.

#6 Updated by Serhiy Yefremenko 19 days ago

Isn't disabling cache safer? Or rolling back to rails 4.2.7, didn't have time to check if that version works but one of that github issues says it does.

#7 Updated by Jean-Philippe Lang 19 days ago

Serhiy Yefremenko wrote:

Isn't disabling cache safer? Or rolling back to rails 4.2.7

We can't stick to 4.2.7 for ever and the issue does not seem to be addressed in Rails 5.
I've committed a better fix in r16767 that ensures that User#project_ids_by_role always returns correct results.

#8 Updated by Jean-Philippe Lang 19 days ago

  • Status changed from Resolved to Closed

I think we have to release a 3.4.1 ASAP.

#9 Updated by Go MAEDA 18 days ago

  • Duplicated by Defect #26389: summary issue list disappeared from project overview page added

#10 Updated by Udo Hain 3 days ago

I just want to mention that I have the same problem with the following environment (on Ubuntu 16.04.2 LTS):

Environment:
  Redmine version                3.2.1.stable
  Ruby version                   2.3.1-p112 (2016-04-26) [x86_64-linux-gnu]
  Rails version                  4.2.9
  Environment                    production
  Database adapter               Mysql2

I have solved the problem with the empty list in the issue tracking table by a patch described in #25828, but the problem with the "Spent time" of 0.0 hours remains. Admin accounts see the correct time, the other users do not. It would be nice if there was a patch for 3.2.1 too!

Also available in: Atom PDF