+I)Berkeley DB: DbTxnMgr.open[P

DbTxnMgr.open





import com.sleepycat.db.*;

Ipublic static DbTxnMgr open(String dir, int flags, int mode, DbEnv dbenv) throws DbException;





Description

The DbTxnMgr.openTmethod returns a "transaction region" identified by the directory dir.

The;dir pathname argument is interpreted as described in@Berkeley DB File Naming.

KThe flags and mode arguments specify how files will be opened,and/or created if they do not already exist.SThe flags value is specified by logically OR'ing together one or more of thefollowing values:

^

Db.DB_CREATE
Create any underlying files, as necessary. If the files do not alreadyBexist and the DB_CREATE flag is not specified, the call will fail.`

Db.DB_THREAD
Cause the m4_reg(DbTxnMgr) handle returned by DbTxnMgr.open to be useable>by multiple threads within a single address space, i.e., to befree-threaded.MNote, threading is assumed in the Java API, so no special flags are required,Tand Berkeley DB functions will always behave as if the DB_THREAD flag was specified.U

Db.DB_TXN_NOSYNC
On transaction commit, do not synchronously flush the log.HThis means that transactions exhibit the ACI (atomicity, consistency andGisolation) properties, but not D (durability), i.e., database integrityBwill be maintained but it is possible that some number of the mostHrecently committed transactions may be undone during recovery instead of being redone.

FThe number of transactions that are potentially at risk is governed bylhow often the log is checkpointed (see db_checkpoint for moreCinformation) and how many log updates can fit on a single log page.



^All files created by the transaction subsystem are created with mode mode (as describedHin chmod(2)) and modified by the process' umask value at the time$of creation (see umask(2)))).IThe group ownership of created files is based on the system and directory6defaults, and is not further specified by Berkeley DB.

'The transaction subsystem is configuredEbased on the dbenv argument. It is expected that applicationsjwill use a single DbEnv object as the argument to all of thetsubsystems in the Berkeley DB package. The fields of the DbEnv object*used by DbTxnMgr.open are described below.nAny of the DbEnv fields that are not explicitly set will defaultto appropriate values.

pThe following fields in the DbEnv object may be initialized, using9the appropriate set method, before calling DbTxnMgr.open:

DbErrcall db_errcall;

String db_errpfx;
z
int db_verbose;
The error fields of the DbEnv behave as described for>DbEnv.appinit.

DbLog lg_info;
The logging region that is being used for this transaction environment.yThe lg_info field contains a return value from the DbLog.open method.4Logging is required for transaction environments,7and it is an error to not specify a logging region.

DbLockTab lk_info;
The locking region that is being used for this transaction environment.The lk_info field contains a return value from the DbLockTab.open method.AIf lk_info is null, no locking is done in this transaction environment.Y

int tx_max;
The maximum number of simultaneous transactions that are supported.FThis bounds the size of backing files and is used to derive limits for)the size of the lock region and logfiles.HWhen there are more than tx_max concurrent transactions, calls to`DbTxnMgr.begin may cause backing files to grow./If tx_max is 0, a default value is used.

The DbTxnMgr.openHmethod throws an exception that encapsulates an errno on failure.

Environment Variables



U

DB_HOME
If the dbenv argument to DbTxnMgr.open was initialized usingiDbEnv.appinit the environment variable DB_HOME mayBbe used as the path of the database home for the interpretation ofthe dir argument.


Z

TMPDIR
If the dbenv argument to DbTxnMgr.open was NULL or not initializednusing DbEnv.appinit the environment variable TMPDIR maySbe used as the directory in which to create the transaction region, as described inDbTxnMgr.open.




Errors

UIf a fatal error occurs in Berkeley DB, the DbTxnMgr.open method may fail and throw a}DbRunRecoveryException, at which point all subsequent database%calls will also fail in the same way.

The DbTxnMgr.open&method may fail and throw an exceptionKfor any of the errors specified for the following Berkeley DB and C library functions: abort(3), close(3),>DbEnv.version, fcntl(3), fflush(3), fprintf(3),free(3), fstat(3), fsync(3), getenv(3), getpid(3), getuid(3), isdigit(3), lseek(3), malloc(3), memcpy(3), memset(3),mmap(3), munmap(3),open(3),pstat_getdynamic(3),read(3), shmat(3), shmctl(3), shmdt(3),sigfillset(3),sigprocmask(3),stat(3), strerror(3), strlen(3), sysconf(3),time(3),BDbTxnMgr.unlink, unlink(3), vfprintf(3), vsnprintf(3),and write(3).

In addition, the DbTxnMgr.open&method may fail and throw an exceptionencapsulating errnofor the following conditions:

R

EAGAIN
The shared memory region was locked and (repeatedly) unavailable.
B

EINVAL
An invalid flag value or parameter was specified.

FThe DB_THREAD flag was specified and spinlocks are not implemented forthis architecture.

$The dbenv parameter was null.





Class

9DbTxnMgr



See Also

@DbTxnMgr.begin,JDbTxnMgr.checkpoint,@DbTxnMgr.close,DbTxnMgr.open,=DbTxnMgr.statandBDbTxnMgr.unlink.