head	1.2;
access;
symbols
	RPM_4_2_1:1.1.1.5
	RPM_4_2:1.1.1.5
	RPM_4_1_1:1.1.1.5
	RPM_4_1:1.1.1.4
	RPM_4_0_5:1.1.1.3
	RPM_4_0_4:1.1.1.2
	RPM_4_0_3:1.1.1.1
	RPM:1.1.1;
locks; strict;
comment	@# @;


1.2
date	2008.01.02.09.58.58;	author rse;	state dead;
branches;
next	1.1;
commitid	z4cpSiAhOCXk5PLs;

1.1
date	2001.07.23.20.45.41;	author rse;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2001.07.23.20.45.41;	author rse;	state Exp;
branches;
next	1.1.1.2;

1.1.1.2
date	2002.01.08.01.45.28;	author rse;	state Exp;
branches;
next	1.1.1.3;

1.1.1.3
date	2003.01.18.13.49.10;	author rse;	state Exp;
branches;
next	1.1.1.4;

1.1.1.4
date	2001.10.15.03.47.28;	author rse;	state Exp;
branches;
next	1.1.1.5;

1.1.1.5
date	2003.01.18.14.05.14;	author rse;	state Exp;
branches;
next	;


desc
@@


1.2
log
@remove the ancient RPM 4.2.1 source tree copy
@
text
@# See the file LICENSE for redistribution information.
#
# Copyright (c) 1996, 1997, 1998, 1999, 2000
#	Sleepycat Software.  All rights reserved.
#
#	$Id: dead004.tcl,v 1.1 2001/07/23 20:45:41 rse Exp $
#
# Deadlock Test 4.
# This test is designed to make sure that we handle youngest and oldest
# deadlock detection even when the youngest and oldest transactions in the
# system are not involved in the deadlock (that is, we want to abort the
# youngest/oldest which is actually involved in the deadlock, not simply
# the youngest/oldest in the system).
# Since this is used for transaction systems, the locker ID is what we
# use to identify age (smaller number is older).
#
# The set up is that we have a total of 6 processes.  The oldest (locker 0)
# and the youngest (locker 5) simply acquire a lock, hold it for a long time
# and then release it.  The rest form a ring, obtaining lock N and requesting
# a lock on (N+1) mod 4.  The deadlock detector ought to pick locker 1 or 4
# to abort  and not 0 or 5.

proc dead004 { } {
	source ./include.tcl

	foreach a { o y } {
		puts "Dead004: Deadlock detector test -a $a"
		env_cleanup $testdir

		# Create the environment.
		puts "\tDead004.a: creating environment"
		set env [berkdb env -create -mode 0644 -lock -home $testdir]
		error_check_good lock_env:open [is_valid_env $env] TRUE
		error_check_good lock_env:close [$env close] 0

		set dpid [exec $util_path/db_deadlock -v -t 5 -a $a \
		    -h $testdir >& $testdir/dd.out &]

		set pidlist ""
		set procs 6

		foreach n $procs {

			sentinel_init

			# Fire off the tests
			puts "\tDead004: $n procs"
			for { set i 0 } { $i < $n } { incr i } {
				puts "$tclsh_path $test_path/wrap.tcl \
				    $testdir/dead004.log.$i \
				    ddoyscript.tcl $testdir $i $n $a"
				set p [exec $tclsh_path \
					$test_path/wrap.tcl \
					ddoyscript.tcl $testdir/dead004.log.$i \
					$testdir $i $n $a &]
				lappend pidlist $p
			}
			watch_procs 5

		}
		# Now check output
		set dead 0
		set clean 0
		set other 0
		for { set i 0 } { $i < $n } { incr i } {
			set did [open $testdir/dead004.log.$i]
			while { [gets $did val] != -1 } {
				switch $val {
					DEADLOCK { incr dead }
					1 { incr clean }
					default { incr other }
				}
			}
			close $did
		}
		puts "dead check..."
		dead_check oldyoung $n $dead $clean $other

		# Now verify that neither the oldest nor the
		# youngest were the deadlock.
		set did [open $testdir/dead004.log.0]
		error_check_bad file:young [gets $did val] -1
		error_check_good read:young $val 1
		close $did

		set did [open $testdir/dead004.log.[expr $procs - 1]]
		error_check_bad file:old [gets $did val] -1
		error_check_good read:old $val 1
		close $did

		exec $KILL $dpid

		# Windows needs files closed before deleting files,
		# so pause a little
		tclsleep 2
		fileremove -f $testdir/dd.out

		# Remove log files
		for { set i 0 } { $i < $n } { incr i } {
			fileremove -f $testdir/dead004.log.$i
		}
	}
}
@


1.1
log
@Initial revision
@
text
@d6 1
a6 1
#	$Id: dead004.tcl,v 11.2 2001/05/17 20:37:04 bostic Exp $
@


1.1.1.1
log
@Import: RPM 4.0.3
@
text
@@


1.1.1.2
log
@Import: RPM 4.0.4
@
text
@d6 1
a6 1
#	Id: dead004.tcl,v 11.6 2001/10/10 16:22:10 ubell Exp 
a24 2
	global lock_curid
	global lock_maxid
d34 1
a44 2
			set ret [$env lock_id_set $lock_curid $lock_maxid]
			error_check_good lock_id_set $ret 0
a48 1
				set locker [$env lock_id]
d51 1
a51 1
				    ddoyscript.tcl $testdir $locker $n $a $i"
d55 1
a55 1
					$testdir $locker $n $a $i &]
d77 1
a77 1
		dead_check oldyoung $n 0 $dead $clean $other
a101 1
		error_check_good lock_env:close [$env close] 0
@


1.1.1.3
log
@Import: RPM 4.0.5
@
text
@d3 1
a3 1
# Copyright (c) 1996-2002
d6 1
a6 1
# Id: dead004.tcl,v 11.11 2002/09/05 17:23:05 sandstro Exp 
d34 1
a34 1
		set env [berkdb_env -create -mode 0644 -lock -home $testdir]
d40 1
a45 1
			set pidlist ""
d62 1
a62 1
			watch_procs $pidlist 5
a79 2
		tclkill $dpid

d94 2
@


1.1.1.4
log
@Import: RPM 4.1
@
text
@d3 1
a3 1
# Copyright (c) 1996, 1997, 1998, 1999, 2000
d6 1
a6 1
#	Id: dead004.tcl,v 11.6 2001/10/10 16:22:10 ubell Exp 
d34 1
a34 1
		set env [berkdb env -create -mode 0644 -lock -home $testdir]
a39 1
		set pidlist ""
d45 1
d62 1
a62 1
			watch_procs 5
d80 2
a95 2

		exec $KILL $dpid
@


1.1.1.5
log
@Import: RPM 4.1.1
@
text
@d3 1
a3 1
# Copyright (c) 1996-2002
d6 1
a6 1
# Id: dead004.tcl,v 11.11 2002/09/05 17:23:05 sandstro Exp 
d34 1
a34 1
		set env [berkdb_env -create -mode 0644 -lock -home $testdir]
d40 1
a45 1
			set pidlist ""
d62 1
a62 1
			watch_procs $pidlist 5
a79 2
		tclkill $dpid

d94 2
@


