1
# See the file LICENSE for redistribution information.
3
# Copyright (c) 1996-2002
4
# Sleepycat Software. All rights reserved.
6
# $Id: txn005.tcl,v 11.35 2002/08/08 15:38:14 bostic Exp $
10
# TEST Test transaction ID wraparound and recovery.
17
puts "Txn005: Test transaction wraparound recovery"
19
# Open/create the txn region
20
puts "\tTxn005.a: Create environment"
21
set e [berkdb_env -create -txn -home $testdir]
22
error_check_good env_open [is_valid_env $e] TRUE
25
error_check_good txn1 [is_valid_txn $txn1 $e] TRUE
27
set db [berkdb_open -env $e -txn $txn1 -create -btree txn005.db]
28
error_check_good db [is_valid_db $db] TRUE
29
error_check_good txn1_commit [$txn1 commit] 0
31
puts "\tTxn005.b: Set txn ids"
32
error_check_good txn_id_set \
33
[$e txn_id_set [expr $txn_maxid - 1] $txn_maxid] 0
35
# txn2 and txn3 will require a wraparound txnid
37
error_check_good txn2 [is_valid_txn $txn2 $e] TRUE
39
error_check_good put [$db put -txn $txn2 "a" ""] 0
40
error_check_good txn2_commit [$txn2 commit] 0
42
error_check_good get_a [$db get "a"] "{a {}}"
44
error_check_good close [$db close] 0
47
error_check_good txn3 [is_valid_txn $txn3 $e] TRUE
49
set db [berkdb_open -env $e -txn $txn3 -btree txn005.db]
50
error_check_good db [is_valid_db $db] TRUE
52
error_check_good put2 [$db put -txn $txn3 "b" ""] 0
53
error_check_good sync [$db sync] 0
54
error_check_good txn3_abort [$txn3 abort] 0
55
error_check_good dbclose [$db close] 0
56
error_check_good eclose [$e close] 0
58
puts "\tTxn005.c: Run recovery"
59
set stat [catch {exec $util_path/db_recover -h $testdir -e -c} result]
61
error "FAIL: Recovery error: $result."
64
puts "\tTxn005.d: Check data"
65
set e [berkdb_env -txn -home $testdir]
66
error_check_good env_open [is_valid_env $e] TRUE
68
set db [berkdb_open -env $e -auto_commit -btree txn005.db]
69
error_check_good db [is_valid_db $db] TRUE
71
error_check_good get_a [$db get "a"] "{a {}}"
72
error_check_bad get_b [$db get "b"] "{b {}}"
73
error_check_good dbclose [$db close] 0
74
error_check_good eclose [$e close] 0