HPlogo ALLBASE/SQL Database Administration Guide: HP 3000 MPE/iX Computer Systems > Chapter 6 Backup and Recovery

Understanding Log File Types

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Index

It is important to understand the different conventions for naming and referring to log files in ALLBASE/SQL. This chapter assumes a basic distinction between the log (a logical object) and the specific log files which the log contains. Information about all the specific files in the log is stored in the DBECon file. You use the SHOWLOG command in SQLUtil to examine the DBECon file's directory of log files. SHOWLOG also displays general information about the log as a whole.

When you configure the DBEnvironment, you specify the names of one or two physical files (depending on whether you have chosen single or dual logging). These physical files will contain log records that are based on the transactions applied in the DBEnvironment. Later, you use the SQLUtil ADDLOG command to add additional log files to the DBEnvironment.

Understanding the LOG FULL Condition

Eventually, log files can become full, and the result is known as a LOG FULL error condition, which means that no additional transactions can be logged until log space is provided. When a LOG FULL condition arises, ALLBASE/SQL rolls back the current transaction and issues the following error message:


   Log Full. (DBERR 14046)

In addition, in most cases other transactions are also rolled back.

NOTE: If a LOG FULL condition occurs while a rollback operation is taking place, all transactions are rolled back, including transactions that have performed no updates.

Using Single or Dual Logs

When you create the DBEnvironment, you specify either single or dual logs. In single logging, ALLBASE/SQL maintains one set of log files in either archive or nonarchive mode. The log file should be placed on a device different from the one containing the DBEnvironment. For greater security, you can specify dual logging, in which a duplicate set of log files is maintained. The second log file should not be on either the drive containing the DBEnvironment or the drive containing the first log file. When dual logging is in effect, all the procedures described in this chapter apply to the files of both logs.

Using Multiple Log Files

To avoid a LOG FULL condition, you can set up a DBEnvironment containing multiple log files for archive or nonarchive use, and in single or dual logging mode. When one file becomes filled, ALLBASE/SQL automatically switches to the next available file.

Log Names and Numbers

Log files are referred to in different ways, depending on the operation you are attempting to perform. In some instances, you must refer to a log by its file name. In other cases, you refer to the log by its identifier number.

Log File Names

Use a file name when you add a new log with the ADDLOG command, when you move it to a new location with MOVELOG, or when you must rescue it with RESCUELOG. The file name is an MPE file name.

Identifier Numbers

Use the identifier number when you purge a log file or when (in archive mode only) you store it. Each log file you add is given a specific identifier number; in the case of dual logging, the same identifier number refers to both files together.

Sequence Numbers

ALLBASE/SQL also keeps track of multiple log files through sequence numbers, which are stored along with the physical file names in the DBECon file. Sequence numbers are also written onto the tape at the time you issue a STORELOG command (described in a later section). In the case of dual logging, the same sequence number refers to both files together.

You never allocate sequence numbers yourself. They are used internally by ALLBASE/SQL to keep track of the order in which files are applied during the recovery process. If you attempt to recover a log file that has the wrong sequence number, you receive an error message.

Sequence numbers continue incrementing each time you switch into a new log file. As an example, suppose the DBEnvironment is configured for single logging in archive mode. Log 1 has the filename DBELog1, and initially it receives log identifier number 1 and sequence number 1. Log 2 has the filename DBELog2, and initially it receives log identifier number 2, and sequence number 2. When Log 1 runs out of space, ALLBASE/SQL switches to Log 2. After Log 1 has been backed up and when it no longer has active transactions in it, it becomes available for reuse. Then, when ALLBASE/SQL switches over to Log 1 again, it receives sequence number 3, although it still has identifier number 1, and it is still called DBELog1.

Using Nonarchive Logs

A nonarchive log behaves like a circular fileset. A circular fileset is a group of files in which the first one is overwritten when the last one is full. If a nonarchive log file becomes full, ALLBASE/SQL first issues a checkpoint in an effort to reclaim the file space taken up by transactions that have already been committed. (A checkpoint is an event that flushes data and log buffer contents to disk, and reclaims nonarchive log file space for reuse.) If a checkpoint does not reclaim enough space for the current transaction, ALLBASE/SQL attempts to switch to the next file (if it is available). A log file is considered available if it does not contain any log records for transactions active at the last checkpoint. If the log is still full, and there is no other log available to switch into, a LOG FULL condition occurs, and the transaction is rolled back.

Multiple Files in Nonarchive Mode

You can add additional physical log files to the nonarchive DBEnvironment by means of the SQLUtil ADDLOG command. You can add log files without stopping the DBEnvironment. Each nonarchive file has a unique log name, which is an MPE file name, and a log identifier, which is an integer by which the file is known internally to ALLBASE/SQL. If you are using dual logging, there are two MPE file names, but there is only one identifier. In nonarchive logging, you can use multiple log files to ensure that even a very large transaction will not cause a LOG FULL condition. You do not back up nonarchive log files.

