blob: a569f1238e201d3a8c5d25dfd17ad50f52501746 (
plain)
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
|
# See the file LICENSE for redistribution information.
#
# Copyright (c) 2001-2004
# Sleepycat Software. All rights reserved.
#
# $Id: rep019.tcl,v 11.7 2004/09/22 18:01:06 bostic Exp $
#
# TEST rep019
# TEST Replication and multiple clients at same LSN.
# TEST Have several clients at the same LSN. Run recovery at
# TEST different times. Declare a client master and after sync-up
# TEST verify all client logs are identical.
#
proc rep019 { method { nclients 3 } { tnum "019" } args } {
global mixed_mode_logging
# This test needs to use recovery, so mixed-mode testing
# isn't appropriate.
if { $mixed_mode_logging == 1 } {
puts "Rep$tnum: Skipping for mixed-mode logging."
return
}
set args [convert_args $method $args]
# Run the body of the test with and without recovery.
set recopts { "" "-recover" }
foreach r $recopts {
puts "Rep$tnum ($method $r):\
Replication and $nclients recovered clients in sync."
rep019_sub $method $nclients $tnum $r $args
}
}
proc rep019_sub { method nclients tnum recargs largs } {
global testdir
global util_path
set orig_tdir $testdir
env_cleanup $testdir
replsetup $testdir/MSGQUEUEDIR
set niter 100
set masterdir $testdir/MASTERDIR
file mkdir $masterdir
# Open a master.
repladd 1
set ma_envcmd "berkdb_env -create -txn nosync -lock_max 2500 \
-home $masterdir -rep_master -rep_transport \[list 1 replsend\]"
# set ma_envcmd "berkdb_env -create $m_txnargs -lock_max 2500 \
# -errpfx MASTER -verbose {rep on} \
# -home $masterdir -rep_master -rep_transport \[list 1 replsend\]"
set menv [eval $ma_envcmd $recargs]
error_check_good master_env [is_valid_env $menv] TRUE
for {set i 0} {$i < $nclients} {incr i} {
set clientdir($i) $testdir/CLIENTDIR.$i
file mkdir $clientdir($i)
set id($i) [expr 2 + $i]
repladd $id($i)
set cl_envcmd($i) "berkdb_env -create -txn nosync \
-lock_max 2500 -home $clientdir($i) \
-rep_client -rep_transport \[list $id($i) replsend\]"
# set cl_envcmd($i) "berkdb_env -create -txn nosync \
# -lock_max 2500 -home $clientdir($i) \
# -errpfx CLIENT$i -verbose {rep on} \
# -rep_client -rep_transport \[list $id($i) replsend\]"
set clenv($i) [eval $cl_envcmd($i) $recargs]
error_check_good client_env [is_valid_env $clenv($i)] TRUE
}
set testfile "test$tnum.db"
set omethod [convert_method $method]
set masterdb [eval {berkdb_open_noerr -env $menv -auto_commit \
-create -mode 0644} $largs $omethod $testfile]
error_check_good dbopen [is_valid_db $masterdb] TRUE
# Bring the clients online by processing the startup messages.
set envlist {}
lappend envlist "$menv 1"
for { set i 0 } { $i < $nclients } { incr i } {
lappend envlist "$clenv($i) $id($i)"
}
process_msgs $envlist
# Run a modified test001 in the master (and update clients).
puts "\tRep$tnum.a: Running test001 in replicated env."
eval rep_test $method $menv $masterdb $niter 0 0
process_msgs $envlist
error_check_good mdb_cl [$masterdb close] 0
# Process any close messages.
process_msgs $envlist
error_check_good menv_cl [$menv close] 0
puts "\tRep$tnum.b: Close all envs and run recovery in clients."
for {set i 0} {$i < $nclients} {incr i} {
error_check_good cl$i.close [$clenv($i) close] 0
set hargs($i) "-h $clientdir($i)"
}
foreach sleep {2 1 0} {
for {set i 0} {$i < $nclients} {incr i} {
set stat [catch {eval exec $util_path/db_recover \
$hargs($i)} result]
error_check_good stat $stat 0
#
# Need to sleep to make sure recovery's checkpoint
# records have different timestamps.
tclsleep $sleep
}
}
puts "\tRep$tnum.c: Reopen clients and declare one master."
for {set i 0} {$i < $nclients} {incr i} {
set clenv($i) [eval $cl_envcmd($i) $recargs]
error_check_good client_env [is_valid_env $clenv($i)] TRUE
}
error_check_good master0 [$clenv(0) rep_start -master] 0
puts "\tRep$tnum.d: Sync up with other clients."
while { 1 } {
set nproced 0
for {set i 0} {$i < $nclients} {incr i} {
incr nproced [replprocessqueue $clenv($i) $id($i)]
}
if { $nproced == 0 } {
break
}
}
puts "\tRep$tnum.e: Verify client logs match."
set i 0
error_check_good cl$i.close [$clenv($i) close] 0
set stat [catch {eval exec $util_path/db_printlog \
$hargs($i) >& $clientdir($i)/prlog} result]
#
# Note we start the loop at 1 here and compare against client0
# which became the master.
#
for {set i 1} {$i < $nclients} {incr i} {
error_check_good cl$i.close [$clenv($i) close] 0
fileremove -f $clientdir($i)/prlog
set stat [catch {eval exec $util_path/db_printlog \
$hargs($i) >> $clientdir($i)/prlog} result]
error_check_good stat_prlog $stat 0
error_check_good log_cmp(0,$i) \
[filecmp $clientdir(0)/prlog $clientdir($i)/prlog] 0
}
replclose $testdir/MSGQUEUEDIR
set testdir $orig_tdir
return
}
|