1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 1996-2002
4
# Sleepycat Software. All rights reserved.
9
# TEST Test txn id wrap-around and recovery.
10
proc recd019 { method {numid 50} args} {
13
global log_log_record_types
16
set orig_fixed_len $fixed_len
17
set opts [convert_args $method $args]
18
set omethod [convert_method $method]
20
puts "Recd019: $method txn id wrap-around test"
22
# Create the database and environment.
25
set testfile recd019.db
27
set flags "-create -txn -home $testdir"
29
puts "\tRecd019.a: creating environment"
30
set env_cmd "berkdb_env $flags"
31
set dbenv [eval $env_cmd]
32
error_check_good dbenv [is_valid_env $dbenv] TRUE
34
# Test txn wrapping. Force a txn_recycle msg.
36
set new_curid $txn_curid
37
set new_maxid [expr $new_curid + $numid]
38
error_check_good txn_id_set [$dbenv txn_id_set $new_curid $new_maxid] 0
41
# We need to create a database to get the pagesize (either
42
# the default or whatever might have been specified).
43
# Then remove it so we can compute fixed_len and create the
45
set oflags "-create $omethod -mode 0644 \
46
-env $dbenv $opts $testfile"
47
set db [eval {berkdb_open} $oflags]
48
error_check_good db_open [is_valid_db $db] TRUE
51
# Compute the fixed_len based on the pagesize being used.
52
# We want the fixed_len to be 1/4 the pagesize.
54
set pg [get_pagesize $stat]
55
error_check_bad get_pagesize $pg -1
56
set fixed_len [expr $pg / 4]
57
error_check_good db_close [$db close] 0
58
error_check_good dbremove [berkdb dbremove -env $dbenv $testfile] 0
60
# Convert the args again because fixed_len is now real.
61
# Create the databases and close the environment.
62
# cannot specify db truncate in txn protected env!!!
63
set opts [convert_args $method ""]
64
set omethod [convert_method $method]
65
set oflags "-create $omethod -mode 0644 \
66
-env $dbenv -auto_commit $opts $testfile"
67
set db [eval {berkdb_open} $oflags]
68
error_check_good db_open [is_valid_db $db] TRUE
71
# Force txn ids to wrap twice and then some.
73
set nument [expr $numid * 3 - 2]
74
puts "\tRecd019.b: Wrapping txn ids after $numid"
75
set file $testdir/$testfile.init
76
catch { file copy -force $testdir/$testfile $file} res
77
copy_extent_file $testdir $testfile init
78
for { set i 1 } { $i <= $nument } { incr i } {
79
# Use 'i' as key so method doesn't matter
85
error_check_good txn_begin [is_valid_txn $txn $dbenv] TRUE
86
error_check_good db_put \
87
[$db put -txn $txn $key [chop_data $method $data]] 0
88
error_check_good txn_commit [$txn commit] 0
90
error_check_good db_close [$db close] 0
91
set file $testdir/$testfile.afterop
92
catch { file copy -force $testdir/$testfile $file} res
93
copy_extent_file $testdir $testfile afterop
94
error_check_good env_close [$dbenv close] 0
96
# Keep track of the log types we've seen
97
if { $log_log_record_types == 1} {
98
logtrack_read $testdir
101
# Now, loop through and recover.
102
puts "\tRecd019.c: Run recovery (no-op)"
103
set ret [catch {exec $util_path/db_recover -h $testdir} r]
104
error_check_good db_recover $ret 0
106
puts "\tRecd019.d: Run recovery (initial file)"
107
set file $testdir/$testfile.init
108
catch { file copy -force $file $testdir/$testfile } res
109
move_file_extent $testdir $testfile init copy
111
set ret [catch {exec $util_path/db_recover -h $testdir} r]
112
error_check_good db_recover $ret 0
114
puts "\tRecd019.e: Run recovery (after file)"
115
set file $testdir/$testfile.afterop
116
catch { file copy -force $file $testdir/$testfile } res
117
move_file_extent $testdir $testfile afterop copy
119
set ret [catch {exec $util_path/db_recover -h $testdir} r]
120
error_check_good db_recover $ret 0