1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 1999-2002
4
# Sleepycat Software. All rights reserved.
9
# TEST This is a recovery test for testing running recovery while
10
# TEST recovery is already running. While bad things may or may not
11
# TEST happen, if recovery is then run properly, things should be correct.
12
proc recd016 { method args } {
15
set args [convert_args $method $args]
16
set omethod [convert_method $method]
18
puts "Recd016: $method ($args) simultaneous recovery test"
19
puts "Recd016: Skipping; waiting on SR #6277"
22
# Create the database and environment.
23
set testfile recd016.db
26
# For this test we create our database ahead of time so that we
27
# don't need to send methods and args to the script.
32
# Use a smaller log to make more files and slow down recovery.
36
set log_max [expr 256 * 1024]
44
# Since we are using txns, we need at least 1 lock per
45
# record (for queue). So set lock_max accordingly.
46
set lkmax [expr $nentries * 2]
48
puts "\tRecd016.a: Create environment and database"
49
set env_cmd "berkdb_env -create -log_max $log_max \
50
-lock_max $lkmax -txn -home $testdir"
51
set env [eval $env_cmd]
52
error_check_good dbenv [is_valid_env $env] TRUE
53
set db [eval {berkdb_open -create} \
54
$omethod -auto_commit -env $env $args $testfile]
55
error_check_good dbopen [is_valid_db $db] TRUE
59
if { [is_record_based $method] == 1 } {
60
set checkfunc recd016_recno.check
61
append gflags " -recno"
63
set checkfunc recd016.check
65
puts "\tRecd016.b: put/get loop"
66
# Here is the loop where we put and get each key/data pair
68
while { [gets $did str] != -1 && $count < $nentries } {
69
if { [is_record_based $method] == 1 } {
72
set key [expr $count + 1]
73
if { 0xffffffff > 0 && $key > 0xffffffff } {
74
set key [expr $key - 0x100000000]
76
if { $key == 0 || $key - 0xffffffff == 1 } {
80
set kvals($key) [pad_data $method $str]
83
set str [reverse $str]
86
# Start a transaction. Alternately abort and commit them.
87
# This will create a bigger log for recovery to collide.
91
{$db put} -txn $txn $pflags {$key [chop_data $method $str]}]
92
error_check_good put $ret 0
94
if {[expr $count % 2] == 0} {
96
error_check_good txn_commit $ret 0
97
set ret [eval {$db get} $gflags {$key}]
98
error_check_good commit_get \
99
$ret [list [list $key [pad_data $method $str]]]
102
error_check_good txn_abort $ret 0
103
set ret [eval {$db get} $gflags {$key}]
104
error_check_good abort_get [llength $ret] 0
111
error_check_good dbclose [$db close] 0
112
error_check_good envclose [$env close] 0
115
puts "\tRecd016.c: Start up $nrec recovery processes at once"
116
for {set i 0} {$i < $nrec} {incr i} {
117
set p [exec $util_path/db_recover -h $testdir -c &]
120
watch_procs $pidlist 5
122
# Now that they are all done run recovery correctly
123
puts "\tRecd016.d: Run recovery process"
124
set stat [catch {exec $util_path/db_recover -h $testdir -c} result]
126
error "FAIL: Recovery error: $result."
129
puts "\tRecd016.e: Open, dump and check database"
130
# Now compare the keys to see if they match the dictionary (or ints)
131
if { [is_record_based $method] == 1 } {
133
for {set i 1} {$i <= $nentries} {incr i} {
135
if { 0xffffffff > 0 && $j > 0xffffffff } {
136
set j [expr $j - 0x100000000]
147
filehead $nentries $dict $t2
150
file rename -force $t3 $t2
152
file rename -force $t3 $t4
153
fileextract $t2 $t4 $t3
154
file rename -force $t3 $t5
156
set env [eval $env_cmd]
157
error_check_good dbenv [is_valid_env $env] TRUE
159
open_and_dump_file $testfile $env $t1 $checkfunc \
160
dump_file_direction "-first" "-next"
162
error_check_good envclose [$env close] 0
164
error_check_good Recd016:diff($t5,$t3) \
167
set stat [catch {exec $util_path/db_printlog -h $testdir \
168
> $testdir/LOG } ret]
169
error_check_good db_printlog $stat 0
170
fileremove $testdir/LOG
173
# Check function for recd016; keys and data are identical
174
proc recd016.check { key data } {
175
error_check_good "key/data mismatch" $data [reverse $key]
178
proc recd016_recno.check { key data } {
181
error_check_good key"$key"_exists [info exists kvals($key)] 1
182
error_check_good "key/data mismatch, key $key" $data $kvals($key)