Data message out-of-order processing method, apparatus, device, medium, and program product

By extracting and calculating the core identifiers of data messages from the database, generating fusion sorting identifiers, and correcting the sorting, the problem of out-of-order data messages is solved, and the accuracy and reliability of data transmission and processing are achieved.

CN123178115APending Publication Date: 2026-11-27CHINA UNITED NETWORK COMM GRP CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611114591.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-24
Publication Date
2026-11-27

AI Technical Summary

Technical Problem

In database data synchronization and message distribution scenarios, due to factors such as network transmission delays, multi-threaded concurrent processing, node failure switching, and log parsing anomalies, the order in which data messages are received is inconsistent with the order in which transactions are executed. Existing technologies struggle to accurately handle data out-of-order phenomena, resulting in low accuracy in data transmission and processing.

Method used

By obtaining the binary log file of the target database, the core identifiers of each data message are extracted, such as the commit sequence number (CSN), transaction identifier, and log track sequence number. The fusion sorting identifier is calculated, sorted according to the receiving order, and compared to correct the sorting of data messages to ensure that it is consistent with the actual execution order.

Benefits of technology

It improves the accuracy of data message transmission and processing, enabling precise processing of data messages and enhancing the reliability of data transmission and processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123178115A_ABST
    Figure CN123178115A_ABST
Patent Text Reader

Abstract

The application provides a data message disorder processing method and device, equipment, medium and program product, relates to the communication technical field, and is used for improving the accuracy in the data transmission and processing process. The specific technical scheme is as follows: a binary log file in a target database is acquired; a core identifier corresponding to each data message in the binary log file is extracted, so that a fusion sorting identifier corresponding to each data message is obtained; the data messages are sorted according to the receiving sequence of each data message in the target database, and a message queue is obtained; all data messages in a predetermined sorting window in the message queue are temporarily sorted in ascending order of the fusion sorting identifier, a first sorting sequence is obtained, and the first sorting sequence is compared with the receiving sequence of all data messages in the predetermined sorting window in the target database, and based on the comparison result, the data messages are processed. The application is applied to the data synchronization and message distribution scene of the database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of big data technology, and in particular to a method, apparatus, device, medium, and program product for processing out-of-order data messages. Background Technology

[0002] In database data synchronization and message distribution scenarios, due to factors such as network transmission delay, multi-threaded concurrent processing, node failure switching, and log parsing anomalies, data messages are prone to out-of-order transmission and processing, meaning that the order in which messages are received is inconsistent with the actual execution order of transactions in the MySQL database.

[0003] In existing technologies, the main method for handling out-of-order data messages is to use a simple multi-identifier concatenation method. Several fixed markers (such as sequence number, timestamp, group ID, etc.) are added before the original data message and concatenated. After the receiving end receives the message, the fixed markers are separated and sorted according to the sequence number.

[0004] However, using the above method to judge and resolve data disorder solely based on the order of time is susceptible to clock deviations, identical timestamps, repeated data, and data loss, resulting in low accuracy in data transmission and processing. Summary of the Invention

[0005] This application provides a method, apparatus, device, medium, and program product for processing out-of-order data messages, which can improve the accuracy of data transmission and processing.

[0006] In a first aspect, embodiments of this application provide a method for processing out-of-order data messages. The method includes: obtaining a binary log file in a target database; extracting at least one core identifier corresponding to each data message in the binary log file; the core identifier corresponding to the data message includes at least one of the following: a submission sequence number (CSN), a transaction identifier, and a log trace sequence number; obtaining a fusion sorting identifier corresponding to each data message based on the at least one core identifier corresponding to each data message, the fusion sorting identifier being used to characterize the actual execution order of the data messages; sorting the data messages according to the receiving order of each data message in the target database to obtain a message queue; temporarily sorting all data messages in a predetermined sorting window in the message queue according to the ascending order of the fusion sorting identifier to obtain a first sorting order, and comparing the first sorting order with the receiving order of all data messages in the predetermined sorting window in the target database to obtain a comparison result; and processing the data messages based on the comparison result.

[0007] The technical solution provided in this application brings at least the following beneficial effects: Based on the core identifier corresponding to each data message in the binary log file of the target database, this application determines the fusion sorting identifier corresponding to each data message. Then, after sorting the data messages according to the receiving order of each data message in the target database to obtain a message queue, since the fusion sorting identifier is used to characterize the actual execution order of the data messages, the data messages in the message queue are temporarily sorted according to the fusion sorting identifier. The sorting result can reflect the actual execution order of the data messages. At this time, by comparing the temporary sorting with the message queue, it can be determined whether the message queue is out of order. Based on the determination result, different message processing operations can be performed on the data messages, thereby enabling precise processing of the data messages and improving the accuracy of data message data transmission and processing.

[0008] One possible implementation is that, based on the comparison result, message processing of the data message includes: if the comparison result indicates that the first sorting order is inconsistent with the receiving order of all data messages in the target database within the predetermined sorting window, correcting the sorting of the data messages in the message queue and performing message processing based on the corrected message queue; or, if the comparison result indicates that the first sorting order is consistent with the receiving order of all data messages in the target database within the predetermined sorting window, performing message processing based on the message queue.

[0009] Another possible implementation, where the comparison result indicates that the first sorting order is inconsistent with the receiving order of all data messages within the predetermined sorting window in the target database, correcting the sorting of data messages in the message queue includes: if the difference between the fusion sorting identifiers corresponding to two data messages is less than a preset threshold, then the CSN and transaction identifier of the two data messages are compared; if the transaction commit order indicated by the CSNs of the two data messages is inconsistent with the sorting order of the fusion sorting identifiers of the two data messages, or if the transactions corresponding to the transaction identifiers of the two data messages have nested or dependent relationships, then the sorting of data messages in the message queue is corrected.

[0010] Another possible implementation involves correcting the order of data messages in the message queue when the comparison result indicates that the first sorting order is inconsistent with the receiving order of all data messages within the predetermined sorting window in the target database. This includes: sorting the data messages in the message queue in ascending order according to the fusion sorting identifier corresponding to each data message; performing a secondary sorting on the sorted data messages in the message queue in ascending order according to the CSN of each data message; and if multiple data messages in the message queue correspond to the same transaction identifier, performing a third sorting on the secondary sorted data messages in the message queue in ascending order according to the log track sequence number of each data message to obtain the corrected message queue.

[0011] Another possible implementation involves obtaining the fusion sorting identifier for each data message based on at least one core identifier corresponding to each data message, including:

[0012] Based on at least one core identifier and the first formula corresponding to each of the above data messages, calculate the fusion sorting identifier corresponding to each of the above data messages;

[0013] The first formula mentioned above is:

[0014] ;

[0015] Where F is the fusion sorting identifier. This is the log track sequence number. The integer conversion value for the transaction identifier. The integer conversion value of CSN. This represents the weighting coefficient of SCN in the fusion sorting identifier.

[0016] Another possible implementation, the data message out-of-order processing method provided in this application embodiment further includes:

[0017] Perform integrity and order checks on the corrected message queue;

[0018] After the verification is successful, the corrected message queue is output.

[0019] After a verification failure, an error log is output, recording the queue information of the aforementioned message queue.

[0020] Secondly, embodiments of this application provide a data message out-of-order processing apparatus, comprising: an acquisition module for acquiring a binary log file in a target database; an extraction module for extracting at least one core identifier corresponding to each data message in the binary log file acquired by the acquisition module; the core identifier corresponding to the data message includes at least one of the following: a submission sequence number (CSN), a transaction identifier, and a log track sequence number; the fusion module is further configured to obtain a fusion sorting identifier corresponding to each data message based on the at least one core identifier corresponding to each data message extracted by the extraction module, the fusion sorting identifier being used to characterize the actual execution order of the data messages; a sorting module for sorting the data messages according to the receiving order of each data message in the target database to obtain a message queue; the sorting module is further configured to temporarily sort all data messages in a predetermined sorting window in the message queue according to the ascending order of the fusion sorting identifier to obtain a first sorting order, and compare the first sorting order with the receiving order of all data messages in the predetermined sorting window in the target database to obtain a comparison result; and a processing module for processing the data messages based on the comparison result obtained by the sorting module.

[0021] One possible implementation is that the above-mentioned processing module is specifically used to: correct the order of data messages in the message queue and perform message processing based on the corrected message queue when the comparison result indicates that the first sorting order is inconsistent with the receiving order of all data messages in the target database within the predetermined sorting window; or, perform message processing based on the message queue when the comparison result indicates that the first sorting order is consistent with the receiving order of all data messages in the target database within the predetermined sorting window.

[0022] In another possible implementation, the aforementioned data message out-of-order processing device further includes: a correction module; the correction module is used to, when the comparison result indicates that the first sorting order is inconsistent with the receiving order of all data messages in the target database within the predetermined sorting window, compare the CSN and transaction identifier of the two data messages if the difference between the fusion sorting identifiers corresponding to the two data messages is less than a preset threshold; if the transaction submission order indicated by the CSN of the two data messages is inconsistent with the sorting order of the fusion sorting identifiers of the two data messages, or if the transactions corresponding to the transaction identifiers of the two data messages have nested or dependent relationships, then correct the sorting of the data messages in the message queue.

[0023] Another possible implementation is that the above-mentioned data message out-of-order processing device further includes: a correction module; the correction module is used to sort the data messages in the message queue in ascending order according to the fusion sorting identifier corresponding to each data message; to perform a secondary sorting of the data messages in the message queue after sorting in ascending order according to the CSN of each data message; if there are multiple data messages in the message queue corresponding to the same transaction identifier, then the data messages in the message queue after secondary sorting are sorted a third time in ascending order according to the log trajectory sequence number of each data message to obtain the corrected message queue.

[0024] Another possible implementation is that the aforementioned processing module is specifically used to: calculate the fusion sorting identifier corresponding to each of the aforementioned data messages based on at least one core identifier and a first formula; wherein the aforementioned first formula is:

[0025] ;

[0026] Where F is the fusion sorting identifier. This is the log track sequence number. The integer conversion value for the transaction identifier. The integer conversion value of CSN. This represents the weighting coefficient of SCN in the fusion sorting identifier.

[0027] Another possible implementation is that the above-mentioned data message out-of-order processing device further includes: a verification module; used to perform integrity and order verification on the corrected message queue; and after the verification passes, outputting the corrected message queue; and after the verification fails, outputting an error log to record the queue information of the message queue.

[0028] Thirdly, this application provides an electronic device comprising: a processor and a memory; the memory stores a program or instructions executable on the processor, wherein the program or instructions, when executed by the processor, implement the method of the first aspect described above.

[0029] Fourthly, this application provides a readable storage medium on which a program or instructions are stored, which, when executed by a computer, implement the method of the first aspect described above.

[0030] Fifthly, this application provides a computer program product stored in a storage medium, which, when executed by a computer, implements the method described in the first aspect.

[0031] In a sixth aspect, embodiments of this application provide a chip including a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the method described in the first aspect.

[0032] The beneficial effects of the second to sixth aspects mentioned above are described in the corresponding description of the first aspect and will not be repeated here. Attached Figure Description

[0033] Figure 1 A schematic diagram of the network architecture for a data message out-of-order processing method provided in this application embodiment;

[0034] Figure 2 A flowchart illustrating a data message out-of-order processing method provided in an embodiment of this application;

[0035] Figure 3 A flowchart illustrating a data message out-of-order processing method provided in an embodiment of this application;

[0036] Figure 4 A flowchart illustrating a data message out-of-order processing method provided in an embodiment of this application;

[0037] Figure 5 A flowchart illustrating a data message out-of-order processing method provided in an embodiment of this application;

[0038] Figure 6 A flowchart illustrating a data message out-of-order processing method provided in an embodiment of this application;

[0039] Figure 7 A flowchart illustrating a data message out-of-order processing method provided in an embodiment of this application;

[0040] Figure 8 A flowchart illustrating the implementation process of a data message out-of-order processing method provided in this application embodiment;

[0041] Figure 9 This is a schematic diagram of the structure of a data message out-of-order processing method apparatus provided in an embodiment of this application;

[0042] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0043] The following will describe in detail the data message out-of-order processing method, apparatus, equipment, medium, and program products provided in this application, with reference to the accompanying drawings.

[0044] The technical solutions of the embodiments of this application will be clearly described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application are within the scope of protection of this application.

[0045] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such use of data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein, and the objects distinguished by "first," "second," etc., are generally of the same class and the number of objects is not limited; for example, a first object can be one or more. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship.

[0046] The terms "at least one," "at least one of," etc., used in the specification and claims of this application refer to any one, any two, or a combination of two or more of the included items. For example, at least one of a, b, and c can mean: "a," "b," "c," "a and b," "a and c," "b and c," and "a, b, and c," where a, b, and c can be single or multiple. Similarly, "at least two" refers to two or more items, and its meaning is similar to that of "at least one."

[0047] In the description of this application, unless otherwise stated, "a plurality of" means two or more.

[0048] The present application provides a data message out-of-order processing method, apparatus, device, medium, and program product that can be applied to database data synchronization and message distribution scenarios.

[0049] Taking MySQL database as an example, in data synchronization and message distribution scenarios, data messages are typically generated based on binlog log parsing to implement core functions such as master-slave synchronization, cross-datacenter data backup, and business data subscription. However, due to factors such as network transmission latency, multi-threaded concurrent processing, node failure switching, and log parsing anomalies, data messages are prone to out-of-order delivery during transmission and processing, meaning that the order in which messages are received is inconsistent with the actual execution order of transactions in the MySQL database.

[0050] In related technologies, the handling of out-of-order MySQL data messages mainly falls into two categories: one is sorting based on a single identifier (such as a transaction identifier (which can be simply called Xid) or a timestamp), and the other is performing order verification based on simple concatenation of multiple identifiers. The single-identifier approach has significant drawbacks: Xid, as the unique identifier for a MySQL transaction, is not always generated in the same order as the transaction execution in multi-session concurrent scenarios; relying solely on Xid cannot accurately reconstruct the transaction execution sequence. Timestamps are significantly affected by system clock deviations and network latency, easily leading to timestamp errors and sorting failures. The Commit Sequence Number (CSN) in MySQL requires a combination of log file number and log position for identification; when used alone, it cannot simultaneously consider the global order and local execution order of transactions. The simple multi-identifier concatenation method does not reasonably allocate the weight of each identifier, and cannot give full play to the advantages of different identifiers in time series representation. For example, it does not consider the global incrementing characteristic of the log track sequence number (TrailSeq) and the adjustment effect of SCN_FACTOR (i.e. SCN coefficient) on time series accuracy, resulting in low sorting efficiency and insufficient accuracy of disorder correction. Especially in high-concurrency, large-data-volume MySQL cluster scenarios, it is easy to cause problems such as inconsistent data synchronization and abnormal business logic, which seriously affects the reliability of data transmission and processing.

[0051] To address the aforementioned technical problems, this application provides a method, apparatus, device, medium, and program product for processing out-of-order data messages. Based on the core identifier corresponding to each data message in the binary log file of the target database, a fusion sorting identifier is determined for each data message. Then, after sorting the data messages according to their receiving order in the target database to obtain a message queue, the fusion sorting identifier is used to characterize the actual execution order of the data messages. Therefore, temporarily sorting the data messages in the message queue according to the fusion sorting identifier reflects the actual execution order of the data messages. By comparing this temporary sort with the message queue, it can be determined whether the message queue is out of order. Based on the determination result, different message processing operations can be performed on the data messages, thereby enabling precise processing of the data messages and improving the accuracy of data message data transmission and processing.

[0052] The following description, in conjunction with the accompanying drawings, details the data message out-of-order processing method, apparatus, device, medium, and program products provided in the embodiments of this application.

[0053] Figure 1 This illustration shows a network architecture for a data message out-of-order processing method provided in an embodiment of this application. For example... Figure 1As shown, the network architecture includes a data message out-of-order processing device 101 and a terminal device 102. The data message out-of-order processing device 101 and the terminal device 102 are interconnected.

[0054] In some embodiments, the data message out-of-order processing device 101 may be a server, a computer, or a processor or processing unit within a server or computer. The server may be a single server or a server cluster consisting of multiple servers. It should be noted that the embodiments of this application do not limit the specific device form of the data message out-of-order processing device 101. Figure 1 The data message out-of-order processing device 101 is shown as a single server as an example.

[0055] In some embodiments, the terminal device may be a mobile phone, tablet computer, laptop computer, handheld computer, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, personal computer (PC), ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc., and the embodiments of this application do not specifically limit it. Figure 1 The example shown is a mobile phone, with terminal device 102 as an example.

[0056] In some embodiments, the data message out-of-order processing device 101 obtains a binary log file from a target database, the binary log file originating from a terminal device 102; extracts at least one core identifier corresponding to each data message in the binary log file; the core identifier corresponding to the data message includes at least one of the following: a submission sequence number (CSN), a transaction identifier, and a log trace sequence number; based on the at least one core identifier corresponding to each data message, obtains a fusion sorting identifier corresponding to each data message, the fusion sorting identifier being used to characterize the actual execution order of the data messages; sorts the data messages according to the receiving order of each data message in the target database to obtain a message queue; temporarily sorts all data messages within a predetermined sorting window in the message queue according to the ascending order of the fusion sorting identifier to obtain a first sorting order, and compares the first sorting order with the receiving order of all data messages within the predetermined sorting window in the target database to obtain a comparison result; and processes the data messages based on the comparison result.

[0057] It should be noted that the network architecture described in the embodiments of this application is for the purpose of more clearly illustrating the technical solutions of the embodiments of this application, and does not constitute a limitation on the technical solutions provided in the embodiments of this application. As network architectures evolve, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.

[0058] See Figure 2 This is a flowchart illustrating a data message out-of-order processing method provided in an embodiment of this application. Figure 2 As shown, the data message out-of-order processing method provided in this application embodiment can be implemented by the above-mentioned data message out-of-order processing device, specifically including the following steps 201 to 206.

[0059] Step 201: The data message out-of-order processing device obtains the binary log file from the target database.

[0060] In some embodiments, the target database may be a MySQL database or other databases, and this application does not limit the scope of the database.

[0061] In some embodiments, the target database contains at least one binary log file, and each binary log file contains at least one data message.

[0062] It is understandable that the aforementioned binary log file is a log file that records data modification operations on the target database.

[0063] For example, the binary log file mentioned above could be the binlog log in a MySQL database.

[0064] Step 202: The data message out-of-order processing device extracts at least one core identifier corresponding to each data message in the binary log file.

[0065] In some embodiments, the core identifier corresponding to the above data message includes at least one of the following: CSN, transaction identifier, and log track sequence number.

[0066] In some embodiments, the CSN mentioned above is a globally monotonically increasing unique number assigned by the database to each transaction commit operation, representing the time sequence marker of the transaction's completion. The transaction identifier mentioned above is a unique number assigned by the target database to each independent database transaction, used to identify a complete operation (e.g., insert, delete, update, transaction commit, and transaction rollback). The log track sequence number mentioned above is used to mark the chronological order of each log record or each transaction change.

[0067] In some embodiments, extracting at least one core identifier corresponding to each data message in a binary log file means first parsing the binary log and then extracting the core identifier corresponding to each data message.

[0068] Step 203: The data message disorder processing device obtains the fusion sorting identifier corresponding to each data message based on at least one core identifier corresponding to each data message.

[0069] In some embodiments, the aforementioned fusion sorting identifier is used to characterize the actual execution order of the aforementioned data messages.

[0070] In some embodiments, combined with Figure 2 ,like Figure 3 As shown, step 203 above can be implemented through step 203a as follows.

[0071] Step 203a: The data message disorder processing device calculates the fusion sorting identifier corresponding to each data message based on at least one core identifier and the first formula corresponding to each data message.

[0072] The first formula is:

[0073] ;

[0074] Where F is the fusion sorting identifier. This is the log track sequence number. The integer conversion value for the transaction identifier. The integer conversion value of CSN. This represents the weighting coefficient of SCN in the fusion sorting identifier.

[0075] It should be noted that the above SCN_FACTOR can be dynamically adjusted. The dynamic adjustment rule for SCN_FACTOR is as follows: when the business concurrency of the target database is ≥1000 TPS, the value of SCN_FACTOR is 800~1000; when the business concurrency of the target database is <1000 TPS, the value of SCN_FACTOR is 1~799.

[0076] It should be noted that the integer conversion method for Xid can be SHA-256 hash, and the integer conversion method for CSN can be "log file number × 10^12 + log position".

[0077] Step 204: The data message out-of-order processing device sorts the data messages according to the receiving order of each data message in the target database to obtain a message queue.

[0078] In some embodiments, the message queue mentioned above refers to a cache queue obtained by sorting each data message in the binary file log according to the order of receipt.

