On Jan 11, 5:11 am, Elvis <[email protected]> wrote:
> Hi, folks!
>
> I have a connection to 2 servers with a single sharded pool. I want to
> run transaction with raw SQL on second server. How can I do it?
>
> When I run:
>
> conn.transaction(:server => :shard_2) do
> conn['SELECT pg_sleep(5)'].single_value
> end
>
> it creates 2 connections and run 'BEGIN; COMMIT;' in first connection
> and 'SELECT pg_sleep(5)' in second. Is this a bug and how it might be
> fixed?
This isn't a bug. The :server option for #transaction only affects
the transaction related code. You are still responsible for making
sure that each query in the transaction is sent to the same server (if
that's what you want). So you probably want:
conn.transaction(:server => :shard_2) do
conn['SELECT pg_sleep(5)'].server(:shard_2).single_value
end
Note that naming your Sequel::Database instance conn is bad style, as
conn is often used internally to reference to individual connection
objects.
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
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.