1# See the file LICENSE for redistribution information. 2# 3# Copyright (c)-2009 Oracle. All rights reserved. 4# 5# TEST repmgr029 6# TEST Repmgr combined with replication-unaware process at master. 7 8proc repmgr029 { } { 9 source ./include.tcl 10 11 set tnum "029" 12 puts "Repmgr$tnum: Replication-unaware process at master." 13 14 env_cleanup $testdir 15 set ports [available_ports 2] 16 foreach {mport cport} $ports {} 17 18 file mkdir [set mdir $testdir/MASTER] 19 file mkdir [set cdir $testdir/CLIENT] 20 21 puts "\tRepmgr$tnum.a: Set up simple master/client pair." 22 make_dbconfig $mdir [set dbconfig {{rep_set_nsites 3}}] 23 set cmds { 24 "home $mdir" 25 "local $mport" 26 "output $testdir/moutput" 27 "open_env" 28 "start master" 29 "open_db test.db" 30 "put k1 v1" 31 "put k2 v2" 32 } 33 set m [open_site_prog [subst $cmds]] 34 35 make_dbconfig $cdir $dbconfig 36 set cmds { 37 "home $cdir" 38 "local $cport" 39 "output $testdir/coutput" 40 "remote localhost $mport" 41 "open_env" 42 "start client" 43 } 44 set c [open_site_prog [subst $cmds]] 45 46 puts "\tRepmgr$tnum.b: Wait for client to finish start-up." 47 set cenv [berkdb_env -home $cdir] 48 await_startup_done $cenv 49 50 puts "\tRepmgr$tnum.c: Run checkpoint in a separate process." 51 exec $util_path/db_checkpoint -h $mdir -1 52 53 # Find out where the checkpoint record is. 54 # 55 set menv [berkdb_env -home $mdir] 56 set curs [$menv log_cursor] 57 set ckp_lsn1 [lindex [$curs get -last] 0] 58 59 puts "\tRepmgr$tnum.d: Write more log records at master." 60 puts $m "put k3 v3" 61 puts $m "put k4 v4" 62 puts $m "echo done" 63 gets $m 64 65 puts "\tRepmgr$tnum.e: Do another checkpoint." 66 exec $util_path/db_checkpoint -h $mdir -1 67 set ckp_lsn2 [lindex [$curs get -last] 0] 68 69 error_check_bad same_ckp_lsn $ckp_lsn2 $ckp_lsn1 70 71 # db_checkpoint could have produced perm failures, because it doesn't 72 # start repmgr explicitly. Instead repmgr starts up automatically, on 73 # the fly, by trapping the first transmitted log record that gets sent. 74 # This causes a connection to be initiated, but that may take some time, 75 # too much time for that first log record to be transmitted. This means 76 # the client will have to request retransmission of this log record 77 # "gap". 78 # 79 # So, pause for a moment, to let replication's gap measurement algorithm 80 # expire, and then send one more transaction from the master, so that 81 # the client is forced to request the gap if necessary. 82 # 83 set perm_failures "Acknowledgement failures" 84 set pfs1 [stat_field $menv repmgr_stat $perm_failures] 85 tclsleep 1 86 87 puts $m "put k5 v5" 88 puts $m "echo done" 89 gets $m 90 set pfs2 [stat_field $menv repmgr_stat $perm_failures] 91 92 # The last "put" operation shouldn't have resulted in any additional 93 # perm failures. 94 # 95 error_check_good perm_fail $pfs2 $pfs1 96 97 # Pause again to allow time for the request for retransmission to be 98 # fulfilled. 99 # 100 tclsleep 1 101 102 # At this point that both checkpoint operations should have been 103 # successfully replicated. Examine the client-side log at the expected 104 # LSNs. 105 # 106 puts "\tRepmgr$tnum.f: Examine client log." 107 foreach lsn [list $ckp_lsn1 $ckp_lsn2] { 108 set lsnarg [join $lsn /] 109 set listing [exec $util_path/db_printlog \ 110 -h $cdir -b $lsnarg -e $lsnarg] 111 112 set first_line [lindex [split $listing "\n"] 0] 113 error_check_good found_ckp \ 114 [string match "*__txn_ckp*" $first_line] 1 115 } 116 117 $curs close 118 $cenv close 119 $menv close 120 close $c 121 close $m 122} 123