NET CHANGE MIRRORING OPTIMIZATION ACROSS TRANSACTIONS IN REPLICATION ENVIRONMENT

Information

  • Patent Application
  • 20190278781
  • Publication Number
    20190278781
  • Date Filed
    May 24, 2019
    5 years ago
  • Date Published
    September 12, 2019
    4 years ago
Abstract
In optimizing net change data replication across a plurality of transactions in a replication environment, a source replication engine at a source database system: obtains a window in a source database log for the net change data replication; for a given row identifier found in the source database log, identifies an initial operation and a latest operation across the plurality of transactions within the window; compares the initial operation and the latest operation for the given row identifier to determine a net change to a row associated with the given row identifier; and stores the net change as a final operation on the given row identifier in an optimization repository for replication to a target database. The operations stored in the optimization repository are then sent to a target database system for replication to the target database.
Description
BACKGROUND

The replication or mirroring of data changes from a source database to a target database can be performed either continuously or periodically according to a schedule. In a scheduled replication, a user specifies a point in a database log at which the replication is to end. The transactions at the source database logs are examined, and the net change between the last replication and the user-specified point is replicated to the target database tables. Optimization techniques exist that examine the end image of a database table row. However, these optimization techniques are limited to net changes within a single transaction.


SUMMARY

Disclosed herein is a method for net change data replication across a plurality of transactions in a replication environment, and a computer program product and system as specified in the independent claims. Embodiments of the present invention are given in the dependent claims. Embodiments of the present invention can be freely combined with each other if they are not mutually exclusive.


According to an embodiment of the present invention, in optimizing net change data replication across a plurality of transactions in a replication environment, a source replication engine at a source database system: obtains a window in a source database log for the net change data replication; for a given row identifier found in the source database log, identifies an initial operation and a latest operation across the plurality of transactions within the window; compares the initial operation and the latest operation for the given row identifier to determine a net change to a row associated with the given row identifier; and stores the net change as a final operation on the given row identifier in an optimization repository for replication to a target database. The operations stored in the optimization repository are then sent to a target database system for replication to the target database.


In one aspect of the present invention, the window is a range of entries in the source database log from a previous net change data replication to a point in the source database log at which the net change data replication is to end.


In one aspect of the present invention, when each transaction of the plurality of transactions commit, each transaction is assigned a system change number (SCN). The initial operation is an operation in the source database log associated with the given row identifier and has a lowest SCN within the window. The latest operation is an operation in the source database log associated with the given row identifier and has a highest SCN within the window.





BRIEF DESCRIPTION OF THE DRAWINGS


FIG. 1 illustrates a replication environment according to embodiments of the present invention.



FIG. 2 illustrates a computer system, one or more of which are used to implement the embodiments of the present invention for optimizing data replication across transactions in a replication environment.



FIG. 3 illustrates a method for optimizing net change data replication across a plurality of transactions in a replication environment according to embodiments of the present invention.



FIG. 4 illustrates in more detail the comparison of the initial and latest operations and the determination of the net change according to embodiments of the present invention.





DETAILED DESCRIPTION


FIG. 1 illustrates a replication environment according to embodiments of the present invention. The replication environment includes a source database system 101 and a target database system 111. The source database system 101 includes a source database 103 comprising tables, each table comprising a plurality of columns and rows. Each row is associated with a unique row identifier. As transactions are performed and committed on the data in the source database 103, the transactions and their operations are stored in a source database log 104. The target database system 111 includes a target database 113 comprising tables that mirror the tables at the source database 103. A source replication engine 102 performs the replication process as described herein and sends replication data to the target replication engine 112. In performing the replication process, optimizations are applied as described herein, and the optimized replication data are stored in an optimization repository 105. The target replication 112 receives the replicated data stored in the optimization repository 105 from the source replication engine 102 and modifies the target database 113 with the replicated data. Access to the replication environment over a communications network 130 is managed by an access server 121. Through the management console 120, the replication process can be managed, configured, and monitored. Configuration can include setting the replication to a net change or scheduled end mode, including a user specifies a point in time or a point in the source database log 104 at which the replication is to be performed.



