DB2 active logs, archive logs, and the BSDS

Every committed UPDATE is useless after a crash unless DB2 can find the matching log records. Those records land first in active logs, then in archive logs after offload. The bootstrap data set (BSDS) is the map of which data sets hold which RBA ranges. This page is the beginner tour of that machinery: dual logging, sizing, SET LOG, truncation, compression, and how recovery reads the same files.

Logging and recovery
Progress0 of 0 lessons

What logging is for

Logging records data changes and significant events as they happen. Restart uses the log to redo committed work and undo uncommitted work. The RECOVER utility uses the log to roll an image copy forward (log apply). Commands after restart are also logged as system events. This is not optional journaling you turn off for speed in production.

Pieces of the log environment
PieceRole
Active logsCurrent write target; reused after offload
Archive logsDurable copies of former actives for recovery
BSDSInventory of logs, RBA/LRSN ranges, checkpoint pointers
Dual copiesCOPY1/COPY2 logs and dual BSDS against single-point failure

Active logs

Db2 writes each log record to a disk VSAM data set called an active log. You define several active log data sets (a ring). When the current data set is full, Db2 switches to the next and offloads the full one. After a successful archive, that active data set can be overwritten on the next cycle.

Active log sizing: too small and you offload constantly (tape mounts, CPU, risk of “all actives full”). Too large and a single media problem loses more history, and offload jobs get huge. IBM: each archive log data set must be at least as large as the active logs. Typical shops use three or more active pairs so offload of one can finish while others accept writes.

If every active log is full and archiving has not completed, update activity does not complete and you may not even be able to stop Db2 cleanly. Monitor offload and archive allocation (including tape units via -SET ARCHIVE).

Dual logging

In dual logging mode Db2 writes the same records to COPY 1 and COPY 2 active logs on separate volumes/control units when possible. A write error on one copy can fall back to single-mode logging; restore dual operation without an outage when you can. Always add NEWLOG data sets in pairs when dual logging is on.

Archive logs

An archive log is the offload target: disk or tape sequential data sets. Archive log sizing follows the active size (at least as large) and your retention: keep archives for as long as you might need to RECOVER from the oldest image copy you still catalog. BSDS records the archive inventory; DSNJU004 (print log map) lists what Db2 thinks it has.

Log compression can reduce archive volume (installation and zparm options). Compressed archives still must be readable by RECOVER on the subsystem that needs them—test restore paths, do not discover compression at the DR site.

-SET ARCHIVE controls how many tape units archive offload may use and how long they stay allocated. Wrong values cause offload delays that fill actives.

BSDS and dual BSDS

The BSDS is a VSAM key-sequenced data set created at installation. It holds:

  • Names and RBA/LRSN ranges of active and archive log data sets
  • Location of the latest checkpoint on the log
  • Conditional restart / log truncation control records
  • BACKUP SYSTEM history (system-level backups)
  • Other restart and DDF-related inventory

Dual BSDS means two copies, updated together. If one copy fails, Db2 can continue; -RECOVER BSDS rebuilds the damaged copy from the good one. Print log map (DSNJU004) and change log inventory (DSNJU003) run against the BSDS while Db2 is down (DSNJU003). Never “fix” BSDS with a text editor.

At migration to Db2 12 you cannot start until the BSDS uses the 10-byte RBA and LRSN format. Convert before or during migration.

Log RBA, LRSN, and log records

A log RBA (relative byte address) locates a record in this member’s log. LRSN (log record sequence number) is the data-sharing time-based sequence used across members. Non-data-sharing recovery points are RBAs; data-sharing recovery points are LRSNs. Log records include undo/redo data for pages, checkpoint records, and system events.

DISPLAY LOG shows current active log names, RBA, offload status, and checkpoint parameters.

