Skip to content

Commit

Permalink
Merge pull request #15064 from isimluk/avoid-queue-overhead-if-sessio…
Browse files Browse the repository at this point in the history
…n-is-turned-off

Performance: Do not schedule Session.purge if this Session is not used
(cherry picked from commit 493a488)

https://bugzilla.redhat.com/show_bug.cgi?id=1510054
  • Loading branch information
martinpovolny authored and simaishi committed Nov 6, 2017
1 parent f562b65 commit 15889ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/models/miq_schedule_worker/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,12 @@ def schedules_for_scheduler_role
enqueue :drift_state_purge_timer
end

# Schedule - Check for session timeouts
scheduler.schedule_every(worker_settings[:session_timeout_interval]) do
# Session is global to the region, therefore, run it only once on the scheduler's server
enqueue :session_check_session_timeout
if Session.enabled?
# Schedule - Check for session timeouts
scheduler.schedule_every(worker_settings[:session_timeout_interval]) do
# Session is global to the region, therefore, run it only once on the scheduler's server
enqueue :session_check_session_timeout
end
end

# Schedule - Check for rogue EVM snapshots
Expand Down
4 changes: 4 additions & 0 deletions app/models/session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ class Session < ApplicationRecord
@@interval = 30 # how often to purge in seconds
@@job ||= nil

def self.enabled?
::Settings.server.session_store == 'sql'
end

def self.check_session_timeout
$log.debug "Checking session data"
purge(::Settings.session.timeout)
Expand Down

0 comments on commit 15889ff

Please sign in to comment.