Figure 6-1 “Nonarchive Log” shows a nonarchive log for a DBEnvironment that is running in multiuser mode, with different users starting and ending transactions at different times.

Figure 6-1 Nonarchive Log

[Nonarchive Log]

The log has three files--File 1, File 2, and File 3; Files 1 and 2 have been filled, so ALLBASE/SQL has already switched to File 3. Assume that transactions 4 and 5 (T4 and T5) are uncommitted. When File 3 becomes full, ALLBASE/SQL will issue an internal checkpoint. Assuming there is not enough space left in File 3, ALLBASE/SQL will switch back to File 1 and continue logging. At the moment shown in the figure, both File 2 and File 3 contain active transactions.

A nonarchive log file should be used when you can frequently do a static backup of the DBEnvironment so that rollforward recovery is not needed to recover in the event of a media failure. (Static backup is described further in a later section.)

Using Archive Logs

Archive logs are also circular filesets. The difference is that file space cannot be reclaimed --even from files with no active transactions in them-- until the files are backed up. If an archive log file becomes full, ALLBASE/SQL attempts to switch to the next file (if one is available). It is available if it does not contain log records for any currently active transactions, and if it has been backed up. If the next file is not available, a switch is attempted again after a checkpoint. (A checkpoint is an event that flushes data and log buffers to disk.) If the switch still fails, a LOG FULL condition occurs, and the transaction is rolled back.

When more space is needed, add a new log file with the ADDLOG command. You can also reclaim log file space by using STORELOG to back up a log file when it is full. Then, if there are no longer any active transactions in the file, it can be reused. You should monitor archive log files periodically with the SHOWLOG command to make sure there is enough space in them.

When you use archive logging, you must periodically back up the DBEnvironment and the log files. The backups may be used in the event of a corruption of the DBEnvironment. Refer to the section "Backup and Recovery Procedures for Archive Logging" later in this chapter for a complete description of the procedures for managing archive log files.

Figure 6-2 “Archive Log” shows an archive log as implemented in ALLBASE/SQL.

Figure 6-2 Archive Log

[Archive Log]

Multiple Files in Archive Mode

Archive log files are known by three different designations:

  • Log name

  • Log identifier

  • Log sequence number

The log identifier is a number that uniquely identifies the file in the log directory. The log name is an MPE file name. If you are using dual logging, there are two MPE file names, but there is only one identifier. The log sequence number is important only for archive log files. It identifies the sequence the file occupies in the stream of rollforward recovery from the time the DBEnvironment was created. Sequence numbers are never reset.

When you use the STOREONLINE command, a new archive point is defined and the sequence number of the log file containing the first active transaction becomes the starting sequence number for the new archive log. As you cycle through a set of log files, filling them with transactions, then backing them up with STORELOG, the sequence number increments each time a new log file is used. Note that the assignment of sequence numbers has nothing to do with log identifier numbers or log names, so the same file may be used again and again with different sequence numbers.

In archive mode, you can use multiple files as a way of ensuring that there is always enough log file space. For example, when the first log file becomes full, ALLBASE/SQL will switch automatically to the second, which is given the next higher sequence number. Then, you can back up the first file, and when all transactions that were in progress in the first file have been committed or otherwise terminated, the file becomes available for reuse. A log file can be backed up as soon as ALLBASE/SQL has finished writing to it, but it cannot be purged or reused until all active transactions in it have been committed or rolled back.

The illustration in Figure 6-3 “Log Switching in Archive Mode” shows a log with three log files--DBELog1, DBELog2, and DBELog3 (identifier numbers 1, 2, and 3) over a period of several days.

Figure 6-3 Log Switching in Archive Mode

[Log Switching in Archive Mode]

At 5 pm on Monday, DBELog1 is not completely full, so it is not ready for backup. It has sequence number 1, whereas the two unused files DBELog2 and DBELog3 both have sequence number 0. On Tuesday at 5 pm, DBELog1 is full; there are still some active transactions in it, but it can be backed up using STORELOG. DBELog2 also has active transactions, but since DBELog2 is not yet full, no backup of DBELog2 is possible yet. On Wednesday, all the active transactions are in DBELog2, but DBELog2 is not yet full and therefore cannot be backed up. DBELog1 is now available for reuse, since it was backed up on Tuesday and now contains no active transactions. On Thursday, DBELog2 is full, so it is ready for backup using STORELOG. Furthermore, DBELog3 is now full and ready for backup. Note that active transactions now "wrap around" into DBELog1, which now has sequence number 4. When there are no more unused files available, ALLBASE/SQL will switch back to an earlier one and reuse it if it has been backed up and if it contains no active transactions. Note also that the sequence number of DBELog1 is 1 on Monday and 4 on Thursday. The file names and identifier numbers of log files are recycled, but the sequence numbers are never repeated.