blob: 179ec007ff0e05841e1344f383a702ed33ddcabb (
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
# See the file LICENSE for redistribution information.
#
# Copyright (c) 2012, 2015 Oracle and/or its affiliates. All rights reserved.
#
# $Id$
#
# Multiple process mpool page extension tester.
# Usage: mpoolscript dir id op numiters
# dir: home directory.
# id: Unique identifier for this process.
# op: Operation to perform. EXTEND, OPEN, STAT
# numiters: Total number of iterations.
source ./include.tcl
source $test_path/test.tcl
source $test_path/testutils.tcl
set usage "mpoolscript dir id op numiters"
#
# We have 3 different types of procs that will run this script:
# STAT: runs mpool stats trying to detect non-multiple of
# pagesize situations.
# EXTEND: runs in a loop continually extending the file by
# writing a dirty page to the end.
# OPEN: runs in a loop continually opening/closing the mpool file.
# It is the open path that checks for non-multiple pagesize and
# sets the stat field.
#
# STAT proc:
# Runs in a loop that looks at the "Odd file size detected" stat.
# There is one of these procs running during the test. This proc
# controls the creation of the MARKER file for the other procs.
# This proc will run until it either reaches a maximum number of
# iterations or it detects the non-multiple pagesize situation.
proc mp6_stat { menv dir niters } {
set done 0
set count 1
while { $done == 0 } {
set odd [stat_field $menv mpool_stat "Odd file size detected"]
puts \
"STAT: $count of $niters iterations: Odd file size found $odd time(s)."
if { $odd != 0 || $count >= $niters } {
set done 1
puts "STAT: [timestamp] Open $dir/MARKER"
set marker [open $dir/MARKER a]
puts $marker DONE
if { $odd != 0 } {
puts "SUCCESS"
}
puts "STAT: [timestamp] close MARKER"
close $marker
} else {
tclsleep 1
incr count
}
}
puts \
"STAT: After $count of $niters iterations: Odd file size found $odd time(s)."
}
# EXTEND proc:
# This proc creates the mpool file and will run in a loop creating a new
# dirty page at the end of the mpool file, extending it each time.
# It runs until it sees the MARKER file created by the STAT proc.
proc mp6_extend { menv dir id pgsize } {
puts "EXTEND: Create file$id"
set mp [$menv mpool -create -mode 0644 -pagesize $pgsize file$id]
error_check_good memp_fopen [is_valid_mpool $mp $menv] TRUE
set pgno 0
while { [file exists $dir/MARKER] == 0 } {
set pg [$mp get -create -dirty $pgno]
$pg put
$mp fsync
incr pgno
set e [file exists $dir/MARKER]
if { [expr $pgno % 10] == 0 } {
puts "[timestamp] Wrote $pgno pages, $dir/MARKER $e"
}
}
puts "EXTEND: Done: Created $pgno pages"
$mp close
}
# OPEN proc:
# This proc open the mpool file and will run in a loop opening and closing
# the mpool file. The BDB open code detects the situation we're looking for.
# It runs until it sees the MARKER file created by the STAT proc.
proc mp6_open { menv dir id pgsize } {
set mark [file exists $dir/MARKER]
set myfile "file$id"
#
# First wait for the EXTEND process to create the file
#
puts "OPEN: Wait for $myfile to be created from EXTEND proc."
while { [file exists $dir/$myfile] == 0 } {
tclsleep 1
}
puts "OPEN: Open and close in a loop"
while { [file exists $dir/MARKER] == 0 } {
set mp [$menv mpool -pagesize $pgsize file$id]
$mp close
}
puts "OPEN: Done"
}
# Verify usage
if { $argc != 4 } {
puts stderr "FAIL:[timestamp] Usage: $usage"
puts $argc
exit
}
# Initialize arguments
set dir [lindex $argv 0]
set id [lindex $argv 1]
set op [lindex $argv 2]
set numiters [ lindex $argv 3 ]
# Give time for all processes to start up.
tclsleep 3
puts -nonewline "Beginning execution for $id: $op $dir $numiters"
flush stdout
set env_cmd {berkdb_env -lock -home $dir}
set menv [eval $env_cmd]
error_check_good env_open [is_valid_env $menv] TRUE
set pgsize [expr 64 * 1024]
if { $op == "STAT" } {
mp6_stat $menv $dir $numiters
} elseif { $op == "EXTEND" } {
mp6_extend $menv $dir $id $pgsize
} elseif { $op == "OPEN" } {
mp6_open $menv $dir $id $pgsize
} else {
error "Unknown op: $op"
}
# Close environment system
set r [$menv close]
error_check_good env_close $r 0
puts "[timestamp] $id Complete"
flush stdout
|