Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[2.4] 1584258: Detach consumers from persistence context to avoid OOM - ENT-583 #2019

Merged
merged 2 commits into from Jun 5, 2018

Conversation

awood
Copy link
Contributor

@awood awood commented Jun 4, 2018

Updating the status of a large number of consumers (roughly 10000) could
run the JVM out of memory due to all the consumers referenced in the
consumerStackedEnts map. During status calculation, the consumer facts
are accessed and during those accesses, the Hibernate proxy object is
replaced by the actual map of facts. The consumerStackedEnts map would
accordingly grow as each status was calculated.

This patch detaches several model objects as soon as we stop needing
them and most importantly, it detaches all the consumers in the
consumerStackedEnts map. The consumers are then fetched again, receive
an updated status, and are then immediately detached to keep the
persistence context at roughly a constant size.

@awood
Copy link
Contributor Author

awood commented Jun 4, 2018

Before:
expired-pools-2 4-before-216s

  • 216s to run
  • perm generation maximum 2GB

After:

  • 287s to run
  • perm generation maximum 4.7GB
    expired-pools-2 4-after-287s

@barnabycourt barnabycourt changed the title [2.4] 1584258: Detach consumers from persistence context to avoid OOM [2.4] 1584258: Detach consumers from persistence context to avoid OOM - ENT-583 Jun 4, 2018
@kahowell kahowell requested a review from Ceiu June 4, 2018 17:54
Updating the status of a large number of consumers (roughly 10000) could
run the JVM out of memory due to all the consumers referenced in the
consumerStackedEnts map.  During status calculation, the consumer facts
are accessed and during those accesses, the Hibernate proxy object is
replaced by the actual map of facts.  The consumerStackedEnts map would
accordingly grow as each status was calculated.

This patch detaches several model objects as soon as we stop needing
them and most importantly, it detaches all the consumers in the
consumerStackedEnts map.  The consumers are then fetched again, receive
an updated status, and are then immediately detached to keep the
persistence context at roughly a constant size.
- Added a new method, getConsumers(Collection), to ConsumerCurator for
  performing bulk consumer fetching/lookup
- Updated the consumer status recalculation loop in CPM.deletePools to
  use the bulk consumer lookup
@barnabycourt barnabycourt merged commit 0939b78 into candlepin-2.4-HOTFIX Jun 5, 2018
@barnabycourt barnabycourt deleted the awood/1584258-oom-2.4 branch June 5, 2018 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants