Method and device for accelerating data synchronization
By executing the target fusion operation in the destination database, the problem of slow data synchronization caused by the inability to execute related data operations concurrently in multiple threads is solved, and the data synchronization efficiency is improved.
Patent Information
- Application Number
- CN202411221908.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-02
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2044-09-02
AI Technical Summary
In the prior art, data synchronization is slow because related data operations cannot be performed concurrently by multiple threads.
By performing conflict detection on the operation log of the source database, generating a target fusion operation, and executing it on the destination database, multiple data operations are merged into one target fusion operation, replacing parallel execution, thus solving the problem of slow data synchronization.
By performing target fusion operations on the target database, data operation steps are reduced and data synchronization efficiency is accelerated.
Smart Images

Figure CN119128008B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data synchronization, and in particular to a method and device for accelerating data synchronization. Background Art
[0002] With the rapid development of information construction, in order to meet business development needs, it is often necessary to synchronize data from one database (ie, the source database) to another database (ie, the destination database) in real time.
[0003] During data synchronization, to improve synchronization efficiency, data operations are typically synchronized using multi-threaded concurrent execution. However, when using this multi-threaded concurrent execution method, data operations must be unrelated to rows. Multiple data operations with related rows cannot be synchronized concurrently and must be executed strictly in the order of the multiple data operations in the source database. For example, if there is data operation 1, "Insert a row R1 into database table T1," and data operation 2, "Update the field value of R1," the synchronization tool must first execute data operation 1 on the destination database before executing data operation 2 to ensure data consistency between the source and destination databases.
[0004] In actual synchronization scenarios, when most data operations in the source database are related, most data operations can only be synchronized to the destination database serially, which greatly affects the data synchronization speed.
[0005] In view of this, overcoming the defects of the prior art is an urgent problem to be solved in this technical field. Summary of the Invention
[0006] The technical problem to be solved by the present invention is to provide a method and device for accelerating data synchronization, the purpose of which is to perform conflict detection on the operation logs of the source database, generate corresponding target fusion operations based on multiple conflicting operation logs, and execute the target fusion operation on the target database instead of executing multiple data operations corresponding to the multiple conflicting operation logs in parallel on the target database. This solves the problem of slow data synchronization caused by the inability to execute related data operations concurrently in multiple threads in the prior art.
[0007] The present invention adopts the following technical solutions:
[0008] In a first aspect, the present invention provides a method for accelerating data synchronization, comprising:
[0009] Obtain the current operation log from the source database, and perform a conflict check between the current operation log and all historical operation logs in the operation registration linked list;
[0010] When there is a conflict between at least one historical operation log and the current operation log, the current operation log is added to the operation registration linked list, and a conflict association relationship is established between the at least one historical operation log and the current operation log;
[0011] generating a corresponding target fusion operation according to the conflict association relationship, the at least one historical operation log, and the current operation log;
[0012] The target fusion operation is performed on the target database to complete data synchronization on the target database according to the at least one historical operation log and the current operation log.
[0013] Furthermore, obtaining the current operation log from the source database and performing a conflict check between the current operation log and all historical operation logs in the operation registration linked list includes:
[0014] Obtain the current operation logs from the source database in ascending order of the source SCN.
[0015] For the current operation log, obtain the LSCN and ROWID of the current operation log; wherein the LSCN of the operation log is the time when the data operated by the operation log was last modified, and the ROWID of the operation log is the ROWID of the data operated by the operation log;
[0016] Obtaining the LSCN and ROWID of the historical operation logs from the operation registration chain list in sequence according to the order in which the historical operation logs are added to the operation registration chain list;
[0017] If the LSCN of the current operation log is inconsistent with the LSCN of the historical operation log, then there is no conflict between the current operation log and the historical operation log; if the LSCN of the current operation log is consistent with the LSCN of the historical operation log, then determine whether the ROWID of the current operation log is consistent with the ROWID of the historical operation log;
[0018] When the ROWID of the current operation log is consistent with the ROWID of the historical operation log, there is a conflict between the current operation log and the historical operation log, so that the conflict check between the current operation log and the historical operation log is completed.
[0019] Furthermore, when there is a conflict between at least one historical operation log and the current operation log, adding the current operation log to the operation registration linked list and establishing a conflict association relationship between the at least one historical operation log and the current operation log includes:
[0020] When the current operation log is added to the operation registration linked list, a conflict association relationship is established between each historical operation log and its next historical operation log in accordance with the order in which the at least one historical operation log is added to the operation registration linked list;
[0021] A conflict association relationship is established between the last historical operation log in the at least one historical operation log and the current operation log.
[0022] Furthermore, the generating a corresponding target fusion operation according to the conflict association relationship, the at least one historical operation log, and the current operation log includes:
[0023] Obtaining the operation log corresponding to the transaction to be executed in the operation registration linked table;
[0024] When the obtained operation logs have conflicting association relationships, obtaining a conflicting association relationship sequence associated with the obtained operation logs; wherein a conflicting association relationship sequence includes at least one conflicting association relationship between the operation logs;
[0025] When the conflict association relationship of the obtained operation log is not the last conflict association relationship in the conflict association relationship sequence, ignoring the obtained operation log, and obtaining the next operation log of the obtained operation log in the to-be-executed transaction;
[0026] When the conflict association relationship of the obtained operation log is the last conflict association relationship in the conflict association relationship sequence, a target fusion operation corresponding to the conflict association relationship sequence is generated according to the operation logs in the conflict association relationship sequence.
[0027] Furthermore, when the conflict association relationship of the obtained operation log is the last conflict association relationship in the conflict association relationship sequence, generating a target fusion operation corresponding to the conflict association relationship sequence according to the operation logs in the conflict association relationship sequence includes:
[0028] Obtaining the first historical operation log in the conflict association sequence according to the conflict operation pointer; except for the first historical operation log, each operation log corresponding to the conflict association sequence has a conflict operation pointer, and the corresponding conflict operation pointers all point to the first historical operation log;
[0029] The target fusion operation is generated according to the operation type and column value information of the first historical operation log and the current historical operation log.
[0030] Furthermore, generating the target fusion operation according to the operation type and column value information of the first historical operation log and the current historical operation log includes:
[0031] When the operation type of the first historical operation log is an insert operation, and the operation type of the current operation log is an update operation, the operation type of the target fusion operation is an insert operation; determining, from columns involved in all old column value information of the current operation log, columns not involved in all new column value information of the current operation log, and obtaining old column value information to be inserted for the determined columns; generating the target fusion operation based on all new column value information of the current operation log and the old column value information to be inserted;
[0032] When the operation type of the first historical operation log is an insert operation and the operation type of the current operation log is a delete operation, a target fusion operation is not generated, so that the target fusion operation is not subsequently executed in the target database;
[0033] When the operation type of the first historical operation log is an update operation and the operation type of the current operation log is an update operation, the operation type of the target fusion operation is an update operation; based on all old column value information of the first historical operation log and the current operation log, determining the column value information before the update and the column value information after the update to generate the target fusion operation;
[0034] When the operation type of the first historical operation log is an update operation, and the operation type of the current operation log is a delete operation, the operation type of the target fusion operation is a delete operation; all old column value information of the first historical operation log is determined as the old column value information to be deleted, and the target fusion operation is generated based on the old column value information to be deleted.
[0035] Furthermore, determining the pre-update column value information and the post-update column value information based on all old column value information of the first historical operation log and the current operation log to generate the target fusion operation includes:
[0036] All old column value information of the first historical operation log is used as the column value information before updating;
[0037] Determine, from the columns involved in the pre-update column value information, the columns not involved in all the new column value information of the current operation log; and obtain, from all the old column value information of the current operation log, the column value information to be updated of the determined columns;
[0038] Obtaining updated column value information based on all new column value information of the current operation log and the column value information to be updated;
[0039] The target fusion operation is generated based on the pre-update column value information and the post-update column value information.
[0040] Furthermore, it also includes:
[0041] If the operation type of the current operation log is a delete operation, selectively not generating a target fusion operation, or immediately generating a target fusion operation based on the current operation log and the corresponding first historical operation log, and executing the target fusion operation in the destination database;
[0042] If the operation type of the current operation log is not a delete operation, then the corresponding target fusion operation is not generated temporarily, and it is determined whether the conflict association relationship sequence corresponding to the current operation log increases within a first preset time;
[0043] When the corresponding conflict association relationship sequence is not increased within the first preset time, generating a target fusion operation according to the current operation log and the corresponding first historical operation log, and executing the target fusion operation in the destination database;
[0044] When the corresponding conflict association relationship sequence increases within the first preset time, a corresponding target fusion operation is generated according to the last operation log in the increased conflict association relationship sequence and the corresponding first historical operation log, and the target fusion operation is executed in the destination database.
[0045] In a second aspect, the present invention further provides a device for accelerating data synchronization, for implementing the method for accelerating data synchronization described in the first aspect, wherein the device for accelerating data synchronization comprises:
[0046] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the processor to execute the method for accelerating data synchronization described in the first aspect.
[0047] In a third aspect, the present invention further provides a non-volatile computer storage medium, wherein the computer storage medium stores computer executable instructions, which are executed by one or more processors to complete the method for accelerating data synchronization described in the first aspect.
[0048] In a fourth aspect, a chip is provided, comprising: a processor and an interface, for calling and running a computer program stored in a memory, and executing the method for accelerating data synchronization as in the first aspect.
[0049] In a fifth aspect, a computer program product comprising instructions is provided, which, when executed on a computer or a processor, causes the computer or the processor to execute the method for accelerating data synchronization as described in the first to fourth aspects and any one of the above.
[0050] In a sixth aspect, a system for accelerating data synchronization is provided, comprising the device for accelerating data synchronization as in the second aspect, and using the method for accelerating data synchronization as described in the first aspect to complete the interaction of the device for accelerating data synchronization as in the second aspect.
[0051] Different from the prior art, the present invention has at least the following beneficial effects:
[0052] The present invention performs a conflict check on the current operation log obtained from the source database and all the historical operation logs in the operation registration linked list. When at least one historical operation log conflicts with the current operation log, the current operation log is added to the operation registration linked list, and a conflict association relationship is established between the at least one historical operation log and the current operation log. According to the conflict association relationship and the at least one historical operation log and the current operation log, a corresponding target fusion operation is generated and executed on the destination database to merge multiple data operations for the same row into one target fusion operation. By executing the target fusion operation on the destination database, multiple conflicting data operations are executed in parallel on the destination database instead of executing them in parallel, thereby reducing the steps of data operations to achieve faster synchronization efficiency, and solving the problem of slow data synchronization speed caused by the inability of multi-threaded concurrent execution of associated data operations in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] To more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. Those skilled in the art can also derive other drawings based on these drawings without inventive effort.
[0054] Figure 1 This is a flow chart of a method for accelerating data synchronization provided by an embodiment of the present invention;
[0055] Figure 2 This is a schematic diagram of an operation registration linked list and related data tables in a synchronization tool provided by an embodiment of the present invention;
[0056] Figure 3 is a flow chart of step 10 provided in an embodiment of the present invention;
[0057] Figure 4 This is a schematic diagram of a conflict check process provided by an embodiment of the present invention;
[0058] Figure 5 is a flow chart of step 20 provided in an embodiment of the present invention;
[0059] Figure 6 is a schematic diagram of an operation registration linked list provided by an embodiment of the present invention;
[0060] Figure 7 is a schematic diagram of a conflict association relationship sequence provided by an embodiment of the present invention;
[0061] Figure 8 is a flow chart of step 30 provided in an embodiment of the present invention;
[0062] Figure 9 This is a schematic diagram of a conflict association relationship sequence after adding a conflict operation pointer provided by an embodiment of the present invention;
[0063] Figure 10 is a schematic diagram of another conflict association relationship sequence provided by an embodiment of the present invention;
[0064] Figure 11 This is a flowchart of a specific example of ignoring conflicting operation logs provided by an embodiment of the present invention;
[0065] Figure 12 is a flowchart of step 3042 provided by an embodiment of the present invention;
[0066] Figure 13 This is a flowchart of generating a target fusion operation under the situation "INS+UPD" provided by an embodiment of the present invention;
[0067] Figure 14 This is a schematic diagram of a specific example of generating a target fusion operation under the situation of "INS+UPD" provided by an embodiment of the present invention;
[0068] Figure 15 This is a flowchart of generating a target fusion operation under the situation of "UPD+UPD" provided by an embodiment of the present invention;
[0069] Figure 16 1 is a schematic diagram of a specific example of generating a target fusion operation under the situation of "UPD+UPD" provided by an embodiment of the present invention;
[0070] Figure 17 This is a schematic diagram of a specific example of generating a target fusion operation under the situation of "UPD+DEL" provided by an embodiment of the present invention;
[0071] Figure 18 This is a schematic diagram of the overall process of a method for accelerating data synchronization provided by an embodiment of the present invention;
[0072] Figure 19 1 is a flow chart of another method for accelerating data synchronization provided by an embodiment of the present invention;
[0073] Figure 20Schematic diagram of the architecture of a device for accelerating data synchronization provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0074] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0075] In order to make the purpose, technical solutions and advantages of the present invention more clearly understood, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.
[0076] Unless the context requires otherwise, throughout the specification and claims, the term "including" is to be interpreted as meaning open inclusion, that is, "including, but not limited to". In the description of the specification, the terms "one embodiment", "some embodiments", "exemplary embodiments", "example", "specific example" or "some examples" and the like are intended to indicate that the specific features, structures, materials or characteristics associated with the embodiment or example are included in at least one embodiment or example of the present disclosure. The schematic representation of the above terms does not necessarily refer to the same embodiment or example. In addition, the specific features, structures, materials or characteristics may be included in any one or more embodiments or examples in any appropriate manner, that is, although they may be carried in the embodiments or examples of the above terms due to reasons such as the order and position of appearance, it is not limited to that they can be carried in combination by one embodiment or example.
[0077] In the description of the present invention, it should be understood that the terms "center", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the accompanying drawings, and are only for the convenience of describing the present disclosure and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present disclosure.
[0078] In the description of the present invention, the terms "first" and "second" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present disclosure, unless otherwise specified, "multiple" means two or more. In addition, for example, the description may also use the method of adding "A" and "B" at the end to describe the same type of nouns as two independent individuals. In this case, the corresponding features defined as "A" and "B" are only used to distinguish the description purposes of the same type of individuals, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated.
[0079] When describing some embodiments, the expressions “coupled”, “coupled” and “connected” and their derivatives may be used. For example, when describing some embodiments, the term “connected” may be used to indicate that two or more components are in direct physical or electrical contact with each other. For another example, when describing some embodiments, the term “coupled” may be used to indicate that two or more components are in direct physical or electrical contact. However, the term “connected” or “coupled” may also mean that two or more components are not in direct contact with each other, but still cooperate or interact with each other, such as “optical coupling”, “wireless connection”, etc. The embodiments disclosed herein are not necessarily limited to the contents of the present invention.
[0080] In the description of the present invention, the expression "A and / or B" (where A and B are used to formally represent specific characteristic contents) will be involved, and the corresponding expressions include the following three combinations: only A, only B, and a combination of A and B.
[0081] As used herein, "about," "substantially," or "approximately" includes the stated value and an average value that is within an acceptable range of deviation from the particular value as determined by one of ordinary skill in the art taking into account the measurements in question and the errors associated with the measurement of the particular quantity (i.e., the limitations of the measurement system).
[0082] Example 1:
[0083] In order to solve the above problems, Figure 1 As shown, an embodiment of the present invention provides a method for accelerating data synchronization, including:
[0084] Step 10: Obtain the current operation log from the source database, and perform a conflict check between the current operation log and all historical operation logs in the operation registration linked list.
[0085] Among them, one source-end database corresponds to one operation registration linked list.
[0086] The real-time database synchronization tool mines the source database's operation logs, restores the source database's data operations, and then synchronizes these operations to the destination database. For ease of description, the term "synchronization tool" will be used below to refer to the "real-time database synchronization tool." The smallest unit of synchronization between the source and destination databases is the operation log, which contains data rows for specific operations and records of modifications to those rows. The synchronization tool parses the source database's operation logs and, based on the parsed information, generates and executes the operations performed in the destination database, thereby synchronizing the corresponding data operations based on the operation logs.
[0087] The synchronization tool first reads the operation logs of the source database in sequence, and adds the current operation log to the operation registration list each time; when adding, it performs a conflict check between the current operation log and the historical operation logs already in the operation registration list. In an optional embodiment, the operation registration list can be implemented using a bidirectional linked list; a specific example of the operation registration list OPS_LST is as follows Figure 2 As shown, the operation registration linked list OPS_LST includes operation log OP1, operation log OP2 and operation log OP3, etc. Its structure and corresponding fields will be explained below.
[0088] Step 20: When there is a conflict between at least one historical operation log and the current operation log, the current operation log is added to the operation registration linked list, and a conflict association relationship is established between the at least one historical operation log and the current operation log.
[0089] Among them, the existence of a conflict means that the operation object of the corresponding historical operation log and the current operation log is the same row; for example, the historical operation log OP1 is the operation log of data operation 1 "insert a row R1 into database table T1" in the source database, the historical operation log OP2 is the operation log of data operation 2 "update the field value of R1 to 1" in the source database, and the current operation log OPn is the operation log of data operation n "update the field value of R1 to 4" in the source database. In this case, there is a conflict between the historical operation log OP1, the historical operation log OP2 and the current operation log OPn. Each time the synchronization tool adds the read current operation log to the operation registration linked list, if it conflicts with the operation log already existing in the operation registration linked list, it is necessary to establish a corresponding conflict association relationship in the operation registration linked list to record the corresponding conflict, so as to facilitate the optimization of conflict handling during subsequent synchronization. For example, after performing a conflict check, the synchronization tool determines that the current operation log OPn conflicts with the historical operation logs OP1 and OP2 in the operation registration list OPS_LST, so the current operation log OPn is first added to the operation registration list OPS_LST, and the corresponding conflict association relationship is established when adding.
[0090] Step 30: Generate a corresponding target fusion operation according to the conflict association relationship, the at least one historical operation log, and the current operation log.
[0091] For example, information about data operation 1 is obtained based on the historical operation log OP1, information about data operation 2 is obtained based on the historical operation log OP2, and information about data operation n is obtained based on the current operation log OPn. A target fusion operation is generated according to the above three pieces of information. Executing the target fusion operation in the target database can replace the serial execution of the historical operation log OP1, the historical operation log OP2, and the current operation log OPn.
[0092] Step 40: Execute the target fusion operation in the destination database to complete data synchronization in the destination database according to the at least one historical operation log and the current operation log.
[0093] The present invention performs a conflict check on the current operation log obtained from the source database and all the historical operation logs in the operation registration linked list. When at least one historical operation log conflicts with the current operation log, the current operation log is added to the operation registration linked list, and a conflict association relationship is established between the at least one historical operation log and the current operation log. According to the conflict association relationship and the at least one historical operation log and the current operation log, a corresponding target fusion operation is generated and executed on the destination database to merge multiple data operations for the same row into one target fusion operation. By executing the target fusion operation on the destination database, multiple conflicting data operations are executed in parallel on the destination database instead of executing them in parallel, thereby reducing the steps of data operations to achieve faster synchronization efficiency, and solving the problem of slow data synchronization speed caused by the inability of multi-threaded concurrent execution of associated data operations in the prior art.
[0094] To illustrate the process of conflict checking, Figure 3 As shown, the step 10 includes:
[0095] Step 101: Obtain the current operation logs from the source database in ascending order of the source SCN.
[0096] The source SCN is the system change number (SCN) when the data operation corresponding to the operation log is executed in the source database. The source SCN is generated according to the internal clock of the source database. Since the source SCN of each data operation is from small to large when the source parses the corresponding data operation to generate the operation log, the OP_SCN (i.e., source SCN) in the operation registration list is also from small to large. Since multiple data operations with associated rows must be executed strictly according to the source SCN in the destination database, the synchronization tool reads the operation logs from the operation registration list in the order in which the operation logs are added to the operation registration list, generates the corresponding data operations, and synchronizes them to the destination database.
[0097] In an optional embodiment, the information obtained from the operation log may include: (1) OP_SCN: the source end SCN. OP_SCN increases sequentially, and the OP_SCN of the data operation executed later is greater than the OP_SCN of the data operation executed earlier; (2) OP_TRXID: the transaction number of the data operation. Each data operation contains a transaction number, and data operations with the same transaction number belong to the same transaction. (3) OP_OBJ: the object to which the data operation belongs; (4) OP_TYPE: the operation type of the data operation, which includes insert operation (INSERT), update operation (UPDATE), delete operation (DELELTE), transaction commit (COMMIT), and transaction rollback (ROLLBACK). (5) LSCN (Last System Change Number): The SCN of the last operation on the data operated by this data operation; (6) OP_VAL: All column value information of the data operated by this data operation; among them, all column value information of the insert operation is all new column value information (OP_NEW_VAL), all column value information of the delete operation is all old column value information (OP_OLD_VAL), and all column value information of the update operation is all old column value information and all new column value information (OP_NEW_VAL+OP_OLD_VAL); (7) ROWID: The unique identifier of the row of the data operated by this data operation.
[0098] Step 102: For the current operation log, obtain the LSCN and ROWID of the current operation log; wherein the LSCN of the operation log is the time when the data operated by the operation log was last modified, and the ROWID of the operation log is the ROWID of the data operated by the operation log.
[0099] Among them, the operation log of a source database corresponds to a source SCN, the LSCN of the current operation log is the time when the data operated by the current operation log was last modified, and the ROWID of the current operation log is the ROWID of the data operated by the current operation log.
[0100] Step 103: according to the order in which the historical operation logs are added to the operation registration linked list, the LSCN and ROWID of the historical operation logs are sequentially obtained from the operation registration linked list.
[0101] The LSCN of the historical operation log is the time when the data operated by the historical operation log was last modified, and the ROWID of the historical operation log is the ROWID of the data operated by the historical operation log.
[0102] Step 104: If the LSCN of the current operation log is inconsistent with the LSCN of the historical operation log, there is no conflict between the current operation log and the historical operation log; if the LSCN of the current operation log is consistent with the LSCN of the historical operation log, determine whether the ROWID of the current operation log is consistent with the ROWID of the historical operation log.
[0103] If the LSCNs are consistent, it means that the corresponding data operations are performed on the same database table. Since the same LSCN may correspond to more than one data operation, it is necessary to further determine whether the ROWIDs are consistent.
[0104] Step 105: When the ROWID of the current operation log is consistent with the ROWID of the historical operation log, there is a conflict between the current operation log and the historical operation log, so that the conflict check between the current operation log and the historical operation log is completed.
[0105] For multiple operation logs operating the same database table, when the ROWIDs recorded therein are the same, it means that the multiple data operations are operating on the same row of data, so there is a conflict between them. Figure 4 As shown, the LSCN of the current operation log is LSCN1. Each time, the LSCN of a historical operation log, i.e., SCNi, is obtained from the operation registration linked list OPS_LST, and LSCN1 is compared to see if it is equal to SCNi. If they are not equal, the current operation log does not conflict with the historical operation log obtained this time. If they are equal, continue to obtain the ROWID of the current operation log, i.e., R1, and then obtain the ROWID of the historical operation log obtained this time, i.e., R2. Compare R1 to see if it is equal to R2. If they are not equal, the current operation log does not conflict with the historical operation log obtained this time. If they are equal, the current operation log conflicts with the historical operation log obtained this time.
[0106] In order to illustrate the process of establishing conflict associations, Figure 5 As shown, the step 20 includes:
[0107] Step 201: When the current operation log is added to the operation registration linked list, conflict association relationships are established between each historical operation log and its next historical operation log in accordance with the order in which the at least one historical operation log is added to the operation registration linked list.
[0108] Step 202: Establish a conflict association relationship between the last historical operation log in the at least one historical operation log and the current operation log.
[0109] When there is a conflict, it means that the operation registration list contains at least two data operations that operate on the same row of data, and it is necessary to associate the data operations that operate on the same row. Figure 6 As shown, for example, if there is a conflict between the historical operation log OP1 and the current operation log OPn, a conflict association relationship is established between the historical operation log OP1 and the current operation log OPn. In an optional embodiment, the conflict association relationship can be established using a pointer, and a pointer (op_next) is added to the historical operation log OP1, and the pointer points to the current operation log OPn with the conflicting operation.
[0110] like Figure 7 As shown, for multiple historical operation logs that conflict with the current operation log OPn, after the conflict association relationship is established, they will establish a series of conflict association relationships through the pointer op_next.
[0111] In order to explain the synchronization process of the synchronization tool, Figure 8 As shown, the step 30 includes:
[0112] Step 301: Obtain the operation log corresponding to the transaction to be executed from the operation registration linked list.
[0113] The synchronization tool synchronizes data from the source database to the destination database in transactions. Therefore, when synchronizing, the pending transaction is determined first. During the synchronization of the pending transaction, the operation logs are sequentially retrieved from the operation registration list and synchronized according to the corresponding operation logs.
[0114] The embodiment of the present invention provides a specific example of determining pending transactions and obtaining operation logs during synchronization, which is described below: Figure 2As shown, the synchronization tool synchronizes according to the pending transaction list TRX_LST; the pending transaction list TRX_LST is a collection of completed transactions in the source database. After parsing the operation log, the synchronization tool uses the transaction number OP_TRXID of the operation log as the key value to search for the corresponding transaction description information TRX_INFO in the synchronization tool transaction table TRX_HASH, and adds the operation log to TRX_OPS of TRX_INFO. Among them, TRX_HASH is a set of pointers pointing to TRX_INFO. TRX_INFO uses OP_TRXID as the key value to find the corresponding position in TRX_HASH and point the pointer of the corresponding position to TRX_INFO; TRX_OPS is a linked list of operation pointers contained in the transaction. TRX_INFO collects the operations of a transaction, and the synchronization tool synchronizes the operations to the destination database in units of transactions. If the operation type OP_TYPE of the parsed operation log is COMMIT or ROLLBACK, it indicates that the transaction has ended in the source database and the corresponding data can be synchronized to the destination database. At this time, TRX_OPS is removed from TRX_HASH and added to TRX_LST. In addition, a transaction registration table TRX_TABLE can be set. TRX_TABLE exists in the destination database. After the TRX_INFO of a transaction is executed in the destination database, the transaction information is registered in TRX_TABLE. TRX_TABLE includes the following fields: (1) TRXID: the transaction number of TRX_INFO; (2) STARTSCN: the SCN of the first operation log in TRX_INFO; (3) ENDSCN: the SCN of the last operation log in TRX_INFO.
[0115] When the acquired operation logs do not contain conflicting relationships, corresponding operation statements are generated based on the acquired operation logs. These generated operation statements are executed on the destination database to synchronize the acquired operation logs. The operation statements are implemented using Structured Query Language (SQL). For non-conflicting operation logs, the synchronization tool converts them into SQL statements and synchronizes them to the destination database, enabling parallel synchronization using multiple threads.
[0116] Step 302: When the obtained operation logs have conflicting associations, a conflicting association sequence associated with the obtained operation logs is obtained; wherein a conflicting association sequence includes at least one conflicting association between the operation logs.
[0117] The following combination Figure 6 and Figure 7, explaining the relationship between conflict association sequence and conflict association:
[0118] like Figure 6 As shown, in the operation registration linked list OPS_LST, there are multiple operation logs according to the source SCN order of reading the operation logs; among them, the historical operation log OP1 conflicts with the current operation log OPn, and there is a conflict association relationship between the two (that is, there is a pointer op_next in the historical operation log OP1, and it points to the current operation log OPn); while the historical operation log OP2 has no conflict with the historical operation log OP1 or the current operation log OPn.
[0119] like Figure 7 The figure shows a specific example of a conflict association relationship sequence; the historical operation log OP1 conflicts with the historical operation log OPi, and there is a corresponding conflict association relationship between the two; the historical operation log OPi conflicts with the historical operation log OPj, and there is a corresponding conflict association relationship between the two; the historical operation log OPj conflicts with the current operation log OPn, and there is a corresponding conflict association relationship between the two; the historical operation log OP1, the historical operation log OPi, the historical operation log OPj and the current operation log OPn and the corresponding conflict association relationships between them constitute the following. Figure 7 A conflict relationship sequence is shown in FIG. It should be noted that, Figure 6 The conflict relationship and the corresponding conflict relationship sequence shown in Figure 7 Different as shown.
[0120] Step 303: When the conflict association relationship of the obtained operation log is not the last conflict association relationship in the conflict association relationship sequence, the obtained operation log is ignored, and the next operation log of the obtained operation log is obtained in the to-be-executed transaction.
[0121] like Figure 7 As shown, when processing the conflict between the historical operation log OP1, the historical operation log OPi, the historical operation log OPj and the current operation log OPn, the conflict association relationship sequence associated with the obtained operation logs is obtained; for example, when processing the historical operation log OP1, the conflict association relationship sequence associated with the obtained operation logs is obtained. Figure 7 The sequence of conflicting associations shown.
[0122] Step 304: When the conflict association relationship of the obtained operation log is the last conflict association relationship in the conflict association relationship sequence, a target fusion operation corresponding to the conflict association relationship sequence is generated according to the operation logs in the conflict association relationship sequence.
[0123] In the prior art, data operations corresponding to conflicting operation logs must be executed serially. Since conflicting data operations process the same data rows, during the synchronization process, only the final data operation results need to be synchronized to the destination database. Therefore, during the synchronization process, the synchronization tool of the embodiment of the present invention adopts the "ignore + merge operation data" method to optimize the synchronization of conflicting data. The specific process will be described below: Step 304 includes:
[0124] Step 3041: Obtain the first historical operation log in the conflict association sequence according to the conflict operation pointer; except for the first historical operation log, each operation log corresponding to the conflict association sequence has a conflict operation pointer, and the corresponding conflict operation pointers all point to the first historical operation log.
[0125] like Figure 9 As shown, the first historical operation log in the conflict association relationship sequence is the conflict operation head, and the last operation log in the conflict association relationship sequence is the conflict operation tail; when the current operation log OPn needs to be synchronized, since it is the conflict operation tail, the conflict operation head is determined based on the historical operation log OP1 pointed to by its conflict operation pointer op_base.
[0126] The conflict operation header and conflict operation pointer are explained below:
[0127] like Figure 10 As shown, the first conflict association relationship is represented by the pointer op_next from the operation log OP1 to the operation log OPi, and the conflict operation head is the operation log OP1. In an optional embodiment, as Figure 9 As shown, when the corresponding conflict association does not involve the conflicting operation header, that is, for operation logs OPi, OPj, and OPn, a conflicting operation pointer op_base is constructed, with op_base pointing to operation log OP1; operation log OPn is the conflicting operation tail. It should be noted that during operation, if a newly added operation log for a data row conflicts with an operation log in the operation registration linked list, the corresponding conflicting operation tail will change, becoming the newly added operation log.
[0128] Step 3042: Generate the target fusion operation according to the operation type and column value information of the first historical operation log and the current historical operation log.
[0129] like Figure 11 As shown in the figure, when the synchronization tool processes the operation log according to the transaction, when processing any operation log except the tail of the conflicting operation, the corresponding operation log is ignored, that is, it is not converted into the corresponding SQL statement. Figure 9As shown, when processing operation logs OP1, OPi, and OPj, they are all ignored. When processing operation log OPn, conflicting operations are fused to obtain the target fused operation for synchronization. The specific synchronization method is described below. In actual application scenarios, the more conflicting conflict relationship sequences there are, or the more operation logs in the conflict relationship sequence, the more operation logs are ignored, and the faster the synchronization tool is.
[0130] No matter how many conflicting data operations a row of data corresponds to, the fusion only involves the first and last data operations in the conflicting relationship sequence. The corresponding operation logs are the first historical operation log OP1 and the current operation log OPn. This is because the first historical operation log OP1 contains the state of the row's data in the destination database, while the current operation log OPn contains the final state of the row's data after synchronizing each data operation in the conflicting relationship sequence. Since the operation type of the first historical operation log OP1 can only be an insert operation (as described below), Figure 14 INS) or update operations (as shown in Figure 14 The operation type of the current operation log OPn can only be UPD or delete operation (as shown in the following Figure 15 DEL shown in ), so there are only four cases of conflicting operations in fusion: "INS+UPD", "INS+DEL", "UPD+UPD" and "UPD+DEL".
[0131] In order to illustrate the process of generating target fusion operations, such as Figure 12 As shown, step 3042 includes:
[0132] Step 30421: When the operation type of the first historical operation log is an insert operation, and the operation type of the current operation log is an update operation, the operation type of the target fusion operation is an insert operation; from the columns involved in all the old column value information of the current operation log, determine the columns not involved in all the new column value information of the current operation log, and obtain the old column value information to be inserted of the determined columns; based on all the new column value information of the current operation log and the old column value information to be inserted, generate the target fusion operation.
[0133] For the case of "INS+UPD", in an optional embodiment, as Figure 13As shown, all columns involved in the old column value information OP_OLD_VAL of the current operation log are traversed. When one of the columns COLi is not involved in all the new column value information OP_NEW_VAL of the current operation log, the old column value information of column COLi is obtained. Finally, based on all the new column value information OP_NEW_VAL and the old column value information of column COLi, the column value information required to generate the target fusion operation is obtained, and then the insert operation is generated. Figure 14 As shown, all the old column value information OP_OLD_VAL of the current operation log is (c1=2, c2=1), and all the new column value information OP_NEW_VAL of the current operation log is (c2=2), where column c1 is an unrelated column, so "c1=2" is obtained from all the old column value information of the current operation log; finally, "c1=2" and "c2=2" are used as the column values of the insert operation to generate the insert operation.
[0134] Step 30422: When the operation type of the first historical operation log is an insert operation and the operation type of the current operation log is a delete operation, a target fusion operation is not generated so that the target fusion operation is not subsequently executed in the target database.
[0135] For the "INS+DEL" scenario, since an insert operation is performed first and then a delete operation is performed on the same data row, it is equivalent to not performing an insert operation on the data row directly. Therefore, this embodiment of the present invention ignores the current operation log, does not generate a target fusion operation, and maintains the consistency of the data row in the source database and the destination database.
[0136] Step 30423: When the operation type of the first historical operation log is an update operation, and the operation type of the current operation log is an update operation, the operation type of the target fusion operation is an update operation; based on all the old column value information of the first historical operation log and the current operation log, the column value information before the update and the column value information after the update are determined to generate the target fusion operation.
[0137] For the case of "UPD+UPD", all the old column value information of the first historical operation log is used as the column value information before the update. Figure 15 and Figure 16 As shown, all old column value information OP_OLD_VAL of the first historical operation log, that is, (C1=1, C2=1), is obtained as the updated column value information OP_OLD_VAL of the target fusion operation.
[0138] From the columns involved in the pre-update column value information, determine the columns not involved in all the new column value information in the current operation log. For example, from (C1=1, C2=1), determine the columns not involved in all the new column value information OP_NEW_VAL in the current operation log, namely column C1; from all the old column value information OP_OLD_VAL in the current operation log, obtain the column value information to be updated for column C1 as "C1=3".
[0139] The to-be-updated column value information for the determined column is obtained from all the old column value information in the current operation log. The updated column value information is obtained based on all the new column value information in the current operation log and the to-be-updated column value information. For example, the updated column value information OP_NEW_VAL for the target fusion operation is obtained based on all the new column value information OP_NEW_VAL in the current operation log and the to-be-updated column value information "C1=3" for column C1.
[0140] The target fusion operation is generated based on the pre-update column value information and the post-update column value information. For example, "c1=1" and "c2=1" are used as the pre-update column value information of the update operation, and "c1=3" and "c2=2" are used as the post-update column value information of the update operation to generate the update operation.
[0141] Step 30424: When the operation type of the first historical operation log is an update operation, and the operation type of the current operation log is a delete operation, the operation type of the target fusion operation is a delete operation; all the old column value information of the first historical operation log is determined as the old column value information to be deleted, and the target fusion operation is generated based on the old column value information to be deleted.
[0142] For the case "UPD+DEL", such as Figure 17 As shown, all old column value information of the first historical operation log is (c1=1, c2=1), and "c1=1" and "c2=1" are used as column values of the deletion operation to generate the deletion operation.
[0143] When all the operation logs corresponding to the pending transaction are processed, all the operation logs corresponding to the pending transaction are deleted from the operation registration list. Figure 18As shown, during synchronization, the synchronization tool first obtains TRX_INFO from TRX_LST in sequence. If a TRX_INFO record exists in TRX_TABLE, the TRX_INFO is ignored. Otherwise, the operation log OP is obtained from TRX_INFO in sequence. If the operation log OP has a conflict relationship (i.e., OP.op_next is not null), and the operation log OP is not the end of the data conflict operation, the operation log OP is ignored and the next operation log OP is obtained. If OP.op_base is not null, the conflict operation fusion method is used to obtain the target fusion operation and synchronize with the destination database. When all operation logs in TRX_INFO are executed, the operation log belonging to the TRX_INFO is deleted from OPS_LST and the TRX_INFO information is recorded in the committed transaction registration table TRX_TABLE.
[0144] When the synchronization tool crashes or restarts during the synchronization process, an embodiment of the present invention provides a method for ensuring data consistency: during the operation of the synchronization tool, each time at intervals of a second preset time, the source SCN of the latest operation log that has completed synchronization is used to update the starting SCN; in the operation registration linked list, all operation logs before the starting SCN of the corresponding source SCN are determined, the conflicting operation pointer of the determined operation log is saved to a file, and the operation log pointed to by the conflicting operation pointer (i.e., the corresponding conflicting operation header) is saved to a file. Among them, the second preset time is selected by those skilled in the art based on the specific usage scenario and experience. The starting SCN is the source SCN of the first operation log to be synchronized after the synchronization tool is restarted. For example, in OP_LST, the operation logs before the starting SCN of the source SCN are operation log OP1, operation log OPi, and operation log OPn. Since there is no conflicting operation pointer in operation log OP1, the conflicting operation pointer op_base of operation log OPi and the conflicting operation pointer op_base of operation log OPn are written to the file for storage, and the operation log OP1 is saved to the file.
[0145] On this basis, each time synchronization between the source database and the destination database is restarted, the conflicting operation pointers and operation logs saved in the file are loaded into memory to restore the corresponding conflicting operation pointers to the operation registration list. For example, the conflicting operation pointer op_base of the operation log OPi, the conflicting operation pointer op_base of the operation log OPn, and the operation log OP1 are loaded from the file into memory and restored to the operation registration list OPS_LST, so that OP_LST is restored to the state at the start SCN time. After OP_LST is restored, the synchronization tool starts from the start SCN and resynchronizes according to the method for accelerating data synchronization according to an embodiment of the present invention.
[0146] Example 2:
[0147] The embodiment of the present invention is a preferred embodiment of embodiment 1, as Figure 19 As shown, it also includes:
[0148] In step 501, if the operation type of the current operation log is a delete operation, the target fusion operation is selectively not generated, or the target fusion operation is immediately generated based on the current operation log and the corresponding first historical operation log, and the target fusion operation is executed in the destination database.
[0149] For a Figure 9 The conflicting relationship sequence shown, as described in Example 1, includes two cases where the operation type at the end of the conflicting operation is a delete operation: (1) Case "INS+DEL" is equivalent to not performing an insert operation on the data row, omitting all operations in the conflicting relationship sequence. Therefore, in this case, the target merge operation is not generated directly, and the synchronization of the conflicting relationship sequence is completed. (2) Case "UPD+DEL" is equivalent to the partial update operation on the data row being subsequently deleted. To speed up synchronization, when the current operation log is processed, a delete operation (i.e., the target merge operation) is immediately generated and executed, omitting some of the update operations that will be deleted later.
[0150] In step 502, if the operation type of the current operation log is not a delete operation, the corresponding target fusion operation is not generated temporarily, and it is determined whether the conflict association relationship sequence corresponding to the current operation log increases within a first preset time.
[0151] The first preset time is selected by those skilled in the art based on specific usage scenarios and experience.
[0152] In step 503, when the corresponding conflict association relationship sequence is not increased within the first preset time, a target fusion operation is generated according to the current operation log and the corresponding first historical operation log, and the target fusion operation is executed in the target database.
[0153] In step 504, when the corresponding conflict association relationship sequence increases within the first preset time, the corresponding target fusion operation is generated according to the last operation log in the increased conflict association relationship sequence and the corresponding first historical operation log, and the target fusion operation is executed in the target database.
[0154] In actual application scenarios, the synchronization tool may process multiple operation logs that operate on the same data row within a period of time. If the target fusion operation is generated and executed based on its conflict association sequence when processing the first operation log, then when the next operation log that operates on the same data row is read subsequently, the conflict association sequence needs to be re-established, which will affect the synchronization speed. For example, in the source database, operation log OP1, operation log OPi, operation log OPj, operation log OPn1, operation log OPn2 and operation log OPn3 are operation logs that operate on the same data row. When the synchronization tool only registers operation log OP1, operation log OPi, operation log OPj and operation log OPn1 to the operation registration linked list, operation log OP1, operation log OPi, operation log OPj and operation log OPn1 constitute the first conflict association sequence. Synchronization The tool first ignores the operation log OP1, operation log OPi and operation log OPj in the processing order of the transactions to be executed. When processing the operation log OPn1, based on the first conflict association relationship sequence, the first target fusion operation is generated and executed according to the operation log OP1 and the operation log OPn1 to complete the synchronization of the operation log OP1, the operation log OPi, the operation log OPj and the operation log OPn1; when the first target fusion operation is generated and executed, the operation log OPn2 and the operation log OPn3 are registered to the operation registration linked list immediately, then it is necessary to re-establish the second conflict association relationship sequence, and ignore the operation log OPn2 in the processing order of the transactions to be executed. When processing the operation log OPn3, based on the second conflict association relationship sequence, the second target fusion operation is generated and executed according to the operation log OPn2 and the operation log OPn3 to complete the synchronization of the operation log OPn2 and the operation log OPn3.
[0155] To address this situation, an embodiment of the present invention performs a second preset wait time on subsequent operation logs when the conflicting operation at the end of the conflicting association sequence is not a delete operation. If, during the second preset wait time, the conflicting operation at the end of the conflicting association sequence changes (i.e., the conflicting operation at the end is a newly added operation log), a target fusion operation is generated based on the newly added operation log, further accelerating synchronization by ignoring more operation logs. It should be noted that because the delete operation has more omitting execution steps and is the most effective in accelerating synchronization, it is given the highest execution priority and is only waited for when the conflicting operation at the end is not a delete operation.
[0156] Example 3:
[0157] like Figure 20FIG2 is a schematic diagram of the structure of the apparatus for accelerating data synchronization according to an embodiment of the present invention. The apparatus for accelerating data synchronization according to this embodiment includes one or more processors 21 and a memory 22. Figure 20 A processor 21 is taken as an example.
[0158] The processor 21 and the memory 22 may be connected via a bus or other means. Figure 20 The bus connection is taken as an example.
[0159] Memory 22, as a nonvolatile computer-readable storage medium, can be used to store nonvolatile software programs and nonvolatile computer-executable programs, such as the method for accelerating data synchronization in this embodiment. Processor 21 executes the method for accelerating data synchronization by running the nonvolatile software programs and instructions stored in memory 22.
[0160] The memory 22 may include high-speed random access memory and non-volatile memory, such as at least one disk storage device, flash memory device, or other non-volatile solid-state memory device. In some embodiments, the memory 22 may optionally include a memory remotely located relative to the processor 21, and such remote memory may be connected to the processor 21 via a network. Examples of such networks include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0161] The program instructions / modules are stored in the memory 22 and, when executed by the one or more processors 21, perform the method for accelerating data synchronization in the above embodiment, for example, performing the above described Figure 1 、 Figure 3 、 Figure 5 、 Figure 8 、 Figure 12 and Figure 19 The steps shown.
[0162] An embodiment of the present invention further provides a non-volatile computer storage medium, wherein the computer storage medium stores computer executable instructions, and the computer executable instructions are executed by one or more processors, for example Figure 20 A processor 21 can enable the one or more processors to execute the method for accelerating data synchronization in the specific embodiment of the present invention, for example, executing the above-described Figure 1 、 Figure 3 、 Figure 5 、 Figure 8 、 Figure 12 and Figure 19 The steps shown can also be implemented Figure 20 The various modules and units described above; or executing the method for accelerating data synchronization in the specific embodiment of the present invention, for example, executing the method described above Figure 1、 Figure 3 、 Figure 5 、 Figure 8 、 Figure 12 and Figure 19 The steps shown can also be implemented Figure 20 The various modules and units described.
[0163] It is worth noting that the information interaction, execution process, etc. between the modules and units within the above-mentioned devices and systems are based on the same concept as the processing method embodiment of the present invention. The specific content can be found in the description of the method embodiment of the present invention and will not be repeated here.
[0164] Those skilled in the art will understand that all or part of the steps in the various methods of the embodiments can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium, which may include: read-only memory (ROM), random access memory (RAM), a disk or an optical disk, etc.
[0165] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for accelerating data synchronization, characterized in that: include: Obtain the current operation log from the source database, and perform a conflict check between the current operation log and all historical operation logs in the operation registration linked list; When there is a conflict between at least one historical operation log and the current operation log, the current operation log is added to the operation registration linked list, and a conflict association relationship is established between the at least one historical operation log and the current operation log; generating a corresponding target fusion operation according to the conflict association relationship, the at least one historical operation log, and the current operation log; executing the target fusion operation in the destination database to complete data synchronization in the destination database according to the at least one historical operation log and the current operation log; Generating a corresponding target fusion operation according to the conflict association relationship, the at least one historical operation log, and the current operation log includes: Obtaining the operation log corresponding to the transaction to be executed in the operation registration linked table; When the obtained operation logs have conflicting association relationships, obtaining a conflicting association relationship sequence associated with the obtained operation logs; wherein a conflicting association relationship sequence includes at least one conflicting association relationship between the operation logs; When the conflict association relationship of the obtained operation log is not the last conflict association relationship in the conflict association relationship sequence, ignoring the obtained operation log, and obtaining the next operation log of the obtained operation log in the to-be-executed transaction; When the conflict association relationship of the obtained operation log is the last conflict association relationship in the conflict association relationship sequence, a target fusion operation corresponding to the conflict association relationship sequence is generated according to the operation logs in the conflict association relationship sequence.
2. The method for accelerating data synchronization according to claim 1, wherein: The obtaining of the current operation log from the source database and performing a conflict check between the current operation log and all historical operation logs in the operation registration linked list include: Obtain the current operation logs from the source database in ascending order of the source SCN. For the current operation log, obtain the LSCN and ROWID of the current operation log; wherein the LSCN of the operation log is the time when the data operated by the operation log was last modified, and the ROWID of the operation log is the ROWID of the data operated by the operation log; Obtaining the LSCN and ROWID of the historical operation logs from the operation registration chain table in sequence according to the order in which the historical operation logs are added to the operation registration chain table; If the LSCN of the current operation log is inconsistent with the LSCN of the historical operation log, then there is no conflict between the current operation log and the historical operation log; if the LSCN of the current operation log is consistent with the LSCN of the historical operation log, then determine whether the ROWID of the current operation log is consistent with the ROWID of the historical operation log; When the ROWID of the current operation log is consistent with the ROWID of the historical operation log, there is a conflict between the current operation log and the historical operation log, so that the conflict check between the current operation log and the historical operation log is completed.
3. The method for accelerating data synchronization according to claim 1, wherein: When there is a conflict between at least one historical operation log and the current operation log, adding the current operation log to the operation registration linked list and establishing a conflict association relationship between the at least one historical operation log and the current operation log includes: When the current operation log is added to the operation registration linked list, a conflict association relationship is established between each historical operation log and its next historical operation log in accordance with the order in which the at least one historical operation log is added to the operation registration linked list; A conflict association relationship is established between the last historical operation log in the at least one historical operation log and the current operation log.
4. The method for accelerating data synchronization according to claim 1, wherein: When the conflict association relationship of the obtained operation log is the last conflict association relationship in the conflict association relationship sequence, generating a target fusion operation corresponding to the conflict association relationship sequence according to the operation logs in the conflict association relationship sequence includes: Obtaining the first historical operation log in the conflict association sequence according to the conflict operation pointer; except for the first historical operation log, each operation log corresponding to the conflict association sequence has a conflict operation pointer, and the corresponding conflict operation pointers all point to the first historical operation log; The target fusion operation is generated according to the operation type and column value information of the first historical operation log and the current historical operation log.
5. The method for accelerating data synchronization according to claim 4, characterized in that: Generating the target fusion operation according to the operation type and column value information of the first historical operation log and the current historical operation log includes: When the operation type of the first historical operation log is an insert operation, and the operation type of the current operation log is an update operation, the operation type of the target fusion operation is an insert operation; determining, from columns involved in all old column value information of the current operation log, columns not involved in all new column value information of the current operation log, and obtaining old column value information to be inserted for the determined columns; generating the target fusion operation based on all new column value information of the current operation log and the old column value information to be inserted; When the operation type of the first historical operation log is an insert operation and the operation type of the current operation log is a delete operation, a target fusion operation is not generated, so that the target fusion operation is not subsequently executed in the target database; When the operation type of the first historical operation log is an update operation and the operation type of the current operation log is an update operation, the operation type of the target fusion operation is an update operation; based on all old column value information of the first historical operation log and the current operation log, determining the column value information before the update and the column value information after the update to generate the target fusion operation; When the operation type of the first historical operation log is an update operation, and the operation type of the current operation log is a delete operation, the operation type of the target fusion operation is a delete operation; all old column value information of the first historical operation log is determined as the old column value information to be deleted, and the target fusion operation is generated based on the old column value information to be deleted.
6. The method for accelerating data synchronization according to claim 5, characterized in that: The determining, based on all old column value information of the first historical operation log and the current operation log, the column value information before and after the update to generate the target fusion operation includes: All old column value information of the first historical operation log is used as the column value information before updating; Determine, from the columns involved in the pre-update column value information, the columns not involved in all the new column value information of the current operation log; and obtain, from all the old column value information of the current operation log, the column value information to be updated of the determined columns; Obtaining updated column value information based on all new column value information of the current operation log and the column value information to be updated; The target fusion operation is generated based on the pre-update column value information and the post-update column value information.
7. The method for accelerating data synchronization according to any one of claims 1 to 6, characterized in that: Also includes: If the operation type of the current operation log is a delete operation, selectively not generating a target fusion operation, or immediately generating a target fusion operation based on the current operation log and the corresponding first historical operation log, and executing the target fusion operation in the destination database; If the operation type of the current operation log is not a delete operation, then the corresponding target fusion operation is not generated temporarily, and it is determined whether the conflict association relationship sequence corresponding to the current operation log increases within a first preset time; When the corresponding conflict association relationship sequence is not increased within the first preset time, generating a target fusion operation according to the current operation log and the corresponding first historical operation log, and executing the target fusion operation in the destination database; When the corresponding conflict association relationship sequence increases within the first preset time, a corresponding target fusion operation is generated according to the last operation log in the increased conflict association relationship sequence and the corresponding first historical operation log, and the target fusion operation is executed in the destination database.
8. A device for accelerating data synchronization, characterized in that: The device for accelerating data synchronization includes at least one processor and a memory, and the at least one processor and the memory are connected via a data bus. The memory stores instructions that can be executed by the at least one processor. After being executed by the processor, the instructions are used to implement the method for accelerating data synchronization described in any one of claims 1-7.
9. A non-volatile computer storage medium, characterized in that The computer storage medium stores computer-executable instructions, and the computer-executable instructions are executed by one or more processors to implement the method for accelerating data synchronization according to any one of claims 1 to 7.
Citation Information
Patent Citations
Database adding column synchronization method and device based on log analysis
CN111221907A
Data synchronization method
CN117370462A