Tuesday, January 03, 2006

Q. So What Is an Audio Database?

A. Simply put, the Audio Database is essentially built on top of a "page" server.

Q. Well that's simple... but what exactly is a Page Server?

A. Here's where it gets interesting...

Page Server


A page is simply a block of memory - currently fixed in size at 8192 bytes (8Kb).
The idea is that each database file is divided into pages and the page server maintains a memory cache of loaded/modified pages.

To facilitate recovery, if a page is changed then the changes must be logged to the transaction log before the page itself is written to disk (lazy write).

Once the page change has been logged we are free to save the actual data page at any time we choose (since the change itself is logged and can be recovered).

Forced Saves
To ensure consistency the page server will occassionally perform a forced save of all cached pages - this is known as a checkpoint operation. The checkpoint is very important as this defines the last known recovery point when the page server is restarted.

Still with me? Good!

Recovery
Clearly when a database is brought online there are some extra recovery steps which must be performed before the data store is synchronised with the logged transactions.

The process is known as recovery. During recovery all log records between a check-point start and a check-point end are analysed.

All committed transactions are rolled forward (ie: the log entries are compared with the pages and if the logged change has not been performed on the page then it is redone).

All rolled-back transactions (including those still in progress at the time of the EndCheckpointRecord) are rolled back (ie: the log entries are compared with the pages and if the logged change has been performed on the page then it is undone).

At the end of the recovery operation any transactions which were implicitly rolled back will have Rollback log records added.

Finally a checkpoint will be issued and this marks the end of the recovery phase and the page-server is open for business.

No comments: