The subject matter that is regarded as the invention is particularly pointed out and distinctly claimed in the claims at the conclusion of the specification. The foregoing and other objects, features, and advantages of the invention are apparent from the following detailed description taken in conjunction with the accompanying drawings in which:
The detailed description explains the preferred embodiments of the invention, together with advantages and features, by way of example with reference to the drawings.
Embodiments of the present invention provide a method and system for rapidly replicating a data record change in a database while minimizing the need for the database servers to negotiate what data will be replicated, by allowing the source server to independently decide what changes the destination server requires. The minimization of the required negotiations between servers results in a reduction in Central Processor Unit (CPU) utilization and provides improved CPU availability, improved network bandwidth, and a lower end-to-end replication delay. For replication to detect what items have changed, each data record is associated with a sequence number to identify the number of changes that have occurred to the data record since it was created.
When a data record in the database is changed, the information needs to be replicated to all other replicas of the database. Each data record in a database may contain multiple “Items”. An item is a unit (or part) of the data record that has a name (or label), and contains data. The exact format of an item is implementation dependant, but the basic idea is that a data record can be broken down into several distinct items. An example might be a data record in a discussion database. The data record in the database might contain multiple meta-data items such as “Author”, “Subject”, “Body”, and “Time”. Each of these items might be changeable by the user or the application. As the items change, the changes must replicate to other servers containing replicas of this database. The other servers will apply the changes to the other replicas of the databases, keeping all the replicas in sync.
One method of replication involves negotiation between servers. This might involve the source server (the server where the data record change occurred) contacting the destination server (another server containing a replica of the database) to determine which data records have changed, and what the changes are. Negotiation of what changes to replicate will cause only the necessary changes to replicate, but involves a higher overhead since a number of network operations would be involved in negotiating replication. To minimize the overhead associated with replication, a new method of replication involves an “optimistic” approach to replicating data. This method of replication eliminates the negotiation between servers, by allowing the source server to independently decide what changes it thinks the destination server requires. The source server identifies the most recent item changes for the changed data record, and immediately sends these to the destination server, without knowledge of whether the destination server already had the change, or if it was up to date with the source server.
In order for optimistic replication to detect what items have changed, each data record is associated with a sequence number to identify how many changes have been made to the data record since creation. For example, when a new data record is created, it will be associated with a sequence number of 1. As changes are made to the data record, the sequence number is incremented. A sequence number is associated with each item corresponding to the sequence number of the data record when the item was changed. If a given item sequence number is the same as the data record sequence number, then the change in the item corresponded to the most recent change to the data record. In addition, multiple items can be changed during one change to the data record. For example, a user or application may change multiple items during a single change. These items that are changed will have the same sequence number, which will also correspond to the data record sequence number. Please see Table 1 example for an illustration.
When the source server detects that a data record has changed, it collects the items that have the same sequence number as the data record itself (in other words, the items that were most recently changed) and sends these to the next replication server in the replication topology for this replica of the database. Only the highest sequenced items are delivered to the adjacent servers. The destination server, upon receiving the updated items will apply the items to its replica of the database. The destination server may then relay the information to other adjacent servers (if any) with replicas of the database.
The situation that is illustrated in
Embodiments of the present invention may also need to handle conflicts that would be caused by an item being simultaneously and independently changed on more than one server. In order to detect conflicts, there would need to be a record of time stamps for each of the data record changes done on a source server. This record of time stamps might be kept in an item of the data record. The implementation would use this record of changes to detect that a conflict has occurred, and will need to deal with the conflict in an implementation specific manner.
The flow diagrams depicted herein are just examples. There may be many variations to these diagrams or the steps (or operations) described therein without departing from the spirit of the invention. For instance, the steps may be performed in a differing order, or steps may be added, deleted or modified. All of these variations are considered a part of the claimed invention.
While the preferred embodiment to the invention has been described, it will be understood that those skilled in the art, both now and in the future, may make various improvements and enhancements which fall within the scope of the claims which follow. These claims should be construed to maintain the proper protection for the invention first described.