blob: 1f0639d5ee29285c7d774b181e4c991f7200b780 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
# See the file LICENSE for redistribution information.
#
# Copyright (c) 1996-2009 Oracle. All rights reserved.
#
# $Id$
#
# TEST log005
# TEST Check that log file sizes can change on the fly.
proc log005 { } {
# Skip the test for HP-UX, where we can't do the second
# env open.
global is_hp_test
if { $is_hp_test == 1 } {
puts "Log005: Skipping for HP-UX."
return
}
foreach inmem { 1 0 } {
log005_body $inmem
}
}
proc log005_body { inmem } {
source ./include.tcl
env_cleanup $testdir
puts -nonewline "Log005: Check that log file sizes can change"
if { $inmem == 0 } {
puts " (on-disk logging)."
} else {
puts " (in-memory logging)."
}
# Open the environment, set and check the log file size.
puts "\tLog005.a: open, set and check the log file size."
set logargs ""
if { $inmem == 1 } {
set lbuf [expr 1024 * 1024]
set logargs "-log_inmemory -log_buffer $lbuf"
}
set env [eval {berkdb_env} -create -home $testdir \
$logargs -log_max 1000000 -txn]
error_check_good envopen [is_valid_env $env] TRUE
set db [berkdb_open \
-env $env -create -mode 0644 -btree -auto_commit a.db]
error_check_good dbopen [is_valid_db $db] TRUE
# Get the current log file maximum.
set max [log005_stat $env "Current log file size"]
error_check_good max_set $max 1000000
# Reset the log file size using a second open, and make sure
# it changes.
puts "\tLog005.b: reset during open, check the log file size."
set envtmp [berkdb_env -home $testdir -log_max 900000 -txn]
error_check_good envtmp_open [is_valid_env $envtmp] TRUE
error_check_good envtmp_close [$envtmp close] 0
set tmp [log005_stat $env "Current log file size"]
error_check_good max_changed 900000 $tmp
puts "\tLog005.c: fill in the current log file size."
# Fill in the current log file.
set new_lsn 0
set data [repeat "a" 1024]
for { set i 1 } \
{ [log005_stat $env "Current log file number"] != 2 } \
{ incr i } {
set t [$env txn]
error_check_good txn [is_valid_txn $t $env] TRUE
set ret [$db put -txn $t $i $data]
error_check_good put $ret 0
error_check_good txn [$t commit] 0
set last_lsn $new_lsn
set new_lsn [log005_stat $env "Current log file offset"]
}
# The last LSN in the first file should be more than our new
# file size.
error_check_good "lsn check < 900000" [expr 900000 < $last_lsn] 1
# Close down the environment.
error_check_good db_close [$db close] 0
error_check_good env_close [$env close] 0
if { $inmem == 1 } {
puts "Log005: Skipping remainder of test for in-memory logging."
return
}
puts "\tLog005.d: check the log file size is unchanged after recovery."
# Open again, running recovery. Verify the log file size is as we
# left it.
set env [berkdb_env -create -home $testdir -recover -txn]
error_check_good env_open [is_valid_env $env] TRUE
set tmp [log005_stat $env "Current log file size"]
error_check_good after_recovery 900000 $tmp
error_check_good env_close [$env close] 0
}
# log005_stat --
# Return the current log statistics.
proc log005_stat { env s } {
set stat [$env log_stat]
foreach statpair $stat {
set statmsg [lindex $statpair 0]
set statval [lindex $statpair 1]
if {[is_substr $statmsg $s] != 0} {
return $statval
}
}
puts "FAIL: log005: stat string $s not found"
return 0
}
|