hutch icon indicating copy to clipboard operation
hutch copied to clipboard

Hutch.connect erases Hutch::Config

Open niuage opened this issue 8 years ago • 6 comments

Hey,

We updated Hutch from 0.21 to 0.22.1, and we now have the following issue:

> Hutch::Config.get(:mq_host)
# => xyz.rmq.cloudamqp.com

> Hutch.connected?
# => nil

> Hutch.connect
#2016-10-10T22:14:44Z 3 INFO -- connecting to rabbitmq (amqp://[email protected]:5672/)
# [...] Could not establish TCP connection to 127.0.0.1:5672 [...]

> Hutch::Config.get(:mq_host)
# => "127.0.0.1"

Notice how the Hutch::Config value is correct the first time, then after calling .connect, it's different, and is back to the default value?

Looking at the code...

def self.connect(options = {}, config = Hutch::Config)
    return if connected?

    @broker = Hutch::Broker.new(config)
    @broker.connect(options)
end

... it should be using the Hutch::Config class as default, and I checked the value of the mq_host attribute just before.

Interestingly, after all this mess, if I reset the values in the config class, with Hutch::Config.set..., and then call Hutch.connect, it works. Could this be a thread/fork issue? We're on heroku, just fyi.

Any idea about what's going on? Thanks.

niuage avatar Oct 10 '16 22:10 niuage

Investigating, it appears to be related to this commit:

https://github.com/gocardless/hutch/commit/6bd0cc8055ae17404c553da2bcecc687d57d4ee5

logger called from the broker resets the connection settings

zuuno avatar Oct 12 '16 13:10 zuuno

Good find, thanks for looking into it.

niuage avatar Oct 12 '16 18:10 niuage

@niuage Are you able to try to try to reproduce with current master? Here's a commits list between that tag (which is latest release) and HEAD: https://github.com/gocardless/hutch/compare/23ad748e6a968cbfa511d31dd4e0cda19bffd8dc...master

The last line of config.rb is "please initialize with the defaults unless something is set". https://github.com/gocardless/hutch/blob/master/lib/hutch/config.rb#L270 In the released version, that line isn't there.

Is that line Hutch::Config.initialize in lib/hutch/logging.rb now superfluous?

olleolleolle avatar Oct 19 '16 08:10 olleolleolle

@niuage Please re-test with 0.23.1.

olleolleolle avatar Oct 20 '16 10:10 olleolleolle

@niuage Have you had the time to look into this?

olleolleolle avatar Jan 23 '17 14:01 olleolleolle

I haven't yet, sorry. I'll try today possibly.

niuage avatar Jan 23 '17 15:01 niuage