[0079] Step 205: The data message out-of-order processing device temporarily sorts all data messages in the predetermined sorting window of the message queue according to the ascending order of the fusion sorting identifier to obtain a first sorting order, and compares the first sorting order with the receiving order of all data messages in the predetermined sorting window in the target database to obtain the comparison result.

[0080] In some embodiments, the aforementioned predetermined sorting window can be dynamically adjusted, and this application does not limit this.

[0081] In some embodiments, after acquiring the message queue, the data message out-of-order processing device may set a temporary sorting window (i.e., the aforementioned predetermined sorting window) and temporarily sort all the data messages in the message queue within the temporary sorting window according to the ascending order of the fusion sorting identifier to obtain a first sorting order that does not affect the original storage order of the data messages in the message queue.

[0082] It should be noted that the above temporary sorting refers to a temporary sorting operation performed on all data messages within a predetermined sorting window. This temporary sorting operation does not change the original storage order of the data messages in the message queue. It only temporarily generates an ordered sorting result when the above comparison operation is performed. After the comparison operation is completed, the sorting effect disappears, and the data messages in the message queue remain as they were.

[0083] In some embodiments, when comparing the first sorting order with the receiving order of all data messages in the target database within the predetermined sorting window, the two sorting orders are usually compared element by element from the beginning to determine whether the elements corresponding to each position are the same. If the elements corresponding to any position in the two sorting orders are different, the two sorting orders are determined to be inconsistent.

[0084] In some embodiments, if the first sorting order is completely consistent with the receiving order of all data messages in the target database within the predetermined sorting window, it is determined that the messages in the predetermined sorting window are not out of order; conversely, if the first sorting order does not match the receiving order of all data messages in the target database within the predetermined sorting window, it is determined that the messages in the predetermined sorting window are out of order.

[0085] For example, if it is determined that the data messages within the predetermined sorting window are out of order, the position of the out-of-order data messages, the fusion sorting identifier, and the core identifier information can be recorded.

[0086] For example, if it is determined that data messages within a predetermined sorting window are out of order, a secondary determination can be made using auxiliary verification information to avoid misjudgment due to identifier conversion errors. Specifically, if the difference between the merged sorting identifiers of two data messages is less than a preset threshold (for example, the preset threshold can be 10 times SCN_FACTOR), then the CSN and Xid of the two data messages are further compared. If the transaction commit order corresponding to the CSN of the two data messages is inconsistent with the sorting order of the merged sorting identifiers of the two data messages, or if the transactions corresponding to the Xid of the two data messages have nested or dependent relationships, then it is confirmed that there is out of order, thus avoiding misjudgment due to identifier conversion errors.

[0087] Step 206: The data message out-of-order processing device processes the data message based on the comparison results.

[0088] For example, if the comparison result indicates that all data messages within the predetermined sorting window are received in the target database in the correct order, then no further correction and verification processing is required.

[0089] For example, if the comparison result indicates that the receiving order of all data messages in the target database within the predetermined sorting window is not completely correct, then subsequent correction and verification processing is required.

[0090] In some embodiments, combined with Figure 2 ,like Figure 4 As shown, step 206 above can be implemented through step 206a or step 206b.

[0091] Step 206a: When the comparison result indicates that the first sorting order is inconsistent with the receiving order of all data messages in the target database within the predetermined sorting window, the data message out-of-order processing device corrects the sorting of data messages in the message queue and performs message processing based on the corrected message queue.

[0092] Step 206b: When the comparison result indicates that the first sorting order is consistent with the receiving order of all data messages in the target database within the predetermined sorting window, the data message out-of-order processing device performs message processing based on the message queue.

[0093] Thus, based on the above comparison results, it can be determined whether there is out-of-order message in the message queue. Based on the determination result, different message processing operations can be performed on the data message, thereby enabling precise processing of the data message and improving the accuracy of data message transmission and processing.

[0094] In some embodiments, combined with Figure 4 ,like Figure 5As shown, in step 206a above, "when the comparison result indicates that the first sorting order is inconsistent with the receiving order of all data messages in the target database within the predetermined sorting window, the sorting of data messages in the message queue is corrected" can be specifically implemented through the following steps 206a1 to 206a2.

[0095] Step 206a1: If the comparison result indicates that the first sorting order is inconsistent with the receiving order of all data messages in the target database within the predetermined sorting window, and if the difference between the fusion sorting identifiers corresponding to the two data messages is less than a preset threshold, the data message out-of-order processing device compares the CSN and transaction identifier of the two data messages.

[0096] In some embodiments, the threshold is 10 times that of SCN_FACTOR.

[0097] For example, if the comparison result indicates that the first sorting order is inconsistent with the receiving order of all data messages in the target database within the predetermined sorting window, and the difference between the fusion sorting identifiers corresponding to the two data messages is less than a preset threshold, the message queue may be further determined to be out of order based on dual judgment logic (i.e., fusion identifier sorting comparison, combined with auxiliary verification information for secondary confirmation).

[0098] Step 206a2: If the comparison result indicates that the first sorting order is inconsistent with the receiving order of all data messages in the target database within the predetermined sorting window, and if the transaction commit order indicated by the CSN of the two data messages is inconsistent with the sorting order of the fusion sorting identifier of the two data messages, or if the transactions corresponding to the transaction identifiers of the two data messages have a nested or dependent relationship, then the data message out-of-order processing device corrects the sorting of the data messages in the message queue.

[0099] In some embodiments, if the transaction commit order corresponding to CSN is inconsistent with the first sorting order, or if the transaction corresponding to Xid has nesting or dependency relationships, then out-of-order is confirmed to avoid misjudgment due to identifier conversion error.

[0100] In this way, by comparing the results and using auxiliary verification information to make a secondary judgment on the message queue, we can determine whether the message queue is out of order. Based on the judgment result, we can perform different message processing operations on the data message, thereby enabling precise processing of the data message and improving the accuracy of data message transmission and processing.

[0101] In some embodiments, the sorting of data messages in the above-mentioned correction message queue can be divided into three-level correction strategies, including: a first-level correction strategy, a second-level correction strategy, and a third-level correction strategy.

[0102] For example, combined Figure 4,like Figure 6 As shown, in step 206a above, "correcting the order of data messages in the message queue when the comparison result indicates that the first sorting order is inconsistent with the receiving order of all data messages in the target database within the predetermined sorting window" can be specifically implemented through steps 206a3 to 206a5.

[0103] Step 206a3: The data message out-of-order processing device sorts the data messages in the message queue in ascending order according to the fusion sorting identifier corresponding to each data message.

[0104] In some embodiments, based on the fusion sorting identifier F, the data messages in the message queue are rearranged in ascending order according to the F value to ensure that the message order is consistent with the time sequence represented by the fusion identifier.

[0105] In other words, the correction strategy corresponding to step 206a3 above can be considered as a first-level correction strategy.

[0106] Step 206a4: The data message out-of-order processing device performs a secondary sorting of the data messages in the sorted message queue according to the ascending order of the CSN of each data message.