FIG. 2 illustrates a computer system, one or more of which are used to implement the embodiments of the present invention for optimizing data replication across transactions in a replication environment. The computer system 200 is operationally coupled to a processor or processing units 206, a memory 201, and a bus 209 that couples various system components, including the memory 201 to the processor 206. The bus 109 represents one or more of any of several types of bus structure, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, and a processor or local bus using any of a variety of bus architectures. The memory 201 may include computer readable media in the form of volatile memory, such as random access memory (RAM) 202 or cache memory 203, or non-volatile storage media 204. The memory 201 may include at least one program product having a set of at least one program code module 205 that are configured to carry out the functions of embodiment of the present invention when executed by the processor 206. The computer system 200 may also communicate with one or more external devices 211, such as a display 210, via I/O interfaces 207. The computer system 200 may communicate with a database management system 212 over one or more networks via network adapter 208.



FIG. 3 illustrates a method for optimizing net change data replication across a plurality of transactions in a replication environment according to embodiments of the present invention. As a prerequisite, each table in the source database 103 is associated with a table key. The source replication engine 102 groups the plurality of transactions captured in the source database log entries using the table key. The source replication engine 102 obtains the window for a scheduled or net change data replication (301). The window may be defined by configuring a point in the source database log 104 at which the replication is to end. The window is thus the range of source database log entries from the last net change replication to the configured point. The size of the window may be a configuration parameter by users and may be based on a time duration (e.g. two hours), a number of transactions (e.g. 1000 transactions), or some combination thereof. Each log entry records a transaction and its operations performed on specific source database table rows, each row being associated with a unique row identifier or table key. For a given row identifier found in the source database log 104, the source replication engine 102 identifies the initial operation and the latest operation across the plurality of transactions within the window (302). In this exemplary embodiment, each committed transaction is sequentially assigned a system change number (SCN), which is stored in the source database log entries. From the SCN's, the order in which the plurality of transactions committed can be determined. The initial operation is thus the operation with the lowest or earliest SCN within the window and involve a row associated with the given row identifier. The latest operation is the operation with the latest or highest SCN within the window and involve a row associated with the given row identifier. The source replication engine 102 then compares the initial and the latest operations for the given row identifier to determine a net change to the data in the row associated with the given row identifier (303). The source replication engine 102 stores, in the optimization repository 105, the net change as a final operation on the given row identifier for replication to the target database 113 (304). Steps 302-304 are repeated for other row identifiers. The source replication engine 102 then sends the operations stored in the optimization repository 105 to the target replication engine 112 at the target database system 111 for replication to the target database 113.


For example, assume that, for a given row identifier, 1000 UPDATE operations across multiple transactions were performed within the window, where a “salary” column value in a row with an “empid” column value=1 was changed. The initial operation is identified as the first UPDATE operation, and the latest operation is identified as the last UPDATE operation on the row (302). However, the last UPDATE operation sets the final salary value. The source replication engine 102 compares the initial and latest operations and determines that the net change is the value for the “salary” column as updated by the last operation (303). In this case, using the optimization process according to the present invention, only an UPDATE operation setting the final salary value is stored in the optimization repository 105 to be replicated to the target database 113 (305), avoiding the replication of the other 999 UPDATE operations.


For another example, assume that, for a given row identifier, an INSERT operation is performed in an initial operation within the window and a DELETE operation is performed in a latest operation within the window. The initial operation is identified as the INSERT operation, and the latest operation is identified as the DELETE operation (302). The source replication engine 102 compare the initial and the latest operations to determine that the net change is the deletion of the row associated with the given row identifier (303). Thus, neither operations is replicated to the target database 113 (304), avoiding the replication of both the INSERT and the DELETE operation, and any intervening operations, for the given row identifier within the same window.



FIG. 4 illustrates in more detail the comparison of the initial and latest operations and the determination of the net change according to embodiments of the present invention. After identifying the initial and latest operations for a given row identifier (302, FIG. 3), the source replication engine 102 determines whether the initial operation is an INSERT or an UPDATE (401). When the initial operation is an INSERT, the source replication engine 102 determines whether the latest operation is a DELETE or an UPDATE (407). When the initial operation is an INSERT and the latest operation is a DELETE, then the net change is null, and there is no replication (412). Neither operation is stored in the optimization repository 105. When the initial operation is an INSERT (401) and the latest operation is an UPDATE (407), the source replication engine 102 determines whether the latest UPDATE operation is in scope (408), i.e., whether the UPDATE is within the window. If the latest UPDATE operation is not in scope, then no replication occurs (412). If the latest UPDATE operation is in scope (408), then the net change is an INSERT of the final data of the latest operation, and an INSERT with the latest operation data is stored in the optimization repository (409).


