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
|
# See the file LICENSE for redistribution information.
#
# Copyright (c) 2006, 2013 Oracle and/or its affiliates. All rights reserved.
#
# $Id$
#
# TEST rep062
# TEST Test of internal initialization where client has a different
# TEST kind of database than the master.
# TEST
# TEST Create a master of one type, and let the client catch up.
# TEST Close the client.
# TEST Remove the database on the master, and create a new
# TEST database of the same name but a different type.
# TEST Run the master ahead far enough that internal initialization
# TEST will be required on the reopen of the client.
# TEST Reopen the client and verify.
proc rep062 { method {tnum "062"} args } {
source ./include.tcl
global databases_in_memory
global repfiles_in_memory
global env_private
# This test uses different access methods internally.
# Called from outside, accept only btree.
if { $checking_valid_methods } {
set test_methods { btree }
return $test_methods
}
if { [is_btree $method] != 1 } {
puts "Skipping rep$tnum for method $method."
return
}
# This test needs to set its own pagesize.
set pgindex [lsearch -exact $args "-pagesize"]
if { $pgindex != -1 } {
puts "Rep$tnum: skipping for specific pagesizes"
return
}
set logsets [create_logsets 2]
# 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"
}
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.
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):\
Internal initialization with change in\
access method of database $msg $msg2 $msg3."
puts "Rep$tnum: Master logs are [lindex $l 0]"
puts "Rep$tnum: Client logs are [lindex $l 1]"
rep062_sub $method $tnum $l $r $args
}
}
}
proc rep062_sub { method tnum logset recargs largs } {
global testdir
global util_path
global passwd
global has_crypto
global encrypt
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 masterdir $testdir/MASTERDIR
set clientdir $testdir/CLIENTDIR
# Log size is small so we quickly create more than one.
# The documentation says that the log file must be at least
# four times the size of the in-memory log buffer.
set maxpg 16384
set log_max [expr $maxpg * 8]
set cache [expr $maxpg * 32]
set m_logtype [lindex $logset 0]
set c_logtype [lindex $logset 1]
# In-memory logs cannot be used with -txn nosync.
set m_logargs [adjust_logargs $m_logtype]
set c_logargs [adjust_logargs $c_logtype]
set m_txnargs [adjust_txnargs $m_logtype]
set c_txnargs [adjust_txnargs $c_logtype]
# Set up pairs of databases to test. The first element is whether
# to open an encrypted env, the second is the original database
# method and flags, the third is the replacement database and flags.
set pairlist {
{ 0 {btree ""} {hash ""} }
{ 0 {queueext "-pagesize 2048"} {queue ""} }
{ 0 {queueext ""} {btree ""} }
{ 0 {queue ""} {recno ""} }
{ 0 {hash ""} {queue ""} }
{ 0 {recno ""} {btree ""} }
{ 0 {hash ""} {queueext "-pagesize 16384"} }
{ 0 {queueext "-pagesize 2048"} {queueext "-pagesize 16384"} }
{ 0 {queueext "-pagesize 16384"} {queueext "-pagesize 2048"} }
{ 0 {queue ""} {queueext "-pagesize 16384"} }
{ 1 {btree ""} {btree "-encrypt"} }
{ 1 {btree "-encrypt"} {btree ""} }
{ 1 {queue ""} {queue "-encrypt"} }
{ 1 {queue "-encrypt"} {queue ""} }
}
foreach p $pairlist {
# Extract values from the list.
set encryptenv [lindex [lindex $p 0] 0]
set encryptmsg "clear"
if { $has_crypto == 0 && $encryptenv == 1 } {
continue
}
if { $encryptenv == 1 } {
set encryptmsg "encrypted"
}
set method1 [lindex [lindex $p 1] 0]
set method2 [lindex [lindex $p 2] 0]
if { $databases_in_memory } {
if { [is_queueext $method1] || [is_queueext $method2] } {
puts "Skipping this set for in-memory databases"
continue
}
}
env_cleanup $testdir
replsetup $testdir/MSGQUEUEDIR
file mkdir $masterdir
file mkdir $clientdir
set flags1 [lindex [lindex $p 1] 1]
set flags2 [lindex [lindex $p 2] 1]
puts "Rep$tnum: Testing with $encryptmsg env."
puts -nonewline "Rep$tnum: Replace [lindex $p 1] "
puts "database with [lindex $p 2] database."
# Set up flags for encryption if necessary.
set envflags ""
set enc ""
if { $encryptenv == 1 } {
set envflags "-encryptaes $passwd"
set enc " -P $passwd"
}
# Derive args for specified methods.
set args1 [convert_args $method1 ""]
set args2 [convert_args $method2 ""]
# Open a master.
repladd 1
set ma_envcmd "berkdb_env_noerr -create $m_txnargs \
$m_logargs -log_max $log_max $verbargs -errpfx MASTER \
-cachesize { 0 $cache 1 } $envflags $repmemargs \
$privargs \
-home $masterdir -rep_transport \[list 1 replsend\]"
set masterenv [eval $ma_envcmd $recargs -rep_master]
# Open a client.
repladd 2
set cl_envcmd "berkdb_env_noerr -create $c_txnargs \
$c_logargs -log_max $log_max $verbargs -errpfx CLIENT \
-cachesize { 0 $cache 1 } $envflags $repmemargs \
$privargs \
-home $clientdir -rep_transport \[list 2 replsend\]"
set clientenv [eval $cl_envcmd $recargs -rep_client]
# Bring the client online by processing the startup messages.
set envlist "{$masterenv 1} {$clientenv 2}"
process_msgs $envlist
# Clobber replication's 30-second anti-archive timer, which will have
# been started by client sync-up internal init, so that we can do a
# log_archive in a moment.
#
$masterenv test force noarchive_timeout
# Open two databases on the master - one to test different
# methods, one to advance the log, forcing internal
# initialization.
puts "\tRep$tnum.a: Open test database (it will change methods)."
if { $databases_in_memory } {
set testfile { "" "test.db" }
set testfile2 { "" "test2.db" }
} else {
set testfile "test.db"
set testfile2 "test2.db"
}
set omethod1 [convert_method $method1]
set db1 [eval {berkdb_open} -env $masterenv -auto_commit \
-create $omethod1 $flags1 $args1 -mode 0644 $testfile]
error_check_good db1open [is_valid_db $db1] TRUE
puts "\tRep$tnum.b: Open log-advance database."
set db2 [eval {berkdb_open} -env $masterenv -auto_commit \
-create $omethod1 $flags1 $args1 -mode 0644 $testfile2]
error_check_good db2open [is_valid_db $db2] TRUE
puts "\tRep$tnum.c: Add a few records to test db."
set nentries 10
set start 0
if { $encryptenv == 1 } {
set encrypt 1
}
eval rep_test $method1 \
$masterenv $db1 $nentries $start $start 0 $args1
incr start $nentries
process_msgs $envlist
# Close the database on the master, and if it's on-disk,
# remove it. Now create a new database of different type.
puts "\tRep$tnum.e: Remove test database."
error_check_good db1_close [$db1 close] 0
error_check_good db1_remove [eval {$masterenv dbremove} $testfile] 0
puts "\tRep$tnum.f: \
Create new test database; same name, different method."
set omethod2 [convert_method $method2]
set db1 [eval {berkdb_open} -env $masterenv -auto_commit \
-create $omethod2 $flags2 $args2 -mode 0644 $testfile]
error_check_good db1open [is_valid_db $db1] TRUE
# Create a gap requiring internal initialization. Run the
# master forward in the extra db.
set flags $enc
set dbhandle $db2
set cid 2
set niter 100
set start [push_master_ahead $omethod1 $masterenv $masterdir $m_logtype \
$clientenv $cid $dbhandle $start $niter $flags $args2]
puts "\tRep$tnum.i: Reopen client."
set clientenv [eval $cl_envcmd $recargs -rep_client]
error_check_good client_env [is_valid_env $clientenv] TRUE
set envlist "{$masterenv 1} {$clientenv 2}"
process_msgs $envlist 0 NONE err
puts "\tRep$tnum.j: Add a few records to cause initialization."
set entries 20
eval rep_test $method2 \
$masterenv $db1 $entries $start $start 0 $args2
incr start $entries
process_msgs $envlist 0 NONE err
puts "\tRep$tnum.k: Verify logs and databases"
# Make sure encryption value is correct.
if { $encryptenv == 1 } {
set encrypt 1
}
rep_verify $masterdir $masterenv $clientdir $clientenv 1 1 1
set testfile2 "test2.db"
rep_verify $masterdir $masterenv $clientdir $clientenv 1 1 1 $testfile2
# Check that logs are in-memory or on-disk as expected.
check_log_location $masterenv
check_log_location $clientenv
error_check_good db1_close [$db1 close] 0
error_check_good db2_close [$db2 close] 0
error_check_good masterenv_close [$masterenv close] 0
error_check_good clientenv_close [$clientenv close] 0
replclose $testdir/MSGQUEUEDIR
}
}
|