[0107] In some embodiments, the data messages in the sorted message queue are sorted a second time in ascending order of CSN to correct the timing deviation caused by the adjustment of SCN_FACTOR and ensure the accuracy of the transaction commit order.

[0108] In other words, the correction strategy corresponding to step 206a4 above can be considered a secondary correction strategy.

[0109] Step 206a5: If multiple data messages in the message queue correspond to the same transaction identifier, the data message out-of-order processing device sorts the data messages in the message queue after the second sorting in ascending order of the log track sequence number of each data message, and obtains the corrected message queue.

[0110] In some embodiments, for data messages in the message queue after secondary sorting, the uniqueness of Xid and transaction dependencies are verified. If there are multiple messages corresponding to the same Xid (different operations of the same transaction), they are sorted in ascending order of TrailSeq to ensure the correct order of operations within the same transaction. If there is a transaction dependency (a transaction needs to depend on another transaction to complete), the message order is adjusted according to the transaction association corresponding to Xid to meet the dependency requirements.

[0111] In other words, the correction strategy corresponding to step 206a5 above can be considered as a three-level correction strategy.

[0112] It should be noted that the first-level correction strategy in the above-mentioned hierarchical correction strategy can be regarded as the first-level fusion identifier sorting strategy, the second-level correction strategy can be regarded as the second-level CSN sorting strategy, and the third-level correction strategy can be the third-level Xid transaction dependency adjustment strategy.

[0113] In this way, by performing a three-level stepped correction on the out-of-order message queue, the correction accuracy is increased, thereby improving the accuracy of data message transmission and processing.

[0114] The data message out-of-order processing method provided in this application determines the fusion sorting identifier for each data message based on the core identifier corresponding to each data message in the binary log file of the target database. Then, after sorting the data messages according to the receiving order of each data message in the target database to obtain a message queue, since the fusion sorting identifier is used to characterize the actual execution order of the data messages, the data messages in the message queue are temporarily sorted according to the fusion sorting identifier. The sorting result can reflect the actual execution order of the data messages. At this time, by comparing the temporary sorting with the message queue, it can be determined whether the message queue is out of order. Based on the determination result, different message processing operations can be performed on the data messages, thereby enabling precise processing of the data messages and improving the accuracy of data message data transmission and processing.

[0115] In some embodiments, such as Figure 7 As shown, the data message out-of-order processing method provided in this application embodiment may further include steps 207 to 209.

[0116] Step 207: The data message out-of-order processing device performs integrity and order verification on the corrected message queue.

[0117] In some embodiments, integrity verification refers to checking whether there are missing or duplicate messages in the message sequence. If there are missing messages, they are collected again; if there are duplicate messages, redundant messages are deleted.

[0118] In some embodiments, sequentiality verification refers to recalculating the fusion sorting identifier F for each message, verifying whether the message sequence is arranged in ascending order of F value, and verifying whether the transaction commit order corresponding to CSN (i.e., the aforementioned commit sequence number), the transaction uniqueness corresponding to Xid (i.e., the aforementioned transaction identifier), and the log generation order corresponding to TrailSeq (i.e., the aforementioned log trajectory sequence number) are consistent. If they are inconsistent, the process is re-executed.

[0119] Step 208: After the data message out-of-order processing device passes the verification, it outputs the corrected message queue.

[0120] In some embodiments, the corrected message queue is output to the corresponding functional module (such as master-slave synchronization module, data subscription module) in the server for processing.

[0121] Step 209: After the verification fails, the data message out-of-order processing device outputs an error log and records the message queue information.

[0122] In some embodiments, the message queue information includes: core identifier, fusion identifier, receiving location, etc.

[0123] In this way, by double-checking the corrected message queue, different message processing operations can be performed on out-of-order messages, thereby enabling precise processing of data messages and improving the accuracy of data message transmission and processing.

[0124] The following specific embodiments illustrate the data message out-of-order processing method provided in this application.

[0125] like Figure 8 As shown, the implementation process of the data message out-of-order processing method provided in this application embodiment includes the following steps S1 to S5.

[0126] The following will provide a detailed explanation of each step from S1 to S5.

[0127] Step S1: Message collection and identifier extraction.

[0128] For example, binlog logs generated by a MySQL database are collected, the binlog logs are parsed, and the core identifiers corresponding to each data message are extracted. The core identifiers include TrailSeq, SCN_FACTOR, Xid, and CSN.

[0129] Among them, TrailSeq is the trajectory sequence number of the MySQL binlog log, which is globally incremented by the log parsing module according to the log generation order and is used to represent the generation time sequence of messages; SCN_FACTOR is the SCN coefficient, which is dynamically adjusted according to the transaction concurrency of the MySQL database, with a value range of 1 to 1000, and is used to adjust the weight of CSN in the time sequence sorting; Xid is the unique identifier of MySQL transaction, which adopts the triple format of "gtrid,bqual,formatID" to uniquely identify a single transaction, where gtrid is the global transaction identifier, bqual is the branch qualifier, and formatID is the format identifier, with a default value of 1; CSN is the transaction commit sequence number, which is composed of "log file number:log position" in MySQL and is used to represent the commit time sequence of transactions. The log position is the offset of the start transaction recorded in the log file.

[0130] At the same time, the transaction type (INSERT, UPDATE, DELETE), execution timestamp, and database instance ID corresponding to each data message are extracted as auxiliary verification information for subsequent out-of-order correction.

[0131] Step S2: Calculate the fusion identifier.

[0132] For example, a fusion ranking identifier is constructed based on the extracted core identifier, wherein the calculation formula for the fusion ranking identifier is:

[0133] ;(Formula 1)

[0134] Where F is the fusion sorting identifier, is the integer conversion value of Xid, which converts the triple format of Xid into 64-bit integer data through a hash algorithm; and is the integer conversion value of CSN, which converts the combination format of "log file number:log position" into 64-bit integer data to ensure that the integer value corresponding to different CSNs is unique and positively correlated with the commit time sequence.

[0135] It should be noted that the dynamic adjustment rule of SCN_FACTOR is as follows: when the transaction concurrency of the MySQL database is ≥1000 TPS, the value of SCN_FACTOR is 800~1000, which increases the weight of CSN in the fusion identifier and prioritizes the transaction commit order; when the transaction concurrency is <1000 TPS, the value of SCN_FACTOR is 1~799, which balances the weight of TrailSeq, Xid and CSN, taking into account both the message generation order and the uniqueness of the transaction identifier.

[0136] Step S3: Queue out-of-order identification.

[0137] For example, a message cache queue (i.e., the message queue mentioned above) is constructed, and the data messages with the calculated fusion sorting identifier F are stored in the cache queue in the order of receipt; a sorting window (i.e., the predetermined sorting window mentioned above) is set, and the window size is dynamically adjusted according to the MySQL transaction concurrency (the higher the concurrency, the larger the window, with a value range of 10 to 1000 messages); all data messages in the sorting window are temporarily sorted in ascending order according to the fusion sorting identifier F, and the message order after temporary sorting is compared with the receipt order in the cache queue.

