Project

General

Profile

Bug #16996

eager_load in PuppetclassesController makes Classes view unusable

Added by Martin Schurz over 3 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Performance
Target version:
Difficulty:
trivial
Triaged:
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

Hi,

at first I have to say this bug might only appear when you have many environments and hostgroups. What we have, is around 1400 Classes, 70 Environments and 600 Hostgroups.

In our installation it is not possible to open the Classes view, because the ruby process will eat all the memory and then crash the server. We were able to track this down to the controller, which eager loads all the depending elements. In our case this results in a 800k rows resultset. When this is converted to ActiveRecord objects it takes a long time and uses a lot (>16GB) of memory.

In app/controllers/puppetclasses_controller.rb:

  def index
    eager_load_tables = [:config_group_classes, :class_params, :environments,
                         :hostgroups]
    @puppetclasses = resource_base_search_and_page(eager_load_tables)
    @hostgroups_authorizer = Authorizer.new(User.current, :collection => HostgroupClass.where(:puppetclass_id => @puppetclasses.map(&:id)).uniq.pluck(:hostgroup_id))
  end

Removing the eager loading solves all of our problems and makes the view work again (and really fast too).

Associated revisions

Revision 68f481c5 (diff)
Added by Martin Schurz over 3 years ago

fixes #16996 - reduce eager_load of tables

Revision a6361cfe (diff)
Added by Martin Schurz over 3 years ago

fixes #16996 - reduce eager_load of tables

(cherry picked from commit 68f481c58496cae5229fc3f670840e152158b789)

History

#1 Updated by The Foreman Bot over 3 years ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/3951 added

#2 Updated by Anonymous over 3 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#3 Updated by Dominic Cleal over 3 years ago

  • Legacy Backlogs Release (now unused) set to 203

#4 Updated by Tomer Brisker over 3 years ago

  • Bugzilla link set to 1393773

Also available in: Atom PDF