blob: b308b72a6fea57a8d0b6b38d5c632e25be6fa3bf (
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
|
# See the file LICENSE for redistribution information.
#
# Copyright (c) 2005, 2015 Oracle and/or its affiliates. All rights reserved.
#
# $Id$
#
# Log008 script - dbreg_ckp and txn_ckp records spanning log files.
#
# Usage: log008script
source ./include.tcl
set tnum "008"
set usage "log008script nhandles"
# Verify usage
if { $argc != 1 } {
puts stderr "FAIL:[timestamp] Usage: $usage"
exit
}
# Initialize arguments
set nhandles [ lindex $argv 0 ]
# We make the log files small so it's likely that the
# records will end up in different files.
set maxbsize [expr 8 * 1024]
set maxfile [expr 32 * 1024]
# Set up environment.
set envcmd "berkdb_env -create -txn -home $testdir \
-log_buffer $maxbsize -log_max $maxfile"
set dbenv [eval $envcmd]
error_check_good dbenv [is_valid_env $dbenv] TRUE
# Open a lot of database handles.
set filename TESTFILE
set handlelist {}
for { set i 0 } { $i < $nhandles } { incr i } {
set db [berkdb_open \
-create -env $dbenv -auto_commit -btree $filename]
lappend handlelist $db
}
# Fill log files, checking LSNs before and after a checkpoint,
# until we generate a case where the records span two log files.
set i 0
while { 1 } {
set txn [$dbenv txn]
foreach handle $handlelist {
error_check_good \
db_put [$handle put -txn $txn key.$i data.$i] 0
incr i
}
error_check_good txn_commit [$txn commit] 0
# Find current LSN file number.
set filenum [stat_field $dbenv log_stat "Current log file number"]
# Checkpoint.
error_check_good checkpoint [$dbenv txn_checkpoint] 0
# Find current LSN.
set newfilenum [stat_field $dbenv log_stat "Current log file number"]
if { [expr $newfilenum > $filenum] } {
break
}
}
# Do one more transactional operation per fileid.
set txn [$dbenv txn]
foreach handle $handlelist {
error_check_good \
db_put [$handle put -txn $txn key.$i data.$i] 0
incr i
}
error_check_good txn_commit [$txn commit] 0
foreach handle $handlelist {
error_check_good db_close [$handle close] 0
}
# Archive, deleting the log files we think we no longer need.
# Flush first to be sure everything is on disk for db_archive.
$dbenv log_flush
error_check_good env_close [$dbenv close] 0
set stat [eval exec $util_path/db_archive -d -h $testdir]
# Child is done. Exit, abandoning the env instead of closing it.
exit
|