[0138] Specifically, if both are completely identical, the messages within the window are determined to be in no out-of-order. If at least one message has a mismatched position, out-of-order messages are determined, and the position, fusion identifier F, and core identifier information of the out-of-order messages are recorded. Simultaneously, a secondary determination is made using auxiliary verification information: if the difference in fusion identifier F between the two messages is less than a preset threshold (the threshold is 10 times SCN_FACTOR), the CSN and Xid of the two messages are further compared. If the transaction commit order corresponding to the CSN is inconsistent with the sorting order of the F values, or if the transactions corresponding to the Xid have nested or dependent relationships, out-of-order messages are confirmed, thus avoiding misjudgments due to identifier conversion errors.

[0139] Step S4: Queue disorder correction.

[0140] For example, a hierarchical correction strategy is adopted for the identified out-of-order messages, specifically including:

[0141] First-level correction: Based on the fusion sorting identifier F, the out-of-order messages are rearranged in ascending order according to the F value to ensure that the message order is consistent with the time sequence represented by the fusion identifier;

[0142] Secondary correction: After primary correction, messages are sorted a second time in ascending order of CSN to correct timing deviations caused by SCN_FACTOR adjustment and ensure the accuracy of transaction commit order;

[0143] Level 3 Correction: For messages corrected in Level 2, the uniqueness of the Xid and transaction dependencies are verified. If multiple messages (different operations within the same transaction) correspond to the same Xid, they are arranged in ascending order of TrailSeq to ensure the correct order of operations within the same transaction. If transaction dependencies exist (a transaction depends on another transaction to complete), the message order is adjusted according to the transaction association corresponding to the Xid to meet the dependency requirements. After correction, the corrected messages are retrieved from the cache queue and sent to the subsequent message processing module. If a message is found to be missing during the correction process (the F value of a message is between the F values ​​of two adjacent messages, but the message was not collected), the message re-collection mechanism is triggered to re-collect the corresponding binlog log fragment, extract the missing message, and supplement it to the corresponding position to ensure message integrity.

[0144] Step S5: Verification and Feedback.

[0145] For example, the integrity and order of the corrected message sequence are checked.

[0146] Integrity verification: Check whether there are missing or duplicate messages in the message sequence. If there are missing messages, re-collect them; if there are duplicate messages, delete redundant messages.

[0147] Sequence verification: Recalculate the fusion sorting identifier F for each message, verify whether the message sequence is arranged in ascending order of F value, and at the same time verify whether the transaction commit order corresponding to CSN, the transaction uniqueness corresponding to Xid, and the log generation order corresponding to TrailSeq are consistent. If they are inconsistent, repeat step S4 to correct them.

[0148] If the verification passes, the message sequence will be output to the target module (such as the master-slave synchronization module or the data subscription module); if the verification fails, an error log will be output, recording detailed information of the out-of-order messages (core identifier, fusion identifier, and receiving location), and triggering an alarm mechanism.

[0149] In this way, by fusing multiple identifiers, accurate identification and efficient correction of out-of-order messages can be achieved, thereby ensuring that the order in which data messages are received is consistent with the order in which MySQL transactions are executed, and thus improving the accuracy of data transmission and processing.

[0150] The main innovations of the data message out-of-order processing method provided in this application are as follows:

[0151] 1. Core identifier fusion scheme: The scheme adopts the fusion of four identifiers: TrailSeq×SCN_FACTOR+Xid+CSN, instead of a single identifier or simple concatenation. TrailSeq represents the message generation time sequence, CSN represents the transaction commit time sequence, Xid ensures the uniqueness of the transaction, and SCN_FACTOR dynamically adjusts the weight to balance the accuracy of the time sequence and the uniqueness of the transaction.

[0152] 2. Dynamic adaptation mechanism: SCN_FACTOR dynamically adjusts its value based on the transaction concurrency of the MySQL database (e.g., transaction concurrency ≥1000 TPS / <1000 TPS), and the sorting window dynamically adapts to the concurrency (e.g., 10~1000 rows) to adapt to different high / low concurrency scenarios.

[0153] Layered correction and dual verification: Out-of-order correction adopts a layered strategy of "fusion identifier first-level correction → CSN second-level correction → Xid transaction dependency third-level correction"; out-of-order identification combines fusion identifier comparison + auxiliary verification information (transaction type, timestamp, etc.) for secondary judgment to avoid misjudgment.

[0154] 3. Efficient identifier conversion: Xid is converted to a 64-bit integer using the SHA-256 hash algorithm, and CSN is converted to a 64-bit integer using "log file number × 10^12 + log position", ensuring that the converted data is unique and positively correlated with the time sequence.

[0155] 4. Integrity Guarantee: A message re-sampling mechanism is set up to handle message missing issues discovered during the correction process; during the verification phase, integrity (no missing, no duplicate) and sequence checks are performed simultaneously to ensure the reliability of the message sequence.

[0156] It should be noted that the main protection points of the data message out-of-order processing method provided in this application embodiment are:

[0157] This application provides a method for out-of-order processing of MySQL data messages based on TrailSeq×SCN_FACTOR+Xid+CSN. This method includes message collection and identifier extraction (extracting four core identifiers: TrailSeq, SCN_FACTOR, Xid, and CSN), and identifier fusion calculation (according to a formula). The complete process includes calculation, out-of-order identification (i.e., using dynamic windows combined with dual judgment to identify out-of-order items), hierarchical out-of-order correction (i.e., the above three-level correction strategy), and verification and feedback (a dual verification mode combining integrity verification and sequence verification).

[0158] It should be noted that the above-described method embodiments, or the various possible implementations of the method embodiments, can be executed individually, or, provided there is no conflict, they can be combined with each other. The specific implementation can be determined according to actual usage requirements, and this application embodiment does not impose any restrictions on this.

[0159] As can be seen, the above mainly describes the solutions provided by the embodiments of this application from a methodological perspective. To achieve the above functions, the embodiments of this application provide corresponding hardware structures and / or software modules for executing each function. Those skilled in the art should readily recognize that, in conjunction with the modules and algorithm steps of the various examples described in the embodiments disclosed herein, the embodiments of this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0160] This application embodiment can divide the data message out-of-order processing device into functional modules according to the above method example. For example, each function can be divided into its own functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. Optionally, the module division in this application embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.

[0161] In some embodiments, this application also provides a data message out-of-order processing apparatus. This data message out-of-order processing apparatus may include one or more functional modules for implementing the data message out-of-order processing method of the above method embodiments.

[0162] For example, Figure 9 This is a schematic diagram of a data message out-of-order processing device provided in an embodiment of this application. Figure 9 As shown, the data message out-of-order processing device 900 includes: an acquisition module 901, an extraction module 902, a fusion module 903, a sorting module 904, and a processing module 905.

[0163] The aforementioned acquisition module 901 is used to acquire binary log files in the target database;

[0164] The extraction module 902 is used to extract at least one core identifier corresponding to each data message in the binary log file obtained by the acquisition module 901; the core identifier corresponding to the data message includes at least one of the following: commit sequence number CSN, transaction identifier, and log track sequence number;

