On Tuesday, June 20, 2017 at 12:40:43 PM UTC-7, Mark Allen wrote:
>
> Hello, I'm getting race conditions which seems to be caused by read
> replicas. Is there a way to configure Sequel to always use the master
> server inside a DB.transaction block? I know there exists DB.with_server,
> but I'm hoping to avoid updating our entire codebase, and having to
> remember to DB.with_server every time in the future.
>
> I believe this is what's happening:
>
> DB.transaction do
> u = User.create
> u2 = User[u.id] # Record not found.
> end
>
> Maybe I am doing something else wrong.
>
> Thanks!
> -Mark
>
I think you could do something like:
def DB.transaction(opts={})
with_server(opts[:server]||:default){super}
end
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.