Table of Contents

Class TransactionOptions

Namespace
RocksDbNet
Assembly
RocksDb.Net.dll

Settings for a single Transaction. Maps to rocksdb_transaction_options_t.

public sealed class TransactionOptions : RocksDbHandle, IDisposable
Inheritance
TransactionOptions
Implements
Inherited Members

Remarks

RocksDb copies these when the transaction begins, so this object may be disposed straight afterwards. Database-wide settings live on TransactionDbOptions.

Constructors

TransactionOptions()

Creates options with RocksDb's defaults.

public TransactionOptions()

Properties

CommitBypassMemtable

Whether a commit may write its data directly rather than through the memtable.

public bool CommitBypassMemtable { get; set; }

Property Value

bool

DeadlockDetect

Whether to detect deadlocks and fail immediately rather than waiting for the lock timeout.

public bool DeadlockDetect { get; set; }

Property Value

bool

Remarks

Detection costs a graph walk on every blocked acquisition, bounded by DeadlockDetectDepth. Without it a deadlock resolves as an ordinary timeout, which is slower but cheaper to police.

DeadlockDetectDepth

How deep the deadlock detector will search, when DeadlockDetect is enabled.

public long DeadlockDetectDepth { get; set; }

Property Value

long

DeadlockTimeoutMicros

How long a blocked acquisition waits before running deadlock detection, in microseconds.

public long DeadlockTimeoutMicros { get; set; }

Property Value

long

Expiration

How long the transaction may live before another may forcibly expire it, in milliseconds. Negative, the default, means it never expires.

public long Expiration { get; set; }

Property Value

long

Remarks

Guards against a transaction that holds locks and is never committed or rolled back, for instance because the process handling it stalled.

LargeTransactionCommitOptimizeByteThreshold

Size in bytes above which commit takes an optimised path, or zero to disable.

public ulong LargeTransactionCommitOptimizeByteThreshold { get; set; }

Property Value

ulong

LargeTransactionCommitOptimizeThreshold

Number of pending operations above which commit takes an optimised path, or zero to disable.

public uint LargeTransactionCommitOptimizeThreshold { get; set; }

Property Value

uint

LockTimeout

How long this transaction waits for a lock, in milliseconds. Negative means use TransactionLockTimeout.

public long LockTimeout { get; set; }

Property Value

long

Remarks

A non-negative value replaces the database-wide timeout for this transaction, in either direction: it can wait longer than the database setting allows as readily as it can give up sooner. Measured against a database configured to fail immediately, a transaction asking for three seconds waits the full three. Zero fails immediately on contention, which is what a test wanting a deterministic conflict should use.

MaxWriteBatchSize

Maximum size in bytes of the transaction's pending writes, or zero for no limit. A write that would exceed it fails.

public ulong MaxWriteBatchSize { get; set; }

Property Value

ulong

SetSnapshot

Whether to take a snapshot when the transaction begins, so that its writes are validated against the state at that moment.

public bool SetSnapshot { get; set; }

Property Value

bool

Remarks

This is what turns a transaction from "last writer wins on the keys I locked" into repeatable-read behaviour. Without it, a locking read sees the latest committed value rather than the value as of the transaction's start, so a read-modify-write can be based on data written by a transaction that committed after this one began.

With it, a commit fails when a key the transaction read has changed since the snapshot, and the caller retries.

SkipConcurrencyControl

Whether to skip locking and conflict detection for this transaction.

public bool SkipConcurrencyControl { get; set; }

Property Value

bool

Remarks

Carries the same warning as SkipConcurrencyControl: it removes the guarantee the transaction exists to provide.

SkipPrepare

Whether committing skips the prepare phase, for two-phase commit.

public bool SkipPrepare { get; set; }

Property Value

bool

UseOnlyTheLastCommitTimeBatchForRecovery

Whether recovery uses only the last commit-time write batch.

public bool UseOnlyTheLastCommitTimeBatchForRecovery { get; set; }

Property Value

bool

WriteBatchFlushThreshold

Size in bytes at which pending writes are flushed to the memtable early.

public long WriteBatchFlushThreshold { get; set; }

Property Value

long

Remarks

Zero disables early flushing rather than selecting a default. A negative value, which is what this starts at, is the one that defers to DefaultWriteBatchFlushThreshold.

WriteBatchTrackTimestampSize

Whether the transaction's write batch tracks the size of user-defined timestamps.

public bool WriteBatchTrackTimestampSize { get; set; }

Property Value

bool

Methods

DisposeHandle()

Releases the native handle. Called during disposal.

protected override void DisposeHandle()

Remarks

Protected rather than public: it destroys the native object without marking this instance disposed or clearing the handle, so calling it from outside and then disposing normally would free the same pointer twice. It was the most Dispose-looking member on the type. Callers want Dispose().