{"action":"created","issue":{"url":"https://api.github.com/repos/TalentBox/sequel-rails/issues/168","repository_url":"https://api.github.com/repos/TalentBox/sequel-rails","labels_url":"https://api.github.com/repos/TalentBox/sequel-rails/issues/168/labels{/name}","comments_url":"https://api.github.com/repos/TalentBox/sequel-rails/issues/168/comments","events_url":"https://api.github.com/repos/TalentBox/sequel-rails/issues/168/events","html_url":"https://github.com/TalentBox/sequel-rails/issues/168","id":393901284,"node_id":"MDU6SXNzdWUzOTM5MDEyODQ=","number":168,"title":"Multi DB with SequelRails (issues and possible solution way)","user":{"login":"gencer","id":1711576,"node_id":"MDQ6VXNlcjE3MTE1NzY=","avatar_url":"https://avatars0.githubusercontent.com/u/1711576?v=4","gravatar_id":"","url":"https://api.github.com/users/gencer","html_url":"https://github.com/gencer","followers_url":"https://api.github.com/users/gencer/followers","following_url":"https://api.github.com/users/gencer/following{/other_user}","gists_url":"https://api.github.com/users/gencer/gists{/gist_id}","starred_url":"https://api.github.com/users/gencer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gencer/subscriptions","organizations_url":"https://api.github.com/users/gencer/orgs","repos_url":"https://api.github.com/users/gencer/repos","events_url":"https://api.github.com/users/gencer/events{/privacy}","received_events_url":"https://api.github.com/users/gencer/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-24T15:42:00Z","updated_at":"2018-12-24T18:05:33Z","closed_at":null,"author_association":"NONE","body":"When multiple databases used with Sequel' s internal system, SequelRails tries to log connection and using this connection for all models even if model belongs to another connection.\r\n\r\n## Problem\r\n\r\nSequelRails has an ActiveSupport Notification instrument. When anything goes to this, primary (default) connection is used for all models regardless which model belongs to which connection.\r\n\r\nSee below stack trace. You will see that `emails` table does not exists. It's because SequelRails executes this in primary database which has no `emails` table. When I debug line-by-line, I see that conn value is my primary database and not secondary.\r\n\r\n## How I solved this?\r\n\r\nNot quite correct but commenting/removing this line: https://github.com/TalentBox/sequel-rails/blob/master/lib/sequel_rails/sequel/database/active_support_notification.rb#L21\r\n solves my problem. Simply I tell SequelRails to only log but not raise error.\r\n\r\n## Question.\r\n\r\nDo you have any other idea how we can overcome on this? Monkey-patch using `lib/` dir or any other idea?\r\n\r\n**Stack error:**\r\n```\r\nI, [2018-12-24T15:27:23.097385 #6287]  INFO -- : Refreshing Gem list\r\nSequel::DatabaseError: PG::UndefinedTable: ERROR:  relation \"emails\" does not exist\r\nLINE 1: SELECT * FROM \"emails\" LIMIT 1\r\n                      ^\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/adapters/postgres.rb:152:in `async_exec'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/adapters/postgres.rb:152:in `block in execute_query'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-rails-1.0.1/lib/sequel_rails/sequel/database/active_support_notification.rb:17:in `block in log_connection_yield'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/notifications.rb:168:in `block in instrument'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/notifications/instrumenter.rb:23:in `instrument'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/notifications.rb:168:in `instrument'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-rails-1.0.1/lib/sequel_rails/sequel/database/active_support_notification.rb:11:in `log_connection_yield'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/adapters/postgres.rb:152:in `execute_query'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/adapters/postgres.rb:140:in `block in execute'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/adapters/postgres.rb:116:in `check_disconnect_errors'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/adapters/postgres.rb:140:in `execute'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/adapters/postgres.rb:496:in `_execute'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/adapters/postgres.rb:314:in `block (2 levels) in execute'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/adapters/postgres.rb:518:in `check_database_errors'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/adapters/postgres.rb:314:in `block in execute'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/connection_pool/threaded.rb:92:in `hold'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/database/connecting.rb:270:in `synchronize'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/adapters/postgres.rb:314:in `execute'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/dataset/actions.rb:1083:in `execute'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/adapters/postgres.rb:610:in `fetch_rows'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/dataset/actions.rb:151:in `each'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel_pg-1.11.0/lib/sequel_pg/sequel_pg.rb:81:in `each'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/dataset/actions.rb:85:in `columns!'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/dataset/actions.rb:75:in `columns'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/model/base.rb:242:in `columns'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-auditer-0.1.0/lib/sequel/plugins/auditer.rb:118:in `block in configure'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-auditer-0.1.0/lib/sequel/plugins/auditer.rb:92:in `instance_eval'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-auditer-0.1.0/lib/sequel/plugins/auditer.rb:92:in `configure'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/sequel-5.15.0/lib/sequel/model/base.rb:550:in `plugin'\r\n  /disk5/www/gb/box/releases/20181224143406/app/models/mailbox/email.rb:4:in `<class:Email>'\r\n  /disk5/www/gb/box/releases/20181224143406/app/models/mailbox/email.rb:3:in `<module:Mailbox>'\r\n  /disk5/www/gb/box/releases/20181224143406/app/models/mailbox/email.rb:2:in `<top (required)>'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/skylight-core-3.1.2/lib/skylight/core/probes.rb:119:in `require'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/skylight-core-3.1.2/lib/skylight/core/probes.rb:119:in `require'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:378:in `block in require_or_load'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:37:in `block in load_interlock'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies/interlock.rb:14:in `block in loading'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/concurrency/share_lock.rb:151:in `exclusive'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies/interlock.rb:13:in `loading'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:37:in `load_interlock'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:356:in `require_or_load'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:334:in `depend_on'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:246:in `require_dependency'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/engine.rb:478:in `block (2 levels) in eager_load!'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/engine.rb:477:in `each'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/engine.rb:477:in `block in eager_load!'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/engine.rb:475:in `each'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/engine.rb:475:in `eager_load!'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/engine.rb:356:in `eager_load!'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/application/finisher.rb:69:in `each'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/application/finisher.rb:69:in `block in <module:Finisher>'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:32:in `instance_exec'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:32:in `run'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:61:in `block in run_initializers'\r\n  /home/gencer/.rbenv/versions/2.5.3/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each'\r\n  /home/gencer/.rbenv/versions/2.5.3/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'\r\n  /home/gencer/.rbenv/versions/2.5.3/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from'\r\n  /home/gencer/.rbenv/versions/2.5.3/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component'\r\n  /home/gencer/.rbenv/versions/2.5.3/lib/ruby/2.5.0/tsort.rb:347:in `each'\r\n  /home/gencer/.rbenv/versions/2.5.3/lib/ruby/2.5.0/tsort.rb:347:in `call'\r\n  /home/gencer/.rbenv/versions/2.5.3/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component'\r\n  /home/gencer/.rbenv/versions/2.5.3/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each'\r\n  /home/gencer/.rbenv/versions/2.5.3/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:60:in `run_initializers'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/application.rb:361:in `initialize!'\r\n  /disk5/www/gb/box/releases/20181224143406/config/environment.rb:6:in `<top (required)>'\r\n  config.ru:4:in `require_relative'\r\n  config.ru:4:in `block in <main>'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/builder.rb:55:in `instance_eval'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/rack-2.0.6/lib/rack/builder.rb:55:in `initialize'\r\n  config.ru:1:in `new'\r\n  config.ru:1:in `<main>'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/unicorn-5.4.1/lib/unicorn.rb:56:in `eval'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/unicorn-5.4.1/lib/unicorn.rb:56:in `block in builder'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:795:in `build_app!'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:139:in `start'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/gems/unicorn-5.4.1/bin/unicorn:126:in `<top (required)>'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/bin/unicorn:23:in `load'\r\n  /disk5/www/gb/box/shared/bundle/ruby/2.5.0/bin/unicorn:23:in `<top (required)>'\r\n\r\n```\r\nRelated issues: #74, #75 and #137."},"comment":{"url":"https://api.github.com/repos/TalentBox/sequel-rails/issues/comments/449760224","html_url":"https://github.com/TalentBox/sequel-rails/issues/168#issuecomment-449760224","issue_url":"https://api.github.com/repos/TalentBox/sequel-rails/issues/168","id":449760224,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0OTc2MDIyNA==","user":{"login":"gencer","id":1711576,"node_id":"MDQ6VXNlcjE3MTE1NzY=","avatar_url":"https://avatars0.githubusercontent.com/u/1711576?v=4","gravatar_id":"","url":"https://api.github.com/users/gencer","html_url":"https://github.com/gencer","followers_url":"https://api.github.com/users/gencer/followers","following_url":"https://api.github.com/users/gencer/following{/other_user}","gists_url":"https://api.github.com/users/gencer/gists{/gist_id}","starred_url":"https://api.github.com/users/gencer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gencer/subscriptions","organizations_url":"https://api.github.com/users/gencer/orgs","repos_url":"https://api.github.com/users/gencer/repos","events_url":"https://api.github.com/users/gencer/events{/privacy}","received_events_url":"https://api.github.com/users/gencer/received_events","type":"User","site_admin":false},"created_at":"2018-12-24T18:05:33Z","updated_at":"2018-12-24T18:05:33Z","author_association":"NONE","body":"@JonathanTron, two more questions:\r\n\r\nI've monkey-patched (ugly) using initializer. Now everything works fine.\r\n\r\nBut, I still want to hear your idea. Actually, do you still support this gem? I see no improvements on issues for a while except one PR.\r\n\r\nThanks,\r\nGencer."}}
{"actor":{"display_login":"gencer"}}