sauspiel / postamt Goto Github PK
View Code? Open in Web Editor NEWPostamt is a sane, Rails-4-ready solution for performing database reads against a hot standby server.
License: MIT License
Postamt is a sane, Rails-4-ready solution for performing database reads against a hot standby server.
License: MIT License
Rails versions:
When I ran rspec for some models, it caused the following error.
Does anybody know postamt 0.10.0 can support Rails 5.0?
Failure/Error: Postamt.force_connection || Postamt.connection_stack.last || Postamt.overwritten_default_connections[klass.name] || klass.default_connection || Postamt.default_connection
NoMethodError:
undefined method `name' for "primary":String
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/postamt-d4ac81440aab/lib/postamt/connection_handler.rb:96:in `connection_for'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/postamt-d4ac81440aab/lib/postamt/connection_handler.rb:104:in `pool_for'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/postamt-d4ac81440aab/lib/postamt/connection_handler.rb:73:in `retrieve_connection_pool'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/bundler/gems/postamt-d4ac81440aab/lib/postamt/connection_handler.rb:51:in `retrieve_connection'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_handling.rb:128:in `retrieve_connection'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/connection_handling.rb:91:in `connection'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/fixtures.rb:516:in `create_fixtures'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/fixtures.rb:1015:in `load_fixtures'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/fixtures.rb:988:in `setup_fixtures'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-5.0.7/lib/active_record/fixtures.rb:852:in `before_setup'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-rails-3.7.2/lib/rspec/rails/adapters.rb:126:in `block (2 levels) in <module:MinitestLifecycleAdapter>'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:447:in `instance_exec'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:447:in `instance_exec'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/hooks.rb:375:in `execute_with'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/hooks.rb:608:in `block (2 levels) in run_around_example_hooks_for'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:342:in `call'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/hooks.rb:609:in `run_around_example_hooks_for'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/hooks.rb:466:in `run'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:457:in `with_around_example_hooks'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:500:in `with_around_and_singleton_context_hooks'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example.rb:251:in `run'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example_group.rb:628:in `block in run_examples'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example_group.rb:624:in `map'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example_group.rb:624:in `run_examples'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/example_group.rb:590:in `run'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:118:in `block (3 levels) in run_specs'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:118:in `map'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:118:in `block (2 levels) in run_specs'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/configuration.rb:1926:in `with_suite_hooks'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:113:in `block in run_specs'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/reporter.rb:79:in `report'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:112:in `run_specs'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:87:in `run'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:71:in `run'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/lib/rspec/core/runner.rb:45:in `invoke'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/rspec-core-3.7.1/exe/rspec:4:in `<top (required)>'
# /usr/local/rbenv/versions/2.3.0/bin/rspec:23:in `load'
# /usr/local/rbenv/versions/2.3.0/bin/rspec:23:in `<top (required)>'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/bundler/cli/exec.rb:74:in `load'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/bundler/cli/exec.rb:74:in `kernel_load'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/bundler/cli/exec.rb:28:in `run'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/bundler/cli.rb:424:in `exec'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/bundler/cli.rb:27:in `dispatch'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/bundler/cli.rb:18:in `start'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.16.2/exe/bundle:30:in `block in <top (required)>'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/bundler/friendly_errors.rb:124:in `with_friendly_errors'
# /usr/local/rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/bundler-1.16.2/exe/bundle:22:in `<top (required)>'
# /usr/local/rbenv/versions/2.3.0/bin/bundle:23:in `load'
# /usr/local/rbenv/versions/2.3.0/bin/bundle:23:in `<main>'
#
# Showing full backtrace because every line was filtered out.
# See docs for RSpec::Configuration#backtrace_exclusion_patterns and
# RSpec::Configuration#backtrace_inclusion_patterns for more information.
I installed postamt 0.10.0 by like:
gem 'postamt', github: 'sauspiel/postamt', branch: 'rails5'
When having newrelic_rpm
(version 3.15.0.314) as a dependency in a rails app together with postamt, destroying ActiveRecord records fails with an SystemStackError: stack level too deep
.
The last stack frames look like:
from /Users/kommen/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/relation.rb:304:in `ensure in scoping'
from /Users/kommen/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/relation.rb:304:in `scoping'
from /Users/kommen/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/activerecord-4.2.6/lib/active_record/relation/delegation.rb:70:in `name'
from /Users/kommen/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/newrelic_rpm-3.15.0.314/lib/new_relic/agent/instrumentation/active_record_helper.rb:53:in `delete_all'
from /Users/kommen/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/postamt-0.9.7/lib/postamt.rb:121:in `block in delete_all'
from /Users/kommen/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/postamt-0.9.7/lib/postamt.rb:19:in `on'
from /Users/kommen/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/postamt-0.9.7/lib/postamt.rb:121:in `delete_all'
from /Users/kommen/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/newrelic_rpm-3.15.0.314/lib/new_relic/agent/instrumentation/active_record_helper.rb:54:in `block in delete_all'
from /Users/kommen/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/newrelic_rpm-3.15.0.314/lib/new_relic/agent.rb:574:in `with_database_metric_name'
from /Users/kommen/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/newrelic_rpm-3.15.0.314/lib/new_relic/agent/instrumentation/active_record_helper.rb:53:in `delete_all'
from /Users/kommen/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/postamt-0.9.7/lib/postamt.rb:121:in `block in delete_all'
from /Users/kommen/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/postamt-0.9.7/lib/postamt.rb:19:in `on'
from /Users/kommen/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/postamt-0.9.7/lib/postamt.rb:121:in `delete_all'
from /Users/kommen/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/newrelic_rpm-3.15.0.314/lib/new_relic/agent/instrumentation/active_record_helper.rb:54:in `block in delete_all'
from /Users/kommen/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/newrelic_rpm-3.15.0.314/lib/new_relic/agent.rb:574:in `with_database_metric_name'
from /Users/kommen/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/newrelic_rpm-3.15.0.314/lib/new_relic/agent/instrumentation/active_record_helper.rb:53:in `delete_all'
The issue was not present with older newrelic_rpm versions (e.g. 3.9.0.229). This commit looks like it could be the cause: newrelic/newrelic-ruby-agent@9c267ff
I've experiencing problems while using Postamt and Grape together. For some reason, ActiveRecord::Relation.prepend Postamt::Relation
results in a recursive call to delete_all
method when destroying an object. I replaced the line with ActiveRecord::Relation.include Postamt::Relation
and it seems to work fine. Can you please help me?
Adding the postamt gem to a fresh rails4 rc1 project breaks rake db:test:purge
with
PG::Error: ERROR: cannot drop the currently open database
: DROP DATABASE IF EXISTS "testin_test"
Using ObjectSpace as workaround right now. That's horrible. Stop doing that.
Hi,
I would like to use separate db for one model. Unfortunately when I use
establish_connection("another_db_#{Rails.env}"])
my app still use main db. When I commented out "development" settings in database.yml, Postamt return me:
ActiveRecord::ConnectionNotEstablished: ActiveRecord::ConnectionNotEstablished
in
gems/postamt-0.9.0/lib/postamt/connection_handler.rb:53:in `retrieve_connection'
Any ideas how to use "establish_connection" simultaneously with Postamt?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.