octopus icon indicating copy to clipboard operation
octopus copied to clipboard

Octopus and CPK

Open rayko opened this issue 8 years ago • 4 comments

I've recently discovered an issue when using Octopus 0.8.5 and composite_primary_key 7.0.16, under Rails 4.1.7. The setup includes a few tables using CPK, and Octopus with 2 databases in RDS as master and slave with full replication.

The behavior I was noticing is that Octopus wasn't working properly, it loads its configuration with no error on boot, but some classes weren't being used or loaded. It wasn't showing the debug output in logs on development, shards weren't queried, even when specifying the shard. The Octopus.using(:slave1){} had no effect, I had errors while doing test queries because Octopus wasn't setting the shard properly. Octopus wasn't making any use of the shards defined in its config, all queries were executed on master, regardless of how it was done.

I fixed this problem on my setup by altering the order of gem loads, placing CPK avobe Octopus, this restores the functionality and Octopus seems to work as expected now.

I belive CPK overrides methods on ActiveRecord related to the connection pool and the establish connection mechanism, replacing the methods Octopus expect from AR. I couldn't narrow down the problem, but it might be the connection_specification_changes.rb in CPK that makes overrides in that matter.

I know I should be more specific to this issue and provide more "tangible" information, but since I sorted this up, I no longer require assistance for this. This may be useful for someone else.

Moving CPK gem below Octopus causes the problems I described above.

rayko avatar Jun 06 '16 20:06 rayko

This looks like the same cause/resolution as https://github.com/thiagopradi/octopus/issues/342

washogren avatar Aug 12 '16 23:08 washogren

hi @rayko - I'm sorry for the late reply to your ticket. I know you sorted your problem out, but I'd like to fix it. Do you have more information about it? I would like to reproduce the problem locally.

thiagopradi avatar Oct 17 '16 01:10 thiagopradi

I haven't inspected the issue in more depth after I found the solution. My previous post has pretty much all the info I collected when I encountered the problem. I couldn't identify any method in particular that could be causing the problem, the only weird sight was the connection pool, which makes sense, if the Octopus connection pool is not used, it would be like there's no Octopus. If I have time this week, I'll see if I can replicate the problem on a fresh app and get you some logs or something.

rayko avatar Oct 17 '16 12:10 rayko

Sorry for the late response, I replicated the problem in a brand new app. I uploaded the code for you to inspect if you want.

https://github.com/rayko/octopus_debug

rayko avatar Feb 07 '17 17:02 rayko