This documentation is archived and is not being maintained.

ReservationCollection Class

Manages the collection of space reservations made in a record sequence.

Namespace: System.IO.Log
Assembly: System.IO.Log (in

public abstract class ReservationCollection : ICollection<long>, IEnumerable<long>, 
public abstract class ReservationCollection implements ICollection<long>, 
	IEnumerable<long>, IEnumerable
public abstract class ReservationCollection implements ICollection<long>, 
	IEnumerable<long>, IEnumerable
Not applicable.

This class represents a set of reservation areas that have been made in a record sequence. Adding items to the collection allocates new reservations. Removing items from the collection frees those reservations.

An application reserves space in the log when it has data that will be written to the log in the future, but cannot write it immediately. Reservations provide a guarantee that the data can be written to the log when the data is available to be written. When using logs, applications often reserve one or more log records in a marshalling area. You must reserve records prior to appending them.

Reservations can be used to guarantee that an operation can be completed before the data is committed; otherwise, the changes are rolled back. It can also be used to record an "undo action" in the log. During a rollback operation, a transactional resource manager (RM) must be able to recover its state if the RM is interrupted during the rollback operation. By using a reservation area, an RM can reserve space in a log before it is used.

The ReserveAndAppend method can either reserve space or append data, or both, depending on the parameters that are specified when making the call. As work progresses in a transaction, an application can append the undo information and reserve space for compensation records. During a rollback operation, compensation records that are created indicate what has been undone on the disk. The records are appended using space that has been previously reserved. This guarantees that an RM does not run out of log space, which is a fatal condition, while performing a rollback operation. If a log fills up during a transaction, an application can safely roll back a transaction without corrupting durable data.

CLFS is an ARIES-compliant logging system, meant for write-ahead logging. In write-ahead logging, an application writes an undo record before it performs the operation, reserving the amount of space it would take in the log to write a compensating record, which may be used during rollback. Later, the reserved space is used when the compensation record is actually written.

Applications can either reserve or consume long space at any given time (they are mutually exclusive operations). After a commit record is written to the log, an application can free up the reservations for the compensation records. This action can be done by calling either the FreeReservation or ReserveAndAppend method. Calling the ReserveAndAppend method guarantees that the operation is atomic, while calling the FreeReservation method does not.

When you free records, you must free the same records that you reserved together in a previous call to the ReserveAndAppend method.


Your implementation of IRecordSequence must implement the MakeReservation and FreeReservation methods to perform the actual reservation allocation and deallocation. In addition, your implementation must also call ReservationFreed when a record is written into a reserved space.

Reservations can be performed in two ways as shown in the following examples. You can adopt the practices in the samples for robust processing. Notice that this task can only be performed when using the CLFS-based LogRecordSequence class.

//Using the ReserveAndAppend Method
ReservationCollection reservations = recordSequence.CreateReservationCollection();
long[] lengthOfUndoRecords = new long[] { 1000 };
recordSequence.Append(undoRecordData,    // If necessary …

// Using the Manual Approach
ReservationCollection reservations = recordSequence.CreateReservationCollection();
   recordSequence.Append(recordData, userSqn, previousSqn, RecordAppendOptions.None);
catch (Exception)

recordSequence.Append(undoRecordData, userSqn, previousSqn, RecordAppendOptions.ForceFlush, reservations);


Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0