How Db2 protects data consistency in a data sharing environment

Applications can access data from any Db2 subsystem in a data sharing group. Many subsystems can potentially read and write the same data. Db2 uses special data sharing mechanisms for locking and caching to ensure data consistency.

When multiple members of a data sharing group have opened the same table space, index space, or partition, and at least one of them has opened it for writing, the data is said to be of inter-Db2 read-write interest to the members. (Sometimes this information uses the term inter-Db2 interest.) To control access to data that is of inter-Db2 interest, whenever the data is changed, Db2 caches it in a storage area that is called a group buffer pool (GBP).

Db2 dynamically detects inter-Db2 interest, which means that Db2 can invoke intersystem data sharing protocols only when data is actively read-write shared between members. Db2 can detect when data is not actively intersystem read-write shared. In these cases, data sharing locking or caching protocols are not needed, which can result in better performance.

When inter-Db2 read-write interest exists in a particular table space, index, or partition, this inter-Db2 read-write interest is dependent on the group buffer pool, or group buffer pool dependent.

You define group buffer pools by using coupling facility resource management (CFRM) policies. For more information, see Defining coupling facility structures.

The following figure shows the mapping that exists between a group buffer pool and the buffer pools of the group members. For example, each Db2 subsystem has a buffer pool named BP0. For data sharing, you must define a group buffer pool (GBP0) in the coupling facility that maps to buffer pool BP0. GBP0 is used for caching the Db2 catalog table space and its index, and any other table spaces, indexes, or partitions that use buffer pool BP0.

Figure 1. Relationship of buffer pools to group buffer pools. One group buffer pool exists for all buffer pools of the same name.
Begin figure description. Members DB2A and DB2B both have buffer pools 0, 1, and n that map to the group buffer pools 0, 1, and n, respectively. End figure description.

The same group buffer pool cannot reside in more than one coupling facility (unless it is duplexed).

When a particular page of data is changed, Db2 caches that page in the group buffer pool. The coupling facility invalidates any image of the page that might exist in the buffer pools that are associated with each member. Then, when another Db2 subsystem subsequently requests that same data, that Db2 subsystem looks for the data in the group buffer pool.

Performance benefits
The coupling facility provides fast, global locking operations for concurrency control. The Parallel Sysplex® offers the following performance and scalability benefits:
  • Changed pages are written synchronously to the coupling facility, without the process switching that is associated with disk I/O.
  • Buffer invalidation signals are sent and processed without causing any processor interrupts, unlike message-passing techniques.
  • A fast hardware instruction detects invalidated buffers, and the coupling facility can refresh invalidated buffers synchronously with no process switching overhead, unlike disk I/O.
Performance options to fit your application's needs
Although the default behavior is to cache only the updated data, you also have options of caching all or none of your data. You even have the option to cache large object (LOB) data.