Mainframe Path Start learning free
Applied11 min readLesson 2 of 3

The coupling facility and data sharing

The coupling facility is a special LPAR that holds shared lock, cache and list structures in fast memory. Db2, IMS, VSAM RLS and MQ use those structures so that programs on several systems can update the same data at once without corrupting it.

What a coupling facility is

A coupling facility (CF) is an LPAR that runs Coupling Facility Control Code (CFCC), IBM licensed internal code, instead of z/OS. It usually runs on processors configured as ICFs (internal coupling facility engines). z/OS systems reach it over coupling links; on current machines these include short-reach ICA SR links, long-reach Coupling Express links and internal (IC) links inside one CPC. The exact link types depend on the machine generation.

A CF runs no application code. It holds structures: areas of memory that z/OS components and subsystems use to share state. Requests to it take microseconds, which is what makes sharing data across systems practical.

The three kinds of CF structure
Lock
A table of lock entries showing which systems have an interest in a resourceLets a system grant most locks without asking the othersUsed by IRLM for Db2 and IMS, VSAM RLS and GRS star
Cache
Shared buffers plus a directory of who holds which pageTells other systems when their local copy is staleUsed by Db2 group buffer pools, IMS database buffers, VSAM RLS, the RACF database
List
Shared lists and queues with serialised accessSupports ordered entries and notificationUsed by XCF signalling, JES2 checkpoint, system logger, MQ shared queues, IMS shared queues

Keeping caches honest

Each Db2 member keeps pages in its own local buffer pool. If two systems hold a copy of the same page and one updates it, the other copy is now wrong. The cache structure solves this with cross-invalidation: it records which systems hold each page and, when one system writes a changed page, the CF marks every other copy invalid. The next time another system needs the page, it rereads the current version from the group buffer pool or from disk.

Cross-invalidation in a Db2 group buffer pool
SYSA updates pagein its local buffer
Writes to GBPcache structure
CF invalidatesSYSB's local copy
SYSB rereadsgets the current page

Data sharing in the real products

Data sharing means several systems read and update the same data at the same time with full integrity. Each major subsystem does it in its own way:

ProductWhat is sharedCF structures used
Db2 data sharingSeveral Db2 members, one set of databases and one catalogLock (through IRLM), group buffer pools (cache), shared communications area (list)
IMS data sharing and shared queuesIMS databases; with shared queues, the input messages tooIRLM lock, OSAM and VSAM cache structures, list structures for message queues
VSAM RLSVSAM datasets opened by CICS regions on many systems, locked at record levelA lock structure (IGWLOCK00) and cache structures, managed by the SMSVSAM address space
IBM MQ shared queuesQueues shared by every queue manager in a queue-sharing groupList structures, plus an administration structure; large messages are offloaded to shared message data sets or Db2

See RLS for the VSAM side and Db2 for the database side. Applications usually need little or no code change to run in a data sharing group, but they must avoid affinities, such as state kept in one region's memory, or the workload cannot move freely.

Defining structures: the CFRM policy

Structures are described in the CFRM policy, created with the administrative data utility IXCMIAPU and activated with SETXCF START,POLICY,TYPE=CFRM,POLNAME=name. IBM's CFSizer tool helps estimate sizes.

Part of a CFRM structure definition (illustrative)What it means
STRUCTURE NAME(DSNDB0G_LOCK1)
Db2 lock structures are named after the data sharing group
INITSIZE(65536) SIZE(131072)
Starting and maximum size; 1 KB units by default. Real values come from sizing
PREFLIST(CF01,CF02)
Which CFs to use, in order of preference
DUPLEX(ENABLED)
Keep a duplexed copy in a second CF where the product supports it
Allocated structures (illustrative, abbreviated)
D XCF,STR
STRNAME            STATUS
DSNDB0G_LOCK1      ALLOCATED
DSNDB0G_GBP0       ALLOCATED (DUPLEXED)
IGWLOCK00          ALLOCATED
ISGLOCK            ALLOCATED
QSG1CSQ_ADMIN      ALLOCATED

Surviving a CF failure

TRY IT YOURSELF

Which of the three CF structure types (one word) holds IBM MQ shared queues?

Show a hint

Messages are ordered entries on a queue.

Show the solution

List. MQ shared queues are held in CF list structures.

Common mistakes

Assuming every application can be spread across systems

Affinities such as region-local temporary storage or single-system file access stop work moving. Find and remove them before relying on data sharing.

Running production with a single coupling facility

If that CF fails there is nowhere to rebuild structures. Production needs two or more CFs, sized so either can hold the critical structures.

Sizing structures once and forgetting them

Volumes grow. An undersized lock structure causes false contention and an undersized cache causes extra I/O. Review sizes with the RMF CF reports and CFSizer as workload changes.

What you will see at work

Key terms

Check your understanding.
Take this lesson's quiz and save your progress. Free.

Take the lesson quiz
← From one system to many: sysplex, XCF and couple data setsContinuous availability: balancing, rolling IPLs, GDPS and common problems →