When the initial operation is an UPDATE (401), the source replication engine 102 determines whether the initial UPDATE operation is in scope (402). If the initial UPDATE operation is not in scope, and the latest operation is a DELETE (407), then the net change is null, and there is no replication (412). If the initial UPDATE operation is not in scope (402), and the latest operation is an UPDATE (407) that is also not in scope (408), then the net change is null, and there is no replication (412). If the initial UPDATE operation is not in scope (402), and the latest UPDATE operation is in scope (408), then the net change is a match to the latest operation, and an INSERT with the latest operation data is stored in the optimization repository (409).


If the initial UPDATE operation is in scope (402), and the latest operation is a DELETE (403), then the net change is a DELETE, and a DELETE with the initial operation data is stored in the optimization repository (410). If the initial UPDATE operation is in scope (402) and the latest UPDATE operation is also in scope (403-404), then the source replication engine 102 determines whether the replication key has changed (405). If the replication key has not changed, then the net change is an update, and an UPDATE with the latest operation data is stored in the optimization repository (411). If the replication has changed (405), then to ensure that the old replication key is not replicated, a DELETE with the initial operation data and an INSERT with the latest operation data are stored in the optimization repository (406).


Embodiments of the present invention can significantly reduce the overall elapsed time for performing a net change replication. The embodiments can also significantly reduce the overall amount of data being replicated, hence reducing the workload of the entire replication pipeline from source to target. The embodiments can further increase the throughput of the net change replication. A configurable number of multiple threads may be used. By optimizing net change replication in the above described manner, the use of resources of the source replication engine 102, such as CPU cycles, memory, and disk space, may be optimized.


The present invention may be a system, a method, and/or a computer program product. The computer program product may include a computer readable storage medium (or media) having computer readable program instructions thereon for causing a processor to carry out aspects of the present invention.


The computer readable storage medium can be a tangible device that can retain and store instructions for use by an instruction execution device. The computer readable storage medium may be, for example, but is not limited to, an electronic storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. A non-exhaustive list of more specific examples of the computer readable storage medium includes the following: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), a static random access memory (SRAM), a portable compact disc read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanically encoded device such as punch-cards or raised structures in a groove having instructions recorded thereon, and any suitable combination of the foregoing. A computer readable storage medium, as used herein, is not to be construed as being transitory signals per se, such as radio waves or other freely propagating electromagnetic waves, electromagnetic waves propagating through a waveguide or other transmission media (e.g., light pulses passing through a fiber-optic cable), or electrical signals transmitted through a wire.


Computer readable program instructions described herein can be downloaded to respective computing/processing devices from a computer readable storage medium or to an external computer or external storage device via a network, for example, the Internet, a local area network, a wide area network and/or a wireless network. The network may comprise copper transmission cables, optical transmission fibers, wireless transmission, routers, firewalls, switches, gateway computers and/or edge servers. A network adapter card or network interface in each computing/processing device receives computer readable program instructions from the network and forwards the computer readable program instructions for storage in a computer readable storage medium within the respective computing/processing device.


Computer readable program instructions for carrying out operations of the present invention may be assembler instructions, instruction-set-architecture (ISA) instructions, machine instructions, machine dependent instructions, microcode, firmware instructions, state-setting data, or either source code or object code written in any combination of one or more programming languages, including an object oriented programming language such as Smalltalk, C++ or the like, and conventional procedural programming languages, such as the “C” programming language or similar programming languages. The computer readable program instructions may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider). In some embodiments, electronic circuitry including, for example, programmable logic circuitry, field-programmable gate arrays (FPGA), or programmable logic arrays (PLA) may execute the computer readable program instructions by utilizing state information of the computer readable program instructions to personalize the electronic circuitry, in order to perform aspects of the present invention.


Aspects of the present invention are described herein with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer readable program instructions.


These computer readable program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks. These computer readable program instructions may also be stored in a computer readable storage medium that can direct a computer, a programmable data processing apparatus, and/or other devices to function in a particular manner, such that the computer readable storage medium having instructions stored therein comprises an article of manufacture including instructions which implement aspects of the function/act specified in the flowchart and/or block diagram block or blocks.


