Class TransactionDBOptions
- All Implemented Interfaces:
AutoCloseable
-
Field Summary
Fields inherited from class org.rocksdb.RocksObject
nativeHandle_Fields inherited from class org.rocksdb.AbstractImmutableNativeReference
owningHandle_ -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected final voiddisposeInternal(long handle) longThe wait timeout in milliseconds when writing a key OUTSIDE of a transaction (ie by callingRocksDB.put(byte[], byte[]),RocksDB.merge(byte[], byte[]),RocksDB.delete(byte[])orRocksDB.write(org.rocksdb.WriteOptions, org.rocksdb.WriteBatch)directly).longSpecifies the maximum number of keys that can be locked at the same time per column family.longThe number of sub-tables per lock table (per column family)longThe default wait timeout in milliseconds when a transaction attempts to lock a key if not specified byTransactionOptions.setLockTimeout(long)If 0, no waiting is done if a lock cannot instantly be acquired.The policy for when to write the data into the DB.setDefaultLockTimeout(long defaultLockTimeout) If positive, specifies the wait timeout in milliseconds when writing a key OUTSIDE of a transaction (ie by callingRocksDB.put(byte[], byte[]),RocksDB.merge(byte[], byte[]),RocksDB.delete(byte[])orRocksDB.write(org.rocksdb.WriteOptions, org.rocksdb.WriteBatch)directly).setMaxNumLocks(long maxNumLocks) Specifies the maximum number of keys that can be locked at the same time per column family.setNumStripes(long numStripes) Increasing this value will increase the concurrency by dividing the lock table (per column family) into more sub-tables, each with their own separate mutex.setTransactionLockTimeout(long transactionLockTimeout) If positive, specifies the default wait timeout in milliseconds when a transaction attempts to lock a key if not specified byTransactionOptions.setLockTimeout(long)If 0, no waiting is done if a lock cannot instantly be acquired.setWritePolicy(TxnDBWritePolicy writePolicy) The policy for when to write the data into the DB.Methods inherited from class org.rocksdb.RocksObject
disposeInternal, getNativeHandleMethods inherited from class org.rocksdb.AbstractImmutableNativeReference
close, disOwnNativeHandle, isOwningHandle
-
Constructor Details
-
TransactionDBOptions
public TransactionDBOptions()
-
-
Method Details
-
getMaxNumLocks
public long getMaxNumLocks()Specifies the maximum number of keys that can be locked at the same time per column family.If the number of locked keys is greater than
#getMaxNumLocks(), transaction writes (or GetForUpdate) will return an error.- Returns:
- The maximum number of keys that can be locked
-
setMaxNumLocks
Specifies the maximum number of keys that can be locked at the same time per column family.If the number of locked keys is greater than
getMaxNumLocks(), transaction writes (or GetForUpdate) will return an error.- Parameters:
maxNumLocks- The maximum number of keys that can be locked; If this value is not positive, no limit will be enforced.- Returns:
- this TransactionDBOptions instance
-
getNumStripes
public long getNumStripes()The number of sub-tables per lock table (per column family)- Returns:
- The number of sub-tables
-
setNumStripes
Increasing this value will increase the concurrency by dividing the lock table (per column family) into more sub-tables, each with their own separate mutex.Default: 16
- Parameters:
numStripes- The number of sub-tables- Returns:
- this TransactionDBOptions instance
-
getTransactionLockTimeout
public long getTransactionLockTimeout()The default wait timeout in milliseconds when a transaction attempts to lock a key if not specified byTransactionOptions.setLockTimeout(long)If 0, no waiting is done if a lock cannot instantly be acquired. If negative, there is no timeout.- Returns:
- the default wait timeout in milliseconds
-
setTransactionLockTimeout
If positive, specifies the default wait timeout in milliseconds when a transaction attempts to lock a key if not specified byTransactionOptions.setLockTimeout(long)If 0, no waiting is done if a lock cannot instantly be acquired. If negative, there is no timeout. Not using a timeout is not recommended as it can lead to deadlocks. Currently, there is no deadlock-detection to recover from a deadlock.Default: 1000
- Parameters:
transactionLockTimeout- the default wait timeout in milliseconds- Returns:
- this TransactionDBOptions instance
-
getDefaultLockTimeout
public long getDefaultLockTimeout()The wait timeout in milliseconds when writing a key OUTSIDE of a transaction (ie by callingRocksDB.put(byte[], byte[]),RocksDB.merge(byte[], byte[]),RocksDB.delete(byte[])orRocksDB.write(org.rocksdb.WriteOptions, org.rocksdb.WriteBatch)directly).If 0, no waiting is done if a lock cannot instantly be acquired. If negative, there is no timeout and will block indefinitely when acquiring a lock.
- Returns:
- the timeout in milliseconds when writing a key OUTSIDE of a transaction
-
setDefaultLockTimeout
If positive, specifies the wait timeout in milliseconds when writing a key OUTSIDE of a transaction (ie by callingRocksDB.put(byte[], byte[]),RocksDB.merge(byte[], byte[]),RocksDB.delete(byte[])orRocksDB.write(org.rocksdb.WriteOptions, org.rocksdb.WriteBatch)directly).If 0, no waiting is done if a lock cannot instantly be acquired. If negative, there is no timeout and will block indefinitely when acquiring a lock.
Not using a timeout can lead to deadlocks. Currently, there is no deadlock-detection to recover from a deadlock. While DB writes cannot deadlock with other DB writes, they can deadlock with a transaction. A negative timeout should only be used if all transactions have a small expiration set.
Default: 1000
- Parameters:
defaultLockTimeout- the timeout in milliseconds when writing a key OUTSIDE of a transaction- Returns:
- this TransactionDBOptions instance
-
getWritePolicy
The policy for when to write the data into the DB. The default policy is to write only the committed dataTxnDBWritePolicy.WRITE_COMMITTED. The data could be written before the commit phase. The DB then needs to provide the mechanisms to tell apart committed from uncommitted data.- Returns:
- The write policy.
-
setWritePolicy
The policy for when to write the data into the DB. The default policy is to write only the committed dataTxnDBWritePolicy.WRITE_COMMITTED. The data could be written before the commit phase. The DB then needs to provide the mechanisms to tell apart committed from uncommitted data.- Parameters:
writePolicy- The write policy.- Returns:
- this TransactionDBOptions instance
-
disposeInternal
protected final void disposeInternal(long handle) - Specified by:
disposeInternalin classRocksObject
-