Abstract:
A computer program product for a system and method for destaging changed data from a shared cache castout in a shared data environment distributes castout ownership for a dataset among a plurality of systems having an update interest in the dataset. One system is designated as having castout ownership of the dataset in a primary state. All other systems having an update interest in the dataset hold castout ownership for the dataset in a backup state. When the primary owner relinquishes ownership, primary ownership is passed to one of the backup systems. A structure castout owner for the entire cache assumes the responsibility of castout out changed data for a dataset for which the primary castout owner has had a failure.

Description:
This application is a division of application Ser. No. 08/311,755 filed Sep. 23, 1994, (status:pending). 
    
    
     CROSS-REFERENCE TO OTHER APPLICATION(S) 
     The following application of common assignee is related to the present application, and is believed to have an effective filing date identical with that of the present application: 
     U.S. Patent Application entitled System And Method For Including Stored Procedures, User-Defined Functions, And Trigger Processing In An Existing Unit Of Work, by Curt L. Cotner, Robert J. Heaps, Wendy L. Koontz, Benjamin R. Little, and Thomas J. Toomire, Ser. No. 08/311,035 (filed Sep. 23, 1994) incorporated herein by reference in its entirety. 
     1. Technical Field 
     The present invention relates generally to shared disk systems and more particularly to a system and method for continuous destaging of changed data from a shared cache. 
     2. Background Art 
     With the advent of shared data systems came the requirement that data updates be propagated to all systems sharing those data. Several techniques have been developed in response to this requirement. One such technique utilizes a high speed electronic cache for propagating data updates among the various systems in the data sharing facility. One example of such a cache is a coupling facility available from International Business Machines, Inc. 
     In a shared data facility implementing this cache technique, when. one system updates data (for example a page of data in a data file), that system forwards the updated data (e.g., the updated page) to the cache. However, due to the high costs typically associated with cache storage, the size of such a cache is much smaller than the capacity of the shared disk(s). Consequently, a process is provided to periodically destage, or cast out changed data from the shared cache. Such a process is commonly known as a castout process. In this environment, the system performing the update sends the updated data (e.g., the page) to the cache. At some later moment, the castout process fetches the updated data from the cache and replaces the corresponding data on the shared disk. 
     SUMMARY OF THE INVENTION 
     The present invention is directed to a system and method for distributing the task of destaging, or casting out, changed data in a shared cache. According to the invention, each system that has an update interest in a dataset is capable of acquiring a castout ownership interest in this dataset. Thus, the invention provides for continuous destaging of changed data from the shared cache in the presence of failures of systems using the cache. The destaging of cached data is distributed among the systems for the purpose of load balancing and for backup in the event of a system failure. 
     A hierarchical structure for castout ownership is provided. The systems using the shared cache for their shared data allocate a piece of the cache referred to as the cache structure. This cache structure is used for caching data for one or more datasets which are shared by multiple systems. One of these systems using the cache structure becomes the &#34;structure owner&#34;and has the responsibility for initiating castouts at the dataset level. 
     Systems can hold a castout ownership interest in the dataset at one of two levels: primary and backup. At any one time, only one system can hold a primary castout ownership interest; all other systems having castout ownership have such ownership in the backup state. 
     The first time a system updates a shared dataset, that system attempts to acquire castout ownership. This system is granted primary castout ownership, but only if no other system holds primary castout ownership for that dataset. Otherwise, the system acquires a backup ownership interest in the dataset. 
     When a system having castout lock in a dataset loses its update interest in that dataset, the system relinquishes castout lock for that dataset. If the system held lock in the backup state, no further action is required. If, however, the system held a primary ownership interest in the dataset, primary ownership must pass to a backup system. If no backup system exists, all changed data from the dataset are castout by the primary system and the castout process for that dataset is folded up before the primary system relinquishes ownership. If one or more backup systems do exist, primary ownership responsibility is passed on to one of these systems. 
     A structure castout ownership level is provided whereby a system is designated as having castout responsibility for the whole cache structure in the shared cache. The system having castout ownership at the structure level accomplishes its tasks by calling on systems having castout ownership (preferably primary ownership) for the datasets. Periodically, a process within the structure castout owner takes a checkpoint to determine a timestamp for recovery purposes. At checkpoint, the structure castout owner attempts to castout all dirty data for the cache structure used by the system. 
     In the event of a failure of the primary castout owner for a dataset, the structure castout owner detects the absence of the primary castout owner and assumes the responsibility for casting out changed data of that dataset. 
     An advantage of the invention is that castout responsibility is distributed among several systems. Thus, bottlenecks caused by an overloaded system can be avoided. A further advantage is that by distributing the castout workload, the impact on transaction processing is minimized and protection is provided against loss of the castout feature. 
     One object of the invention is to have an uninterrupted service of casting out changed pages from the shared cache regardless of a failure of individual system(s) performing that task. 
     Further features, advantages and objects of the present invention, as well as the structure and operation of various embodiments of the present invention, are described in detail below with reference to the accompanying drawings. 
     The foregoing and other objects, features and advantages of the invention will be apparent from the following more particular description of (a) preferred embodiment(s) of the invention, as illustrated in the accompanying drawing(s). 
    
    
     BRIEF DESCRIPTION OF DRAWINGS 
     The present invention is described with reference to the accompanying drawings. In the drawings, like reference numbers indicate identical or functionally similar elements. Additionally, the left-most digit(s) of a reference number identifies the drawing in which the reference number first appears. 
     FIG. 1 is a block diagram illustrating a shared data environment; 
     FIG. 2 is an operational flow diagram illustrating a method by which primary or backup castout ownership is established for a dataset; 
     FIG. 3 is an operational flow diagram illustrating a method by which a system can relinquish castout lock on a dataset; 
     FIG. 4 is an operational flow diagram illustrating a method by which a system manages structure castout; 
     FIG. 5 is an operational flow diagram illustrating a method by which a system having primary structure castout lock acquires castout lock for a dataset. 
    
    
     DETAILED DESCRIPTION 
     The present invention is directed toward a system and method for distributing the castout work of a shared cache process among several systems (e.g., DBMS, or data base management systems) in a shared data facility. This distribution is also used to manage recovery from failed castout processes caused by system failures. According to the invention, when a system is required to update data (such as a page in a dataset), it attempts to become a castout owner for that dataset. As the castout owner, that system contains the castout process for that dataset. 
     Because multiple systems may wish to update the same dataset, and hence, attempt to become a castout owner, the invention provides for the establishment of a castout owner hierarchy and dynamic assignment of castout ownership within this hierarchy. According to this hierarchy, one system is the primary castout owner for the dataset and all others are backup owners for this dataset. It is the system that is the primary owner that contains the castout process. If the primary owner relinquishes its castout interest, a backup owner is upgraded to the status of a primary owner. If there is no backup owner for that dataset, a cache structure owner eventually assumes the responsibility for casting out changed data for that dataset. 
     FIG. 1 is a block diagram illustrating an example of a shared data facility 100 in which the invention can be implemented. According to this example, shared data facility 100 includes several systems 104A-104N (generally referred to as systems 104), a shared disk 108 and a coupling facility 112 which contains a cache structure 113. Systems 104 running application programs share data stored in shared disk 108. Data updates are performed using coupling facility 112. Systems 104 can be collocated in a single location or plant. Alternatively, systems 104 can be located at various different sites physically removed from each other. 
     In the description provided herein, data updates are discussed in terms of data in data files (or, using IBM terminology, datasets). After reading the description provided herein, it will become apparent to a person skilled in the relevant art how to implement the invention using other data structures. 
     If coupling facility 112 were to be implemented as a write through cache, data updates would be automatically forwarded to shared disk 108. However, where coupling facility 112 is not a write through facility, the updates of data (e.g., a page) in a dataset are first stored in the cache structure 113. At some later time, the updated data are read by a system 104 and the shared disk 108 version of the data is replaced. Thus, conventional systems assign the castout process to a single system which handles the updates for the entire cache structure 113. There are, however, disadvantages with such a conventional arrangement. First, if the system 104 that contains the castout process goes down or is otherwise unavailable, the castout cannot take place. If the castout feature is lost, data-sharing can potentially be disabled because there is no longer a way to propagate updates across the systems 104. Second, in a data sharing facility 100 handling a high transaction volume, it is important not to overburden any one system 104 with the task of performing castout. 
     To get around these drawbacks, the castout workload is distributed among multiple systems 104. By distributing the castout workload, the impact on transaction processing is minimized (i.e., CPU cycles used up by castout), and protection is provided against loss of the castout feature due to a failure on the system 104 that is responsible for castout. 
     In one embodiment, the services of a lock manager, a commonly available service in transaction processing systems, are utilized to distribute the castout workload among systems 104. Responsibility for the castout of a particular dataset is assigned to a particular system 104. Because each system 104 is susceptible to failure, a scheme is provided whereby the castout responsibility can be transferred to another system 104. According to the invention, castout responsibility is assigned according to the dataset (e.g., file or pageset) update interest. Data in a given dataset are castout by the system 104 that has established itself as the primary castout owner for that file. This system can be considered the &#34;owner&#34;of the castout function for that file. 
     Because the castout responsibility is distributed among multiple systems 104, there can be more than one castout owner for the entire collection of files. For each of these datasets, only one system 104 is designated as having primary castout responsibility for each dataset. All other systems 104 (other than primary) having an update intereset for a dataset have backup castout responsibility in that dataset. 
     The first time a system 104, for example system 104A, updates data in a shared dataset, that system 104A attempts to become the castout owner for that dataset. It does so by acquiring a castout lock in the backup state. If no other system 104 is the primary castout owner for that dataset, system 104A acquires primary castout ownership. In this case, system 104A is said to have castout lock in the primary state. If another system 104 already has primary responsibility for that dataset, system 104A acquires backup castout ownership. In this second case, system 104A acquires castout lock in the backup state. 
     The process of acquiring castout lock is now described. FIG. 2 is an operational flow diagram illustrating the process of acquiring castout lock. Referring now to FIG. 2, in a step 204, a system 104 (e.g., 104A) opens a dataset for the first update of that dataset and attempts to acquire castout responsibility for that dataset. In a step 208, system 104A acquires castout lock in the backup state for that dataset. Because there can be numerous systems 104 having castout lock in the backup state, such lock is granted in step 208 unconditionally. 
     In a step 212, system 104A attempts to acquire castout lock in the primary state for the subject dataset. If the primary state is available in step 216 (i.e., if no other system 104 has primary castout ownership for that dataset), system 104A acquires castout lock in the primary state as illustrated by step 220. If, on the other hand, the primary state is not available in step 216, system 104A maintains castout lock in the backup state as illustrated by step 224. 
     This protocol of first becoming a backup castout owner and then primary ensures that each system having an update interest in the dataset can become the primary castout owner for that dataset if no other primary exists. This is because by first becoming the backup, the system 104 gets on the lock manager&#39;s notification list for becoming the primary in the event the primary fails or relinquishes its responsibility. 
     According to one embodiment, a system 104 acquires dataset castout responsibility only if it has an update interest in the dataset, and not if it has read interest only. This protocol is advantageous where a dataset is to be opened in a read/write mode only when a system 104 has an update interest. Thus, a system 104 with a read-only interest would not be a good candidate for writing castout data to the associated dataset on shared disk 108. 
     When a system 104 having castout lock in a dataset loses its update interest, it relinquishes castout lock. The process of relinquishing castout lock is described with reference to the operational flow diagram depicted in FIG. 3. 
     Referring now to FIG. 3, in a step 304, a system 104 having castout lock for a dataset (e.g., system 104A) relinquishes its update interest in that dataset. In a step 308, that system 104A relinquishes castout lock for that dataset. If system 104A held lock in the backup state (decision block 312), no further processing takes place in other instances of systems 104. If, however, system 104A held lock in the primary state (decision block 312), primary ownership must pass to a backup system 104. However, if no backup system 104 exists (decision block 316), the dataset is castout by system 104A and the castout process is folded up as illustrated in a step 320. 
     If a backup system 104 exists, in a step 324 the global lock manager notifies the backup system 104 (e.g., system 104B) that it may now hold lock in the primary state. If the backup system 104B accepts this primary responsibility for the dataset (decision block 328), system 104B becomes the primary owner of the castout responsibility for this dataset as illustrated in a step 332. 
     When the primary owner relinquishes its interest, the global lock manager informs the primary owner as to the state of the castout lock held by other systems 104 for that dataset. 
     Note that system 104B may refuse to accept primary castout responsibility for the dataset as illustrated by decision block 328. This may be because system 104B is overloaded and does not want to accept castout responsibility. However, if system 104B is the only remaining system 104 that holds castout lock for this dataset, it is not allowed to refuse primary castout responsibility. 
     In one embodiment, some systems may be disabled from having castout responsibility, or even disabled from having primary castout responsibility, due to cost or performance constraints. For example, due to communications costs and bandwidth constraints, it would be costly and/or inefficient to assign primary castout responsibility to a system 104 that is located at a very far distance from the shared disk 112. 
     In one embodiment, the castout feature of the invention uses a two-level hierarchy of systems 104 that communicate via messages. At the lower level of the hierarchy are system 104 that are in charge of castouts for datasets. At the higher level is a system 104 that controls castout responsibility for the whole cache structure 113. This system 104 at the higher level is referred to as the structure castout owner. The structure castout owner accomplishes its tasks by calling upon services of systems 104 at the lower level. Structure castout ownership is assigned by acquiring a structure castout lock in the primary state. Backup responsibility is assigned by acquiring structure castout lock in the backup state. 
     A method by which the structure castout owner manages cleanup of datasets with changed data is illustrated in FIG. 4. In a step 404, one system (e.g., system 104A) is assigned structure castout ownership in the primary state. Periodically, a process within structure castout owner system 104A takes a cache structure checkpoint. Such a checkpoint is preferably time driven. This is illustrated in step 408. The purpose of this checkpoint is to determine a timestamp for recovery purposes. Also, at the cache structure checkpoint, the system attempts to castout all data for cache structure 113. 
     At cache structure checkpoint, the structure castout owner system 104A starts processing a cache structure&#39;s directory to get a &#34;min&#34; timestamp for recovery purposes. This is illustrated by a step 412. This process is fully described in U.S. Pat. No. 5,280,611,to Mohan, et al, the full disclosure of which is incorporated herein by reference as if reproduced in full below. 
     While the structure castout owner system 104A scans the coupling facility directory, in a step 416, system 104A builds a list of datasets having updated data in the cache structure 113. In a step 420, the structure castout owner system 104A notifies the respective owner systems 104 of these datasets to castout all updated data for their datasets. 
     As stated above, in step 420 the structure castout owner system 104A notifies the primary castout owner of the dataset that there is dirty data. However, if the primary owner system 104A for this dataset has failed and if there is no backup owner, the castout function can only arise at the cache structure checkpoint. When, in step 420, the structure castout owner system 104A determines that there is no primary lock holder for the dataset, system 104A assumes temporary castout ownership for that dataset, casts out the data from the dataset, closes the dataset, and relinquishes the castout responsibility for that dataset. FIG. 5 is an operational flow diagram illustrating the process of assuming temporary castout ownership in greater detail. 
     As stated above, in step 420 the structure castout owner system 104A notifies the owner system 104 that there is dirty data. More specifically, as illustrated in a step 420, system 104A notifies the system having lock in the primary state for the specific dataset. If there is a system 104 having lock in the primary state (decision block 508), that system 104 handles the castout for the dataset. If, however, there is no system having lock in the primary state for the dataset, in a step 512, the structure castout owner system 104A physically opens the subject dataset. 
     In a step 516, the structure castout owner system 104A attempts to acquire castout lock for the dataset in the primary state. If this attempt fails (decision block 520), this indicates that another system has acquired primary lock in the dataset. Therefore, the operation continues at step 420 as illustrated by flowline 562. If, on the other hand, castout owner system 104A acquires castout lock for the dataset in the primary state, in step 524 castout owner system 104A casts out the data. 
     While various embodiments of the present invention have been described above, it should be understood that they have been presented by way of example only, and not limitation. Thus, the breadth and scope of the present invention should not be limited by any of the above-described exemplary embodiments, but should be defined only in accordance with the following claims and their equivalents. 
     BEST MODE FOR CARRYING OUT THE INVENTION 
     While the invention has been particularly shown and described with reference to (a) preferred embodiment(s) thereof, it will be understood by those skilled in the art that (various changes) (the foregoing and other changes) in form and details may be made therein without departing from the spirit and scope of the invention.