Abstract:
Techniques for coordinating updates to replicated data are disclosed. For example, in a system comprised of a plurality of nodes, a method for maintaining consistent copies of data across said nodes comprises the following steps. A copy of an object o 1  is maintained by a plurality of nodes. In response to a request r 1  to update a copy of object o 1 , a message is sent to at least some of said plurality of nodes instructing a node receiving the message to invalidate its copy of object o 1 . In response to a node n 1  receiving an invalidation message arising from r 1  wherein n 1  is processing another request r 2  to update object o 1 , requests r 1  and r 2  are coordinated to prevent the requests from causing conflicting updates or invalidations.

Description:
FIELD OF THE INVENTION  
       [0001]    The present invention relates to data processing systems and, more particularly, to techniques for coordinating updates to replicated data in such systems. 
       BACKGROUND OF THE INVENTION  
       [0002]    Replication is commonly employed to address the Quality of Service requirements of distributed applications. In general, distributed applications are software programs running on multiple computing nodes in a distributed computing network. Examples of distributed applications include electronic commerce (e-commerce) applications, financial institution commodity trading applications, private business entity applications, to name just a few. 
         [0003]    While replication improves both scalability and availability, it also introduces the problem of maintaining data consistent among the replicated computer nodes. In particular, strong consistency, which requires that all replicated data are current at all times, requires considerable overhead. 
       SUMMARY OF THE INVENTION  
       [0004]    Principles of the invention provide techniques for coordinating updates to replicated data. 
         [0005]    For example, in one embodiment, a method for maintaining consistent copies of data across nodes in a system comprised of a plurality of nodes comprises the following steps. A copy of an object o 1  is maintained by a plurality of nodes. In response to a request r 1  to update a copy of object o 1 , a message is sent to at least some of said plurality of nodes instructing a node receiving the message to invalidate its copy of object o 1 . In response to a node n 1  receiving an invalidation message arising from r 1  wherein n 1  is processing another request r 2  to update object o 1 , requests r 1  and r 2  are coordinated to prevent the requests from causing conflicting updates or invalidations. 
         [0006]    The step of coordinating requests may further comprise the steps of selecting one of said requests r 1  and r 2 , and updating object o 1  based on the selected request. An update associated with a request which is not selected may be ignored. A request may be selected based on a time associated with the request. The step of coordinating requests may further comprise merging new content from both r 1  and r 2 . 
         [0007]    The method may further comprise the steps of maintaining a log of updates to o 1 , and using said log to undo at least one update to o 1 . The method may comprise the steps of maintaining statistics on frequencies with which objects are accessed and updated, and in response to o 1  having a high ratio of accesses to updates, propagating a new value of o 1  to at least one remote node. 
         [0008]    Further, the method may comprise the steps of exchanging periodic heartbeat messages between said nodes to maintain availability information, and in response to a node failing to respond to a heartbeat message after a time period has elapsed, declaring said node failed. 
         [0009]    Additionally, the method may comprise the step of in response to a node failing to respond to an invalidation message after a time period has elapsed, declaring said node failed. An update associated with a request which is not selected may be aborted and retried. 
         [0010]    Still further, the method may comprise the step of exchanging lists of failed nodes to ensure nodes have a similar notion of which nodes have failed. 
         [0011]    These and other objects, features and advantages of the present invention will become apparent from the following detailed description of illustrative embodiments thereof, which is to be read in connection with the accompanying drawings. 
     
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS  
         [0012]      FIG. 1  illustrates a client-server system using replication, according to an embodiment of the invention. 
           [0013]      FIG. 2  illustrates our replication architecture, according to an embodiment of the invention. 
           [0014]      FIG. 3  illustrates a plurality of computer nodes communicating over a network to maintain consistency, according to an embodiment of the invention. 
           [0015]      FIG. 4  illustrates a sample message exchange using a protocol, according to an embodiment of the invention. 
           [0016]      FIG. 5  illustrates a middleware implementation of a replication architecture, according to an embodiment of the invention. 
           [0017]      FIG. 6  illustrates a computer system, according to an embodiment of the invention. 
       
    
    
     DETAILED DESCRIPTION OF PREFERRED EMBODIMENTS  
       [0018]    Principles of the invention provide a distributed protocol for providing strong consistency with less overhead than current lock-based approaches. We have implemented our protocol in a middleware that provides consistent replication for distributed multi-tier architectures. 
         [0019]    The replication model  100  we are considering in this illustrative implementation is shown in  FIG. 1 . As shown, distributed computing network  100  includes a plurality of client devices  102 - 1  through  102 - m  (client computing nodes or client nodes) operatively coupled to a plurality of server systems  106 - 1  through  106 - n  (server nodes) via a front-end computing device  104 . 
         [0020]    In general, server systems ( 106 - 1  through  106 - n ) provide services (in accordance with applications running thereon), which are accessed by clients ( 102 - 1  through  102 - m ) over a network. Clients are redirected to servers via the front-end  104 . The front-end distributed requests among servers trying to optimize some criterion, such as balancing the load across servers, or assigning clients to their geographically closest server. Replication is transparent to the clients, i.e., regardless of which server they communicate with, they see the same data at all times. A server can be hosted by one or more machines, but it represents one logical unit in our model. Servers communicate with each other over communication network  108 , to maintain consistency, which is required for replication transparency. Strong consistency requires that, at all times, all clients access the same versions of all data replicated between the servers. 
         [0021]    Each server ( 106 - 1  through  106 - n ) assumes a tiered architecture  200  as shown in  FIG. 2 . A presentation tier includes a web server ( 202 - 1  . . .  202 - n ) and is responsible for interaction with the clients. It accepts user requests and provides service results back to clients. A logic tier includes an application server ( 204 - 1  . . .  204 - n ) and is responsible for executing the business logic (specific application logic). It executes the required services to produce the requested results. A data tier permanently stores the state of services in a database ( 208 - 1  . . .  208 - n ). The inventive replication middleware ( 206 - 1  . . .  206 - n ) lies between the logic and the data tiers and provides consistent replication. 
         [0022]    To maintain consistency among server replicas, all accesses to the data tier are intercepted. Thus, the logic tier communicates only with the replication middleware, which is responsible for making the actual database calls. This interception can be active, by changing the application code running on the logic tier, or passive, by having the middleware provide an interface that makes it indistinguishable from a database from the application&#39;s perspective. 
         [0023]    At each server, write operations (or, more simply, “writes”) at a server are intercepted by the middleware ( 206 ) of that server, and in addition to being applied locally they are collected and sent to the rest of the servers in the form of updates (via communication network  108 ). Every server also receives updates from other servers and applies them locally. To provide strong consistency, read operations (or, more simply, “reads”) at a server are also intercepted by the middleware ( 206 ) of that server, to ensure all updates have been applied before data are returned to a client. 
         [0024]    We now describe the design of our distributed protocol for providing strong consistency without requiring locking or lock managers. Assuming nodes that maintain copies of data objects, we describe how the copies are kept consistent. The particular types of data objects are dependent on the particular application being executed. However, by way of example only, data objects may include data (e.g., documents, records, data sets, data units, etc.) associated with such applications as e-commerce sites, commodity trading sites, private business entity sites, etc. 
         [0025]      FIG. 3  depicts a plurality of computer nodes (servers), s 1 , s 2 , and s 3 , communicating over a network ( 300 ) to maintain consistency. The key problem is how to maintain copies of data objects in different nodes consistently. We now outline a method for maintaining copies of objects consistently, so that different versions of the same object are not offered by different nodes at the same time. In other words, we want to ensure that once a copy of an object o 1  is updated in a node s 1 , the copies of o 1  in all other nodes are updated as well, and that after the update has succeeded at s 1 , no other node serves an outdated copy of o 1 . The latter is important to offer strong and not just weak consistency. For strong consistency, it is not sufficient that all copies are updated at some point. It is also required that after an object update has been acknowledged as successful in any node, all nodes serve the updated version of the object. 
         [0026]    Our protocol has three phases for updating an object, which include the exchange of corresponding messages, as shown in  FIG. 4 . The three phases are the invalidation request ( 402 ), the invalidation reply ( 404 ), and the actual update ( 406 ). Invalidation requests and replies are used to coordinate the updates on the copies of the objects. An example  400  of the execution of the distributed protocol is shown in  FIG. 4 . All phases are discussed in detail below. 
         [0027]    It is important to handle update requests to objects in a consistent fashion. Let us assume that each node stores a copy of an object o 1 . Suppose that a node s 1  receives a request r 1  to update a data object o 1 . Update requests have timestamps associated with them, signifying when the request was generated. When node s 1  attempts to update data object o 1 , it sends invalidation requests to other nodes that may have copies of o 1 ; these invalidation requests include the timestamp of the update request r 1 . The timestamp reflects the local time at node s 1  that initiated the request. While the clocks of all nodes can be loosely synchronized, the correctness of the protocol does not depend on that. As explained in the next paragraphs, the timestamps are used for the nodes to agree on a relative order between them, and could therefore be arbitrary. After s 1  has received positive invalidation replies from all the nodes, indicating that they have invalidated their copies (or did not have a valid copy at the time the invalidation request was received), it can update o 1 . However, as we describe below, s 1  may not always receive these positive invalidation replies and may not always be able to update o 1 . 
         [0028]    When a node s 2  receives s 1 &#39;s invalidation request to invalidate its copy of object o 1 , it responds with a positive or a negative invalidation reply depending on whether it will ensure that any valid copy of o 1  has been invalidated. To decide whether it will invalidate an existing copy of o 1 , s 2  checks whether it is also in the process of updating o 1 . If s 2  is not in the process of updating o 1 , and if it has no valid copy of o 1 , it simply responds with a positive invalidation reply. If s 2  is not in the process of updating o 1  but has a valid copy of o 1 , it invalidates its copy of o 1  and also responds with a positive invalidation reply. 
         [0029]    If s 2  is in the process of updating o 1 , let r 2  be the update request associated with s 2  that s 2  is processing. Node s 2  compares the timestamp of its update request, r 2 , with r 1  (the update request associated with s 1 ). The request with the earlier timestamp is ignored. (If both timestamps are equal, there are several methods for breaking this tie. For example, an ordering of the nodes could be imposed by comparing the hashes of the nodes&#39; Internet Protocol (IP) addresses and port numbers and having the request from the node with the larger hash value dominate.) If r 1  has the later timestamp, s 2  invalidates o 1  and sends a positive invalidation reply to s 1 . If r 2  haw the later timestamp, s 2  sends a negative invalidation reply to s 1 . 
         [0030]    Node s 1  updates object o 1  after it has received positive invalidation replies from all other nodes; these indicate that the other nodes no longer have valid copies of the object. If s 1  receives one or more negative invalidation replies, it aborts its attempt to update o 1 , and its update will be ignored. When s 1  will receive the invalidation request for o 1  corresponding to a request with a timestamp after r 1 , it will invalidate its copy of o 1  and send a positive invalidation reply. More generally, after a node attempting to perform an update receives positive invalidation replies that all other nodes no longer have valid copies of o 1 , it will proceed with the update. 
         [0031]    In some cases, a node may fail to respond to an invalidation message. In these situations, after a timeout period, the node may be declared down and the system can assume that the node no longer has a valid copy of the object. We describe in more detail how to handle failure detection below. 
         [0032]    A variation on this approach is for a node s 3  which is not processing an update request for o 1  but has recently processed at least one invalidation request for o 1  to maintain the latest timestamp, tl, of an update request corresponding to recently received invalidation requests for o 1 . If it receives a new invalidation request for o 1  from a node s 4  with a timestamp after tl, it sends back a positive invalidation reply. If it receives a new invalidation request for o 1  from a node s 4  with a timestamp before tl, it sends back a negative invalidation reply. This indicates to s 4  that there is an update request with a later timestamp than its own update request and that it should not waste resources continuing to process its update request for o 1  because it will be aborted. Negative invalidation replies from nodes that are not the ones intending to perform an update accelerate the decision of whether an object can be updated. However, the protocol correctness only depends on the replies of the nodes that are actually intending to perform an update. These nodes are the ones that will always send a negative invalidation reply, whereas other nodes may or may not do so, depending on the order with which they receive the invalidation requests. 
         [0033]    Note how this method avoids locks. Furthermore, updates that would be overwritten are coalesced. When different nodes are concurrently processing different updates, only the update with the latest timestamp needs to be applied. 
         [0034]    A node propagates an updated object to the rest of the nodes that maintained earlier copies of this object, using either a pull- or a push-based method, named demand-based updating and prefetching, respectively. 
         [0035]    With demand-based updating, a node receives a new copy of an object only after receiving a request for this object. This pull-based method conserves resources in the event that an object is not requested. However, it incurs some additional latency the first time an object is accessed, since the object has to be fetched at that time. This method is appropriate for infrequently requested objects. 
         [0036]    With prefetching, a node receives a new copy of an object before the object is requested; for example, this could happen right after that object is updated. This push-based method does not incur latency the first time an object is accessed, since the object has already been fetched. However, it wastes resources if an object is not accessed before it becomes obsolete. This method is appropriate for frequently requested objects. 
         [0037]    To decide whether an updated object is propagated using demand-based updating or prefetching, statistics regarding the frequency with which objects are both accessed and updated can be maintained. If an object has a high ratio of accesses to updates, prefetching may be utilized. Otherwise, demand-based updating may be preferable for that object. 
         [0038]    In most applications, if multiple entities attempt to concurrently update the same object, one writer simply overwrites the other. Thus, in our illustrative consistency protocol, updates are coalesced by applying only the latest one and ignoring the rest. If the application requires reconciling updates from multiple sources, when multiple writers detect each other, a reconciliation process can take place so that the concurrent updates are merged instead of always having one completely overwrite another. As an example, the merging process could be similar to that used by source control systems such as Concurrent Versions System (CVS). Other merging processes could be used as well. For example, the earliest update can be applied and the latest aborted and retried. 
         [0039]    Another variation of our approach is to keep histories of updates and allow updates to be undone. To facilitate this reconciliation process, a log of received updates can be maintained, used to undo updates to objects. Updates can be made in a transactional fashion in which one or more updates can be committed at the same time. 
         [0040]    To detect failures, nodes can exchange periodic heartbeat messages. When a node fails to respond to heartbeat messages after a threshold timeout period has elapsed, other nodes declare it as failed and do not require its invalidation replies before updating objects. When a node fails to receive heartbeat messages, it declares its replicated content invalid until it can revalidate them after connectivity is established again. This way a disconnected node (for example, due to a network partition) will not serve obsolete data. 
         [0041]    After node failures are detected using the above heartbeat messages, we describe how they are handled for the different phases of the consistency protocol: if a node fails before replying to an invalidation request, the node that sent the invalidation request declares it as failed and does not require its invalidation reply. If a node fails after initiating but before completing an invalidation, in other words after sending invalidation requests, we consider two cases: if the node&#39;s update would have been overwritten due to a concurrent update (with a later timestamp) produced by another node, again it is declared as failed and its invalidation reply is not required. If the node&#39;s update was the single update, or the dominating one in case of multiple concurrent updates (the one with the latest timestamp), the rest of the nodes will not invalidate their copies. This way the incomplete update of the failed node is ignored. 
         [0042]    To handle cases of network partitioning, i.e., cases in which certain nodes can communicate with each other while others cannot, we can give nodes a common view of failed nodes by disseminating that information whenever they determine a node failure. 
         [0043]    We have implemented the above strong consistency protocol in a replication middleware, as a multi-threaded Java program. The middleware is used to maintain consistency among object replicas stored in databases that are queried by application servers to provide dynamic web content. Three types of messages are exchanged between nodes to implement the distributed protocol: invalidation requests, invalidation replies, and updates. Invalidation requests and replies are used to decide which changes should be applied. Updates are used to prefetch the object changes to the nodes. 
         [0044]      FIG. 5  shows the building blocks of our replication middleware ( 500 ), responsible for consistency maintenance of the local objects and for communication with the remote nodes. There are six major modules. The replica access module ( 502 ) is responsible for providing permission to access objects in the local node and for sending invalidation requests and updates to the remote nodes. The invalidation requests manager module ( 504 ) keeps track of the invalidation requests the local node makes and notifies the replica access module once all remote nodes have replied to an invalidation request. The invalidations manager module ( 506 ) keeps track of the objects that have been invalidated and notifies the replica access module once an invalid object has been updated with its new version. The message sender module ( 508 ) is responsible for sending invalidation requests, invalidation replies, and updates to the remote nodes. The message receiver module ( 510 ) is a thread listening for incoming messages. Once a message is received, a new thread that implements the message processor module ( 512 ) is spawned to apply an update, or to determine whether an invalidation request should be positively or negatively acknowledged. For efficiency, we can avoid the creation and destruction of threads, by maintaining a thread pool. 
         [0045]    We now describe in more detail how the protocol execution takes place using the modules above. A sample message exchange is shown in  FIG. 4  and is discussed in the following paragraphs. When a node wants to read or write an object, the replica access grants that permission once the invalidations manager notifies it that the object is not invalid as currently being updated remotely. If the object is currently being updated, the notification takes place once the update is completed. When a node s 1  wants to write on an object o 1 , it first ensures via the invalidations manager that o 1  is not currently being updated. It then sends invalidation requests to all remote nodes that host copies of the object. It also calls the invalidation requests manager, which notifies it once all remote nodes have replied. If at least one of the invalidation replies was negative, this signifies that an update with a later timestamp will be applied on o 1  by another node. Therefore, s 1  aborts its attempt to write on o 1 , notifying the invalidation requests manager that the request was unsuccessful. If all invalidation replies were positive, the update can proceed. The invalidation requests manager is called to register the fact that the request was successful, the invalidations manager is called to register the fact that object o 1  is currently being updated, the updates are sent, and the invalidations manager is called again to register the fact that o 1  is not being updated anymore. 
         [0046]    When a node s 2  receives an invalidation request from node s 1  to invalidate object o 1 , the message processor consults the invalidation requests manager to determine whether s 2  has already sent invalidation requests for o 1 . If this is the case, the timestamps of the local (s 2 &#39;s) and the remote (s 1 &#39;s) invalidation requests are compared. The request with the later timestamp dominates and the one with the earlier timestamp will be ignored. If both timestamps are equal, the hashes of the nodes&#39; IP addresses and port numbers are compared and the request from the node with the largest hash value dominates. If the local (s 2 &#39;s) invalidation request dominated, a negative invalidation reply is sent from s 2  to s 1 . If the remote (s 1 &#39;s) invalidation request dominated, the invalidations request manager is called to register the fact that the local request is unsuccessful, and a positive invalidation reply is sent from s 2  to s 1 . The invalidations manager at s 2  is called to register the fact that object o 1  is being updated. It is called again when the update message for o 1 , sent from s 1 , is received by s 2 , to register the fact that o 1  is not being updated anymore. 
         [0047]    When a node s 3 , that has not sent invalidation requests for o 1 , but has received an invalidation request for o 1  from s 2 , receives an invalidation request for o 1  from s 1 , it performs the timestamp comparison described above and sends a positive or negative invalidation reply to s 1 . If s 1 &#39;s invalidation request dominates, s 3  calls its invalidations manager to register the fact that o 1  is now being updated by s 1  instead of s 2 . 
         [0048]    Replies from nodes that are not the ones intending to perform an update can accelerate the decision of which update to be applied. However, the protocol correctness only depends on the replies of the nodes that are actually intending to perform an update, as is illustrated in the example of  FIG. 4 , which shows a sample message exchange. In dashed lines are the messages pertaining to s 1 &#39;s update attempt. In solid lines are the messages pertaining to s 2 &#39;s update attempt. “INV” denotes invalidation requests, “ACK” denotes positive invalidation replies, “NACK” denotes negative invalidation replies, and “UPD” denotes updates. Both s 1  and s 2  send invalidation request messages. Node s 2 &#39;s timestamp dominates and therefore its update is applied. The nodes responsible for deciding which update will be applied are s 1  and s 2 . The rest of the nodes (s 3  and s 4 ) also compare timestamps and their replies can accelerate the decision, but the protocol correctness does not depend on their replies. 
         [0049]    This is illustrated by the message exchange shown in  FIG. 4 : s 2  compares the timestamp of its own invalidation request to the timestamp of the invalidation request of s 1  and determines that its own update will be applied. Therefore, it sends a negative invalidation reply to s 1 . Similarly, s 4  reaches the same conclusion and sends a positive invalidation reply to s 2 . Node s 3 , however, because of communication delay has received and processed the invalidation request of s 1  before receiving the invalidation request of s 2 . Therefore, it sends a positive invalidation reply to s 1 , because it does not have to compare the timestamp of s 1 &#39;s invalidation request to that of any other request at that point. Once s 3  receives the invalidation request of s 2 , it performs the timestamp comparison and sends a positive invalidation reply to s 2  as well. Despite the fact that s 3  sent a positive invalidation reply to s 1 , s 1  still does not perform its update because of the negative invalidation reply it receives from s 2  (and from s 4 ). Therefore, the protocol execution is correct. Regardless of the replies of s 3  and s 4  (which depend on the order with which s 3  and s 4  happen to receive the invalidation requests of s 1  and s 2 ), s 2  will definitely send a negative invalidation reply to s 1 . If the negative invalidation reply of one of the other nodes (s 4  in this example) reaches s 1  before s 2 &#39;s invalidation reply, s 1  determines faster that its invalidation request was not successful. If due to communication delays causing nodes to receive messages in different order, one of the nodes other than s 2  sends a positive invalidation reply (s 3  in this example) that still does not lead s 1  to reach a wrong conclusion, since it will definitely have a negative invalidation reply from s 2 . 
         [0050]    Lastly,  FIG. 6  illustrates a computer system in accordance with which one or more components/steps of the techniques of the invention may be implemented. It is to be further understood that the individual components/steps may be implemented on one such computer system or on more than one such computer system. In the case of an implementation on a distributed computing system, the individual computer systems and/or devices may be connected via a suitable network, e.g., the Internet or World Wide Web. However, the system may be realized via private or local networks. In any case, the invention is not limited to any particular network. 
         [0051]    Thus, the computer system shown in  FIG. 6  may represent one or more client devices, one or more servers, or one or more other processing devices capable of providing all or portions of the functions described herein in the context of  FIGS. 1-5 . 
         [0052]    The computer system  600  may generally include a processor  602 , memory  604 , input/output (I/O) devices  606 , and network interface  608 , coupled via a computer bus  610  or alternate connection arrangement. 
         [0053]    It is to be appreciated that the term “processor” as used herein is intended to include any processing device, such as, for example, one that includes a CPU and/or other processing circuitry. It is also to be understood that the term “processor” may refer to more than one processing device and that various elements associated with a processing device may be shared by other processing devices. 
         [0054]    The term “memory” as used herein is intended to include memory associated with a processor or CPU, such as, for example, RAM, ROM, a fixed memory device (e.g., hard disk drive), a removable memory device (e.g., diskette), flash memory, etc. The memory may be considered a “computer readable storage medium.” 
         [0055]    In addition, the phrase “input/output devices” or “I/O devices” as used herein is intended to include, for example, one or more input devices (e.g., keyboard, mouse, etc.) for entering data to the processing unit, and/or one or more output devices (e.g., display, etc.) for presenting results associated with the processing unit. 
         [0056]    Still further, the phrase “network interface” as used herein is intended to include, for example, one or more transceivers to permit the computer system to communicate with another computer system via an appropriate communications protocol. 
         [0057]    Accordingly, software components including program instructions or code for performing the methodologies described herein may be stored in one or more of the associated memory devices (e.g., ROM, fixed or removable memory) and, when ready to be utilized, loaded in part or in whole (e.g., into RAM) and executed by a CPU. Such a memory device with said stored program instructions is an example of a “computer program product.” 
         [0058]    In any case, it is to be appreciated that the techniques of the invention, described herein and shown in the appended figures, may be implemented in various forms of hardware, software, or combinations thereof, e.g., one or more operatively programmed general purpose digital computers with associated memory, implementation-specific integrated circuit(s), functional circuitry, etc. Given the techniques of the invention provided herein, one of ordinary skill in the art will be able to contemplate other implementations of the techniques of the invention. 
         [0059]    Although illustrative embodiments of the present invention have been described herein with reference to the accompanying drawings, it is to be understood that the invention is not limited to those precise embodiments, and that various other changes and modifications may be made by one skilled in the art without departing from the scope or spirit of the invention.