【问题标题】:Running delayed worker ends up with Dalli error运行延迟的工作人员最终会出现 Dalli 错误
【发布时间】:2020-03-05 05:53:44
【问题描述】:

这里是 gem 和 rails 版本:

宝石:

delayed_job (4.1.5)

达利 (2.7.8)

memcached -h |头 -1

memcached 1.4.25

导轨

Rails 5.1.5

我通过这个文件./bin/delayed_job run运行延迟的worker 看起来像这样:

require File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))
require 'delayed/command'
Delayed::Command.new(ARGV).daemonize

当我运行命令时出现错误:error log

缓存存储配置如下: config.cache_store = :dalli_store, 'localhost:11211'

我连接到内存缓存服务器

abv@abv:~/git/csrhub-frontend$ telnet localhost 11211
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
stats
STAT pid 25174
STAT uptime 197
STAT time 1573225519
STAT version 1.4.25 Ubuntu
STAT libevent 2.0.21-stable

ti 似乎有效。

然后我尝试从 Rails 控制台获取数据:

irb(main):004:0> Rails.cache.dalli.set('spree/app_configuration/admin_path', '/some/path')
=> 216172782113783808
irb(main):005:0> Rails.cache.dalli.fetch('spree/app_configuration/admin_path')
=> "/some/path"
irb(main):006:0> Rails.cache.dalli.flush
=> [true]
irb(main):007:0> Rails.cache.dalli.fetch('spree/app_configuration/admin_path')
=> nil

它似乎工作。我找不到问题。 非常欢迎任何想法! 谢谢。

我在缓存写入之间打印了Dalli::Client

#<Dalli::Client:0x0000000009104038 @servers=["memcached:11211"], @options={:compress=>nil}, @ring=#<Dalli::Ring:0x000000000a3ab510 @servers=[#<Dalli::Server:0x000000000a3ab7e0 @hostname="memcached", @port=11211, @weight=1, @socket_type=:tcp, @fail_count=0, @down_at=2019-11-08 19:16:10 +0000, @last_down_at=2019-11-08 19:16:10 +0000, @options={:down_retry_delay=>60, :socket_timeout=>0.5, :socket_max_failures=>2, :socket_failure_delay=>0.01, :value_max_bytes=>1048576, :error_when_over_max_size=>false, :compressor=>Dalli::Compressor, :compression_min_size=>1024, :compression_max_size=>false, :serializer=>Marshal, :username=>nil, :password=>nil, :keepalive=>true, :sndbuf=>nil, :rcvbuf=>nil, :compress=>nil}, @sock=nil, @msg="closed stream", @error="IOError", @pid=nil, @inprogress=false, @lock=#<Monitor:0x000000000a3ab3f8 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::Mutex:0x000000000a3ab380>>, @version="1.5.16">], @continuum=nil, @failover=true>>

【问题讨论】:

    标签: ruby-on-rails memcached delayed-job dalli


    【解决方案1】:

    问题已通过在延迟作业本身内重新初始化 Dalli cahce 得到解决。

    connection = Dalli::Client.new Environment.config('cache_store')['host'].to_s + ':' + Environment.config('cache_store')['port'].to_s
    

    似乎工作人员没有正确加载环境。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-21
      • 2017-04-03
      • 2017-11-17
      • 2013-09-23
      • 1970-01-01
      • 2011-08-29
      • 1970-01-01
      • 2012-04-10
      相关资源
      最近更新 更多