On Saturday, March 31, 2012 12:30:45 PM UTC-7, entropy wrote:
>
> Hi,
>
> I have an odd scenario where I need to update one table indicating the
> progress of a very large and long running transaction.
>
> What I have (is semi-pseudo-code) is something like:
>
> DB.transaction do # Super long running transaction
>     do_transactional_stuff
>     update_table_indicating_progress # This must happen outside of the
> transaction as an atomic update
>     do_transactional_stuff
>     update_table_indicating_progress # This must happen outside of the
> transaction as an atomic update
>     do_transactional_stuff
>     update_table_indicating_progress # This must happen outside of the
> transaction as an atomic update
> end
>
> Is this at all possible with Sequel?
>
> Thank you,
> Clive
>

Yes, using either a new thread (using the standard threaded connection 
pool):

  DB.transaction do # Super long running transaction
    do_transactional_stuff
    Thread.new{update_table_indicating_progress}.join
    do_transactional_stuff
    Thread.new{update_table_indicating_progress}.join
  end

or sharding:

  DB = Sequel.connect(..., :servers=>{:something=>{}})
  Sequel.extension :server_block
  DB.extend Sequel::ServerBlock
  DB.transaction do # Super long running transaction
    do_transactional_stuff
    with_server(:something){update_table_indicating_progress}
    do_transactional_stuff
    with_server(:something){update_table_indicating_progress}
  end

Jeremy

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/Lb0gSX8imwMJ.
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.

Reply via email to