The computer readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device to cause a series of operational steps to be performed on the computer, other programmable apparatus or other device to produce a computer implemented process, such that the instructions which execute on the computer, other programmable apparatus, or other device implement the functions/acts specified in the flowchart and/or block diagram block or blocks.


The flowchart and block diagrams in the Figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of instructions, which comprises one or more executable instructions for implementing the specified logical function(s). In some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts or carry out combinations of special purpose hardware and computer instructions.


The descriptions of the various embodiments of the present invention have been presented for purposes of illustration, but are not intended to be exhaustive or limited to the embodiments disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The terminology used herein was chosen to best explain the principles of the embodiments, the practical application or technical improvement over technologies found in the marketplace, or to enable others of ordinary skill in the art to understand the embodiments disclosed herein.

Claims
  • 1. A method for optimizing net change data replication across a plurality of transactions in a replication environment, comprising: obtaining, by a source replication engine at a source database system, a window in a source database log for the net change data replication;for a given row identifier found in the source database log, identifying, by the source replication engine, an initial operation and a latest operation across the plurality of transactions within the window;comparing, by the source replication engine, the initial operation and the latest operation for the given row identifier to determine a net change to a row associated with the given row identifier; andstoring, by the source replication engine, the net change as a final operation on the given row identifier in an optimization repository for replication to a target database.
  • 2. The method of claim 1, wherein the comparing of the initial operation and the latest operation for the given row identifier to determine the net change and the storing of the net change as the final operation on the given row identifier in the optimization repository for replication to the target dataset comprises: determining that the initial operation is a first INSERT operation or a first UPDATE operation that is not in scope of the window;when further the latest operation is a DELETE operation or a second UPDATE operation that is not in scope of the window, determining that the net change is null; andwhen further the latest operation is a third UPDATE operation that is in scope of the window, determining that the net change comprises a second INSERT operation with data of the latest operation and storing the second INSERT operation in the optimization repository.
  • 3. The method of claim 1, wherein the comparing of the initial operation and the latest operation for the given row identifier to determine the net change and the storing of the net change as the final operation on the given row identifier in the optimization repository for replication to the target dataset comprises: determining that the initial operation is a first UPDATE operation that is in scope of the window;determining that the latest operation is a first DELETE operation or a second UPDATE operation that is not in scope of the window;in response to determining that the initial operation is the first UPDATE operation that is in scope of the window and that the latest operation is the first DELETE operation or the second UPDATE operation that is not in scope of the window, determining that the net change comprises a second DELETE operation with data of the initial operation; andstoring the second DELETE operation in the optimization repository.
  • 4. The method of claim 1, wherein the comparing of the initial operation and the latest operation for the given row identifier to determine the net change and the storing of the net change as the final operation on the given row identifier in the optimization repository for replication to the target dataset comprises: determining that the initial operation is a first UPDATE operation that is in scope of the window;determining that the latest operation is a second UPDATE operation that is in scope of the window;in response to determining that the initial operation is the first UPDATE operation that is in scope of the window and that the latest operation is the second UPDATE operation that is in scope of the window, determining whether a replication key has changed;when the replication key has changed, determining that the net change comprises a DELETE operation with data of the initial operation and an INSERT operation with data of the latest operation and storing the DELETE operation and the INSERT operation in the optimization repository; andwhen the replication key has not changed, determining that the net change comprises a third UPDATE operation with the data of the latest operation and storing the third UPDATE operation in the optimization repository.
  • 5. The method of claim 1, wherein the window comprises a range of entries in the source database log from a previous net change data replication to a point in the source database log at which the net change data replication is to end.
  • 6. The method of claim 1, wherein when each transaction of the plurality of transactions commit, each transaction is assigned a system change number (SCN), wherein the initial operation is an operation in the source database log associated with the given row identifier and has a lowest SCN within the window, wherein the latest operation is an operation in the source database log associated with the given row identifier and has a highest SCN within the window.
  • 7. The method of claim 1, further comprising: sending operations stored in the optimization repository to a target database system for replication to the target database.
Continuations (1)
Number Date Country
Parent 15803170 Nov 2017 US
Child 16421481 US