Question
Different Redis behaviour between macOS and Ubuntu 18.04.
I’m not sure where to start and where I should go to ask for the issue I’m having. Hopefully I can get solution or direction here. Apologise if these are confusing. Questions at the end.
BASE
- rails 5.2 + resque + resque-schedule
- enqueue job through
rails resque:scheduler
- has following job
class ThisJob < ActiveJob::Base
queue_as :high
def perform
cache-A = Rails.cache.fetch('cache-key', namespace: 'appname:cache') { -- cache-data -- }
task-A # insert into database by mixing values from cache-A
end
end
macOS: Install redis 5 via homebrew
Ubuntu 18.04: Install redis 5 by following How To Install Redis from Source on Ubuntu 18.04
EXPECTED BEHAVIOUR
cache-key can be fetched from ApplicationController and ActionJob
cache-key is stored in Redis
macOS:
- Run
redis-server
,rails s
,rails resque:scheduler
,rails resque:work queue=*
in that sequence from terminal. - worker executes
ThisJob
and it works as expected redis-cli keys *
return cache-key.
This is what i get from redis-cli monitor
if cache-key is not present.
1566012687.511574 [0 127.0.0.1:58933] "smembers" "resque:workers"
1566012687.512668 [0 127.0.0.1:58933] "mget" "resque:worker:--host info--:*"
1566012687.513653 [0 127.0.0.1:58933] "smembers" "resque:workers"
1566012691.258800 [0 127.0.0.1:57822] "smembers" "resque:queues"
1566012691.259296 [0 127.0.0.1:57822] "lpop" "resque:queue:high"
1566012691.260567 [0 127.0.0.1:57822] "set" "resque:worker:--host info--:*" "{--job here--}"
1566012691.269345 [0 127.0.0.1:58976] "auth" "foobared"
1566012691.506790 [0 127.0.0.1:58977] "auth" "foobared"
1566012691.506960 [0 127.0.0.1:58977] "get" "--appname:cache:cache-key--"
1566012691.651050 [0 127.0.0.1:58977] "set" "--appname:cache:cache-key--" "\x04\bo: ActiveSupport::Cache::Entry\t:\x0b@valueI"
1566012693.568291 [0 127.0.0.1:57822] "del" "resque:worker:--host info--:*"
Ubuntu 18.04:
- Boot
redis-server
,rails s
,rails resque:scheduler
,rails resque:work queue=*
from systemd - worker executes
ThisJob
, it goes straight to cache-data, then executes task-A. It does not fetch cache-key. redis-cli keys *
does not return cache-key.
This is what i get from redis-cli monitor
if cache-key is not present.
1566013554.022762 [0 127.0.0.1:60584] "smembers" "resque:workers"
1566013554.023089 [0 127.0.0.1:60584] "mget" "resque:worker:--host info--:*"
1566013554.023519 [0 127.0.0.1:60584] "smembers" "resque:workers"
1566013554.890333 [0 127.0.0.1:60574] "evalsha" "8f4a4e422bfa8f9a0931e350d6e30b1c3ce97c33" "1" "resque:resque:resque_scheduler_master_lock" "--host info--"
1566013554.890381 [0 lua] "SETNX" "resque:resque:resque_scheduler_master_lock" "--host info--"
1566013554.891184 [0 127.0.0.1:60574] "evalsha" "8d4e4994f7049799013e71b43d439219209e9f57" "1" "resque:resque:resque_scheduler_master_lock" "--host info--"
1566013554.891208 [0 lua] "GET" "resque:resque:resque_scheduler_master_lock"
1566013554.891226 [0 lua] "EXPIRE" "resque:resque:resque_scheduler_master_lock" "180"
1566013554.891236 [0 lua] "GET" "resque:resque:resque_scheduler_master_lock"
1566013554.891851 [0 127.0.0.1:60574] "zrangebyscore" "resque:delayed_queue_schedule" "-inf" "1566013554" "LIMIT" "0" "1"
1566013556.780238 [0 127.0.0.1:60580] "lpop" "resque:queue:high"
1566013556.781916 [0 127.0.0.1:60580] "set" "resque:worker:--host info--:*" "{--job here--}"
1566013556.788373 [0 127.0.0.1:60662] "auth" "--password--"
1566013558.503842 [0 127.0.0.1:60580] "del" "resque:worker:--host info--:*"
ATTEMPT in Ubuntu 18.04:
- Tried to trigger
ThisJob.perform_now
from index.html.erb, and it works as expected. - Tried running
rails s
,rails resque:scheduler
,rails resque:work queue=*
in that sequence from terminal, and the result just like when running from systemd. redis-cli keys *
has cache-key
cache-A = Rails.cache.read('cache-key', namespace: 'appname:cache')
cache-A returns null
Questions
- Is it because macOS and Ubuntu have differences in running Redis?
- Is it because homebrew and apt install have differences in building Redis?
- Any idea how to make this scheduler fetch Redis cache?
- Something I missed?
Thank you.