Read Oracle documentation for better understanding.
Returns the memory pool (that is, the buffer cache) subsystem statistics.
The returning value is a tuple. The first element is a dictionary with the general stats. The second element is another dictionary, keyed by filename, and the values are the stats for each file.
The first dictionary contains these data:
gbytes Gigabytes of cache (total cache size is st_gbytes + st_bytes). bytes Bytes of cache (total cache size is st_gbytes + st_bytes). ncache Number of caches. max_ncache Maximum number of caches, as configured with the DB_ENV->set_cache_max() method. regsize Individual cache size, in bytes. mmapsize Maximum memory-mapped file size. maxopenfd Maximum open file descriptors. maxwrite Maximum sequential buffer writes. maxwrite_sleep Microseconds to pause after writing maximum sequential buffers. map Requested pages mapped into the process’ address space (there is no available information about whether or not this request caused disk I/O, although examining the application page fault rate may be helpful). cache_hit Requested pages found in the cache. cache_miss Requested pages not found in the cache. page_create Pages created in the cache. page_in Pages read into the cache. page_out Pages written from the cache to the backing file. ro_evict Clean pages forced from the cache. rw_evict Dirty pages forced from the cache. page_trickle Dirty pages written using the DB_ENV->memp_trickle() method. pages Pages in the cache. page_clean Clean pages currently in the cache. page_dirty Dirty pages currently in the cache. hash_buckets Number of hash buckets in buffer hash table. hash_searches Total number of buffer hash table lookups. hash_longest Longest chain ever encountered in buffer hash table lookups. hash_examined Total number of hash elements traversed during hash table lookups. hash_nowait Number of times that a thread of control was able to obtain a hash bucket lock without waiting. hash_wait Number of times that a thread of control was forced to wait before obtaining a hash bucket lock. hash_max_nowait The number of times a thread of control was able to obtain the hash bucket lock without waiting on the bucket which had the maximum number of times that a thread of control needed to wait. hash_max_wait Maximum number of times any hash bucket lock was waited for by a thread of control. region_wait Number of times that a thread of control was forced to wait before obtaining a cache region mutex. region_nowait Number of times that a thread of control was able to obtain a cache region mutex without waiting. mvcc_frozen Number of buffers frozen. mvcc_thawed Number of buffers thawed. mvcc_freed Number of frozen buffers freed. alloc Number of page allocations. alloc_buckets Number of hash buckets checked during allocation. alloc_max_buckets Maximum number of hash buckets checked during an allocation. alloc_pages Number of pages checked during allocation. alloc_max_pages Maximum number of pages checked during an allocation. io_wait Number of operations blocked waiting for I/O to complete. sync_interrupted Number of mpool sync operations interrupted.
The second dictionary contains these data:
pagesize Page size in bytes. cache_hit Requested pages found in the cache. cache_miss Requested pages not found in the cache. map Requested pages mapped into the process’ address space. page_create Pages created in the cache. page_in Pages read into the cache. page_out Pages written from the cache to the backing file.
Returns the intermediate directory permissions.
Intermediate directories are directories needed for recovery. Normally, Berkeley DB does not create these directories and will do so only if the DB_ENV->set_intermediate_dir_mode() method is called.
By default, Berkeley DB does not create intermediate directories needed for recovery, that is, if the file /a/b/c/mydatabase is being recovered, and the directory path b/c does not exist, recovery will fail. This default behavior is because Berkeley DB does not know what permissions are appropriate for intermediate directory creation, and creating the directory might result in a security problem.
The DB_ENV->set_intermediate_dir_mode() method causes Berkeley DB to create any intermediate directories needed during recovery, using the specified permissions.
By default when DB.get or DBCursor.get, get_both, first, last, next or prev encounter a DB_NOTFOUND error they return None instead of raising DBNotFoundError. This behaviour emulates Python dictionaries and is convenient for looping.
You can use this method to toggle that behaviour for all of the aformentioned methods or extend it to also apply to the DBCursor.set, set_both, set_range, and set_recno methods. Supported values of flag:
The default of returning None makes it easy to do things like this without having to catch DBNotFoundError (KeyError):
data = mydb.get(key)
if data:
doSomething(data)
or this:
rec = cursor.first()
while rec:
print rec
rec = cursor.next()
Making the cursor set methods return None is useful in order to do this:
rec = mydb.set()
while rec:
key, val = rec
doSomething(key, val)
rec = mydb.next()
The downside to this it that it is inconsistent with the rest of the package and noticeably diverges from the Oracle Berkeley DB API. If you prefer to have the get and set methods raise an exception when a key is not found, use this method to tell them to do so.
Calling this method on a DBEnv object will set the default for all DB’s later created within that environment. Calling it on a DB object sets the behaviour for that DB only.
The previous setting is returned.
Files that are opened read-only in the memory pool (and that satisfy a few other criteria) are, by default, mapped into the process address space instead of being copied into the local cache. This can result in better-than-usual performance, as available virtual memory is normally much larger than the local cache, and page faults are faster than page copying on many systems. However, in the presence of limited virtual memory it can cause resource starvation, and in the presence of large databases, it can result in immense process sizes.
This method sets the maximum file size, in bytes, for a file to be mapped into the process address space. If no value is specified, it defaults to 10MB. More info...
Returns a dictionary of locking subsystem statistics with the following keys:
id Last allocated lock ID. cur_maxid The current maximum unused locker ID. nmodes Number of lock modes. maxlocks Maximum number of locks possible. maxlockers Maximum number of lockers possible. maxobjects Maximum number of objects possible. nlocks Number of current locks. maxnlocks Maximum number of locks at once. nlockers Number of current lockers. nobjects Number of current lock objects. maxnobjects Maximum number of lock objects at once. maxnlockers Maximum number of lockers at once. nrequests Total number of locks requested. nreleases Total number of locks released. nupgrade Total number of locks upgraded. ndowngrade Total number of locks downgraded. lock_wait The number of lock requests not immediately available due to conflicts, for which the thread of control waited. lock_nowait The number of lock requests not immediately available due to conflicts, for which the thread of control did not wait. ndeadlocks Number of deadlocks. locktimeout Lock timeout value. nlocktimeouts The number of lock requests that have timed out. txntimeout Transaction timeout value. ntxntimeouts The number of transactions that have timed out. This value is also a component of ndeadlocks, the total number of deadlocks detected. objs_wait The number of requests to allocate or deallocate an object for which the thread of control waited. objs_nowait The number of requests to allocate or deallocate an object for which the thread of control did not wait. lockers_wait The number of requests to allocate or deallocate a locker for which the thread of control waited. lockers_nowait The number of requests to allocate or deallocate a locker for which the thread of control did not wait. locks_wait The number of requests to allocate or deallocate a lock structure for which the thread of control waited. locks_nowait The number of requests to allocate or deallocate a lock structure for which the thread of control did not wait. hash_len Maximum length of a lock hash bucket. regsize Size of the region. region_wait Number of times a thread of control was forced to wait before obtaining the region lock. region_nowait Number of times a thread of control was able to obtain the region lock without waiting.
Return a dictionary of transaction statistics with the following keys:
last_ckp The LSN of the last checkpoint. time_ckp Time the last completed checkpoint finished (as the number of seconds since the Epoch, returned by the IEEE/ANSI Std 1003.1 POSIX time interface). last_txnid Last transaction ID allocated. maxtxns Max number of active transactions possible. nactive Number of transactions currently active. maxnactive Max number of active transactions at once. nsnapshot The number of transactions on the snapshot list. These are transactions which modified a database opened with DB_MULTIVERSION, and which have committed or aborted, but the copies of pages they created are still in the cache. maxnsnapshot The maximum number of transactions on the snapshot list at any one time. nbegins Number of transactions that have begun. naborts Number of transactions that have aborted. ncommits Number of transactions that have committed. nrestores Number of transactions that have been restored. regsize Size of the region. region_wait Number of times that a thread of control was forced to wait before obtaining the region lock. region_nowait Number of times that a thread of control was able to obtain the region lock without waiting.
Returns a dictionary of logging subsystem statistics with the following keys:
magic The magic number that identifies a file as a log file. version The version of the log file type. mode The mode of any created log files. lg_bsize The in-memory log record cache size. lg_size The log file size. record The number of records written to this log. w_mbytes The number of megabytes written to this log. w_bytes The number of bytes over and above w_mbytes written to this log. wc_mbytes The number of megabytes written to this log since the last checkpoint. wc_bytes The number of bytes over and above wc_mbytes written to this log since the last checkpoint. wcount The number of times the log has been written to disk. wcount_fill The number of times the log has been written to disk because the in-memory log record cache filled up. rcount The number of times the log has been read from disk. scount The number of times the log has been flushed to disk. cur_file The current log file number. cur_offset The byte offset in the current log file. disk_file The log file number of the last record known to be on disk. disk_offset The byte offset of the last record known to be on disk. maxcommitperflush The maximum number of commits contained in a single log flush. mincommitperflush The minimum number of commits contained in a single log flush that contained a commit. regsize The size of the log region, in bytes. region_wait The number of times that a thread of control was forced to wait before obtaining the log region mutex. region_nowait The number of times that a thread of control was able to obtain the log region mutex without waiting.
Returns a list of tuples (GID, TXN) of transactions prepared but still unresolved. This is used while doing environment recovery in an application using distributed transactions.
This method must be called only from a single thread at a time. It should be called after DBEnv recovery. More info...
Returns a dictionary of mutex subsystem statistics with the following keys:
mutex_align The mutex alignment, in bytes. mutex_tas_spins The number of times test-and-set mutexes will spin without blocking. mutex_cnt The total number of mutexes configured. mutex_free The number of mutexes currently available. mutex_inuse The number of mutexes currently in use. mutex_inuse_max The maximum number of mutexes ever in use. regsize The size of the mutex region, in bytes. region_wait The number of times that a thread of control was forced to wait before obtaining the mutex region mutex. region_nowait The number of times that a thread of control was able to obtain the mutex region mutex without waiting.
This module automates many of the tasks needed to provide replication abilities in a Berkeley DB system. The module is fairly limited, but enough in many cases. Users more demanding must use the full Base Replication API.
This module requires pthread support (in Unix), so you must compile Berkeley DB with it if you want to be able to use the Replication Manager.
Adds a new replication site to the replication manager’s list of known sites. It is not necessary for all sites in a replication group to know about all other sites in the group.
Method returns the environment ID assigned to the remote site. More info...
Returns a dictionary with the status of the sites currently known by the replication manager.
The keys are the Environment ID assigned by the replication manager. This is the same value that is passed to the application’s event notification function for the DB_EVENT_REP_NEWMASTER event.
The values are tuples containing the hostname, the TCP/IP port number and the link status.
Returns a dictionary with the replication manager statistics. Keys are:
perm_failed | The number of times a message critical for maintaining database integrity (for example, a transaction commit), originating at this site, did not receive sufficient acknowledgement from clients, according to the configured acknowledgement policy and acknowledgement timeout. |
msgs_queued | The number of outgoing messages which could not be transmitted immediately, due to a full network buffer, and had to be queued for later delivery. |
msgs_dropped | The number of outgoing messages that were completely dropped, because the outgoing message queue was full. (Berkeley DB replication is tolerant of dropped messages, and will automatically request retransmission of any missing messages as needed.) |
connection_drop | The number of times an existing TCP/IP connection failed. |
connect_fail | The number of times an attempt to open a new TCP/IP connection failed. |
This section provides the raw methods for replication. If possible, it is recommended to use the Replication Manager.
Processes an incoming replication message sent by a member of the replication group to the local database environment.
Returns a two element tuple.
Configures the database environment as a client or master in a group of replicated database environments.
The DB_ENV->rep_start method is not called by most replication applications. It should only be called by applications implementing their own network transport layer, explicitly holding replication group elections and handling replication messages outside of the replication manager framework.
Returns a dictionary with the replication subsystem statistics. Keys are:
st_bulk_fills | The number of times the bulk buffer filled up, forcing the buffer content to be sent. |
bulk_overflows | The number of times a record was bigger than the entire bulk buffer, and therefore had to be sent as a singleton. |
bulk_records | The number of records added to a bulk buffer. |
bulk_transfers | The number of bulk buffers transferred (via a call to the application’s send function). |
client_rerequests | The number of times this client site received a “re-request” message, indicating that a request it previously sent to another client could not be serviced by that client. (Compare to client_svc_miss.) |
client_svc_miss | The number of “request” type messages received by this client that could not be processed, forcing the originating requester to try sending the request to the master (or another client). |
client_svc_req | The number of “request” type messages received by this client. (“Request” messages are usually sent from a client to the master, but a message marked with the DB_REP_ANYWHERE flag in the invocation of the application’s send function may be sent to another client instead.) |
dupmasters | The number of duplicate master conditions originally detected at this site. |
egen | The current election generation number. |
election_cur_winner | The election winner. |
election_gen | The election generation number. |
election_lsn | The maximum LSN of election winner. |
election_nsites | The number sites responding to this site during the last election. |
election_nvotes | The number of votes required in the last election. |
election_priority | The election priority. |
election_sec | The number of seconds the last election took (the total election time is election_sec plus election_usec). |
election_status | The current election phase (0 if no election is in progress). |
election_tiebreaker | The election tiebreaker value. |
election_usec | The number of microseconds the last election took (the total election time is election_sec plus election_usec). |
election_votes | The number of votes received in the last election. |
elections | The number of elections held. |
elections_won | The number of elections won. |
env_id | The current environment ID. |
env_priority | The current environment priority. |
gen | The current generation number. |
log_duplicated | The number of duplicate log records received. |
log_queued | The number of log records currently queued. |
log_queued_max | The maximum number of log records ever queued at once. |
log_queued_total | The total number of log records queued. |
log_records | The number of log records received and appended to the log. |
log_requested | The number of times log records were missed and requested. |
master | The current master environment ID. |
master_changes | The number of times the master has changed. |
max_lease_sec | The number of seconds of the longest lease (the total lease time is max_lease_sec plus max_lease_usec). |
max_lease_usec | The number of microseconds of the longest lease (the total lease time is max_lease_sec plus max_lease_usec). |
max_perm_lsn | The LSN of the maximum permanent log record, or 0 if there are no permanent log records. |
msgs_badgen | The number of messages received with a bad generation number. |
msgs_processed | The number of messages received and processed. |
msgs_recover | The number of messages ignored due to pending recovery. |
msgs_send_failures | The number of failed message sends. |
msgs_sent | The number of messages sent. |
newsites | The number of new site messages received. |
next_lsn | In replication environments configured as masters, the next LSN expected. In replication environments configured as clients, the next LSN to be used. |
next_pg | The next page number we expect to receive. |
nsites | The number of sites used in the last election. |
nthrottles | Transmission limited. This indicates the number of times that data transmission was stopped to limit the amount of data sent in response to a single call to DB_ENV->rep_process_message. |
outdated | The number of outdated conditions detected. |
pg_duplicated | The number of duplicate pages received. |
pg_records | The number of pages received and stored. |
pg_requested | The number of pages missed and requested from the master. |
startsync_delayed | The number of times the client had to delay the start of a cache flush operation (initiated by the master for an impending checkpoint) because it was missing some previous log record(s). |
startup_complete | The client site has completed its startup procedures and is now handling live records from the master. |
status |
|
txns_applied | The number of transactions applied. |
waiting_lsn | The LSN of the first log record we have after missing log records being waited for, or 0 if no log records are currently missing. |
waiting_pg | The page number of the first page we have after missing pages being waited for, or 0 if no pages are currently missing. |