1# See the file LICENSE for redistribution information. 2# 3# Copyright (c) 2003,2008 Oracle. All rights reserved. 4# 5# $Id: rep040script.tcl,v 12.10 2008/01/08 20:58:53 bostic Exp $ 6# 7# Rep040 script - transaction concurrency with rep_start 8# 9# Repscript exists to call rep_start. The main script will immediately 10# start a transaction, do an operation, then sleep a long time before 11# commiting the transaction. We should be blocked on the transaction 12# when we call rep_start. The main process should sleep long enough 13# that we get a diagnostic message. 14# 15# Usage: repscript masterdir clientdir 16# masterdir: master env directory 17# clientdir: client env directory 18# 19source ./include.tcl 20source $test_path/test.tcl 21source $test_path/testutils.tcl 22source $test_path/reputils.tcl 23 24set usage "repscript masterdir" 25 26# Verify usage 27if { $argc != 1 } { 28 puts stderr "FAIL:[timestamp] Usage: $usage" 29 exit 30} 31 32# Initialize arguments 33set masterdir [ lindex $argv 0 ] 34 35# Join the queue env. We assume the rep test convention of 36# placing the messages in $testdir/MSGQUEUEDIR. 37set queueenv [eval berkdb_env -home $testdir/MSGQUEUEDIR] 38error_check_good script_qenv_open [is_valid_env $queueenv] TRUE 39 40# We need to set up our own machids. 41# Add 1 for master env id, and 2 for the clientenv id. 42repladd 1 43repladd 2 44 45# Join the master env. 46set ma_cmd "berkdb_env_noerr -home $masterdir \ 47 -errfile /dev/stderr -errpfx CHILD.MA \ 48 -txn -rep_master -rep_transport \[list 1 replsend\]" 49# set ma_cmd "berkdb_env_noerr -home $masterdir \ 50# -verbose {rep on} -errfile /dev/stderr -errpfx CHILD.MA \ 51# -txn -rep_master -rep_transport \[list 1 replsend\]" 52set masterenv [eval $ma_cmd] 53error_check_good script_menv_open [is_valid_env $masterenv] TRUE 54 55puts "Master open" 56# Downgrade while transaction is open 57error_check_good downgrade [$masterenv rep_start -client] 0 58 59tclsleep 10 60# Upgrade again 61error_check_good upgrade [$masterenv rep_start -master] 0 62# 63# Create a btree database now. 64# 65rep_test btree $masterenv NULL 10 0 0 0 66 67# Close the envs 68puts "Closing Masterenv $masterenv" 69error_check_good script_master_close [$masterenv close] 0 70puts "\tRepscript completed successfully" 71