# US 2009/0276430 A1 · Record-level locking and page-level recovery in a database management system

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2009/0276430 A1
- Document ID: US20090276430A1
- Status: Published application
- Kind: A1
- Application number: 12/150,646
- Filed: 2008-04-30
- Published: 2009-11-05
- Earliest claimed: 2008-04-30
- Assignees: Unisys Corporation
- Inventors: Kelsey L. Bruso; James M. Plasek
- Web page: https://patentgrep.com/patent/US20090276430A1

## CPC

- G06F 16/2343: {Locking methods, e.g. distributed locking or locking implementation details}
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

Disclosure of approaches for processing database transactions against a database. In one approach, a first transaction is received that specifies an operation for changing state of a first record stored in a first database page. In processing the operation, the state of the record is changed, and information is stored in a companion page. The information includes a transaction identifier, data describing the specified operation, a page identifier of the first page, a before look and an after look of the first record for an update operation, and an after look of the first record for an insert operation. In response to a commit of the first transaction, a process determines whether a second transaction, that specifies a change in state for a second stored in the first page, is in-process. In response to determining that the second transaction is in process, the companion page is stored in an audit trail. In response to determining that no such second transaction is in process, a transaction identifier of the first transaction and associated data of the first page are stored in the audit trail.

## Claims

### Claim 1

A processor-implemented method for processing database transactions against a database having a plurality of records stored on a plurality of database pages, comprising:
receiving a first transaction that specifies an operation for changing state for a first of the plurality of records stored on a first of the plurality of database pages, wherein the operation is one of an insert, update, or delete operations;
changing the state of the first record according to the first transaction;
storing in a companion page, a transaction identifier of the first transaction, data describing the specified operation, a page identifier of the first page, a before look and an after look of the first record for an update operation, and an after look of the first record for an insert operation;
in response to a commit of the first transaction,
determining whether a second transaction, that specifies a change in state for a second of the plurality of records and the second record being stored on the first page, is in-process;
storing, in response to determining that the second transaction is in process, the companion page in an audit trail;
storing in the audit trail, in response to determining that the second transaction is not in process, a transaction identifier of the first transaction and associated data of the first page.

### Claim 2 (depends on 1)

The method of claim 1, further comprising:
obtaining a first lock on the first record by the first transaction before the step of changing the state, wherein the first lock prohibits another transaction from changing the first record and allows scanning all records of the first page and allows operation by another transaction on any record on the first page other than the first record; and
releasing the lock on the first record after the step of storing in the audit trail.

### Claim 3 (depends on 1)

The method of claim 1, further comprising in response to a request to rollback the first transaction and the first transaction specifying an update operation, performing the steps including:
copying the before-look of the first record from the companion page to the first page.

### Claim 4 (depends on 3)

The method of claim 3, further comprising:
obtaining a first lock on the first record by the first transaction before the step of changing the state, wherein the first lock prohibits another transaction from changing the first record and allows scanning all records of the first page and allows operation by another transaction on any record on the first page other than the first record;
releasing the lock on the first record after the step of storing in the audit trail;
obtaining a second lock on the first page for the rollback request before the step of copying, wherein the second lock permits another transaction to access a record other than the first record on the first page and prohibits splitting and merging of the first page while the second lock is held; and
releasing the second lock after the step of copying.

### Claim 5 (depends on 1)

The method of claim 1, further comprising in response to a request to recover the database, performing the steps including:
for each database page in the audit trail for a committed transaction, storing the database page in the database file in persistent storage;
for each companion page in the audit trail that specifies a change to a database page prior to an entry being stored in the audit trail for the database page, bypassing updating the database according to the operation specified in the companion page; and
for each companion page in the audit trail for a committed transaction and for which an entry in the audit file was not made for a corresponding database page, applying the operation specified in the companion page to the database page and storing the database page in persistent storage.

### Claim 6 (depends on 5)

The method of claim 5, further comprising:
in response to detecting an error condition in processing a third transaction, storing a record in the audit trail that specifies that the third transaction was rolled back; and
in response to a request to recover the database and in response to detecting a rollback record in the audit trail for a third transaction, bypassing updating the database according to any audit trail record for the third transaction.

### Claim 7 (depends on 1)

The method of claim 1, further comprising in response to the first transaction specifying a delete operation, storing in the companion page a record number of the first record and for each key column of the database a key column identifier, a data type, a sort order, and a key column value.

### Claim 8 (depends on 1)

The method of claim 1, further comprising in response to a commit of the first transaction, storing in the audit trail a commit record including the transaction identifier of the first transaction and data that indicate the transaction has been committed.

### Claim 9 (depends on 1)

The method of claim 1, further comprising:
obtaining a first lock on the first record by the first transaction before the step of changing the state, wherein the first lock prohibits another transaction from changing the first record and allows scanning all records of the first page and allows operation by another transaction on any record on the first page other than the first record;
releasing the lock on the first record after the step of storing in the audit trail;
in response to a request to recover the database, performing the steps including:
for each database page in the audit trail for a committed transaction, storing the database page in the database file in persistent storage,
for each companion page in the audit trail that specifies a change to a database page prior to an entry being stored in the audit trail for the database page, bypassing updating the database according to the operation specified in the companion page, and
for each companion page in the audit trail for a committed transaction and for which an entry in the audit file was not made for a corresponding database page, applying the operation specified in the companion page to the database page and storing the database page in persistent storage.

### Claim 10 (depends on 1)

