diff options
Diffstat (limited to 'bdb/test/recd013.tcl')
-rw-r--r-- | bdb/test/recd013.tcl | 99 |
1 files changed, 71 insertions, 28 deletions
diff --git a/bdb/test/recd013.tcl b/bdb/test/recd013.tcl index d134d487f1e..e08654f34e0 100644 --- a/bdb/test/recd013.tcl +++ b/bdb/test/recd013.tcl @@ -1,22 +1,22 @@ # See the file LICENSE for redistribution information. # -# Copyright (c) 2000 +# Copyright (c) 2000-2002 # Sleepycat Software. All rights reserved. # -# $Id: recd013.tcl,v 11.10 2000/12/11 17:24:55 sue Exp $ +# $Id: recd013.tcl,v 11.18 2002/02/25 16:44:27 sandstro Exp $ # -# Recovery Test 13. -# Smoke test of aborted cursor adjustments. +# TEST recd013 +# TEST Test of cursor adjustment on child transaction aborts. [#2373] # # XXX # Other tests that cover more specific variants of the same issue # are in the access method tests for now. This is probably wrong; we # put this one here because they're closely based on and intertwined # with other, non-transactional cursor stability tests that are among -# the access method tests, and because we need at least one test to +# the access method tests, and because we need at least one test to # fit under recd and keep logtrack from complaining. We'll sort out the mess # later; the important thing, for now, is that everything that needs to gets -# tested. (This really shouldn't be under recd at all, since it doesn't +# tested. (This really shouldn't be under recd at all, since it doesn't # run recovery!) proc recd013 { method { nitems 100 } args } { source ./include.tcl @@ -48,11 +48,12 @@ proc recd013 { method { nitems 100 } args } { Create environment, database, and parent transaction." set flags "-create -txn -home $testdir" - set env_cmd "berkdb env $flags" + set env_cmd "berkdb_env $flags" set env [eval $env_cmd] error_check_good dbenv [is_valid_env $env] TRUE - set oflags "-env $env -create -mode 0644 -pagesize $pgsz $args $omethod" + set oflags \ + "-auto_commit -env $env -create -mode 0644 -pagesize $pgsz $args $omethod" set db [eval {berkdb_open} $oflags $testfile] error_check_good dbopen [is_valid_db $db] TRUE @@ -63,19 +64,44 @@ proc recd013 { method { nitems 100 } args } { for { set i 1 } { $i <= 2 * $nitems } { incr i 2 } { set key $keybase$i set data [chop_data $method $i$alphabet] + + # First, try to put the item in a child transaction, + # then abort and verify all the cursors we've done up until + # now. + set ctxn [$env txn -parent $txn] + error_check_good child_txn($i) [is_valid_txn $ctxn $env] TRUE + error_check_good fake_put($i) [$db put -txn $ctxn $key $data] 0 + error_check_good ctxn_abort($i) [$ctxn abort] 0 + for { set j 1 } { $j < $i } { incr j 2 } { + error_check_good dbc_get($j) [$dbc($j) get -current] \ + [list [list $keybase$j \ + [pad_data $method $j$alphabet]]] + } + + # Then put for real. error_check_good init_put($i) [$db put -txn $txn $key $data] 0 + + # Set a cursor of the parent txn to each item. + set dbc($i) [$db cursor -txn $txn] + error_check_good dbc_getset($i) \ + [$dbc($i) get -set $key] \ + [list [list $keybase$i [pad_data $method $i$alphabet]]] + + # And verify all the cursors, including the one we just + # created. + for { set j 1 } { $j <= $i } { incr j 2 } { + error_check_good dbc_get($j) [$dbc($j) get -current] \ + [list [list $keybase$j \ + [pad_data $method $j$alphabet]]] + } } - error_check_good init_txn_commit [$txn commit] 0 - # Create an initial txn; set a cursor of that txn to each item. - set txn [$env txn] - error_check_good txn [is_valid_txn $txn $env] TRUE + puts "\t\tRecd0$tnum.a.1: Verify cursor stability after init." for { set i 1 } { $i <= 2 * $nitems } { incr i 2 } { - set dbc($i) [$db cursor -txn $txn] - error_check_good dbc_getset($i) [$dbc($i) get -set $keybase$i] \ + error_check_good dbc_get($i) [$dbc($i) get -current] \ [list [list $keybase$i [pad_data $method $i$alphabet]]] } - + puts "\tRecd0$tnum.b: Put test." puts "\t\tRecd0$tnum.b.1: Put items." set ctxn [$env txn -parent $txn] @@ -99,7 +125,7 @@ proc recd013 { method { nitems 100 } args } { error_check_good curs_close [$curs close] 0 } } - + puts "\t\tRecd0$tnum.b.2: Verify cursor stability after abort." error_check_good ctxn_abort [$ctxn abort] 0 @@ -122,7 +148,7 @@ proc recd013 { method { nitems 100 } args } { error_check_good db_verify \ [verify_dir $testdir "\t\tRecd0$tnum.b.3: "] 0 - # Now put back all the even records, this time in the parent. + # Now put back all the even records, this time in the parent. # Commit and re-begin the transaction so we can abort and # get back to a nice full database. for { set i 2 } { $i <= 2 * $nitems } { incr i 2 } { @@ -135,9 +161,9 @@ proc recd013 { method { nitems 100 } args } { error_check_good txn [is_valid_txn $txn $env] TRUE # Delete test. Set a cursor to each record. Delete the even ones - # in the parent and check cursor stability. Then open a child + # in the parent and check cursor stability. Then open a child # transaction, and delete the odd ones. Verify that the database - # is empty + # is empty. puts "\tRecd0$tnum.c: Delete test." unset dbc @@ -149,8 +175,9 @@ proc recd013 { method { nitems 100 } args } { error_check_good dbc_getset($i) [$dbc($i) get -set $keybase$i] \ [list [list $keybase$i [pad_data $method $i$alphabet]]] } - - puts "\t\tRecd0$tnum.c.1: Delete even items in parent txn." + + puts "\t\tRecd0$tnum.c.1: Delete even items in child txn and abort." + if { [is_rrecno $method] != 1 } { set init 2 set bound [expr 2 * $nitems] @@ -162,9 +189,25 @@ proc recd013 { method { nitems 100 } args } { set bound [expr $nitems + 1] set step 1 } + + set ctxn [$env txn -parent $txn] for { set i $init } { $i <= $bound } { incr i $step } { - error_check_good del($i) [$db del -txn $txn $keybase$i] 0 + error_check_good del($i) [$db del -txn $ctxn $keybase$i] 0 } + error_check_good ctxn_abort [$ctxn abort] 0 + + # Verify that no items are deleted. + for { set i 1 } { $i <= 2 * $nitems } { incr i } { + error_check_good dbc_get($i) [$dbc($i) get -current] \ + [list [list $keybase$i [pad_data $method $i$alphabet]]] + } + + puts "\t\tRecd0$tnum.c.2: Delete even items in child txn and commit." + set ctxn [$env txn -parent $txn] + for { set i $init } { $i <= $bound } { incr i $step } { + error_check_good del($i) [$db del -txn $ctxn $keybase$i] 0 + } + error_check_good ctxn_commit [$ctxn commit] 0 # Verify that even items are deleted and odd items are not. for { set i 1 } { $i <= 2 * $nitems } { incr i 2 } { @@ -181,10 +224,10 @@ proc recd013 { method { nitems 100 } args } { [list [list "" ""]] } - puts "\t\tRecd0$tnum.c.2: Delete odd items in child txn." + puts "\t\tRecd0$tnum.c.3: Delete odd items in child txn." set ctxn [$env txn -parent $txn] - + for { set i 1 } { $i <= 2 * $nitems } { incr i 2 } { if { [is_rrecno $method] != 1 } { set j $i @@ -196,14 +239,14 @@ proc recd013 { method { nitems 100 } args } { } error_check_good del($i) [$db del -txn $ctxn $keybase$j] 0 } - + # Verify that everyone's deleted. for { set i 1 } { $i <= 2 * $nitems } { incr i } { error_check_good get_deleted($i) \ [llength [$db get -txn $ctxn $keybase$i]] 0 } - puts "\t\tRecd0$tnum.c.3: Verify cursor stability after abort." + puts "\t\tRecd0$tnum.c.4: Verify cursor stability after abort." error_check_good ctxn_abort [$ctxn abort] 0 # Verify that even items are deleted and odd items are not. @@ -229,7 +272,7 @@ proc recd013 { method { nitems 100 } args } { # Sync and verify. error_check_good db_sync [$db sync] 0 error_check_good db_verify \ - [verify_dir $testdir "\t\tRecd0$tnum.c.4: "] 0 + [verify_dir $testdir "\t\tRecd0$tnum.c.5: "] 0 puts "\tRecd0$tnum.d: Clean up." error_check_good txn_commit [$txn commit] 0 @@ -238,7 +281,7 @@ proc recd013 { method { nitems 100 } args } { error_check_good verify_dir \ [verify_dir $testdir "\t\tRecd0$tnum.d.1: "] 0 - if { $log_log_record_types == 1 } { + if { $log_log_record_types == 1 } { logtrack_read $testdir } } |