ערוך

שתף באמצעות


LogRecordSequence.AdvanceBaseSequenceNumber(SequenceNumber) Method

Definition

Moves the base sequence number of the log forward. This method cannot be inherited.

public:
 virtual void AdvanceBaseSequenceNumber(System::IO::Log::SequenceNumber newBaseSequenceNumber);
public void AdvanceBaseSequenceNumber (System.IO.Log.SequenceNumber newBaseSequenceNumber);
abstract member AdvanceBaseSequenceNumber : System.IO.Log.SequenceNumber -> unit
override this.AdvanceBaseSequenceNumber : System.IO.Log.SequenceNumber -> unit
Public Sub AdvanceBaseSequenceNumber (newBaseSequenceNumber As SequenceNumber)

Parameters

newBaseSequenceNumber
SequenceNumber

Specifies the new base SequenceNumber for the log. This must lie in the range between the current base sequence number and the last sequence number of the log inclusively.

Implements

Exceptions

newBaseSequenceNumber is not valid for this sequence.

A new or existing archive tail or base of the active log is invalid.

-or-

newBaseSequenceNumber is not between the base and last sequence numbers of this sequence.

The request could not be performed because of an unexpected I/O exception.

-or-

The request could not be performed because of an I/O device error.

The specified log does not have any extents. One or more extents must be created before a record sequence may be used.

The method was called after the sequence has been disposed of.

There is not enough memory to continue the execution of the program.

Access for the specified log sequence is denied by the operating system.

The record sequence is full.

Examples

This example shows how to use the AdvanceBaseSequenceNumber method with the TailPinned event to free up space in a log sequence.

recordSequence.RetryAppend = true;  
recordSequence.TailPinned += new EventHandler<TailPinnedEventArgs>(HandleTailPinned);  

void HandleTailPinned(object sender, TailPinnedEventArgs tailPinnedEventArgs)  
{  
   // tailPinnedEventArgs.TargetSequenceNumber is the target   
   // sequence number to free up space to.    
   // However, this sequence number is not necessarily valid.  We have  
   // to use this sequence number as a starting point for finding a  
   // valid point within the log to advance toward. You need to  
   // identify a record with a sequence number equal to, or greater  
   // than TargetSequenceNumber; let's call this   
   // realTargetSequenceNumber. Once found, move the base  

   recordSequence.AdvanceBaseSequenceNumber(realTargetSequenceNumber);  

}  

Remarks

This method is often used with the TailPinned event to free up space in a record. The TailPinned event indicates that the tail of the sequence (that is, the base sequence number) needs to be moved forward to free up space. Freeing space can be done by either writing restart areas using the WriteRestartArea method, or truncating the log and using the AdvanceBaseSequenceNumber method to advance the base sequence number of a log to the one specified by the newBaseSequenceNumber parameter. The code sample in the Example section demonstrates the second approach.

Note that calling this method is the same as setting a new base sequence number using the WriteRestartArea method, except that no restart record is written to the log.

Applies to