Partager via


Obtaining the Next LSN

If you are trying to advance the base log sequence number (LSN) of a log, or trying to read records from a log, typically you need to specify an LSN to a valid record in the log. There are two ways to obtain the next LSN, and the way you use depends on whether you want the last LSN in the log, or the LSN that will be assigned to the next record added.

The following list identifies the two ways to obtain the next LSN:

  • Reading records sequentially by using the ReadNextLogRecord function always return valid log records. The last valid log record is the last record that is read before encountering the end-of-file marker.
  • Querying the log metadata by using the GetLogFileInformation function returns the next available LSN in the LastLsn member of the CLFS_INFORMATION structure. Then you can use the AdvanceLogBase function to advance the base LSN beyond the last record in the log.

For example, if you are using the AdvanceLogBase or WriteLogRestartArea function, you can advance the base LSN beyond the last record of the log by using the LastLsn member that is returned from the GetLogFileInformation function.