The method of claim 1, further comprising:
obtaining a first lock on the first record by the first transaction before the step of changing the state, wherein the first lock prohibits another transaction from changing the first record and allows scanning all records of the first page and allows operation by another transaction on any record on the first page other than the first record;
releasing the lock on the first record after the step of storing in the audit trail; and
in response to a request to rollback the first transaction and the first transaction specifying an update operation, copying the before-look of the first record from the companion page to the first page.

### Claim 11

A processor-implemented method for processing database transactions against a database having a plurality of records stored on a plurality of database pages, comprising:
in response to receiving a first transaction that specifies an operation for changing state of a first of the plurality of records stored on a first of the plurality of database pages, wherein the operation is one of an insert, update, and delete operation, controlling access to the first page, wherein the controlling access includes,
permitting scanning of all records on the first page while processing another transaction,
denying operations on the first record by another transaction, and
allowing operations by another transaction on any record on the first page other than the first record;
for committing the first transaction, performing the steps including,
in response to there being another transaction changing a record on the first page, storing a companion page in the audit trail, wherein the companion page includes a transaction identifier of the first transaction, data describing the specified operation, a page identifier of the first page, a before look and an after look of the first record for an update operation, and an after look of the first record for an insert operation,
in response to there being no other transaction changing a record on the first page, storing contents of the first page, a page identifier, and a transaction identifier in a record in the audit trail, and
storing a commit record in the audit trail including the transaction identifier of the first transaction and data that indicate the first transaction has been committed.

### Claim 12

An apparatus for processing database transactions, comprising:
means for processing a transaction that specifies an operation for changing state of a record stored to a database page, wherein the operation is one of an insert, update, and delete operation, and the record is one of a plurality of records stored on one of a plurality of database pages, wherein the transaction has a first level of control over access to the record and a second level of control over access to the database page;
means for committing the transaction, including,
means for storing contents of the database page in a record in an audit trail in response to no other transaction having any level of control over access to the database page,
means for storing a before look of the record and an after look of the record for an update database operation in a record in the audit trail in response to another transaction having a level of control over access to the database page, and
means for storing a commit record for the transaction in an audit record in the audit trail.

### Claim 13

A data processing system, for processing database transactions, comprising:
a storage arrangement for storing a database and an audit trail;
a processor coupled to the storage arrangement, wherein the storage arrangement is configured with instructions for causing the processor to perform the operations including,
processing a transaction that specifies an operation for changing state of a record stored to a page of the database, wherein the operation is one of an insert, update, and delete operation, and the record is one of a plurality of records stored on one of a plurality of database pages, wherein the transaction has a first level of control over access to the record and a second level of control over access to the database page, and
committing the transaction, the committing including the operations of,
storing contents of the database page in a record in an audit trail in response to no other transaction having any level of control over access to the database page,
storing a before look of the record and an after look of the record for an update database operation in a record in the audit trail in response to another transaction having a level of control over access to the database page, and
storing a commit record for the transaction in an audit record in the audit trail.

### Claim 14 (depends on 13)

The system of claim 13, the operations further including,
obtaining a first lock on the first record by the first transaction before the step of changing the state, wherein the first lock prohibits another transaction from changing the first record and allows scanning all records of the first page and allows operation by another transaction on any record on the first page other than the first record, and
releasing the lock on the first record after the step of storing in the audit trail.

### Claim 15 (depends on 13)

The system of claim 13, the operations further including, in response to a request to rollback the first transaction and the first transaction specifying an update operation, copying the before-look of the first record from the companion page to the first page.

### Claim 16 (depends on 15)

The system of claim 15, the operations further including,
obtaining a first lock on the first record by the first transaction before the step of changing the state, wherein the first lock prohibits another transaction from changing the first record and allows scanning all records of the first page and allows operation by another transaction on any record on the first page other than the first record,
releasing the lock on the first record after the step of storing in the audit trail,
obtaining a second lock on the first page for the rollback request before the step of copying, wherein the second lock permits another transaction to access a record other than the first record on the first page and prohibits splitting and merging of the first page while the second lock is held, and
releasing the second lock after the step of copying.

### Claim 17 (depends on 13)

The system of claim 13, the operations further including, in response to a request to recover the database, performing the steps of,
for each database page in the audit trail for a committed transaction, storing the database page in the database file in persistent storage,
for each companion page in the audit trail that specifies a change to a database page prior to an entry being stored in the audit trail for the database page, bypassing updating the database according to the operation specified in the companion page, and
for each companion page in the audit trail for a committed transaction and for which an entry in the audit file was not made for a corresponding database page, applying the operation specified in the companion page to the database page and storing the database page in persistent storage.

### Claim 18 (depends on 17)

The system of claim 17, the operations further including,
in response to detecting an error condition in processing a third transaction, storing a record in the audit trail that specifies that the third transaction was rolled back, and
in response to a request to recover the database and in response to detecting a rollback record in the audit trail for a third transaction, bypassing Updating the database according to any audit trail record for the third transaction.

### Claim 19 (depends on 13)

The system of claim 13, the operations further including, in response to the first transaction specifying a delete operation, storing in the companion page a record number of the first record and for each key column of the database a key column identifier,a data type, a sort order, and a key column value.

### Claim 20 (depends on 13)

The system of claim 13, the operations further including, in response to a commit of the first transaction, storing in the audit trail a commit record including the transaction identifier of the first transaction and data that indicate the transaction has been committed.