[0165] The aforementioned fusion module 903 is used to obtain a fusion sorting identifier corresponding to each of the aforementioned data messages based on at least one core identifier corresponding to each of the aforementioned data messages extracted by the extraction module 902. The aforementioned fusion sorting identifier is used to characterize the actual execution order of the data messages.

[0166] The sorting module 904 is used to sort the data messages according to the receiving order of each data message in the target database to obtain a message queue;

[0167] The sorting module 904 is further configured to temporarily sort all data messages in the predetermined sorting window of the message queue according to the ascending order of the fusion sorting identifier to obtain a first sorting order, and compare the first sorting order with the receiving order of all data messages in the predetermined sorting window in the target database to obtain a comparison result.

[0168] The aforementioned processing module 905 is also used to perform message processing on the aforementioned data message based on the comparison results obtained by the sorting module 904.

[0169] The data message out-of-order processing device provided in this application extracts the core identifier from the binary log file, performs fusion calculation on the core identifier to obtain the sorting result of the data messages, compares the result with the order in which the target database receives the data messages, and when out-of-order data message queues are detected, corrects the data message queues and verifies the corrected result. After the verification is passed, the corrected message queue is output, thereby enabling the message queues to be output accurately, thus improving the accuracy of data transmission and processing.

[0170] In some embodiments, the processing module 905 is specifically used for:

[0171] If the comparison results indicate that the first sorting order is inconsistent with the receiving order of all data messages within the predetermined sorting window in the target database, the sorting of data messages in the message queue is corrected, and message processing is performed based on the corrected message queue; or,

[0172] If the comparison results indicate that the first sorting order is consistent with the receiving order of all data messages in the target database within the predetermined sorting window, message processing is performed based on the message queue.

[0173] In some embodiments, the data message out-of-order processing apparatus 900 further includes: a correction module;

[0174] The aforementioned correction module is used to compare the CSN and transaction identifier of the two data messages if the difference between the fusion sorting identifiers corresponding to the two data messages is less than a preset threshold when the comparison result indicates that the first sorting order is inconsistent with the receiving order of all data messages in the predetermined sorting window in the target database.

[0175] If the transaction commit order indicated by the CSN of the above two data messages is inconsistent with the sorting order of the fusion sorting identifier of the above two data messages, or if the transactions corresponding to the transaction identifiers of the above two data messages have nested or dependent relationships, then the sorting of the data messages in the above message queue shall be corrected.

[0176] In some embodiments, the above-described data message out-of-order processing apparatus further includes: a correction module;

[0177] The aforementioned correction module is used to sort the data messages in the aforementioned message queue in ascending order according to the fusion sorting identifier corresponding to each of the aforementioned data messages;

[0178] The data messages in the message queue above are sorted a second time according to the ascending order of the CSN of each data message.

[0179] If multiple data messages in the message queue correspond to the same transaction identifier, the data messages in the message queue after the second sort are sorted a third time according to the ascending order of the log track sequence number of each data message to obtain the corrected message queue.

[0180] In some embodiments, the fusion module 903 is specifically used for:

[0181] Based on at least one core identifier and the first formula corresponding to each of the above data messages, calculate the fusion sorting identifier corresponding to each of the above data messages;

[0182] The first formula mentioned above is:

[0183] ;

[0184] Where F is the fusion sorting identifier. This is the log track sequence number. The integer conversion value for the transaction identifier. The integer conversion value of CSN. This represents the weighting coefficient of SCN in the fusion sorting identifier.

[0185] In some embodiments, the above-described data message out-of-order processing apparatus further includes: a verification module;

[0186] Used to perform integrity and order checks on the corrected message queue; and output the corrected message queue after the check passes; and output an error log after the check fails, recording the queue information of the message queue.

[0187] It should be noted that the data message out-of-order processing device can implement all the processes implemented in the above method embodiments and achieve the same beneficial effects. To avoid repetition, it will not be described again here.

[0188] In the case where the functions of the integrated modules described above are implemented in hardware, this application provides a possible structural schematic diagram of the electronic device involved in the above embodiments. For example... Figure 10 As shown, the electronic device 100 includes: a processor 102, a communication interface 103, and a bus 104. Optionally, the electronic device 100 may also include a memory 101.

[0189] Processor 102 may implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 102 may be a central processing unit, a general-purpose processor, a digital signal processor, an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It may implement or execute various exemplary logic blocks, modules, and circuits described in conjunction with the disclosure of this application. Processor 102 may also be a combination that implements computing functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.

[0190] Communication interface 103 is used to connect with other devices via a communication network. This communication network can be Ethernet, wireless access network, wireless local area network (WLAN), etc.

[0191] The memory 101 may be a read-only memory (ROM) or other type of static storage device capable of storing static information and instructions, random access memory (RAM) or other type of dynamic storage device capable of storing information and instructions, or electrically erasable programmable read-only memory (EEPROM), disk storage media or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but is not limited thereto.

[0192] As one possible implementation, the memory 101 can exist independently of the processor 102. The memory 101 can be connected to the processor 102 via a bus 104 and is used to store instructions or program code. When the processor 102 calls and executes the instructions or program code stored in the memory 101, it can implement the data message out-of-order processing method provided in the embodiments of this application.

[0193] In another possible implementation, the memory 101 can also be integrated with the processor 102.

[0194] Bus 104 can be an Extended Industry Standard Architecture (EISA) bus, etc. Bus 104 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 10 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0195] Through the above description of the implementation methods, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the service calling device can be divided into different functional modules to complete all or part of the functions described above.

[0196] This application embodiment also provides a chip, which includes a processor and a communication interface. The communication interface is coupled to the processor. The processor is used to run programs or instructions to implement the various processes of the above-described data message out-of-order processing method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0197] It should be understood that the chip mentioned in the embodiments of this application may also be referred to as a system-on-a-chip, system chip, chip system, or system-on-a-chip, etc.

[0198] This application also provides a readable storage medium storing a program or instructions that, when executed by a computer, implement the data message out-of-order processing method provided in the above embodiments. It is understood that all or part of the processes in the above method embodiments can be executed by computer instructions instructing related hardware; the readable storage medium can be any of the foregoing embodiments or memory; the readable storage medium can also be an external storage device of the service invocation device, such as a plug-in hard drive, SmartMedia Card (SMC), Secure Digital (SD) card, flash card, etc., equipped on the service invocation device. Further, the readable storage medium can include both internal storage units of the service invocation device and external storage devices. The readable storage medium is used to store the computer program and other programs and data required by the service invocation device. The readable storage medium can also be used to temporarily store data that has been output or will be output.

[0199] This application also provides a computer program product, which is stored in a storage medium and, when executed by a computer, implements the data message out-of-order processing method provided in the above embodiments.

[0200] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.

[0201] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a computer software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of this application.

[0202] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.

Claims

