Octopus with Padrino ActiveRecord 3.2.19 and ruby 2.1.3

61 views
Skip to first unread message

mohit negi

unread,
Apr 25, 2015, 3:11:50 AM4/25/15
to octopus-ac...@googlegroups.com
my shards.yml looks like
octopus:
  replicated: true
  fully_replicated: true
  environments:
    - development
    - staging
    - production

  development:
    shards:
      slave1:
        adapter: mysql2
        host: my_develpment_host
        database: database_name
        username: XXXXXX
        password: XXXXXX

  staging:
    shards:
      slave3:
        adapter: mysql2
        host: my_staging_host
        database: database_name
        username: XXXXXX
        password: XXXXXX

  production:
    shards:
      slave5:
        adapter: mysql2
        host: my_production_host
        database: database_name
        username: XXXXXX
        password: XXXXXX
but when i am doing a select query it raises error 
MyUser.where(:id=>16)
ZeroDivisionError: divided by 0
    from /Users/mohit/.rvm/gems/ruby-2.1.3@consumer_api/gems/ar-octopus-0.8.5/lib/octopus/load_balancing/round_robin.rb:15:in `next'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@consumer_api/gems/ar-octopus-0.8.5/lib/octopus/proxy.rb:414:in `send_queries_to_selected_slave'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@consumer_api/gems/ar-octopus-0.8.5/lib/octopus/proxy.rb:271:in `method_missing'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/activerecord-3.2.19/lib/active_record/querying.rb:38:in `block in find_by_sql'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/activerecord-3.2.19/lib/active_record/explain.rb:41:in `logging_query_plan'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/activerecord-3.2.19/lib/active_record/querying.rb:37:in `find_by_sql'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@consumer_api/gems/newrelic_rpm-3.9.9.275/lib/new_relic/agent/method_tracer.rb:343:in `block in find_by_sql_with_trace_ActiveRecord_self_name_find_by_sql'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@consumer_api/gems/newrelic_rpm-3.9.9.275/lib/new_relic/agent/method_tracer_helpers.rb:82:in `trace_execution_scoped'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@consumer_api/gems/newrelic_rpm-3.9.9.275/lib/new_relic/agent/method_tracer.rb:341:in `find_by_sql_with_trace_ActiveRecord_self_name_find_by_sql'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/activerecord-3.2.19/lib/active_record/relation.rb:171:in `exec_queries'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/activerecord-3.2.19/lib/active_record/relation.rb:160:in `block in to_a'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/activerecord-3.2.19/lib/active_record/explain.rb:41:in `logging_query_plan'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/activerecord-3.2.19/lib/active_record/relation.rb:159:in `to_a'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/activerecord-3.2.19/lib/active_record/relation.rb:498:in `inspect'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/padrino-core-0.10.7/lib/padrino-core/cli/base.rb:68:in `console'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/thor-0.15.2/lib/thor/task.rb:27:in `run'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/thor-0.15.2/lib/thor/invocation.rb:120:in `invoke_task'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/thor-0.15.2/lib/thor.rb:275:in `dispatch'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/thor-0.15.2/lib/thor/invocation.rb:109:in `invoke'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/padrino-core-0.10.7/lib/padrino-core/cli/base.rb:73:in `c'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/thor-0.15.2/lib/thor/task.rb:27:in `run'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/thor-0.15.2/lib/thor/invocation.rb:120:in `invoke_task'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/thor-0.15.2/lib/thor.rb:275:in `dispatch'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/thor-0.15.2/lib/thor/base.rb:408:in `start'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/padrino-core-0.10.7/bin/padrino:9:in `'
    from /Users/mohit/.rvm/rubies/ruby-2.1.3/bin/padrino:23:in `load'
    from /Users/mohit/.rvm/rubies/ruby-2.1.3/bin/padrino:23:in `'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@consumer_api/bin/ruby_executable_hooks:15:in `eval'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@consumer_api/bin/ruby_executable_hooks:15:in `' :005 > 
If i specify a particular slave
MyUser.where(:id=>16).using(:slave1)
RuntimeError: Nonexistent Shard Name: slave1
from /Users/mohit/.rvm/gems/ruby-2.1.3@consumer_api/gems/ar-octopus-0.8.5/lib/octopus/proxy.rb:129:in `current_shard='
    from /Users/mohit/.rvm/gems/ruby-2.1.3@consumer_api/gems/ar-octopus-0.8.5/lib/octopus/proxy.rb:474:in `using_shard'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@consumer_api/gems/ar-octopus-0.8.5/lib/octopus/proxy.rb:225:in `block in run_queries_on_shard'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@consumer_api/gems/ar-octopus-0.8.5/lib/octopus/proxy.rb:462:in `keeping_connection_proxy'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@consumer_api/gems/ar-octopus-0.8.5/lib/octopus/proxy.rb:224:in `run_queries_on_shard'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@consumer_api/gems/ar-octopus-0.8.5/lib/octopus/shard_tracking.rb:30:in `run_on_shard'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@consumer_api/gems/ar-octopus-0.8.5/lib/octopus/scope_proxy.rb:43:in `method_missing'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/padrino-core-0.10.7/lib/padrino-core/cli/base.rb:68:in `console'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/thor-0.15.2/lib/thor/task.rb:27:in `run'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/thor-0.15.2/lib/thor/invocation.rb:120:in `invoke_task'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/thor-0.15.2/lib/thor.rb:275:in `dispatch'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/thor-0.15.2/lib/thor/invocation.rb:109:in `invoke'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/padrino-core-0.10.7/lib/padrino-core/cli/base.rb:73:in `c'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/thor-0.15.2/lib/thor/task.rb:27:in `run'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/thor-0.15.2/lib/thor/invocation.rb:120:in `invoke_task'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/thor-0.15.2/lib/thor.rb:275:in `dispatch'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/thor-0.15.2/lib/thor/base.rb:408:in `start'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@global/gems/padrino-core-0.10.7/bin/padrino:9:in `'
    from /Users/mohit/.rvm/rubies/ruby-2.1.3/bin/padrino:23:in `load'
    from /Users/mohit/.rvm/rubies/ruby-2.1.3/bin/padrino:23:in `'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@consumer_api/bin/ruby_executable_hooks:15:in `eval'
    from /Users/mohit/.rvm/gems/ruby-2.1.3@consumer_api/bin/ruby_executable_hooks:15:in `' :010 > 
Reply all
Reply to author
Forward
0 new messages