You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I've encountered a shard mismatch problem when using octopus with identity_cache gem.
Environment
Databases:
master * 1
replica * 1
Config:
replicated: true
fully_replicated: false (set replicated_model by ourself)
Gems:
rails 4.2.11
octopus: 0.10.2
identity_cache: 0.4.1
Scenario
Model
User (replicated_model)
has_one :setting
Setting (replicated_model)
When I want to update the setting record fetched from cache, the update query will be sent to the replica shard.
# in controller# first request works, later requests all failedUser.fetch(1).setting.update(some_attribute)
By using binding.pry I found that first time .current_shard will return :master, record fetched by another request will get :replica then the update query sent to wrong replica database.
But if I using normal Active Record method (e.g. Member.find(1).setting.update(some_attribute)) all request are success.
Is there some class variables stored across requests but computing after ActiveRecord instance initialize, but record initialized by IdentityCache cause the problem?
Thanks
The text was updated successfully, but these errors were encountered:
Hi, I've encountered a shard mismatch problem when using octopus with identity_cache gem.
Environment
Databases:
Config:
Gems:
Scenario
Model
When I want to update the setting record fetched from cache, the update query will be sent to the replica shard.
By using
binding.pry
I found that first time.current_shard
will return:master
, record fetched by another request will get:replica
then the update query sent to wrong replica database.But if I using normal Active Record method (e.g.
Member.find(1).setting.update(some_attribute)
) all request are success.Is there some class variables stored across requests but computing after ActiveRecord instance initialize, but record initialized by IdentityCache cause the problem?
Thanks
The text was updated successfully, but these errors were encountered: