1# See the file LICENSE for redistribution information. 2# 3# Copyright (c) 2004,2008 Oracle. All rights reserved. 4# 5# $Id: rep032.tcl,v 12.17 2008/01/08 20:58:53 bostic Exp $ 6# 7# TEST rep032 8# TEST Test of log gap processing. 9# TEST 10# TEST One master, one client. 11# TEST Run rep_test. 12# TEST Run rep_test without sending messages to client. 13# TEST Make sure client missing the messages catches up properly. 14# 15proc rep032 { method { niter 200 } { tnum "032" } args } { 16 17 source ./include.tcl 18 if { $is_windows9x_test == 1 } { 19 puts "Skipping replication test on Win 9x platform." 20 return 21 } 22 23 # Valid for all access methods. 24 if { $checking_valid_methods } { 25 return "ALL" 26 } 27 28 set args [convert_args $method $args] 29 set logsets [create_logsets 2] 30 31 # Run the body of the test with and without recovery. 32 set opts { "" "bulk" } 33 foreach r $test_recopts { 34 foreach b $opts { 35 foreach l $logsets { 36 set logindex [lsearch -exact $l "in-memory"] 37 if { $r == "-recover" && $logindex != -1 } { 38 puts "Rep$tnum: Skipping\ 39 for in-memory logs with -recover." 40 continue 41 } 42 puts "Rep$tnum ($method $r $b $args):\ 43 Test of log gap processing." 44 puts "Rep$tnum: Master logs are [lindex $l 0]" 45 puts "Rep$tnum: Client logs are [lindex $l 1]" 46 rep032_sub $method $niter $tnum $l $r $b $args 47 } 48 } 49 } 50} 51 52proc rep032_sub { method niter tnum logset recargs opts largs } { 53 global testdir 54 global util_path 55 global rep_verbose 56 global verbose_type 57 58 set verbargs "" 59 if { $rep_verbose == 1 } { 60 set verbargs " -verbose {$verbose_type on} " 61 } 62 63 env_cleanup $testdir 64 65 replsetup $testdir/MSGQUEUEDIR 66 67 set masterdir $testdir/MASTERDIR 68 set clientdir $testdir/CLIENTDIR 69 70 file mkdir $masterdir 71 file mkdir $clientdir 72 73 set m_logtype [lindex $logset 0] 74 set c_logtype [lindex $logset 1] 75 76 # In-memory logs require a large log buffer, and cannot 77 # be used with -txn nosync. 78 set m_logargs [adjust_logargs $m_logtype] 79 set c_logargs [adjust_logargs $c_logtype] 80 set m_txnargs [adjust_txnargs $m_logtype] 81 set c_txnargs [adjust_txnargs $c_logtype] 82 83 # Open a master. 84 repladd 1 85 set ma_envcmd "berkdb_env_noerr -create $m_txnargs \ 86 $m_logargs $verbargs -home $masterdir -errpfx MASTER \ 87 -rep_transport \[list 1 replsend\]" 88 set masterenv [eval $ma_envcmd $recargs -rep_master] 89 if { $opts == "bulk" } { 90 error_check_good bulk [$masterenv rep_config {bulk on}] 0 91 } 92 93 # Open a client 94 repladd 2 95 set cl_envcmd "berkdb_env_noerr -create $c_txnargs \ 96 $c_logargs $verbargs -home $clientdir -errpfx CLIENT \ 97 -rep_transport \[list 2 replsend\]" 98 set clientenv [eval $cl_envcmd $recargs -rep_client] 99 100 # Bring the client online by processing the startup messages. 101 set envlist "{$masterenv 1} {$clientenv 2}" 102 process_msgs $envlist 103 104 # Run rep_test in the master (and update client). 105 puts "\tRep$tnum.a: Running rep_test in replicated env." 106 set start 0 107 eval rep_test $method $masterenv NULL $niter $start $start 0 0 $largs 108 incr start $niter 109 process_msgs $envlist 110 111 puts "\tRep$tnum.b: Check client processed everything properly." 112 set queued [stat_field $clientenv rep_stat "Maximum log records queued"] 113 set request1 [stat_field $clientenv rep_stat "Log records requested"] 114 error_check_good queued $queued 0 115 116 # Run rep_test in the master (don't update client). 117 # First run with dropping all client messages via replclear. 118 puts "\tRep$tnum.c: Running rep_test dropping client msgs." 119 eval rep_test $method $masterenv NULL $niter $start $start 0 0 $largs 120 incr start $niter 121 replclear 2 122 process_msgs $envlist 123 124 # 125 # Need new operations to force log gap processing to 126 # request missing pieces. 127 # 128 puts "\tRep$tnum.d: Running rep_test again replicated." 129 eval rep_test $method $masterenv NULL $niter $start $start 0 0 $largs 130 incr start $niter 131 process_msgs $envlist 132 133 puts "\tRep$tnum.e: Check we re-requested and had a backlog." 134 set queued [stat_field $clientenv rep_stat "Maximum log records queued"] 135 set request2 [stat_field $clientenv rep_stat "Log records requested"] 136 error_check_bad queued $queued 0 137 error_check_bad request $request1 $request2 138 139 puts "\tRep$tnum.f: Verify logs and databases" 140 # 141 # If doing bulk testing, turn it off now so that it forces us 142 # to flush anything currently in the bulk buffer. We need to 143 # do this because rep_test might have aborted a transaction on 144 # its last iteration and those log records would still be in 145 # the bulk buffer causing the log comparison to fail. 146 # 147 if { $opts == "bulk" } { 148 puts "\tRep$tnum.f.1: Turn off bulk transfers." 149 error_check_good bulk [$masterenv rep_config {bulk off}] 0 150 process_msgs $envlist 0 NONE err 151 } 152 153 # Check that master and client logs and dbs are identical. 154 rep_verify $masterdir $masterenv $clientdir $clientenv 155 156 set bulkxfer [stat_field $masterenv rep_stat "Bulk buffer transfers"] 157 if { $opts == "bulk" } { 158 error_check_bad bulkxferon $bulkxfer 0 159 } else { 160 error_check_good bulkxferoff $bulkxfer 0 161 } 162 163 check_log_location $masterenv 164 check_log_location $clientenv 165 166 error_check_good masterenv_close [$masterenv close] 0 167 error_check_good clientenv_close [$clientenv close] 0 168 replclose $testdir/MSGQUEUEDIR 169} 170