Closed Frank004 closed 8 years ago
@Frank004 can you connect to your local psql and verify that the schema called "companydemo" exists? the error is telling you it doesn't.
@typeoneerror yes it its as im using it. This happen after the last update of sidekiq
irb(main):009:0> Apartment::Tenant.switch!('companydemo')
=> "\"companydemo\""
irb(main):010:0>
@Frank004 is this during a retry? 0.2.1 and 1.0.0 introduced some changes that look to be breaking. I'm working on trying some things now, but I had to roll back to 0.2.0 myself.
@typeoneerror thank you. if you find something out you let me know. ill keep looking at the code.
Fixed #11
I'm still having the same problem. ill keep look at the code maybe some setup or confict with another
02:39:04 worker.1 | 2016-06-09T06:39:04.412Z 21809 TID-ov3dsii2s MyWorker JID-0513e166b0363945760c8a50 INFO: start
02:39:04 worker.1 | 2016-06-09T06:39:04.416Z 21809 TID-ov3dsii2s MyWorker JID-0513e166b0363945760c8a50 INFO: fail: 0.004 sec
02:39:04 worker.1 | 2016-06-09T06:39:04.416Z 21809 TID-ov3dsii2s WARN: {"class":"MyWorker","args":["testing","juan",5],"retry":true,"queue":"default","jid":"0513e166b0363945760c8a50","created_at":1465454206.3338182,"apartment":"companydemo2","enqueued_at":1465454344.410656,"error_message":"One of the following schema(s) is invalid: \"companydemo2\" \"public\"","error_class":"Apartment::TenantNotFound","failed_at":1465454242.2405062,"retry_count":2,"retried_at":1465454344.4156559}
02:39:04 worker.1 | 2016-06-09T06:39:04.416Z 21809 TID-ov3dsii2s WARN: Apartment::TenantNotFound: One of the following schema(s) is invalid: "companydemo2" "public"
02:39:04 worker.1 | 2016-06-09T06:39:04.416Z 21809 TID-ov3dsii2s WARN: /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/apartment-1.1.0/lib/apartment/adapters/postgresql_adapter.rb:72:in `rescue in connect_to_new'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/apartment-1.1.0/lib/apartment/adapters/postgresql_adapter.rb:65:in `connect_to_new'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/apartment-1.1.0/lib/apartment/adapters/abstract_adapter.rb:85:in `switch!'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/apartment-1.1.0/lib/apartment/adapters/abstract_adapter.rb:98:in `switch'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/apartment-sidekiq-1.1.0/lib/apartment/sidekiq/middleware/server.rb:4:in `call'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/server/active_record.rb:6:in `call'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/server/retry_jobs.rb:74:in `call'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/logging.rb:32:in `with_context'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/server/logging.rb:7:in `call'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:133:in `invoke'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:129:in `block in process'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:168:in `stats'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:128:in `process'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:80:in `process_one'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:68:in `run'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/util.rb:17:in `watchdog'
02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/util.rb:25:in `block in safe_thread'
I can pair with you some time next week if you like and we can try to get to the bottom of it.
On Wed, Jun 8, 2016 at 11:42 PM francisco Quinones notifications@github.com wrote:
I'm still having the same problem. ill keep look at the code maybe some setup or confict with another gem. if I run the job in the public schema the job run as normal.
02:39:04 worker.1 | 2016-06-09T06:39:04.412Z 21809 TID-ov3dsii2s MyWorker JID-0513e166b0363945760c8a50 INFO: start 02:39:04 worker.1 | 2016-06-09T06:39:04.416Z 21809 TID-ov3dsii2s MyWorker JID-0513e166b0363945760c8a50 INFO: fail: 0.004 sec 02:39:04 worker.1 | 2016-06-09T06:39:04.416Z 21809 TID-ov3dsii2s WARN: {"class":"MyWorker","args":["testing","juan",5],"retry":true,"queue":"default","jid":"0513e166b0363945760c8a50","created_at":1465454206.3338182,"apartment":"companydemo2","enqueued_at":1465454344.410656,"error_message":"One of the following schema(s) is invalid: \"companydemo2\" \"public\"","error_class":"Apartment::TenantNotFound","failed_at":1465454242.2405062,"retry_count":2,"retried_at":1465454344.4156559} 02:39:04 worker.1 | 2016-06-09T06:39:04.416Z 21809 TID-ov3dsii2s WARN: Apartment::TenantNotFound: One of the following schema(s) is invalid: "companydemo2" "public" 02:39:04 worker.1 | 2016-06-09T06:39:04.416Z 21809 TID-ov3dsii2s WARN: /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/apartment-1.1.0/lib/apartment/adapters/postgresql_adapter.rb:72:in
rescue in connect_to_new' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/apartment-1.1.0/lib/apartment/adapters/postgresql_adapter.rb:65:in
connect_to_new' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/apartment-1.1.0/lib/apartment/adapters/abstract_adapter.rb:85:inswitch!' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/apartment-1.1.0/lib/apartment/adapters/abstract_adapter.rb:98:in
switch' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/apartment-sidekiq-1.1.0/lib/apartment/sidekiq/middleware/server.rb:4:incall' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:130:in
block in invoke' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/server/active_record.rb:6:incall' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:130:in
block in invoke' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/server/retry_jobs.rb:74:incall' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:130:in
block in invoke' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/server/logging.rb:11:inblock in call' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/logging.rb:32:in
with_context' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/server/logging.rb:7:incall' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:130:in
block in invoke' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:133:ininvoke' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:129:in
block in process' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:168:instats' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:128:in
process' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:80:inprocess_one' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:68:in
run' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/util.rb:17:inwatchdog' 02:39:04 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/util.rb:25:in
block in safe_thread'— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/influitive/apartment-sidekiq/issues/10#issuecomment-224812758, or mute the thread https://github.com/notifications/unsubscribe/AANWTLRDcCJ6OfOp36svx4rf0aLso4MVks5qJ7W6gaJpZM4GwI8v .
@typeoneerror thank you. I'm trying to find where is going wrong with my little knowledge, trying to get as much output as I can for you guys.
Gemfile
---------------
gem 'apartment', '~> 1.0', '>= 1.0.2'
gem 'sidekiq', '~> 4.0', '>= 4.1'
gem 'apartment-sidekiq', '~> 1.1.0'
group :production do
gem 'autoscaler', '~> 0.11.0'
end
Procfile
---------------
web: bundle exec puma -C config/puma.rb
log: tail -f log/development.log
redis_s: redis-server
worker: bundle exec sidekiq -e production -C ./config/sidekiq.yml
sidekiq.rb
---------------
require 'sidekiq'
require 'autoscaler/sidekiq'
require 'autoscaler/heroku_scaler'
Rails.logger = Sidekiq::Logging.logger
heroku = nil
if ENV['HEROKU_APP']
heroku = Autoscaler::HerokuScaler.new
end
Sidekiq.configure_client do |config|
config.redis = { size: 1}
if heroku
config.client_middleware do |chain|
chain.add Autoscaler::Sidekiq::Client, 'default' => heroku
end
end
end
Sidekiq.configure_server do |config|
config.redis = { size: 27}
database_url = ENV['DATABASE_URL']
if database_url
ENV['DATABASE_URL'] = "#{database_url}?pool=25"
ActiveRecord::Base.establish_connection
end
config.server_middleware do |chain|
if heroku
p "[Sidekiq] Running on Heroku, autoscaler is used"
chain.add(Autoscaler::Sidekiq::Server, heroku, 60) # 60 seconds timeout
else
p "[Sidekiq] Running locally, so autoscaler isn't used"
end
end
end
sidekiq.yml
---------------
:concurrency: 10
# you can override concurrency based on environment
production:
:concurrency: 25
# Set timeout to 8 on Heroku, longer if you manage your own systems.
:timeout: 8
:queues:
- critical
- default
- paperclip
- low
rails c
MyWorker.perform_in(1.seconds, Apartment::Tenant.current)
class MyWorker
include Sidekiq::Worker
def perform(tenant)
puts "------------------------"
puts "------------------------"
puts "Current Tenant #{Apartment::Tenant.current}"
puts "------------------------"
puts "------------------------"
end
end
So I add it some puts on different parts of the process looking where the item["apartment"] pass and this the output.
If you can see the Apartment::Tenant.switch(item['apartment']) works with "public" but when you switch to any other tenant get the error.
module Apartment::Sidekiq::Middleware
class Server
def call(worker_class, item, queue)
puts "----------------------------"
puts "The item param for apartment: #{item["apartment"]}"
puts "----------------------------"
puts "Worker Class: #{worker_class}"
puts "----------------------------"
puts "The queue: #{queue}"
puts "----------------------------"
puts "Tenant: #{Apartment::Tenant.switch(item['apartment'])}"
puts "----------------------------"
#this just so the job run it will fail im just looking for the top part output
Apartment::Tenant.current do
yield
end
end
end
end
11:20:24 worker.1 | 2016-06-09T15:20:24.581Z 30781 TID-ow4pahmoc MyWorker JID-a5a0ca08afbaaf0b10f37774 INFO: start
11:20:24 worker.1 | ----------------------------
11:20:24 worker.1 | The item param for apartment: public
11:20:24 worker.1 | ----------------------------
11:20:24 worker.1 | Worker Class: #<MyWorker:0x007fbcdc0004b0>
11:20:24 worker.1 | ----------------------------
11:20:24 worker.1 | The queue: default
11:20:24 worker.1 | ----------------------------
11:20:24 worker.1 | Tenant: "public"
11:20:24 worker.1 | ----------------------------
11:20:24 worker.1 | ------------------------
11:20:24 worker.1 | ------------------------
11:20:24 worker.1 | Current Tenant public
11:20:24 worker.1 | ------------------------
11:20:24 worker.1 | ------------------------
11:20:24 worker.1 | 2016-06-09T15:20:24.584Z 30781 TID-ow4pahmoc MyWorker JID-a5a0ca08afbaaf0b10f37774 INFO: done: 0.003 sec
11:20:54 worker.1 | 2016-06-09T15:20:54.436Z 30781 TID-ow4pashdc MyWorker JID-d27f2334ac2452d15e6bf9ba INFO: start
11:20:54 worker.1 | ----------------------------
11:20:54 worker.1 | The item param for apartment: companydemo
11:20:54 worker.1 | ----------------------------
11:20:54 worker.1 | Worker Class: #<MyWorker:0x007fbcd836c968>
11:20:54 worker.1 | ----------------------------
11:20:54 worker.1 | The queue: default
11:20:54 worker.1 | ----------------------------
11:20:54 worker.1 | 2016-06-09T15:20:54.439Z 30781 TID-ow4pashdc MyWorker JID-d27f2334ac2452d15e6bf9ba INFO: fail: 0.003 sec
11:20:54 worker.1 | 2016-06-09T15:20:54.439Z 30781 TID-ow4pashdc WARN: {"class":"MyWorker","args":["companydemo"],"retry":true,"queue":"default","jid":"d27f2334ac2452d15e6bf9ba","created_at":1465485640.888371,"apartment":"companydemo","enqueued_at":1465485654.435481,"error_message":"One of the following schema(s) is invalid: \"companydemo\" \"public\"","error_class":"Apartment::TenantNotFound","failed_at":1465485654.439004,"retry_count":0}
11:20:54 worker.1 | 2016-06-09T15:20:54.439Z 30781 TID-ow4pashdc WARN: Apartment::TenantNotFound: One of the following schema(s) is invalid: "companydemo" "public"
11:20:54 worker.1 | 2016-06-09T15:20:54.439Z 30781 TID-ow4pashdc WARN: /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/apartment-1.1.0/lib/apartment/adapters/postgresql_adapter.rb:72:in `rescue in connect_to_new'
Has I keep looking around I found that it never connect to my DB at this point as I call for the last user to be display.
module Apartment::Sidekiq::Middleware
class Server
def call(worker_class, item, queue)
puts "----------------------------"
puts "The item param for apartment: #{item["apartment"]}"
puts User.last
puts "----------------------------"
Apartment::Tenant.switch(item['apartment']) do
yield
end
end
end
end
11:45:46 worker.1 | 2016-06-09T15:45:46.319Z 31427 TID-out6i5dqo MyWorker JID-e47ae7772c51dcdeef6e7e4a INFO: start
11:45:46 worker.1 | ----------------------------
11:45:46 worker.1 | The item param for apartment: public
11:45:46 worker.1 | 2016-06-09T15:45:46.321Z 31427 TID-out6i5dqo MyWorker JID-e47ae7772c51dcdeef6e7e4a INFO: fail: 0.002 sec
11:45:46 worker.1 | 2016-06-09T15:45:46.321Z 31427 TID-out6i5dqo WARN: {"class":"MyWorker","args":["public"],"retry":true,"queue":"default","jid":"e47ae7772c51dcdeef6e7e4a","created_at":1465487140.9516401,"apartment":"public","enqueued_at":1465487146.318733,"error_message":"PG::UndefinedTable: ERROR: relation \"public.users\" does not exist\nLINE 1: SELECT \"public\".\"users\".* FROM \"public\".\"users\" ORDER BY \"...\n ^\n: SELECT \"public\".\"users\".* FROM \"public\".\"users\" ORDER BY \"public\".\"users\".\"id\" DESC LIMIT 1","error_class":"ActiveRecord::StatementInvalid","failed_at":1465487146.3210812,"retry_count":0}
11:45:46 worker.1 | 2016-06-09T15:45:46.321Z 31427 TID-out6i5dqo WARN: ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "public.users" does not exist
11:45:46 worker.1 | LINE 1: SELECT "public"."users".* FROM "public"."users" ORDER BY "...
11:45:46 worker.1 | ^
11:45:46 worker.1 | : SELECT "public"."users".* FROM "public"."users" ORDER BY "public"."users"."id" DESC LIMIT 1
11:45:46 worker.1 | 2016-06-09T15:45:46.321Z 31427 TID-out6i5dqo WARN: /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `async_exec'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `block in exec_no_cache'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract_adapter.rb:472:in `block in log'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract_adapter.rb:466:in `log'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in `exec_no_cache'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:584:in `execute_and_clear'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql/database_statements.rb:160:in `exec_query'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/database_statements.rb:355:in `select'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/database_statements.rb:32:in `select_all'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/query_cache.rb:70:in `select_all'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/querying.rb:39:in `find_by_sql'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/relation.rb:639:in `exec_queries'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/relation.rb:515:in `load'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/relation.rb:243:in `to_a'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/relation/finder_methods.rb:511:in `find_last'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/relation/finder_methods.rb:160:in `last'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/querying.rb:3:in `last'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/apartment-sidekiq-1.1.0/lib/apartment/sidekiq/middleware/server.rb:6:in `call'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/server/active_record.rb:6:in `call'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/server/retry_jobs.rb:74:in `call'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/logging.rb:32:in `with_context'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/server/logging.rb:7:in `call'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:130:in `block in invoke'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:133:in `invoke'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:129:in `block in process'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:168:in `stats'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:128:in `process'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:80:in `process_one'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:68:in `run'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/util.rb:17:in `watchdog'
11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/util.rb:25:in `block in safe_thread'
After seeing this, I don't think your issue is related to sidekiq or apartment. Let's take this off of their github and either pair or im next week. On Thu, Jun 9, 2016 at 8:51 AM francisco Quinones notifications@github.com wrote:
Has I keep looking around I found that it never connect to my DB at this point as I call for the last user tu be display.
module Apartment::Sidekiq::Middleware class Server def call(worker_class, item, queue) puts "----------------------------" puts "The item param for apartment: #{item["apartment"]}" puts User.last puts "----------------------------" Apartment::Tenant.switch(item['apartment']) do yield end end end end
11:45:46 worker.1 | 2016-06-09T15:45:46.319Z 31427 TID-out6i5dqo MyWorker JID-e47ae7772c51dcdeef6e7e4a INFO: start 11:45:46 worker.1 | ---------------------------- 11:45:46 worker.1 | The item param for apartment: public 11:45:46 worker.1 | 2016-06-09T15:45:46.321Z 31427 TID-out6i5dqo MyWorker JID-e47ae7772c51dcdeef6e7e4a INFO: fail: 0.002 sec 11:45:46 worker.1 | 2016-06-09T15:45:46.321Z 31427 TID-out6i5dqo WARN: {"class":"MyWorker","args":["public"],"retry":true,"queue":"default","jid":"e47ae7772c51dcdeef6e7e4a","created_at":1465487140.9516401,"apartment":"public","enqueued_at":1465487146.318733,"error_message":"PG::UndefinedTable: ERROR: relation \"public.users\" does not exist\nLINE 1: SELECT \"public\".\"users\".* FROM \"public\".\"users\" ORDER BY \"...\n ^\n: SELECT \"public\".\"users\".* FROM \"public\".\"users\" ORDER BY \"public\".\"users\".\"id\" DESC LIMIT 1","error_class":"ActiveRecord::StatementInvalid","failed_at":1465487146.3210812,"retry_count":0} 11:45:46 worker.1 | 2016-06-09T15:45:46.321Z 31427 TID-out6i5dqo WARN: ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "public.users" does not exist 11:45:46 worker.1 | LINE 1: SELECT "public"."users".* FROM "public"."users" ORDER BY "... 11:45:46 worker.1 | ^ 11:45:46 worker.1 | : SELECT "public"."users".* FROM "public"."users" ORDER BY "public"."users"."id" DESC LIMIT 1 11:45:46 worker.1 | 2016-06-09T15:45:46.321Z 31427 TID-out6i5dqo WARN: /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in
async_exec' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in
block in exec_no_cache' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract_adapter.rb:472:inblock in log' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activesupport-4.2.5/lib/active_support/notifications/instrumenter.rb:20:in
instrument' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract_adapter.rb:466:inlog' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:592:in
exec_no_cache' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql_adapter.rb:584:inexecute_and_clear' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/postgresql/database_statements.rb:160:in
exec_query' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/database_statements.rb:355:inselect' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/database_statements.rb:32:in
select_all' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/connection_adapters/abstract/query_cache.rb:70:inselect_all' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/querying.rb:39:in
find_by_sql' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/relation.rb:639:inexec_queries' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/relation.rb:515:in
load' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/relation.rb:243:into_a' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/relation/finder_methods.rb:511:in
find_last' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/relation/finder_methods.rb:160:inlast' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.5/lib/active_record/querying.rb:3:in
last' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/apartment-sidekiq-1.1.0/lib/apartment/sidekiq/middleware/server.rb:6:incall' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:130:in
block in invoke' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/server/active_record.rb:6:incall' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:130:in
block in invoke' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/server/retry_jobs.rb:74:incall' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:130:in
block in invoke' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/server/logging.rb:11:inblock in call' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/logging.rb:32:in
with_context' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/server/logging.rb:7:incall' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:130:in
block in invoke' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/middleware/chain.rb:133:ininvoke' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:129:in
block in process' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:168:instats' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:128:in
process' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:80:inprocess_one' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/processor.rb:68:in
run' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/util.rb:17:inwatchdog' 11:45:46 worker.1 | /Users/IFrank/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/sidekiq-4.1.2/lib/sidekiq/util.rb:25:in
block in safe_thread'— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/influitive/apartment-sidekiq/issues/10#issuecomment-224938807, or mute the thread https://github.com/notifications/unsubscribe/AANWTEL7-aooTSdMxA0fqZ41nr6lcw6pks5qKDZlgaJpZM4GwI8v .
perfect I will create a gist with the info I can get. @typeoneerror https://gist.github.com/Frank004/48276206a96e45102e9004f2c19f38d0
@Frank004 my skype is the same as my github handle. hit me up there next week.
rake middleware
use ActionDispatch::Static
use Rack::Lock
use #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x007febcb0e51f0>
use Rack::Runtime
use Rack::MethodOverride
use ActionDispatch::RequestId
use Rails::Rack::Logger
use ActionDispatch::ShowExceptions
use MetaRequest::Middlewares::Headers
use WebConsole::Middleware
use ActionDispatch::DebugExceptions
use BetterErrors::Middleware
use Raygun::Middleware::RackExceptionInterceptor
use Raygun::Middleware::RailsInsertAffectedUser
use ActionDispatch::RemoteIp
use ActionDispatch::Reloader
use ActionDispatch::Callbacks
use ActiveRecord::Migration::CheckPending
use ActiveRecord::ConnectionAdapters::ConnectionManagement
use ActiveRecord::QueryCache
use ActionDispatch::Cookies
use ActionDispatch::Session::CookieStore
use ActionDispatch::Flash
use ActionDispatch::ParamsParser
use Rack::Head
use Rack::ConditionalGet
use Rack::ETag
use Apartment::Elevators::Subdomain
use Warden::Manager
use Apartment::Reloader
use JQuery::FileUpload::Rails::Middleware
use MetaRequest::Middlewares::MetaRequestHandler
use MetaRequest::Middlewares::AppRequestHandler
use Bullet::Rack
use Apartment::Elevators::Subdomain
use RecurringSelectMiddleware
run APP::Application.routes
can't find the sidekiq middleware on the list
FYI, @Frank004 and I resolved this issue here in case anyone was experiencing a similar issue.
@typeoneerror how did you resolve this problem, I am currently experiencing the same error.
@simonbrazell what gems ver. are you using?
@simonbrazell did you read the stackoverflow thread I linked above?
For debugging, I'd recommend starting a question thread on stackoverflow instead of here on the repo.
@typeoneerror all good, it was a silly mistake by myself in the end, it was getting late and I started to despair... thanks for responding though!
Cheers!
Hi I get this error whe I try to process a img in the background.