LogWriter provides transaction log writing for a specific Connection. It is used to start, control, and inspect eXtremeDB transaction logging for file-based or pipe-based replication workflows.
[Flags]
public enum LogFlags : ushort
{
Aligned = 0x01, // Start each record with new disk page
Append = 0x02, // Append to an existing log file
Crc = 0x04, // Cover transaction data with CRC32
SizeCallback = 0x08, // User callback to limit size (not supported in .NET)
SyncInstantly = 0x10, // Do disk flush on each record
SyncTimer = 0x20, // Do disk flush by timer
SyncCount = 0x40, // Do disk flush by record count
Iterable = 0x80, // Make log applicable for LogReader iteration
Restart = 0x100, // Stop previous log at once
Pipe = 0x200, // Use pipe interface instead of file
DynamicPipe = 0x1000 // Support for dynamic pipes
}
public class LogWriter
{
// ===== NESTED STRUCT: LogParams =====
public struct LogParams
{
public LogFlags Flags;
public ushort DiskPageSize;
public ushort FlushDepth;
public TimeSpan FlushTime;
}
// ===== NESTED STRUCT: LogInfo =====
public struct LogInfo
{
public LogFlags Flags;
public long StartTransCounter;
public long LastTransCounter;
public long StoredTransactions;
public long LogSize;
public long PipeUsedSize;
public int LabelsCount;
public uint MaxParallelTrans;
public uint ExceededTransSlotsCount;
public long MaxTransactionSize;
}
// ===== CONSTRUCTOR =====
public LogWriter(Connection con, string filePath);
// ===== LIFECYCLE METHODS =====
public void Start(LogParams logParams);
public void Stop();
public void Terminate();
public void Truncate();
// ===== LOG MANAGEMENT METHODS =====
public int SetLabel(string label);
public bool SaveSnapshot(String databaseSnapshotFilePath);
public void Flush();
// ===== INFORMATION METHODS =====
public LogInfo GetInfo();
}
Aligned (page-aligned records), Append (continue an existing log), Crc (CRC32 checksums), SyncInstantly/Timer/Count (flush policies), Iterable (enable LogReader iteration APIs), Pipe/DynamicPipe (pipe-based transport), and Restart (replace an existing active log).Flags (behavior modifiers), DiskPageSize (I/O block size), FlushDepth (max unflushed records), FlushTime (timer-based flush interval).Start/LastTransCounter), storage metrics (StoredTransactions, LogSize), pipe usage (PipeUsedSize), label count, MVCC parallelism stats (MaxParallelTrans, ExceededTransSlotsCount), and largest transaction size.Database.Mode.TransactionLoggingSupport flag. In pipe mode, the filePath argument can be null.Stop() or Terminate() is called.LogReader.Apply(labelId) to replay transactions up to this point.Stop() followed by Start() with the same parameters.Database.Open() when Database.Parameters.DatabaseSnapshotFilePath is set. Returns true on success.LogInfo structure.Database.Mode.TransactionLoggingSupport flag. Logging is connection-specific: each LogWriter instance manages logging for its associated Connection.LogParams: SyncInstantly (maximum durability, lowest throughput), SyncTimer (periodic flushes), SyncCount (flush after N records), or combine flags for hybrid behavior.LogFlags.Pipe or LogFlags.DynamicPipe, the log is written through the transaction log pipe interface instead of a regular file. This mode is used together with LogReader.IteratePipe(...) for real-time consumption of log records; in this case the writer is typically created with filePath = null.Start() -> perform transactions -> optionally call SetLabel("checkpoint") -> optionally call SaveSnapshot("backup.db") -> continue logging. On recovery, load the snapshot and use LogReader.Apply(...) to replay transactions to the desired point.