On Saturday, October 20, 2012 8:28:06 AM UTC-7, David Ott wrote:
>
> I am experiencing trouble with the connections dropping and not being 
> re-establised. The air brake error is this: 
>
> Sequel::DatabaseDisconnectError: PG::Error: SSL error: sslv3 alert bad 
> record mac
>
> I assume there is some important thread safety stuff here that I am 
> glossing over due to my inexperience with this kind of setup. What's the 
> best way to deal with this? Is sharing the connection the wrong approach? 
> Should I nix the gem and have this logic in each service? Would wrapping it 
> in a Thread.new block work? Or is there something else I'm missing like 
> disconnecting/reconnecting properly?
>

Sequel is thread-safe, so it's unlikely to be thread safety.  If I had to 
guess, you are using a forking webserver, loading your application code 
before forking, and not calling Database#disconnect before forking, 
resulting in multiple processes sharing the connections.  But that's really 
only a guess based on limited information.

A couple of notes based on the code you posted:

1) Also note that there is no point in building a URL in your code, just 
pass an options hash to Sequel.connect.

2) Your attempts to retry are misguided.  A DatabaseDisconnectError does 
not mean a problem with the Database object, but an issue with a single 
connection in the Database's connection pool, which Sequel handles by 
removing the connection from the pool.  Creating a new Database object is 
absolutely the wrong approach.

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/l6YBOYiS7loJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to