text
1
2
3
4
-DISPLAY LOG -SET LOG LOGLOAD(0) /* force a checkpoint, keep current LOGLOAD */ -SET LOG NEWLOG(DSNCAT.LOGCOPY1.DS04) COPY(1) -SET LOG NEWLOG(DSNCAT.LOGCOPY2.DS04) COPY(2)

Log offload, truncation, and SET LOG

Log offload copies a completed active log to an archive. You can also truncate the current active log (switch early) so a consistent copy exists—used with SET LOG SUSPEND/RESUME and some backup procedures.

-SET LOG can:

  • Change checkpoint frequency (LOGLOAD / related CHK* parameters)
  • SUSPEND / RESUME logging and updates (FlashCopy / volume backup windows)
  • NEWLOG — add a defined active log to the BSDS while Db2 is up
  • REMOVELOG — remove an active log from the BSDS (later Db2 versions; if in use it is flagged until it is no longer current)

NEWLOG/REMOVELOG changes are pervasive (they survive restart). DSNJU003 remains the tool when Db2 is down or for operations SET LOG cannot do (conditional restart records).

Recovery logs and log apply

From RECOVER’s point of view, active and archive data sets are simply recovery logs. After restoring an image copy, log apply reads every log record for that object from the copy’s RBA/LRSN to the target point. The BSDS tells RECOVER which data set contains that range. If you discarded an archive that SYSCOPY still needs, recovery fails. MODIFY RECOVERY deletes old SYSCOPY/SYSLGRNX rows—do that only after you accept that older recovery points are gone.

Point-in-time and disaster recovery procedures always start with “are the BSDS and the needed logs at the recovery site?” Image copies without logs only get you to the copy time, not to current.

Operational checklist

  • Dual active logs on independent hardware; dual BSDS
  • Enough active pairs that offload can lag without filling the ring
  • Archive capacity ≥ active size; tested tape/disk recall
  • Regular DSNJU004 listings stored with DR documentation
  • Monitor offload failures and BSDS I/O errors immediately
  • Do not run DSNJU003 against an active Db2

Explain It Like I'm Five

Active logs are the notebook on the desk. When a notebook is full, you photocopy it into a box in the closet (archive) and reuse the notebook. The BSDS is the list taped to the closet door: which notebook and which box hold which page numbers (RBAs). Dual logging is writing in two notebooks at once so spilling juice on one is not a disaster. Offload stuck with a full desk of notebooks means nobody can write new stories until a box is free.

Exercises

  1. Issue DISPLAY LOG and name the current COPY1/COPY2 active data sets and whether offload is running.
  2. Read a DSNJU004 listing: find the latest checkpoint RBA and count active versus archive entries.
  3. Explain why archive data sets must be at least as large as actives.
  4. Write the SET LOG NEWLOG pair you would use to add a fourth dual active log (names from your shop).
  5. Trace what happens if tape archive allocation fails for two hours during peak update volume.

Quiz

Test Your Knowledge

1. What is the BSDS?

  • A buffer pool for sorts
  • The bootstrap data set that inventories active and archive logs and related restart info
  • Only a COBOL copybook
  • The work file database

2. When an active log data set fills, Db2:

  • Deletes the catalog
  • Offloads (copies) it to an archive log and reuses the active log in the cycle
  • Stops requiring image copies forever
  • Converts RBA to LRSN only

3. Dual logging means:

  • Two independent Db2 subsystems sharing one log
  • Each log record is written to two copies of the active log (COPY1 and COPY2)
  • Only archive logs are duplexed, never actives
  • BSDS cannot be duplexed

4. A log RBA is:

  • A RACF group
  • The relative byte address of a log record in this subsystem’s log stream
  • Always the same as an LRSN in data sharing
  • A buffer pool name

5. Which command can add an active log while Db2 is up (Db2 10+)?

  • -SET LOG NEWLOG(...) COPY(n)
  • -STOP DB2 MODE(FORCE) only
  • DROP TABLE
  • -DISPLAY THREAD only