On Tue, Dec 8, 2020 at 3:44 PM Geff Hanoian <[email protected]> wrote:

> My goal is to have fault tolerance for read only queries with a Single
> Primary and multiple replicas.
>
> So to do that, I'm trying to use the connection validator (timeout = -1)
> with DB.synchronize in the rack middleware to limit the "SELECT NULL"
> queries to one per web request, as the docs state.  This worked very well
> when I just had a single primary defined.  However once I defined read only
> replicas, I get the following during a single web request on a replica:
>
> SELECT NULL
> MY QUERY1
> SELECT NULL
> MY QUERY2
>
> (oddly I get a SELECT NULL on the primary as well during the web request)
>
> I'm wrapping as follows:
>
>     DB.synchronize do
>       app.call(env)
>     end
>
> I feel like I'm crossing the streams and as we all know crossing the
> streams is bad. :)
>
> Any ideas?
>

It looks like something else is checking out a connection from the pool
even though you already have a connection checked out (separate
thread/shard maybe).  You probably want to start logging connection info
and use the caller_logging extension

DB.log_connection_info = true
DB.extension :caller_logging

This should hopefully help you find where the connections are coming from.

If you still need help, please post a minimal, self-contained, reproducible
example showing the problem.

Thanks,
Jeremy

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/CADGZSSdUiYtopA94ELnpBDGRH3%2BRPB039BpM0SLORifYNV6%2BBw%40mail.gmail.com.

Reply via email to