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

Y

Yohanes Santoso

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.
 
T

ts

Y> Is this the expected behaviour?

Yes, it's implemented internally with catch/throw


Guy Decoux
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,434
Messages
2,571,689
Members
48,796
Latest member
Greg L.

Latest Threads

Top