Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing_replication_bug_new branch on Rails 5.1 sending write requests to slave #452

Open
vibro opened this issue Sep 15, 2017 · 0 comments

Comments

@vibro
Copy link

vibro commented Sep 15, 2017

I'm trying to set up octopus with a fully replicated configuration, one master and one slave. I've been having issues with Rails 5.1 compatibility so I tried your feature branch fixing_replication_bug_new as specified in #440. Unfortunately, this configuration seems to send all write requests to the slave and nothing to the master.

shards.yml:

  replicated: true
  fully_replicated: true
  environments:
   - staging
  staging:
    slave1:
      adapter: postgresql
      host: slave1.host.com
      password: <%= ENV['DB_PASSWORD'] %>
      port: 5432
      database: my_db_name

Trying to perform an update (logging in a user):

D, [2017-09-15T13:04:33.710487 #30826] DEBUG -- :    (0.7ms)  BEGIN
D, [2017-09-15T13:04:33.716329 #30826] DEBUG -- : [Shard: slave1]  SQL (1.4ms)  UPDATE "users" SET "current_sign_in_at" = $1, "last_sign_in_at" = $2, "sign_in_count" = $3, "updated_at" = $4 WHERE "users"."id" = $5  [["current_sign_in_at", "2017-09-15 17:04:33.708809"], ["last_sign_in_at", "2017-09-14 20:52:57.704370"], ["sign_in_count", 8371], ["updated_at", "2017-09-15 17:04:33.711694"], ["id", 1]]
D, [2017-09-15T13:04:33.717190 #30826] DEBUG -- :    (0.6ms)  ROLLBACK
I, [2017-09-15T13:04:33.717740 #30826]  INFO -- : Completed 500 Internal Server Error in 71ms (ActiveRecord: 14.5ms)
F, [2017-09-15T13:04:33.719418 #30826] FATAL -- :   
F, [2017-09-15T13:04:33.719493 #30826] FATAL -- : ActiveRecord::StatementInvalid (PG::ReadOnlySqlTransaction: ERROR:  cannot execute UPDATE in a read-only transaction
: UPDATE "users" SET "current_sign_in_at" = $1, "last_sign_in_at" = $2, "sign_in_count" = $3, "updated_at" = $4 WHERE "users"."id" = $5):

In Gemfile:
gem 'ar-octopus', git: 'https://github.com/thiagopradi/octopus.git', branch: 'fixing_replication_bug_new'

I can't use the 0.9.1 version of this gem because it seems to have other compatibility issues with 5.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant