1<!--$Id: txn_stat.so,v 10.68 2007/09/21 20:06:04 bostic Exp $--> 2<!--Copyright (c) 1997,2008 Oracle. All rights reserved.--> 3<!--See the file LICENSE for redistribution information.--> 4<html> 5<head> 6<title>Berkeley DB: DbEnv::txn_stat</title> 7<meta name="description" content="Berkeley DB: An embedded database programmatic toolkit."> 8<meta name="keywords" content="embedded,database,programmatic,toolkit,btree,hash,hashing,transaction,transactions,locking,logging,access method,access methods,Java,C,C++"> 9</head> 10<body bgcolor=white> 11<table width="100%"><tr valign=top> 12<td> 13<b>DbEnv::txn_stat</b> 14</td> 15<td align=right> 16<a href="/api_cxx/api_core.html"><img src="/images/api.gif" alt="API"></a> 17<a href="/ref/toc.html"><img src="/images/ref.gif" alt="Ref"></a></td> 18</tr></table> 19<hr size=1 noshade> 20<tt> 21<b><pre> 22#include <db_cxx.h> 23<p> 24int 25DbEnv::txn_stat(DB_TXN_STAT **statp, u_int32_t flags); 26<p> 27int 28DbEnv::txn_stat_print(u_int32_t flags); 29</pre></b> 30<hr size=1 noshade> 31<b>Description: DbEnv::txn_stat</b> 32<p>The DbEnv::txn_stat method returns the transaction subsystem statistics.</p> 33<p>The DbEnv::txn_stat method creates a statistical structure of type 34DB_TXN_STAT and copies a pointer to it into a user-specified memory 35location.</p> 36<p>Statistical structures are stored in allocated memory. If application-specific allocation 37routines have been declared (see <a href="/api_cxx/env_set_alloc.html">DbEnv::set_alloc</a> for more 38information), they are used to allocate the memory; otherwise, the 39standard C library <b>malloc</b>(3) is used. The caller is 40responsible for deallocating the memory. To deallocate the memory, free 41the memory reference; references inside the returned memory need not be 42individually freed.</p> 43<p>The following DB_TXN_STAT fields will be filled in:</p> 44<br> 45<b>DbLsn st_last_ckp;</b><ul compact><li>The LSN of the last checkpoint.</ul> 46<b>time_t st_time_ckp;</b><ul compact><li>The time the last completed checkpoint finished (as the number of seconds 47since the Epoch, returned by the IEEE/ANSI Std 1003.1 (POSIX) <b>time</b> function).</ul> 48<b>u_int32_t st_last_txnid;</b><ul compact><li>The last transaction ID allocated.</ul> 49<b>u_int32_t st_maxtxns;</b><ul compact><li>The maximum number of active transactions configured.</ul> 50<b>u_int32_t st_nactive;</b><ul compact><li>The number of transactions that are currently active.</ul> 51<b>u_int32_t st_nsnapshot;</b><ul compact><li>The number of transactions on the snapshot list. These are transactions 52which modified a database opened with <a href="/api_cxx/db_open.html#DB_MULTIVERSION">DB_MULTIVERSION</a>, 53and which have committed or aborted, but the copies of pages they 54created are still in the cache.</ul> 55<b>u_int32_t st_maxnactive;</b><ul compact><li>The maximum number of active transactions at any one time.</ul> 56<b>u_int32_t st_maxnsnapshot;</b><ul compact><li>The maximum number of transactions on the snapshot list at any one time.</ul> 57<b>u_int32_t st_nbegins;</b><ul compact><li>The number of transactions that have begun.</ul> 58<b>u_int32_t st_naborts;</b><ul compact><li>The number of transactions that have aborted.</ul> 59<b>u_int32_t st_ncommits;</b><ul compact><li>The number of transactions that have committed.</ul> 60<b>u_int32_t st_nrestores;</b><ul compact><li>The number of transactions that have been restored.</ul> 61<b>roff_t st_regsize;</b><ul compact><li>The size of the transaction region, in bytes.</ul> 62<b>u_int32_t st_region_wait;</b><ul compact><li>The number of times that a thread of control was forced to wait before 63obtaining the transaction region mutex.</ul> 64<b>u_int32_t st_region_nowait;</b><ul compact><li>The number of times that a thread of control was able to obtain 65the transaction region mutex without waiting.</ul> 66<b>DB_TXN_ACTIVE *st_txnarray;</b><ul compact><li>A pointer to an array of <b>st_nactive</b> DB_TXN_ACTIVE structures, 67describing the currently active transactions. The following fields of 68the DB_TXN_ACTIVE structure will be filled in:</ul> 69<br> 70<b>u_int32_t txnid;</b><ul compact><li>The transaction ID of the transaction.</ul> 71<b>u_int32_t parentid;</b><ul compact><li>The transaction ID of the parent transaction (or 0, if no parent).</ul> 72<b>pid_t pid;</b><ul compact><li>The process ID of the originator of the transaction.</ul> 73<b>uintmax_t tid;</b><ul compact><li>The thread of control ID of the originator of the transaction.</ul> 74<b>DbLsn lsn;</b><ul compact><li>The current log sequence number when the transaction was begun.</ul> 75<b>DbLsn read_lsn;</b><ul compact><li>The log sequence number of reads for snapshot transactions.</ul> 76<b>u_int32_t mvcc_ref;</b><ul compact><li>The number of buffer copies created by this transaction that remain in cache.</ul> 77<b>u_int32_t status;</b><ul compact><li>One of the following list of constants: TXN_ABORTED, TXN_COMMITTED, 78TXN_PREPARED, TXN_RUNNING.</ul> 79<b>u_int32_t xa_status;</b><ul compact><li>If the transaction is an XA transaction, the <b>xa_status</b> of the 80transaction will be one of the following list of constants: 81TXN_XA_ABORTED, TXN_XA_DEADLOCKED, TXN_XA_ENDED, TXN_XA_PREPARED, 82TXN_XA_STARTED, or TXN_XA_SUSPENDED. Otherwise, the <b>xa_status</b> 83will be 0.</ul> 84<b>u_int8_t xid[DB_XIDDATASIZE];</b><ul compact><li>If the transaction is an XA transaction, the transaction's XA ID. If 85the transaction was prepared separately from the XA interfaces, the 86transaction's Global ID. Otherwise, the <b>xid</b> contents are 87undefined.</ul> 88<b>char name[];</b><ul compact><li>If a name was specified for the transaction, up to the first 50 bytes 89of that name, followed by a nul termination byte.</ul> 90<br> 91<br> 92<p>The DbEnv::txn_stat method may not be called before the <a href="/api_cxx/env_open.html">DbEnv::open</a> method is called.</p> 93<p>The DbEnv::txn_stat method 94either returns a non-zero error value 95or throws an exception that encapsulates a non-zero error value on 96failure, and returns 0 on success. 97</p> 98<b>Parameters</b> <br> 99 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or 100the following value: 101<br> 102<b><a name="DB_STAT_CLEAR">DB_STAT_CLEAR</a></b><ul compact><li>Reset statistics after returning their values.</ul> 103<br></ul> 104 <b>statp</b><ul compact><li>The <b>statp</b> parameter references memory into which 105a pointer to the allocated statistics structure is copied.</ul> 106<br> 107<br><b>Errors</b> 108<p>The DbEnv::txn_stat method 109may fail and throw 110<a href="/api_cxx/except_class.html">DbException</a>, 111encapsulating one of the following non-zero errors, or return one of 112the following non-zero errors:</p> 113<br> 114<b>EINVAL</b><ul compact><li>An 115invalid flag value or parameter was specified.</ul> 116<br> 117<hr size=1 noshade> 118<b>Description: DbEnv::txn_stat_print</b> 119<p>The DbEnv::txn_stat_print method displays the 120transaction subsystem statistical information, as described for the DbEnv::txn_stat method. 121The information is printed to a specified output channel (see the 122<a href="/api_cxx/env_set_msgfile.html">DbEnv::set_msgfile</a> method for more information), or passed to an 123application callback function (see the <a href="/api_cxx/env_set_msgcall.html">DbEnv::set_msgcall</a> method for 124more information).</p> 125<p>The DbEnv::txn_stat_print method may not be called before the <a href="/api_cxx/env_open.html">DbEnv::open</a> method is called.</p> 126<p>The DbEnv::txn_stat_print method 127either returns a non-zero error value 128or throws an exception that encapsulates a non-zero error value on 129failure, and returns 0 on success. 130</p> 131<b>Parameters</b> <br> 132 <b>flags</b><ul compact><li>The <b>flags</b> parameter must be set to 0 or by bitwise inclusively <b>OR</b>'ing together one 133or more of the following values: 134<br> 135<b><a name="DB_STAT_ALL">DB_STAT_ALL</a></b><ul compact><li>Display all available information.</ul> 136<b><a name="DB_STAT_CLEAR">DB_STAT_CLEAR</a></b><ul compact><li>Reset statistics after displaying their values.</ul> 137<br></ul> 138<br> 139<hr size=1 noshade> 140<br><b>Class</b> 141<a href="/api_cxx/env_class.html">DbEnv</a>, <a href="/api_cxx/txn_class.html">DbTxn</a> 142<br><b>See Also</b> 143<a href="/api_cxx/txn_list.html">Transaction Subsystem and Related Methods</a> 144</tt> 145<table width="100%"><tr><td><br></td><td align=right> 146<a href="/api_cxx/api_core.html"><img src="/images/api.gif" alt="API"></a><a href="/ref/toc.html"><img src="/images/ref.gif" alt="Ref"></a> 147</td></tr></table> 148<p><font size=1>Copyright (c) 1996,2008 Oracle. All rights reserved.</font> 149</body> 150</html> 151