On Tuesday, January 3, 2017 at 8:12:44 PM UTC-8, melody wrote:
>
> Another question, since i wrapped my sql in a transaction, then it shoud
> guarantee the feature transaction implies.
>
It does guarantee that the block given will be run in a transaction on the
server you specify via the :server option (or the default server). It does
not effect which server is used for queries. As I already mentioned, you
need to use the server_block extension if you want to do that. It's fairly
simple to integrate the two to get the behavior you describe:
def DB.transaction(opts={}, &block)
with_server(opts[:server]||:default, &block)
end
> As mentioned above when didn't set default server, the select sql and sqls
> other then select sql go different shards,
>
And as I mentioned in response, that's the expected default behavior.
> I use postgres with default isolation level, aka read commited:
>
>> When a transaction uses this isolation level, a SELECT query (without a
>> FOR UPDATE/SHARE clause) sees only data committed before the query began;
>> it never sees either uncommitted data or changes committed during query
>> execution by concurrent transactions. In effect, a SELECT query sees a
>> snapshot of the database as of the instant the query begins to run.
>> However, SELECT does see the effects of previous updates executed within
>> its own transaction, even though they are not yet committed.
>
> Dose sequel provides the above features across shards? if not, why?
> thanks!
>
I answered this earlier, but let me rephrase in the hope that it is easier
to understand. Sequel's behavior is fairly simple in regards to shard
choosing. Unless you specify a shard, Sequel uses the read_only shard for
SELECT queries (anything that uses Dataset#fetch_rows), and the default
shard for all other queries. If you want to override the default server
for a given block of code, use the server_block extension.
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.