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 System.IO.Log.dll)

public ref class ReservationCollection abstract : ICollection<long long>, 
	IEnumerable<long long>, IEnumerable

This class represents a set of reservation areas that are 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 is to 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 takes 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 access 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 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0