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
|
# See the file LICENSE for redistribution information.
#
# Copyright (c) 2001, 2013 Oracle and/or its affiliates. All rights reserved.
#
# $Id$
#
# TEST rep047
# TEST Replication and log gap bulk transfers.
# TEST Set bulk transfer replication option.
# TEST Run test. Start a new client (to test ALL_REQ and bulk).
# TEST Run small test again. Clear messages for 1 client.
# TEST Run small test again to test LOG_REQ gap processing and bulk.
# TEST Process and verify on clients.
#
proc rep047 { method { nentries 200 } { tnum "047" } args } {
source ./include.tcl
global databases_in_memory
global repfiles_in_memory
global env_private
# Valid for all access methods.
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,
# and with and without cleaning. Skip recovery with in-memory
# logging - it doesn't make sense.
foreach r $test_recopts {
foreach l $logsets {
set logindex [lsearch -exact $l "in-memory"]
if { $r == "-recover" && $logindex != -1 } {
puts "Skipping rep$tnum for -recover\
with in-memory logs."
continue
}
puts "Rep$tnum ($method $r): Replication\
and resend bulk transfer $msg $msg2 $msg3."
puts "Rep$tnum: Master logs are [lindex $l 0]"
puts "Rep$tnum: Client logs are [lindex $l 1]"
puts "Rep$tnum: Client 2 logs are [lindex $l 2]"
rep047_sub $method $nentries $tnum $l $r $args
}
}
}
proc rep047_sub { method niter tnum logset recargs largs } {
global testdir
global util_path
global overflowword1 overflowword2
global databases_in_memory
global repfiles_in_memory
global env_private
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 overflowword1 "0"
set overflowword2 "0"
set orig_tdir $testdir
env_cleanup $testdir
replsetup $testdir/MSGQUEUEDIR
set masterdir $testdir/MASTERDIR
set clientdir $testdir/CLIENTDIR
set clientdir2 $testdir/CLIENTDIR2
file mkdir $masterdir
file mkdir $clientdir
file mkdir $clientdir2
set m_logtype [lindex $logset 0]
set c_logtype [lindex $logset 1]
set c2_logtype [lindex $logset 2]
# In-memory logs cannot be used with -txn nosync.
set m_logargs [adjust_logargs $m_logtype]
set c_logargs [adjust_logargs $c_logtype]
set c2_logargs [adjust_logargs $c2_logtype]
set m_txnargs [adjust_txnargs $m_logtype]
set c_txnargs [adjust_txnargs $c_logtype]
set c2_txnargs [adjust_txnargs $c2_logtype]
set in_memory_log \
[expr { $m_logtype == "in-memory" || $c_logtype == "in-memory" || \
$c2_logtype == "in-memory" }]
# If databases are in-memory we'll need a bigger cache.
set cacheargs ""
if { $databases_in_memory } {
set cachesize [expr 20 * (1024 * 1024)]
set cacheargs "-cachesize {0 $cachesize 1} "
}
# Open a master.
repladd 1
set ma_envcmd "berkdb_env -create $m_txnargs $m_logargs \
$verbargs -errpfx MASTER -home $masterdir $repmemargs \
$privargs \
$cacheargs -rep_master -rep_transport \[list 1 replsend\]"
set masterenv [eval $ma_envcmd $recargs]
error_check_good master_env [is_valid_env $masterenv] TRUE
# Open two clients.
repladd 2
set cl_envcmd "berkdb_env -create $c_txnargs $c_logargs \
$verbargs -errpfx CLIENT -home $clientdir $repmemargs \
$privargs \
$cacheargs -rep_client -rep_transport \[list 2 replsend\]"
set clientenv [eval $cl_envcmd $recargs]
error_check_good client_env [is_valid_env $clientenv] TRUE
repladd 3
set cl2_envcmd "berkdb_env -create $c2_txnargs $c2_logargs \
$verbargs -errpfx CLIENT2 -home $clientdir2 $repmemargs \
$privargs \
$cacheargs -rep_client -rep_transport \[list 3 replsend\]"
# Bring the client online by processing the startup messages.
set envlist "{$masterenv 1} {$clientenv 2}"
process_msgs $envlist
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 -env $masterenv -auto_commit \
-create -mode 0644} $largs $omethod $dbname]
error_check_good dbopen [is_valid_db $masterdb] TRUE
# Bring the client online by processing the startup messages.
set envlist "{$masterenv 1} {$clientenv 2}"
process_msgs $envlist
# Run a modified test001 in the master (and update clients).
puts "\tRep$tnum.b: Basic long running txn"
rep_test_bulk $method $masterenv $masterdb $niter 0 0 0
process_msgs $envlist
rep_verify $masterdir $masterenv\
$clientdir $clientenv $in_memory_log 1 1
# Clean up after rep_verify: remove the temporary "prlog" file. Now
# that a newly joining client uses internal init, when the master scans
# its directory for database files it complains about prlog not looking
# like a proper db. This is harmless, but it does put a distracting
# error message into the test output.
#
file delete $masterdir/prlog
puts "\tRep$tnum.c: Bring new client online"
replclear 3
set bulkxfer1 [stat_field $masterenv rep_stat "Bulk buffer transfers"]
set clientenv2 [eval $cl2_envcmd $recargs]
error_check_good client_env [is_valid_env $clientenv2] TRUE
set envlist "{$masterenv 1} {$clientenv 2} {$clientenv2 3}"
process_msgs $envlist
set bulkxfer2 [stat_field $masterenv rep_stat "Bulk buffer transfers"]
error_check_good xferstat [expr $bulkxfer2 > $bulkxfer1] 1
puts "\tRep$tnum.c.0: Take new client offline"
puts "\tRep$tnum.d: Run small test creating a log gap"
set skip $niter
set start $niter
set niter 10
rep_test_bulk $method $masterenv $masterdb $niter $start $skip 0
#
# Skip and clear messages for client 2.
#
replclear 3
set envlist "{$masterenv 1} {$clientenv 2}"
process_msgs $envlist
puts "\tRep$tnum.e: Bring new client online again"
set envlist "{$masterenv 1} {$clientenv 2} {$clientenv2 3}"
#
# Since we're relying on the client to detect a gap and request missing
# records, reset gap parameters to small values. Otherwise,
# "wait_recs" is still set at its maximum "high" value, due to this
# client having been through an internal init. Send a record to
# create a real gap and not an end-of-record stream pause.
#
$masterenv txn_checkpoint -force
$clientenv2 rep_request 4000 128000
process_msgs $envlist
tclsleep 1
set bulkrec1 [stat_field $masterenv rep_stat "Bulk records stored"]
set bulkxfer1 [stat_field $masterenv rep_stat "Bulk buffer transfers"]
set skip [expr $skip + $niter]
set start $skip
rep_test_bulk $method $masterenv $masterdb $niter $start $skip 0
process_msgs $envlist
#
# We know we added 2*$niter items to the database so there should be
# at least 2*$niter records stored to the log. Verify that
# when we brought client 2 online, we sent at least 2*$niter more
# records via bulk.
#
set bulkrec2 [stat_field $masterenv rep_stat "Bulk records stored"]
set bulkxfer2 [stat_field $masterenv rep_stat "Bulk buffer transfers"]
set recstat [expr $bulkrec2 > [expr $bulkrec1 + [expr 2 * $niter]]]
error_check_good recstat $recstat 1
error_check_good xferstat [expr $bulkxfer2 > $bulkxfer1] 1
# 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
rep_verify $masterdir $masterenv\
$clientdir $clientenv $in_memory_log 1 1
# Process messages again in case we are running with debug_rop.
process_msgs $envlist
rep_verify $masterdir $masterenv\
$clientdir2 $clientenv2 $in_memory_log 1 1
error_check_good dbclose [$masterdb close] 0
error_check_good mclose [$masterenv close] 0
error_check_good cclose [$clientenv close] 0
error_check_good c2close [$clientenv2 close] 0
replclose $testdir/MSGQUEUEDIR
}
|