Skip to content

Commit

Permalink
Do not schedule Session.purge if the Session model is not used
Browse files Browse the repository at this point in the history
You can use memcache or SQL session. When you use memcache this whole
job does nothing. Just inserts into a queue, updates queue, selects
empty from Session and then removes from queue.

This also frees up some memory and scheduler cycles. Yaix!

Note, we already require users (in documentation) to restart EVM server
when they change session store (so we can do this).
  • Loading branch information
isimluk committed May 11, 2017
1 parent dcf61f4 commit d393bef
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 d393bef

Please sign in to comment.