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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354
|
# See the file LICENSE for redistribution information.
#
# Copyright (c) 2001, 2013 Oracle and/or its affiliates. All rights reserved.
#
# $Id$
#
# TEST rep046
# TEST Replication and basic bulk transfer.
# TEST Set bulk transfer replication option.
# TEST Run long txns on master and then commit. Process on client
# TEST and verify contents. Run a very long txn so that logging
# TEST must send the log. Process and verify on client.
#
proc rep046 { method { nentries 200 } { tnum "046" } args } {
source ./include.tcl
global databases_in_memory
global repfiles_in_memory
global env_private
if { $checking_valid_methods } {
return "ALL"
}
set args [convert_args $method $args]
set logsets [create_logsets 3]
# Set up for on-disk or in-memory databases.
set msg "using on-disk databases"
if { $databases_in_memory } {
set msg "using named in-memory databases"
if { [is_queueext $method] } {
puts -nonewline "Skipping rep$tnum for method "
puts "$method with named in-memory databases."
return
}
}
set msg2 "and on-disk replication files"
if { $repfiles_in_memory } {
set msg2 "and in-memory replication files"
}
set msg3 ""
if { $env_private } {
set msg3 "with private env"
}
# Run the body of the test with and without recovery.
set throttle { "throttle" "" }
foreach r $test_recopts {
foreach l $logsets {
set logindex [lsearch -exact $l "in-memory"]
if { $r == "-recover" && $logindex != -1 } {
puts "Skipping test with -recover for \
in-memory logs."
continue
}
foreach t $throttle {
puts "Rep$tnum ($method $r $t):\
Replication and bulk transfer\
$msg $msg2 $msg3."
puts "Rep$tnum: Master logs are [lindex $l 0]"
puts "Rep$tnum: Client 0 logs are [lindex $l 1]"
puts "Rep$tnum: Client 1 logs are [lindex $l 2]"
rep046_sub $method $nentries $tnum $l $r \
$t $args
}
}
}
}
proc rep046_sub { method niter tnum logset recargs throttle largs } {
global overflowword1
global overflowword2
global databases_in_memory
global repfiles_in_memory
global env_private
global testdir
global rep_verbose
global verbose_type
set verbargs ""
if { $rep_verbose == 1 } {
set verbargs " -verbose {$verbose_type on} "
}
set repmemargs ""
if { $repfiles_in_memory } {
set repmemargs "-rep_inmem_files "
}
set privargs ""
if { $env_private == 1 } {
set privargs " -private "
}
set orig_tdir $testdir
env_cleanup $testdir
replsetup $testdir/MSGQUEUEDIR
set masterdir $testdir/MASTERDIR
set clientdir $testdir/CLIENTDIR
file mkdir $masterdir
file mkdir $clientdir
set m_logtype [lindex $logset 0]
set c_logtype [lindex $logset 1]
set c2_logtype [lindex $logset 2]
set in_memory_log \
[expr { $m_logtype == "in-memory" || $c_logtype == "in-memory" || \
$c2_logtype == "in-memory" }]
# In-memory logs require a large log buffer, and can not
# be used with -txn nosync. Adjust the args for master
# and client.
# This test has a long transaction, allocate a larger log
# buffer for in-memory test.
set m_logargs [adjust_logargs $m_logtype [expr 60 * 1024 * 1024]]
set c_logargs [adjust_logargs $c_logtype [expr 60 * 1024 * 1024]]
set c2_logargs [adjust_logargs $c2_logtype [expr 60 * 1024 * 1024]]
set m_txnargs [adjust_txnargs $m_logtype]
set c_txnargs [adjust_txnargs $c_logtype]
set c2_txnargs [adjust_txnargs $c2_logtype]
# If replication files or databases are in-memory we'll need a bigger
# cache.
set cacheargs ""
set cacheadj 0
if { $repfiles_in_memory } {
set cacheadj [expr $cacheadj + 8]
}
if { $databases_in_memory } {
set cacheadj [expr $cacheadj + 20]
}
if { $repfiles_in_memory || $databases_in_memory } {
set cachesize [expr $cacheadj * (1024 * 1024)]
set cacheargs "-cachesize {0 $cachesize 1} "
}
set bigniter [expr 10000 - [expr 2 * $niter]]
set lkmax [expr $bigniter * 2]
# Open a master.
repladd 1
set ma_envcmd "berkdb_env_noerr -create $m_txnargs $m_logargs \
$repmemargs $cacheargs $privargs \
$verbargs -lock_max_locks 10000 -lock_max_objects 10000 \
-errpfx MASTER -home $masterdir -rep_master -rep_transport \
\[list 1 replsend\]"
set masterenv [eval $ma_envcmd $recargs]
error_check_good master_env [is_valid_env $masterenv] TRUE
repladd 2
set cl_envcmd "berkdb_env_noerr -create $c_txnargs $c_logargs \
$repmemargs $cacheargs $privargs \
$verbargs -home $clientdir -errpfx CLIENT \
-lock_max_locks 10000 -lock_max_objects 10000 \
-rep_client -rep_transport \[list 2 replsend\]"
set clientenv [eval $cl_envcmd $recargs]
if { $throttle == "throttle" } {
set clientdir2 $testdir/CLIENTDIR2
file mkdir $clientdir2
repladd 3
set cl2_envcmd "berkdb_env_noerr -create $c2_txnargs $verbargs \
$repmemargs $cacheargs $privargs \
$c2_logargs -home $clientdir2 -errpfx CLIENT2 \
-lock_max_locks 10000 -lock_max_objects 10000 \
-rep_client -rep_transport \[list 3 replsend\]"
set cl2env [eval $cl2_envcmd $recargs]
set envlist "{$masterenv 1} {$clientenv 2} {$cl2env 3}"
#
# Turn throttling on in master
#
error_check_good thr [$masterenv rep_limit 0 [expr 32 * 1024]] 0
} else {
set envlist "{$masterenv 1} {$clientenv 2}"
}
# Bring the client online by processing the startup messages.
process_msgs $envlist
#
# Turn on bulk processing now on the master.
#
error_check_good set_bulk [$masterenv rep_config {bulk on}] 0
puts "\tRep$tnum.a: Create and open master database"
# Set up databases as in-memory or on-disk.
if { $databases_in_memory } {
set dbname { "" "test.db" }
} else {
set dbname "test.db"
}
set omethod [convert_method $method]
set masterdb [eval {berkdb_open_noerr -env $masterenv -auto_commit \
-create -mode 0644} $largs $omethod $dbname]
error_check_good dbopen [is_valid_db $masterdb] TRUE
# Process database.
process_msgs $envlist
# Run a modified test001 in the master (and update clients).
puts "\tRep$tnum.b: Basic long running txn"
set bulkrec1 [stat_field $masterenv rep_stat "Bulk records stored"]
set bulkxfer1 [stat_field $masterenv rep_stat "Bulk buffer transfers"]
set overflowword1 "0"
set overflowword2 "0"
rep_test_bulk $method $masterenv $masterdb $niter 0 0
process_msgs $envlist
set bulkrec2 [stat_field $masterenv rep_stat "Bulk records stored"]
set bulkxfer2 [stat_field $masterenv rep_stat "Bulk buffer transfers"]
error_check_good recstat [expr $bulkrec2 > $bulkrec1] 1
error_check_good xferstat [expr $bulkxfer2 > $bulkxfer1] 1
rep_verify $masterdir $masterenv\
$clientdir $clientenv $in_memory_log 1 1
puts "\tRep$tnum.c: Very long txn"
# Determine whether this build is configured with --enable-debug_rop
# or --enable-debug_wop.
set conf [berkdb getconfig]
set debug_rop_wop 0
if { [is_substr $conf "debug_rop"] == 1 || \
[is_substr $conf "debug_wop"] == 1 } {
set debug_rop_wop 1
}
# If debug_rop/wop is set test will write more info to log.
# An in-memory log has a smaller "file" size than the large
# items written in this part of the test, so skip this section
# if any in-memory logs and debug_rop/wop is set.
if { $in_memory_log == 1 && $debug_rop_wop == 1 } {
puts "\t\tSkipping for in-memory log and debug_rop/wop"
} else {
set skip $niter
set start $niter
set orig $niter
set bulkfill1 [stat_field $masterenv rep_stat \
"Bulk buffer fills"]
rep_test_bulk $method $masterenv $masterdb $bigniter \
$start $skip
set start [expr $niter + $bigniter]
if { $throttle == "throttle" } {
#
# If we're throttling clear all messages from client 3
# so that we force a huge gap that the client will have
# to ask for to invoke a rerequest that throttles.
#
replclear 3
set old_thr \
[stat_field $masterenv rep_stat \
"Transmission limited"]
}
process_msgs $envlist
set bulkfill2 [stat_field $masterenv rep_stat \
"Bulk buffer fills"]
error_check_good fillstat [expr $bulkfill2 > $bulkfill1] 1
rep_verify $masterdir $masterenv $clientdir $clientenv \
$in_memory_log 1 1
}
puts "\tRep$tnum.d: Very large data"
# If debug_rop/wop is set test will write entire item to log.
# An in-memory log has a smaller "file" size than the large
# items written in this part of the test, so skip this section
# if any in-memory logs and debug_rop/wop is set.
if { $in_memory_log == 1 && $debug_rop_wop == 1 } {
puts "\t\tSkipping for in-memory log and debug_rop/wop"
} else {
set bulkovf1 [stat_field $masterenv rep_stat \
"Bulk buffer overflows"]
set bulkfill1 [stat_field $masterenv rep_stat \
"Bulk buffer fills"]
#
# Send in '2' exactly because we're sending in the flag to use
# the overflow entries. We have 2 overflow entries.
# If it's fixed length, we can't overflow. Induce throttling
# by putting in a bunch more entries. Create a gap by
# forcing a checkpoint record.
#
$masterenv txn_checkpoint -force
process_msgs $envlist
tclsleep 1
if { [is_fixed_length $method] == 1 } {
rep_test_bulk $method $masterenv $masterdb $niter \
$start $start 0
} else {
rep_test_bulk $method $masterenv $masterdb 2 0 0 1
}
process_msgs $envlist
# Generally overflows cannot happen because large data gets
# broken up into overflow pages, and none will be larger than
# the buffer. However, if we're configured for debug_rop/wop
# then we record the data as is and will overflow.
#
set bulkovf2 [stat_field $masterenv rep_stat \
"Bulk buffer overflows"]
set bulkfill2 [stat_field $masterenv rep_stat \
"Bulk buffer fills"]
if { [is_fixed_length $method] == 0 } {
error_check_good fillstat1 \
[expr $bulkfill2 > $bulkfill1] 1
if { $debug_rop_wop == 1 } {
error_check_good overflows \
[expr $bulkovf2 > $bulkovf1] 1
} else {
error_check_good no_overflows $bulkovf2 0
}
}
}
# !!!
# Turn off bulk processing now on the master. We need to do
# this because some configurations (like debug_rop/wop) will
# generate log records when verifying the logs and databases.
# We want to control processing those messages.
#
error_check_good set_bulk [$masterenv rep_config {bulk off}] 0
if { $in_memory_log == 1 && $debug_rop_wop == 1 } {
puts "\t\tSkipping for in-memory log and debug_rop/wop"
} else {
rep_verify $masterdir $masterenv $clientdir $clientenv \
$in_memory_log
if { $throttle == "throttle" } {
puts "\tRep$tnum.e: Verify throttling."
set new_thr \
[stat_field $masterenv rep_stat \
"Transmission limited"]
error_check_bad nthrottles1 $new_thr -1
error_check_bad nthrottles0 $new_thr 0
error_check_good nthrottles \
[expr $old_thr < $new_thr] 1
process_msgs $envlist
rep_verify $masterdir $masterenv $clientdir2 $cl2env \
$in_memory_log
}
}
if { $throttle == "throttle" } {
error_check_good cclose [$cl2env close] 0
}
error_check_good dbclose [$masterdb close] 0
error_check_good mclose [$masterenv close] 0
error_check_good cclose [$clientenv close] 0
replclose $testdir/MSGQUEUEDIR
}
|