1. A method for processing out-of-order data messages, characterized in that, The data message out-of-order processing method includes: Obtain the binary log file from the target database; Extract at least one core identifier corresponding to each data message in the binary log file; the core identifier corresponding to the data message includes at least one of the following: commit sequence number (CSN), transaction identifier, and log track sequence number; Based on at least one core identifier corresponding to each data message, a fusion sorting identifier corresponding to each data message is obtained, and the fusion sorting identifier is used to characterize the actual execution order of the data messages; The data messages are sorted according to the order in which each data message is received in the target database to obtain a message queue; All data messages in the predetermined sorting window in the message queue are temporarily sorted in ascending order according to the fusion sorting identifier to obtain a first sorting order. The first sorting order is then compared with the receiving order of all data messages in the predetermined sorting window in the target database to obtain a comparison result. Based on the comparison results, the data message is processed.

2. The data message out-of-order processing method according to claim 1, characterized in that, The message processing based on the comparison result includes: If the comparison result indicates that the first sorting order is inconsistent with the receiving order of all data messages within the predetermined sorting window in the target database, the sorting of data messages in the message queue is corrected, and message processing is performed based on the corrected message queue; or, If the comparison result indicates that the first sorting order is consistent with the receiving order of all data messages in the target database within the predetermined sorting window, message processing is performed based on the message queue.

3. The data message out-of-order processing method according to claim 2, characterized in that, When the comparison result indicates that the first sorting order is inconsistent with the receiving order of all data messages in the target database within the predetermined sorting window, correcting the sorting of data messages in the message queue includes: If the comparison result indicates that the first sorting order is inconsistent with the receiving order of all data messages in the target database within the predetermined sorting window, and if the difference between the fusion sorting identifiers corresponding to the two data messages is less than a preset threshold, then the CSN and transaction identifier of the two data messages are compared. If the transaction commit order indicated by the CSN of the two data messages is inconsistent with the sorting order of the merge sorting identifiers of the two data messages, or if the transactions corresponding to the transaction identifiers of the two data messages have nested or dependent relationships, then the sorting of the data messages in the message queue shall be corrected.

4. The data message out-of-order processing method according to claim 2, characterized in that, When the comparison result indicates that the first sorting order is inconsistent with the receiving order of all data messages in the target database within the predetermined sorting window, correcting the sorting of data messages in the message queue includes: The data messages in the message queue are sorted in ascending order according to the fusion sorting identifier corresponding to each data message; The data messages in the message queue are then sorted a second time according to the ascending order of the CSN of each data message; If multiple data messages in the message queue correspond to the same transaction identifier, the data messages in the message queue after the second sort are sorted a third time according to the ascending order of the log trajectory sequence number of each data message to obtain the corrected message queue.

5. The data message out-of-order processing method according to claim 1, characterized in that, The step of obtaining the fusion sorting identifier corresponding to each data message based on at least one core identifier corresponding to each data message includes: Based on at least one core identifier and a first formula corresponding to each data message, calculate the fusion sorting identifier corresponding to each data message; The first formula is: ; Where F is the fusion sorting identifier. This is the log track sequence number. The integer conversion value for the transaction identifier. The integer conversion value of CSN. This represents the weighting coefficient of SCN in the fusion sorting identifier.

6. The data message out-of-order processing method according to claim 2, characterized in that, The data message out-of-order processing method further includes: Perform integrity and order checks on the corrected message queue; After the verification is successful, the corrected message queue is output; After a verification failure, an error log is output, recording the queue information of the message queue.

7. A data message out-of-order processing device, characterized in that, The data message out-of-order processing device includes: The acquisition module is used to acquire binary log files from the target database; The extraction module is used to extract at least one core identifier corresponding to each data message in the binary log file obtained by the acquisition module; the core identifier corresponding to the data message includes at least one of the following: commit sequence number (CSN), transaction identifier, and log track sequence number; The fusion module is used to obtain a fusion sorting identifier corresponding to each data message based on at least one core identifier corresponding to each data message extracted by the extraction module. The fusion sorting identifier is used to characterize the actual execution order of the data messages. The sorting module is used to sort the data messages according to the receiving order of each data message in the target database to obtain a message queue; The sorting module is further configured to temporarily sort all data messages in the predetermined sorting window of the message queue according to the ascending order of the fusion sorting identifier to obtain a first sorting order, and compare the first sorting order with the receiving order of all data messages in the predetermined sorting window in the target database to obtain a comparison result. The processing module is further configured to perform message processing on the data message based on the comparison result obtained by the sorting module.

8. The data message out-of-order processing apparatus according to claim 7, characterized in that, The processing module is specifically used for: If the comparison result indicates that the first sorting order is inconsistent with the receiving order of all data messages within the predetermined sorting window in the target database, the sorting of data messages in the message queue is corrected, and message processing is performed based on the corrected message queue; or, If the comparison result indicates that the first sorting order is consistent with the receiving order of all data messages in the target database within the predetermined sorting window, message processing is performed based on the message queue.

9. The data message out-of-order processing apparatus according to claim 8, characterized in that, The data message out-of-order processing device further includes: a correction module; The correction module is used to compare the CSN and transaction identifier of the two data messages if the difference between the fusion sorting identifiers corresponding to the two data messages is less than a preset threshold when the comparison result indicates that the first sorting order is inconsistent with the receiving order of all data messages in the predetermined sorting window in the target database. If the transaction commit order indicated by the CSN of the two data messages is inconsistent with the sorting order of the merge sorting identifiers of the two data messages, or if the transactions corresponding to the transaction identifiers of the two data messages have nested or dependent relationships, then the sorting of the data messages in the message queue shall be corrected.

10. The data message out-of-order processing apparatus according to claim 8, characterized in that, The data message out-of-order processing device further includes: a correction module; The correction module is used to sort the data messages in the message queue in ascending order according to the fusion sorting identifier corresponding to each data message; The data messages in the message queue are then sorted a second time according to the ascending order of the CSN of each data message; If multiple data messages in the message queue correspond to the same transaction identifier, the data messages in the message queue after the second sort are sorted a third time according to the ascending order of the log trajectory sequence number of each data message to obtain the corrected message queue.

11. The data message out-of-order processing apparatus according to claim 7, characterized in that, The fusion module is specifically used for: Based on at least one core identifier and a first formula corresponding to each data message, calculate the fusion sorting identifier corresponding to each data message; The first formula is: ; Where F is the fusion sorting identifier. This is the log track sequence number. The integer conversion value for the transaction identifier. The integer conversion value of CSN. This represents the weighting coefficient of SCN in the fusion sorting identifier.

12. The data message out-of-order processing apparatus according to claim 8, characterized in that, The data message out-of-order processing device further includes: a verification module; The verification module is used to perform integrity and order verification on the corrected message queue; and output the corrected message queue after the verification passes; and output an error log to record the queue information of the message queue after the verification fails.

13. An electronic device, characterized in that, It includes a processor and a memory, the memory storing a program or instructions that can run on the processor, the program or instructions being executed by the processor to implement the data message out-of-order processing method as described in any one of claims 1-6.

14. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions, which, when executed by a computer, implement the data message out-of-order processing method as described in any one of claims 1-6.

15. A computer program product, characterized in that, The computer program product is stored in a storage medium, and when the computer program product is executed by a computer, it implements the data message out-of-order processing method as described in any one of claims 1-6.