On Tue, Jan 6, 2015 at 2:17 AM, Jeremy Evans <[email protected]> wrote:
> There's nothing specifically logged when a connection is disconnected and a
> new connection is made.  But it's fairly easy to add such logging yourself:
>
> def DB.disconnect_connection(conn)
>   super
>   log_info("Disconnecting connection #{conn.object_id}")
> end
>
> def DB.connect(server)
>   conn = super
>   log_info("Creating new connection #{conn.object_id}")
>   conn
> end
>
> Thanks,
> Jeremy

I just applied connection_validator and set connection_validation_timeout to -1,
along with a middleware doing DB.synchronize around app.call as the document
suggests, and report if there's a disconnection along with call stack.

The result was a bit surprising, that the validation with `SELECT NULL` always
passed, and the disconnections happened on a specific query. Well, but only on
production and only after a few seconds or minutes after the server restarted.
After a burst of disconnections, everything went back to normal.

Here's some code snippets to show the context, and note that this is not the
exact code on production because it's simplified.

    aid = 1
    # This is fine:
    ids = B.where(aid => Sequel.pg_array_op(:a_ids).any).select_map(:id)
    # Then we disconnect on:
    C.where(:id => ids).eager(:d).all

This might not be the only query which would disconnect, I did see some other
would fail before, but this time it all happened on that line. I'll
keep monitoring
and report if I have further information.

At least I could restart the server without too much fear now :P

Cheers,

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to