diff options
author | Jesse Morgan <jesse@jesterpm.net> | 2016-12-17 21:28:53 -0800 |
---|---|---|
committer | Jesse Morgan <jesse@jesterpm.net> | 2016-12-17 21:28:53 -0800 |
commit | 54df2afaa61c6a03cbb4a33c9b90fa572b6d07b8 (patch) | |
tree | 18147b92b969d25ffbe61935fb63035cac820dd0 /db-4.8.30/test/log008script.tcl |
Berkeley DB 4.8 with rust build script for linux.
Diffstat (limited to 'db-4.8.30/test/log008script.tcl')
-rw-r--r-- | db-4.8.30/test/log008script.tcl | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/db-4.8.30/test/log008script.tcl b/db-4.8.30/test/log008script.tcl new file mode 100644 index 0000000..bffa5e9 --- /dev/null +++ b/db-4.8.30/test/log008script.tcl @@ -0,0 +1,82 @@ +# See the file LICENSE for redistribution information. +# +# Copyright (c) 2005-2009 Oracle. All rights reserved. +# +# $Id$ +# +# Log008 script - dbreg_ckp and txn_ckp records spanning log files. +# +# Usage: log008script + +source ./include.tcl +set tnum "008" +set usage "log008script nhandles" + +# Verify usage +if { $argc != 1 } { + puts stderr "FAIL:[timestamp] Usage: $usage" + exit +} + +# Initialize arguments +set nhandles [ lindex $argv 0 ] + +# We make the log files small so it's likely that the +# records will end up in different files. +set maxbsize [expr 8 * 1024] +set maxfile [expr 32 * 1024] + +# Set up environment. +set envcmd "berkdb_env -create -txn -home $testdir \ + -log_buffer $maxbsize -log_max $maxfile" +set dbenv [eval $envcmd] +error_check_good dbenv [is_valid_env $dbenv] TRUE + +# Open a lot of database handles. +set filename TESTFILE +set handlelist {} +for { set i 0 } { $i < $nhandles } { incr i } { + set db [berkdb_open \ + -create -env $dbenv -auto_commit -btree $filename] + lappend handlelist $db +} + +# Fill log files, checking LSNs before and after a checkpoint, +# until we generate a case where the records span two log files. +set i 0 +while { 1 } { + set txn [$dbenv txn] + foreach handle $handlelist { + error_check_good \ + db_put [$handle put -txn $txn key.$i data.$i] 0 + incr i + } + error_check_good txn_commit [$txn commit] 0 + + # Find current LSN file number. + set filenum [stat_field $dbenv log_stat "Current log file number"] + + # Checkpoint. + error_check_good checkpoint [$dbenv txn_checkpoint] 0 + + # Find current LSN. + set newfilenum [stat_field $dbenv log_stat "Current log file number"] + if { [expr $newfilenum > $filenum] } { + break + } +} + +# Do one more transactional operation per fileid. +set txn [$dbenv txn] +foreach handle $handlelist { + error_check_good \ + db_put [$handle put -txn $txn key.$i data.$i] 0 + incr i +} +error_check_good txn_commit [$txn commit] 0 + +# Archive, deleting the log files we think we no longer need. +set stat [eval exec $util_path/db_archive -d -h $testdir] + +# Child is done. Exit, abandoning the env instead of closing it. +exit |