bdb: txn.abort/txn.commit immediately exits the txn_begin block

Discussion in 'Ruby' started by Yohanes Santoso, Sep 29, 2003.

  1. Executing txn.abort/txn.commit within a txn_begin block immediately
    exits the block.

    Is this the expected behaviour? If so, then it means not all the code
    in the ensure block is executed, as guaranteed.


    ruby 1.8, bdb 0.4.8, libdb4.1

    --------------------------------------------------
    require 'bdb41'
    db = BDB::Env.new("testdb", BDB::CREATE|BDB::INIT_TRANSACTION|BDB::THREAD)
    table = db.open_db(BDB::BTREE, "test", nil, BDB::CREATE)
    db.txn_begin(table) {|txn, t|
    begin
    t[234]='sdfds'
    rescue Exception => e
    p e
    ensure
    puts "Aborting trans..."
    txn.abort # txn.commit also produces the same result
    puts "Trans aborted."
    end
    }
    puts "Test DONE"
    --------------------------------------------------

    produces:

    $ ruby1.8 storage_test.rb
    Aborting trans...
    Test DONE



    YS.
    Yohanes Santoso, Sep 29, 2003
    #1
    1. Advertising

  2. Yohanes Santoso

    ts Guest

    >>>>> "Y" == Yohanes Santoso <> writes:

    Y> Is this the expected behaviour?

    Yes, it's implemented internally with catch/throw


    Guy Decoux
    ts, Sep 29, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ahn Ki-yung

    ANN: BDB++ 0.99b released

    Ahn Ki-yung, May 6, 2004, in forum: C++
    Replies:
    1
    Views:
    600
    Volker Lukas
    May 6, 2004
  2. Ahn Ki-yung

    ANN: BDB++ 1.0 release

    Ahn Ki-yung, Jan 26, 2005, in forum: C++
    Replies:
    0
    Views:
    322
    Ahn Ki-yung
    Jan 26, 2005
  3. Replies:
    0
    Views:
    386
  4. morrell
    Replies:
    1
    Views:
    936
    roy axenov
    Oct 10, 2006
  5. Lou Pecora
    Replies:
    6
    Views:
    523
    Lou Pecora
    Mar 17, 2009
Loading...

Share This Page