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 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674
|
# See the file LICENSE for redistribution information.
#
# Copyright (c) 2009, 2013 Oracle and/or its affiliates. All rights reserved.
#
# $Id$
#
# TEST env017
# TEST Check documented "stat" fields against the fields
# TEST returned by the "stat" functions. Make sure they
# TEST match, and that none are missing.
# TEST These are the stat functions we test:
# TEST env log_stat
# TEST env lock_stat
# TEST env txn_stat
# TEST env mutex_stat
# TEST env rep_stat
# TEST env repmgr_stat
# TEST env mpool_stat
# TEST db stat
# TEST seq stat
# TEST db compact_stat
proc env017 { } {
puts "\nEnv017: Check the integrity of the various stat"
env017_log_stat
env017_lock_stat
env017_txn_stat
env017_mutex_stat
env017_rep_stat
env017_repmgr_stat
env017_mpool_stat
env017_db_stat
env017_seq_stat
env017_compact_stat
}
# Check the log stat field.
proc env017_log_stat { } {
puts "\nEnv017: Check the Log stat field"
set check_type log_stat_check
set stat_method log_stat
set envargs {-create -log}
set map_list {
{ "Magic" st_magic }
{ "Log file Version" st_version }
{ "Region size" st_regsize }
{ "Log file mode" st_mode }
{ "Log record cache size" st_lg_bsize }
{ "Current log file size" st_lg_size }
{ "Initial fileid allocation" st_fileid_init }
{ "Current fileids in use" st_nfileid }
{ "Maximum fileids ever used" st_maxnfileid }
{ "Log file records written" st_record }
{ "Mbytes written" st_w_mbytes }
{ "Bytes written (over Mb)" st_w_bytes }
{ "Mbytes written since checkpoint" st_wc_mbytes }
{ "Bytes written (over Mb) since checkpoint"
st_wc_bytes }
{ "Times log written" st_wcount }
{ "Times log written because cache filled up"
st_wcount_fill }
{ "Times log read from disk" st_rcount }
{ "Times log flushed to disk" st_scount }
{ "Current log file number" st_cur_file }
{ "Current log file offset" st_cur_offset }
{ "On-disk log file number" st_disk_file }
{ "On-disk log file offset" st_disk_offset }
{ "Max commits in a log flush" st_maxcommitperflush }
{ "Min commits in a log flush" st_mincommitperflush }
{ "Number of region lock waits" st_region_wait }
{ "Number of region lock nowaits" st_region_nowait }
}
set doc_list [list st_magic st_version st_mode st_lg_bsize st_lg_size \
st_fileid_init st_nfileid st_maxnfileid \
st_record st_w_mbytes st_w_bytes st_wc_mbytes st_wc_bytes \
st_wcount st_wcount_fill st_rcount st_scount st_cur_file \
st_cur_offset st_disk_file st_disk_offset st_maxcommitperflush \
st_mincommitperflush st_regsize st_region_wait st_region_nowait ]
env017_stat_check \
$map_list $doc_list $check_type $stat_method $envargs
}
# Check the lock stat field.
proc env017_lock_stat { } {
puts "\nEnv017: Check the lock stat field"
set check_type lock_stat_check
set stat_method lock_stat
set envargs {-create -lock}
set map_list {
{ "Region size" st_regsize }
{ "Last allocated locker ID" st_id }
{ "Current maximum unused locker ID" st_cur_maxid }
{ "Initial locks" st_initlocks }
{ "Allocated locks" st_locks }
{ "Maximum locks" st_maxlocks }
{ "Initial lockers" st_initlockers }
{ "Allocated lockers" st_lockers }
{ "Maximum lockers" st_maxlockers }
{ "Initial objects" st_initobjects }
{ "Allocated objects" st_objects }
{ "Maximum objects" st_maxobjects }
{ "Lock modes" st_nmodes }
{ "Number of lock table partitions" st_partitions }
{ "Size of object hash table" st_tablesize }
{ "Current number of locks" st_nlocks }
{ "Maximum number of locks so far" st_maxnlocks }
{ "Maximum number of locks in any hash bucket"
st_maxhlocks }
{ "Maximum number of lock steals for an empty partition"
st_locksteals }
{ "Maximum number lock steals in any partition"
st_maxlsteals }
{ "Current number of lockers" st_nlockers }
{ "Maximum number of lockers so far" st_maxnlockers }
{ "Current number of objects" st_nobjects }
{ "Maximum number of objects so far" st_maxnobjects }
{ "Maximum number of objects in any hash bucket"
st_maxhobjects }
{ "Maximum number of object steals for an empty partition"
st_objectsteals }
{ "Maximum number object steals in any partition"
st_maxosteals }
{ "Lock requests" st_nrequests }
{ "Lock releases" st_nreleases }
{ "Lock upgrades" st_nupgrade }
{ "Lock downgrades" st_ndowngrade }
{ "Number of conflicted locks for which we waited"
st_lock_wait }
{ "Number of conflicted locks for which we did not wait"
st_lock_nowait }
{ "Deadlocks detected" st_ndeadlocks }
{ "Number of region lock waits" st_region_wait }
{ "Number of region lock nowaits" st_region_nowait }
{ "Number of object allocation waits" st_objs_wait }
{ "Number of object allocation nowaits" st_objs_nowait }
{ "Number of locker allocation waits" st_lockers_wait }
{ "Number of locker allocation nowaits" st_lockers_nowait }
{ "Maximum hash bucket length" st_hash_len }
{ "Lock timeout value" st_locktimeout }
{ "Number of lock timeouts" st_nlocktimeouts }
{ "Transaction timeout value" st_txntimeout }
{ "Number of transaction timeouts" st_ntxntimeouts }
{ "Number lock partition mutex waits" st_part_wait }
{ "Number lock partition mutex nowaits" st_part_nowait }
{ "Maximum number waits on any lock partition mutex"
st_part_max_wait }
{ "Maximum number nowaits on any lock partition mutex"
st_part_max_nowait }
}
set doc_list [list st_id st_cur_maxid st_nmodes \
st_initlocks st_initlockers st_initobjects \
st_locks st_lockers st_objects \
st_maxlocks st_maxlockers st_maxobjects \
st_partitions st_tablesize st_nlocks st_maxnlocks \
st_maxhlocks st_locksteals st_maxlsteals st_nlockers \
st_maxnlockers st_nobjects st_maxnobjects st_maxhobjects \
st_objectsteals st_maxosteals st_nrequests st_nreleases st_nupgrade\
st_ndowngrade st_lock_wait st_lock_nowait st_ndeadlocks \
st_locktimeout st_nlocktimeouts st_txntimeout st_ntxntimeouts \
st_objs_wait st_objs_nowait st_lockers_wait st_lockers_nowait \
st_hash_len st_regsize st_part_wait st_part_nowait st_part_max_wait\
st_part_max_nowait st_region_wait st_region_nowait]
env017_stat_check \
$map_list $doc_list $check_type $stat_method $envargs
}
# Check the txn stat field.
proc env017_txn_stat { } {
puts "\nEnv017: Check the transaction stat field"
set check_type txn_stat_check
set stat_method txn_stat
set envargs {-create -txn}
set map_list {
{ "Region size" st_regsize }
{ "LSN of last checkpoint" st_last_ckp }
{ "Time of last checkpoint" st_time_ckp }
{ "Last txn ID allocated" st_last_txnid }
{ "Maximum txns" st_maxtxns }
{ "Initial txns" st_inittxns }
{ "Number aborted txns" st_naborts }
{ "Number txns begun" st_nbegins }
{ "Number committed txns" st_ncommits }
{ "Number active txns" st_nactive }
{ "Number of snapshot txns" st_nsnapshot }
{ "Number restored txns" st_nrestores }
{ "Maximum active txns" st_maxnactive }
{ "Maximum snapshot txns" st_maxnsnapshot }
{ "Number of region lock waits" st_region_wait }
{ "Number of region lock nowaits" st_region_nowait }
}
set doc_list [list st_last_ckp st_time_ckp st_last_txnid st_maxtxns \
st_inittxns st_nactive st_nsnapshot st_maxnactive st_maxnsnapshot \
st_nbegins st_naborts st_ncommits st_nrestores st_regsize \
st_region_wait st_region_nowait ]
env017_stat_check \
$map_list $doc_list $check_type $stat_method $envargs
}
#Check the mutex stat field.
proc env017_mutex_stat { } {
puts "\nEnv017: Check the mutex stat field"
set check_type mutex_stat_check
set stat_method mutex_stat
set envargs {-create}
set map_list {
{ "Mutex align" st_mutex_align }
{ "Mutex TAS spins" st_mutex_tas_spins }
{ "Initial mutex count" st_mutex_init }
{ "Mutex count" st_mutex_cnt }
{ "Mutex max" st_mutex_max }
{ "Free mutexes" st_mutex_free }
{ "Mutexes in use" st_mutex_inuse }
{ "Max in use" st_mutex_inuse_max }
{ "Mutex region size" st_regsize }
{ "Mutex region max" st_regmax }
{ "Number of region waits" st_region_wait }
{ "Number of region no waits" st_region_nowait }
}
set doc_list [list st_mutex_align st_mutex_tas_spins st_mutex_init \
st_mutex_cnt st_mutex_max st_mutex_free st_mutex_inuse \
st_mutex_inuse_max st_regsize st_regmax st_region_wait \
st_region_nowait ]
env017_stat_check \
$map_list $doc_list $check_type $stat_method $envargs
}
# Check the rep stat field.
proc env017_rep_stat { } {
puts "\nEnv017: Check the replication stat field"
set check_type rep_stat_check
set stat_method rep_stat
set envargs {-create -rep -log -txn}
set map_list {
{ "Role" st_status}
{ "Next LSN expected" st_next_lsn }
{ "First missed LSN" st_waiting_lsn }
{ "Maximum permanent LSN" st_max_perm_lsn }
{ "Bulk buffer fills" st_bulk_fills }
{ "Bulk buffer overflows" st_bulk_overflows }
{ "Bulk records stored" st_bulk_records }
{ "Bulk buffer transfers" st_bulk_transfers }
{ "Client service requests" st_client_svc_req }
{ "Client service req misses" st_client_svc_miss }
{ "Client rerequests" st_client_rerequests }
{ "Duplicate master conditions" st_dupmasters }
{ "Environment ID" st_env_id }
{ "Environment priority" st_env_priority }
{ "Generation number" st_gen }
{ "Election generation number" st_egen }
{ "Startup complete" st_startup_complete }
{ "Lease messages sent" st_lease_sends }
{ "Lease checks" st_lease_chk }
{ "Lease check invalid" st_lease_chk_misses }
{ "Lease check refresh" st_lease_chk_refresh }
{ "Duplicate log records received" st_log_duplicated }
{ "Current log records queued" st_log_queued }
{ "Maximum log records queued" st_log_queued_max }
{ "Total log records queued" st_log_queued_total }
{ "Log records received" st_log_records }
{ "Log records requested" st_log_requested }
{ "Master environment ID" st_master }
{ "Master changes" st_master_changes }
{ "Messages with bad generation number" st_msgs_badgen }
{ "Messages processed" st_msgs_processed }
{ "Messages ignored for recovery" st_msgs_recover }
{ "Message send failures" st_msgs_send_failures }
{ "Messages sent" st_msgs_sent }
{ "New site messages" st_newsites }
{ "Number of sites in replication group" st_nsites }
{ "Transmission limited" st_nthrottles }
{ "Outdated conditions" st_outdated }
{ "Transactions applied" st_txns_applied }
{ "Next page expected" st_next_pg }
{ "First missed page" st_waiting_pg }
{ "Duplicate pages received" st_pg_duplicated }
{ "Pages received" st_pg_records }
{ "Pages requested" st_pg_requested }
{ "Elections held" st_elections }
{ "Elections won" st_elections_won }
{ "Election phase" st_election_status }
{ "Election winner" st_election_cur_winner }
{ "Election winner generation number" st_election_gen }
{ "Election data generation number" st_election_datagen }
{ "Election max LSN" st_election_lsn }
{ "Election sites" st_election_nsites }
{ "Election nvotes" st_election_nvotes }
{ "Election priority" st_election_priority }
{ "Election tiebreaker" st_election_tiebreaker }
{ "Election votes" st_election_votes }
{ "Election seconds" st_election_sec }
{ "Election usecs" st_election_usec }
{ "Start-sync operations delayed"
st_startsync_delayed }
{ "Maximum lease seconds" st_max_lease_sec }
{ "Maximum lease usecs" st_max_lease_usec }
{ "File fail cleanups done" st_filefail_cleanups }
}
set doc_list [list st_bulk_fills st_bulk_overflows st_bulk_records \
st_bulk_transfers st_client_rerequests st_client_svc_miss \
st_client_svc_req st_dupmasters st_egen st_election_cur_winner \
st_election_gen st_election_datagen st_election_lsn st_election_nsites \
st_election_nvotes st_election_priority st_election_sec \
st_election_status st_election_tiebreaker st_election_usec \
st_election_votes st_elections st_elections_won st_env_id \
st_env_priority st_filefail_cleanups st_gen st_lease_sends \
st_lease_chk st_lease_chk_misses st_lease_chk_refresh \
st_log_duplicated \
st_log_queued st_log_queued_max st_log_queued_total st_log_records \
st_log_requested st_master st_master_changes st_max_lease_sec \
st_max_lease_usec st_max_perm_lsn st_msgs_badgen st_msgs_processed\
st_msgs_recover st_msgs_send_failures st_msgs_sent st_newsites \
st_next_lsn st_next_pg st_nsites st_nthrottles st_outdated \
st_pg_duplicated st_pg_records st_pg_requested \
st_startsync_delayed st_startup_complete st_status st_txns_applied\
st_waiting_lsn st_waiting_pg ]
env017_stat_check \
$map_list $doc_list $check_type $stat_method $envargs
}
# Check the repmgr stat field.
proc env017_repmgr_stat { } {
puts "\nEnv017: Check the repmgr stat field"
set check_type repmgr_stat_check
set stat_method repmgr_stat
set envargs {-create -txn -rep}
set map_list {
{ "Acknowledgement failures" st_perm_failed }
{ "Messages delayed" st_msgs_queued}
{ "Messages discarded" st_msgs_dropped}
{ "Connections dropped" st_connection_drop}
{ "Failed re-connects" st_connect_fail}
{ "Election threads" st_elect_threads}
{ "Max elect threads" st_max_elect_threads}
}
set doc_list [list st_perm_failed st_msgs_queued st_msgs_dropped \
st_connection_drop st_connect_fail st_elect_threads \
st_max_elect_threads ]
env017_stat_check \
$map_list $doc_list $check_type $stat_method $envargs
}
# Check the mpool stat field.
proc env017_mpool_stat { } {
puts "\nEnv017: Check the mpool stat field"
set check_type mpool_stat_check
set stat_method mpool_stat
set envargs {-create}
set map_list {
{ "Cache size (gbytes)" st_gbytes }
{ "Cache size (bytes)" st_bytes }
{ "Number of caches" st_ncache }
{ "Maximum number of caches" st_max_ncache }
{ "Region size" st_regsize }
{ "Region max" st_regmax }
{ "Maximum memory-mapped file size" st_mmapsize }
{ "Maximum open file descriptors" st_maxopenfd }
{ "Maximum sequential buffer writes" st_maxwrite }
{ "Sleep after writing maximum buffers" st_maxwrite_sleep }
{ "Pages mapped into address space" st_map }
{ "Cache hits" st_cache_hit }
{ "Cache misses" st_cache_miss }
{ "Pages created" st_page_create }
{ "Pages read in" st_page_in }
{ "Pages written" st_page_out }
{ "Clean page evictions" st_ro_evict }
{ "Dirty page evictions" st_rw_evict }
{ "Dirty pages trickled" st_page_trickle }
{ "Cached pages" st_pages }
{ "Cached clean pages" st_page_clean }
{ "Cached dirty pages" st_page_dirty }
{ "Hash buckets" st_hash_buckets }
{ "Mutexes for hash buckets" st_hash_mutexes }
{ "Default pagesize" st_pagesize }
{ "Hash lookups" st_hash_searches }
{ "Longest hash chain found" st_hash_longest }
{ "Hash elements examined" st_hash_examined }
{ "Number of hash bucket nowaits" st_hash_nowait }
{ "Number of hash bucket waits" st_hash_wait }
{ "Maximum number of hash bucket nowaits"
st_hash_max_nowait }
{ "Maximum number of hash bucket waits" st_hash_max_wait }
{ "Number of region lock nowaits" st_region_nowait }
{ "Number of region lock waits" st_region_wait }
{ "Buffers frozen" st_mvcc_frozen }
{ "Buffers thawed" st_mvcc_thawed }
{ "Frozen buffers freed" st_mvcc_freed }
{ "Page allocations" st_alloc }
{ "Buckets examined during allocation" st_alloc_buckets }
{ "Maximum buckets examined during allocation"
st_alloc_max_buckets }
{ "Pages examined during allocation" st_alloc_pages }
{ "Maximum pages examined during allocation"
st_alloc_max_pages }
{ "Threads waiting on buffer I/O" st_io_wait}
{ "Number of syncs interrupted" st_sync_interrupted}
}
set doc_list [list st_gbytes st_bytes st_ncache st_max_ncache \
st_regsize st_regmax st_mmapsize st_maxopenfd st_maxwrite \
st_maxwrite_sleep st_map st_cache_hit st_cache_miss \
st_page_create st_page_in st_page_out st_ro_evict st_rw_evict \
st_page_trickle st_pages st_page_clean st_page_dirty \
st_hash_buckets st_hash_mutexes st_pagesize st_hash_searches \
st_hash_longest st_hash_examined st_hash_nowait st_hash_wait \
st_hash_max_nowait st_hash_max_wait st_region_wait \
st_region_nowait st_mvcc_frozen st_mvcc_thawed st_mvcc_freed \
st_alloc st_alloc_buckets st_alloc_max_buckets st_alloc_pages \
st_alloc_max_pages st_io_wait st_sync_interrupted ]
env017_stat_check \
$map_list $doc_list $check_type $stat_method $envargs
}
# Check the db stat field.
proc env017_db_stat { } {
puts "\nEnv017: Check the db stat field"
set hash_map_list {
{ "Magic" hash_magic }
{ "Version" hash_version }
{ "Page size" hash_pagesize }
{ "Page count" hash_pagecnt }
{ "Number of keys" hash_nkeys }
{ "Number of records" hash_ndata }
{ "Fill factor" hash_ffactor }
{ "Buckets" hash_buckets }
{ "Free pages" hash_free }
{ "Bytes free" hash_bfree }
{ "Number of big pages" hash_bigpages }
{ "Big pages bytes free" hash_big_bfree }
{ "Overflow pages" hash_overflows }
{ "Overflow bytes free" hash_ovfl_free }
{ "Duplicate pages" hash_dup }
{ "Duplicate pages bytes free" hash_dup_free }
{ "Flags" flags }
}
set queue_map_list {
{ "Magic" qs_magic }
{ "Version" qs_version }
{ "Page size" qs_pagesize }
{ "Extent size" qs_extentsize }
{ "Number of keys" qs_nkeys }
{ "Number of records" qs_ndata }
{ "Record length" qs_re_len }
{ "Record pad" qs_re_pad }
{ "First record number" qs_first_recno }
{ "Last record number" qs_cur_recno }
{ "Number of pages" qs_pages }
{ "Bytes free" qs_pgfree}
{ "Flags" flags }
}
set btree_map_list {
{ "Magic" bt_magic }
{ "Version" bt_version }
{ "Number of keys" bt_nkeys }
{ "Number of records" bt_ndata }
{ "Minimum keys per page" bt_minkey }
{ "Fixed record length" bt_re_len }
{ "Record pad" bt_re_pad }
{ "Page size" bt_pagesize }
{ "Page count" bt_pagecnt }
{ "Levels" bt_levels }
{ "Internal pages" bt_int_pg }
{ "Leaf pages" bt_leaf_pg }
{ "Duplicate pages" bt_dup_pg }
{ "Overflow pages" bt_over_pg }
{ "Empty pages" bt_empty_pg }
{ "Pages on freelist" bt_free }
{ "Internal pages bytes free" bt_int_pgfree }
{ "Leaf pages bytes free" bt_leaf_pgfree }
{ "Duplicate pages bytes free" bt_dup_pgfree }
{ "Bytes free in overflow pages" bt_over_pgfree }
{ "Flags" flags }
}
set hash_doc_list [list hash_magic hash_version hash_nkeys hash_ndata \
hash_pagecnt hash_pagesize hash_ffactor hash_buckets hash_free \
hash_bfree hash_bigpages hash_big_bfree hash_overflows \
hash_ovfl_free hash_dup hash_dup_free flags]
set btree_doc_list [list bt_magic bt_version bt_nkeys bt_ndata \
bt_pagecnt bt_pagesize bt_minkey bt_re_len bt_re_pad bt_levels \
bt_int_pg bt_leaf_pg bt_dup_pg bt_over_pg bt_empty_pg bt_free \
bt_int_pgfree bt_leaf_pgfree bt_dup_pgfree bt_over_pgfree flags ]
set queue_doc_list [list qs_magic qs_version qs_nkeys qs_ndata \
qs_pagesize qs_extentsize qs_pages qs_re_len qs_re_pad qs_pgfree \
qs_first_recno qs_cur_recno flags ]
# Check the hash db stat field.
puts "\tEnv017: Check the hash db stat"
env017_dbstat_check \
$hash_map_list $hash_doc_list {hash_db_stat_check} {-create -hash}
# Check the queue db stat field.
puts "\tEnv017: Check the queue db stat"
env017_dbstat_check \
$queue_map_list $queue_doc_list {queue_db_stat_check} \
{-create -queue}
# Check the btree/recno db stat field.
puts "\tEnv017: Check the btree/recno db stat"
env017_dbstat_check \
$btree_map_list $btree_doc_list {btree_db_stat_check} \
{-create -btree}
}
# Check the sequence stat field.
proc env017_seq_stat { } {
puts "\nEnv017: Check the sequence stat field"
source ./include.tcl
env_cleanup $testdir
set file1 db1.db
set db1 [berkdb open -create -btree $testdir/$file1]
error_check_good is_valid_db [is_valid_db $db1] TRUE
set seq [berkdb sequence -create -min 0 -max 1024768 $db1 seq_key1]
error_check_good is_valid_seq [is_valid_seq $seq] TRUE
set stat_list [$seq stat]
set map_list {
{ "Wait" st_wait }
{ "No wait" st_nowait }
{ "Current" st_current }
{ "Cached" st_value }
{ "Max Cached" st_last_value }
{ "Min" st_min }
{ "Max" st_max }
{ "Cache size" st_cache_size}
{ "Flags" st_flags}
}
set doc_list [list st_wait st_nowait st_current st_value \
st_last_value st_min st_max st_cache_size st_flags]
env017_do_check $map_list $stat_list $doc_list {seq_stat}
error_check_good "$seq close" [$seq close] 0
error_check_good "$db1 close" [$db1 close] 0
}
# Check the compact stat field.
proc env017_compact_stat { } {
puts "\nEnv017: Check the compact stat field"
source ./include.tcl
env_cleanup $testdir
set file1 db1.db
set db1 [berkdb open -create -btree $testdir/$file1]
error_check_good is_valid_db [is_valid_db $db1] TRUE
set ret [catch {eval $db1 compact -freespace}]
error_check_good compact_ok $ret 0
set stat_list [$db1 compact_stat]
set map_list {
{ "Pages freed" compact_pages_free }
{ "Pages truncated" compact_pages_truncated }
{ "Pages examined" compact_pages_examine }
{ "Levels removed" compact_levels }
{ "Deadlocks encountered" compact_deadlock }
{ "Empty buckets" compact_empty_buckets }
}
set doc_list [list compact_pages_free compact_pages_truncated \
compact_pages_examine compact_levels compact_deadlock \
compact_empty_buckets]
env017_do_check $map_list $stat_list $doc_list {compact_stat}
error_check_good "$db1 close" [$db1 close] 0
}
# This is common proc for the stat method called by env handle.
proc env017_stat_check { map_list doc_list check_type stat_method \
{envargs {}} } {
source ./include.tcl
set extopts {
{""}
{"-thread"}
{"-private" {"mutex_stat" "requires.*mutex.*subsystem"}}
{"-thread -private"}
}
foreach extopt $extopts {
set extarg [lindex $extopt 0]
set failmsg ""
set fail 0
if {[llength $extopt] > 1} {
set len [llength $extopt]
for {set i 1} {$i < $len} {incr i} {
set item [lindex $extopt $i]
set stat [lindex $item 0]
if {$stat == $stat_method} {
set failmsg [lindex $item 1]
set fail 1
break
}
}
}
env_cleanup $testdir
puts "\tEnv017: Check DB_ENV->$stat_method ($envargs $extarg)"
set env [eval berkdb_env_noerr $extarg $envargs -home $testdir]
error_check_good is_valid_env [is_valid_env $env] TRUE
if {$fail == 0} {
set stat_list [$env $stat_method]
env017_do_check \
$map_list $stat_list $doc_list $check_type
} else {
set ret [catch {eval $env $stat_method} res]
error_check_bad $stat_method $ret 0
error_check_bad chk_err [regexp $failmsg $res] 0
}
error_check_good "$env close" [$env close] 0
}
}
# This is common proc for db stat.
proc env017_dbstat_check { map_list doc_list check_type {dbargs {}} } {
source ./include.tcl
env_cleanup $testdir
set filename "db1.db"
set db [eval berkdb_open_noerr $dbargs $testdir/$filename]
error_check_good is_valid_db [is_valid_db $db] TRUE
set stat_list [$db stat]
env017_do_check $map_list $stat_list $doc_list $check_type
error_check_good "$db close" [$db close] 0
}
# This proc does the actual checking job.
proc env017_do_check { map_list stat_list doc_list check_type } {
# Check if all the items in the stat_list have the corresponding
# item in doc_list.
foreach l $map_list {
set field_map([lindex $l 0]) [lindex $l 1]
}
puts "\tEnv017: Check from stat_list"
set res_stat_list {}
foreach item $stat_list {
puts "\t\tEnv017: Checking item [lindex $item 0]"
if {![info exists field_map([lindex $item 0])]} {
lappend res_stat_list [lindex $item 0]
continue
}
set cur_field $field_map([lindex $item 0])
if {[lsearch -exact $doc_list $cur_field] == -1} {
lappend res_stat_list [lindex $item 0]
}
}
if {[llength $res_stat_list]>0} {
puts -nonewline "FAIL: in stat_list of $check_type, "
puts "Mismatch Items: $res_stat_list"
}
# Check if all the items in the doc_list have the corresponding
# record in the stat_list.
foreach l $map_list {
set field_map([lindex $l 1]) [lindex $l 0]
}
set stat_field_list {}
foreach item $stat_list {
lappend stat_field_list [lindex $item 0]
}
set res_doc_list {}
puts "\tEnv017: Check from doc_list"
foreach item $doc_list {
puts "\t\tEnv017: Checking item [lindex $item 0]"
if {![info exists field_map([lindex $item 0])]} {
lappend res_doc_list [lindex $item 0]
continue
}
set cur_field $field_map([lindex $item 0])
if {[lsearch -exact $stat_field_list $cur_field] == -1} {
lappend res_doc_list [lindex $item 0]
}
}
if {[llength $res_doc_list]>0} {
puts -nonewline "FAIL: in doc_list of $check_type, "
puts "Mismatch Items: $res_doc_list"
}
}
|