Database Backup Method, Apparatus, and Storage Medium

By adopting the TCC transaction processing mechanism and log message system in the TiKV database system, real-time replication and backup of the KV database is achieved, solving the problem that existing systems cannot copy data in real time, and improving the availability and reliability of the data.

CN114443621BActive Publication Date: 2025-06-13JD DIGITS HAIYI INFORMATION TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210111412.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-29
Publication Date
2025-06-13
Estimated Expiration
2042-01-29

AI Technical Summary

Technical Problem

The existing TiKV database system does not implement the binlog function and cannot copy data to the backup system in real time, resulting in the inability to switch to the backup cluster when the cluster crashes, affecting the availability and reliability of the data.

Method used

The TCC transaction processing mechanism is adopted to generate KV record modification messages, and save and maintain the message status in the log message system to realize real-time copying and backup of the KV database.

Benefits of technology

By implementing the binlog function, it can switch to the backup KV database when the main KV database fails, improving the availability and reliability of data and improving the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114443621B_ABST
    Figure CN114443621B_ABST
Patent Text Reader

Abstract

The present disclosure provides a database backup method, apparatus, and storage medium. The method includes: converting a KV record modification request into a KV record operation instruction and sending it to the primary KV database so that the primary KV database executes the KV record operation instruction; generating a KV record modification message corresponding to the KV record modification request; wherein the KV record modification message includes: modified version information; based on the TCC transaction processing mechanism and the execution result of the KV record operation instruction, saving and maintaining the status of the KV record modification message in the log message system; performing data backup processing in the standby KV database according to the KV record modification message in the log message system. The method, apparatus, and storage medium of the present disclosure use the TCC transaction processing mechanism to implement the binlog function for the KV database, can perform real-time replication of the KV database, improve the availability and reliability of data, and improve the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of databases, and in particular, to a database backup method, apparatus, and storage medium. Background Art

[0002] A KV (Key-Value) database system usually consists of multiple nodes, and each piece of data in the KV database system is usually written as multiple copies to different multiple disks. Binlog refers to a log similar to the replication log from MySQL Master to MySQL Slave. Currently, most KV database systems, such as the TiKV database system, etc., do not implement binlog and cannot be deployed in a master-slave manner to replicate data from the master system to the slave system through binlog. For example, the TiKV database system does not have an effective mechanism to replicate data to another backup system in real time. Therefore, during the use of the TiKV database system, when a TiKV cluster crashes, it is impossible to switch to another independent backup TiKV cluster, and the data newly added after the last scan cannot be synchronized. Therefore, for a KV database system without implementing binlog, a database backup technical solution needs to be provided. Summary of the Invention

[0003] In view of this, a technical problem to be solved by the present invention is to provide a database backup method, apparatus, and storage medium.

[0004] According to a first aspect of the present disclosure, there is provided a database backup method, including: receiving a KV record modification request for modifying a KV record by an application; converting the KV record modification request into a KV record operation instruction and sending it to a primary KV database, so that the primary KV database executes the KV record operation instruction; generating modification version information corresponding to the KV record modification request based on the K value of the KV record; generating a KV record modification message corresponding to the KV record modification request; where the KV record modification message includes: modification version information; saving and maintaining the state of the KV record modification message in a log message system based on the TCC transaction processing mechanism and the execution result of the KV record operation instruction; performing data backup processing in a standby KV database according to the KV record modification message in the log message system.

[0005] Optionally, based on the execution result of the TCC transaction processing mechanism and the KV record operation instruction, saving and maintaining the status of the KV record modification message in the log message system includes: sending the KV record modification message to the log message system based on the try method of the TCC transaction processing mechanism; in the state where the execution result is successful, sending a confirmation message corresponding to the KV record modification message to the log message system based on the confim method of the TCC transaction processing mechanism to set the status of the KV record modification message to valid; in the state where the execution result is failed, sending a cancellation message corresponding to the KV record modification message to the log message system based on the cancle method of the TCC transaction processing mechanism to set the status of the KV record modification message to invalid.

[0006] Optionally, generating a feature value based on the K value; determining a corresponding partition in the log message system according to the feature value; wherein, sending the KV record modification message, the confirmation message and the cancellation message to the partition.

[0007] Optionally, setting a log message backup system corresponding to the log message system for sending the KV record modification message, the confirmation message and the cancellation message to the log message backup system after determining that the log message system fails.

[0008] Optionally, the data backup processing in the standby KV database according to the KV record modification message in the log message system includes: obtaining the KV record modification message from the log message system; if a confirmation message or a cancellation message corresponding to the KV record modification message can be obtained in the log message system, performing data backup processing in the standby KV database based on the KV record modification message.

[0009] Optionally, the data backup processing in the standby KV database according to the KV record modification message in the log message system includes: if a confirmation message or a cancellation message corresponding to the KV record modification message cannot be obtained in the log message system, querying the corresponding KV record in the primary KV database based on the KV record modification message; if the corresponding KV record can be obtained, performing data backup processing in the standby KV database based on the KV record modification message.

[0010] Optionally, if it is determined that the same KEY value has been modified multiple times, data garbage collection processing is performed based on the modification version information corresponding to this KEY value.

[0011] According to a second aspect of the present disclosure, there is provided a database backup device, including: a modification request receiving module, configured to receive a KV record modification request for modifying a KV record by an application; a modification request processing module, configured to convert the KV record modification request into a KV record operation instruction and send it to a primary KV database, so that the primary KV database executes the KV record operation instruction; a modified version generation module, configured to generate modified version information corresponding to the KV record modification request based on the K value of the KV record; a modification message generation module, configured to generate a KV record modification message corresponding to the KV record modification request; wherein, the KV record modification message includes: modified version information; a modification message processing module, configured to save and maintain the state of the KV record modification message in a log message system based on a TCC transaction processing mechanism and an execution result of the KV record operation instruction; a data backup processing module, configured to perform data backup processing in a standby KV database according to the KV record modification message in the log message system.

[0012] Optionally, the modification message processing module includes: a message sending unit, configured to send the KV record modification message to the log message system based on a try method of the TCC transaction processing mechanism; a state processing unit, configured to, in a state where the execution result is successful, send a confirmation message corresponding to the KV record modification message to the log message system based on a confirm method of the TCC transaction processing mechanism, so as to set the state of the KV record modification message to valid; in a state where the execution result is failed, send a cancellation message corresponding to the KV record modification message to the log message system based on a cancel method of the TCC transaction processing mechanism, so as to set the state of the KV record modification message to invalid.

[0013] Optionally, the modification message processing module includes: a partition determination unit, configured to generate a feature value based on the K value; determine a corresponding partition in the log message system according to the feature value; the message sending unit, configured to send the KV record modification message to the partition; the state processing unit, configured to send the confirmation message and the cancellation message to the partition.

[0014] Optionally, the modification message processing module includes: a message backup unit, configured to set a log message backup system corresponding to the log message system, so as to send the KV record modification message, the confirmation message and the cancellation message to the log message backup system after determining that the log message system fails.

[0015] Optionally, the data backup processing module is configured to obtain the KV record modification message from the log message system; if an acknowledgement message or a cancellation message corresponding to the KV record modification message can be obtained in the log message system, data backup processing is performed in the standby KV database based on the KV record modification message.

[0016] Optionally, the data backup processing module is further configured to, if an acknowledgement message or a cancellation message corresponding to the KV record modification message cannot be obtained in the log message system, query the corresponding KV record in the primary KV database based on the KV record modification message; if the corresponding KV record can be obtained, data backup processing is performed in the standby KV database based on the KV record modification message.

[0017] Optionally, the modification request processing module is configured to, if it is determined that the same KEY value has been modified multiple times, perform data garbage collection processing based on the modification version information corresponding to the KEY value.

[0018] According to a third aspect of the present disclosure, there is provided a database backup apparatus, including: a memory; and a processor coupled to the memory, the processor being configured to execute the method as described above based on instructions stored in the memory.

[0019] According to a fourth aspect of the present disclosure, there is provided a computer-readable storage medium storing computer instructions, the instructions being executed by a processor to perform the method as described above.

[0020] The database backup method, apparatus, and storage medium of the present disclosure use the TCC transaction processing mechanism to implement the binlog function for the KV database, and can perform data replication based on the binlog function, can perform real-time replication of the KV database, and can switch to the backup KV database when the primary KV database fails, improving the availability and reliability of the data and enhancing the user experience. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the following will briefly introduce the accompanying drawings required for the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only some embodiments of the present disclosure, and those of ordinary skill in the art can also obtain other drawings without creative efforts based on these drawings.

[0022] Figure 1 FIG. is a flowchart showing an embodiment of the database backup method according to the present disclosure;

[0023] Figure 2Schematic flowchart of maintaining the status of the KV record modification message in an embodiment of the database backup method according to the present disclosure;

[0024] Figure 3 Schematic flowchart of data backup processing in the standby KV database in an embodiment of the database backup method according to the present disclosure;

[0025] Figure 4 Schematic diagram of modules in an embodiment of the database backup apparatus according to the present disclosure;

[0026] Figure 5 Schematic diagram of the message modification processing module in an embodiment of the database backup apparatus according to the present disclosure;

[0027] Figure 6 Schematic diagram of modules in another embodiment of the database backup apparatus according to the present disclosure. Detailed implementation manners

[0028] The present disclosure will be described more comprehensively below with reference to the accompanying drawings, in which exemplary embodiments of the present disclosure are illustrated. The technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only a part of the embodiments of the present disclosure, rather than all of the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present disclosure without creative efforts shall fall within the scope of protection of the present disclosure.

[0029] Figure 1 Schematic flowchart of an embodiment of the database backup method according to the present disclosure, as Figure 1 shown:

[0030] Step 101, receive a KV record modification request for modifying a KV record by an application.

[0031] In one embodiment, the application can be various APPs, such as an e-commerce APP, a video APP, etc. The KV database system is a distributed KV database system, that is, a distributed Key Value database system. The KV database system can be an existing TiKV database system, etc. The KV record is one or more records stored in the main KV database system. The KV record modification request carries the K value of the KV record and the operation information for the value.

[0032] Step 102, convert the KV record modification request into a KV record operation instruction and send it to the main KV database so that the main KV database executes the KV record operation instruction.

[0033] Step 103: Generate modified version information corresponding to the KV record modification request based on the K value of the KV record.

[0034] In one embodiment, generate version information based on the current time when the KV record modification request is received. Add the version information to the K value of the KV record to generate modified version information corresponding to the KV record modification request.

[0035] Step 104: Generate a KV record modification message corresponding to the KV record modification request, where the KV record modification message includes the modified version information.

[0036] Step 105: Based on the TCC transaction processing mechanism and the execution result of the KV record operation instruction, save and maintain the status of the KV record modification message in the log message system.

[0037] In one embodiment, start the KV APP. The KV APP is an application for accessing the distributed KV database system. Receive a KV record modification request sent by an external application through the KV APP. The KV record modification request includes an APP Put (set a new value for the KV record) or an APP Delete (delete the KV record) request, etc. The modified version information includes the K value and the version information. Obtain the current time to generate the version information, obtain the K value of the KV record, and add this K value to the version information to generate the modified version information.

[0038] The KV record modification message includes a KV Put (set a new value for the KV record) request message and a KV Delete (delete the KV record) request message, etc. Generate a KV Put request message based on the APP Put request. The KV Put request message contains the information carried by the APP Put request, including the Key and the uniquely ordered version information (version information generated based on the current time), etc.; generate a KV Delete request message based on the APP Delete request. The KV Delete request message contains the information carried by the APP Delete request, including the Key and the uniquely ordered version information, etc.

[0039] APP Put and APP Delete refer to Put and Delete requests for the KV APP from outside the KV APP. KV Put and KV Delete can be Put and Delete requests for a third-party distributed KV system with internally uniquely ordered multi-versions in the Key generated by the KV APP. The third-party distributed KV system includes distributed KV systems without binlog implementation such as TiKV, Cassandra, and HBase, etc.

[0040] Step 106: Modify the message according to the KV record in the log message system and perform data backup processing in the standby KV database.

[0041] TCC refers to the consistency transaction model of the Try-Confirm-Cancel mode. The TCC transaction processing mechanism refers to the existing consistency transaction processing mechanism of the Try-Confirm-Cancel mode. Using the TCC (Try-Confirm-Cancel) transaction processing mechanism, the binlog function is implemented for the distributed KV database, and data replication can be performed based on the binlog function, which can solve the requirement for real-time replication of the KV database. And when the KV database fails, it can be switched to another KV database replicated through the binlog function.

[0042] Figure 2 It is a schematic flow diagram of maintaining the status of the KV record modification message in an embodiment of the database backup method according to the present disclosure, as Figure 2 shown:

[0043] Step 201: Based on the try method of the TCC transaction processing mechanism, send a KV record modification message to the log message system.

[0044] Step 202: Determine whether the execution result is successful. If so, proceed to Step 203; if not, proceed to Step 204.

[0045] Step 203: In the state where the execution result is successful, based on the confim method of the TCC transaction processing mechanism, send a confirmation message corresponding to the KV record modification message to the log message system to set the status of the KV record modification message to valid. The confirmation message carries information such as the modified version information.

[0046] Step 204: In the state where the execution result is failed, based on the cancle method of the TCC transaction processing mechanism, send a cancellation message corresponding to the KV record modification message to the log message system to set the status of the KV record modification message to invalid. The cancellation message carries information such as the modified version information.

[0047] Generate a feature value based on the K value, determine the corresponding partition in the log message system according to the feature value. Send the KV record modification message, confirmation message, and cancellation message to the partition. Set up a log message backup system corresponding to the log message system to send the KV record modification message, confirmation message, and cancellation message to the log message backup system after determining that the log message system fails.

[0048] In one embodiment, the log message system can be binlog kafka, etc. Binlog kafka is a log message system implemented using an existing Kafka queue and serves as a mechanism for implementing binlog. KV Put request messages and KV Put request messages, etc. are Kafka messages, and KV APP sends KV Put request messages and KV Put request messages, etc. to binlog kafka.

[0049] The K value in the KV Put request message and the KV Put request message is obtained through KV APP, and the corresponding partition is determined in binlog kafka based on the hash value corresponding to the K value. A Kafka queue can be divided into multiple partitions, and each partition can be processed concurrently. The KV Put request message and the KV Put request message, etc. are sent by KV APP to the specified partition in binlog kafka to facilitate subsequent message consumption. This stage is the Try stage in the TCC mechanism. Sending messages according to the partition ensures that the try and the corresponding confirm / cancel messages will be in the same partition, making it easy to pair the try and the confirm / cancel when reading Kafka messages (KV Put request messages and KV Put request messages).

[0050] Since the KV Put request message and the KV Put request message carry unique and ordered version information, the KV Put request message and the KV Put request message sent to binlog kafka do not need to ensure strict order. When processing the KV Put request message and the KV Put request message later, the messages can be sorted according to the version information (in the order of time before and after), and then valid data can be obtained based on the sorted results.

[0051] A backup binlog kafka corresponding to the main binlog kafka is set. After the message sending fails, it is determined that the main binlog kafka fails, and KV record modification messages, confirmation messages, cancellation messages, etc. are sent to the backup binlog kafka.

[0052] A confirm field corresponding to the KV record modification message can be set in binlog kafka (or a corresponding file can also be set to record the execution result). In the state where the execution result is successful, based on the confirm method of the TCC transaction processing mechanism, a confirmation message corresponding to the KV record modification message is sent to binlog kafka, and the confirm field is written as 1 (indicating the Confirm stage in TCC).

[0053] In the state where the execution result is a failure, based on the cancel method of the TCC transaction processing mechanism, send a cancellation message corresponding to the KV record modification message to binlogkafka, and write 0 to the confirm field (indicating the Cancel phase in TCC).

[0054] Figure 3 It is a schematic flowchart of data backup processing in the standby KV database in an embodiment of the database backup method according to the present disclosure, as Figure 3 shown:

[0055] Step 301, obtain the KV record modification message from the log message system.

[0056] Step 302, determine whether it is possible to obtain a confirmation message or a cancellation message corresponding to the KV record modification message in the log message system. If so, go to step 303; if not, go to step 304.

[0057] Step 303, if it is possible to obtain a confirmation message or a cancellation message corresponding to the KV record modification message in the log message system, perform data backup processing in the standby KV database based on the KV record modification message. For example, perform operations such as modifying, deleting, and inserting corresponding data in the standby database based on the KV record modification message.

[0058] Step 304, if it is not possible to obtain a confirmation message or a cancellation message corresponding to the KV record modification message in the log message system, query the corresponding KV record in the primary KV database based on the KV record modification message; if the corresponding KV record can be obtained, perform data backup processing in the standby KV database based on the KV record modification message. For example, query the corresponding KV record in the primary KV database and perform operations such as modifying, deleting, and inserting corresponding data in the standby database.

[0059] In one embodiment, start the Restore Service. The Restore Service is a recovery service used to consume the messages in binlog kafka and write the data into the standby KV database according to these messages. The Restore Service consumes (obtains) the Try messages in binlog kafka, searches for the confirmation or cancellation records (messages) that match the Try messages, and obtains the corresponding confirm flag.

[0060] If no matching confirmation or cancellation record is found in binlog kafka, the search operation is performed every 5 seconds, and the maximum number of search operations can be 10 times, etc. If a corresponding confirmation or cancellation record is found in binlog kafka, then set confirm = 1. If no record is finally found in binlog kafka (possibly because the KV APP crashed after sending the Try message), then perform a reverse lookup in the main KV database.

[0061] If a record is found in the main KV database, set confirm = 1 for Put and confirm = 0 for Delete; if no record is still found in the main KV database, set confirm = 0 for Put and confirm = 1 for KVDelete, and data backup processing can be performed in the standby KV database based on the KV record modification message. If confirm = 1, perform KV Put or KV Delete in the standby KV database.

[0062] In one embodiment, if it is determined that the same KEY value has been modified multiple times, data garbage collection processing is performed based on the modification version information corresponding to this KEY value. Start the MvccGcService, which is used to consume multi-version GC messages and perform multi-version recycling on the given key. If multi-version recycling is required, the KV APP sends a multi-version GC (garbage collection) message to MvccGcKafka, obtains the version information in the modification version information, determines the execution time, and can garbage process the KV record modification message and the corresponding confirmation and cancellation messages whose execution time is before the preset time.

[0063] In one embodiment, as Figure 4 shown, the present disclosure provides a database backup device 40, including a modification request receiving module 41, a modification request processing module 42, a modification version generation module 43, a modification message generation module 44, a modification message processing module 45, and a data backup processing module 46.

[0064] The modification request receiving module 41 receives a KV record modification request for modifying the KV record by the application. The modification request processing module 42 converts the KV record modification request into a KV record operation instruction and sends it to the main KV database so that the main KV database executes the KV record operation instruction. The modification version generation module 43 generates modification version information corresponding to the KV record modification request based on the K value of the KV record.

[0065] The modification message generation module 44 generates a KV record modification message corresponding to the KV record modification request; wherein, the KV record modification message includes modification version information. The modification message processing module 45 saves and maintains the status of the KV record modification message in the log message system based on the TCC transaction processing mechanism and the execution result of the KV record operation instruction. The data backup processing module 46 performs data backup processing in the standby KV database according to the KV record modification message in the log message system. If the modification request processing module 42 determines that multiple modifications have been made to the same KEY value, it performs data garbage collection processing based on the modification version information corresponding to this KEY value.

[0066] In one embodiment, as Figure 5 shown, the modification message processing module 45 includes: a message sending unit 451, a status processing unit 452, a partition determination unit 453, and a message backup unit 454. The message sending unit 451 sends the KV record modification message to the log message system in the try method of the TCC transaction processing mechanism.

[0067] In the state where the execution result is successful, the status processing unit 452 sends a confirmation message corresponding to the KV record modification message to the log message system based on the confim method of the TCC transaction processing mechanism, so as to set the status of the KV record modification message to valid.

[0068] In the state where the execution result is failed, the status processing unit 452 sends a cancellation message corresponding to the KV record modification message to the log message system based on the cancle method of the TCC transaction processing mechanism, so as to set the status of the KV record modification message to invalid.

[0069] The partition determination unit 453 generates a feature value based on the K value, and determines the corresponding partition in the log message system according to the feature value. The message sending unit 451 sends the KV record modification message to the partition. The status processing unit 452 sends the confirmation message and the cancellation message to the partition.

[0070] The message backup unit 454 sets a log message backup system corresponding to the log message system, so as to send the KV record modification message, the confirmation message, and the cancellation message to the log message backup system after determining that the log message system fails.

[0071] In one embodiment, the data backup processing module 46 obtains the KV record modification message from the log message system. If the data backup processing module 46 can obtain the confirmation message or the cancellation message corresponding to the KV record modification message in the log message system, the data backup processing module 46 performs data backup processing in the standby KV database based on the KV record modification message.

[0072] If the data backup processing module 46 cannot obtain the confirmation message or cancellation message corresponding to the KV record modification message in the log message system, the data backup processing module 46 queries the corresponding KV record in the primary KV database based on the KV record modification message. If the data backup processing module 46 can obtain the corresponding KV record, the data backup processing module 46 performs data backup processing in the standby KV database based on the KV record modification message.

[0073] Figure 6 Schematic diagram of a module according to another embodiment of the database backup device according to the present disclosure. As Figure 6 shown, the device may include a memory 61, a processor 62, a communication interface 63, and a bus 64. The memory 61 is used to store instructions, and the processor 62 is coupled to the memory 61. The processor 62 is configured to execute the database backup method described above based on the instructions stored in the memory 61.

[0074] The memory 61 may be a high-speed RAM memory, a non-volatile memory, etc. The memory 61 may also be a memory array. The memory 61 may also be partitioned, and the blocks may be combined into virtual volumes according to certain rules. The processor 62 may be a central processing unit CPU, or an application specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the database backup method of the present disclosure.

[0075] In one embodiment, the present disclosure provides a computer-readable storage medium storing computer instructions that, when executed by a processor, implement the database backup method in any of the above embodiments.

[0076] The database backup method, device, and storage medium in the above embodiments use the TCC transaction processing mechanism to implement the binlog function for the KV database, and can replicate data based on the binlog function, can perform real-time replication of the KV database, and can switch to the backup KV database when the primary KV database fails, improving the availability and reliability of the data and the user experience.

[0077] The methods and systems of the present disclosure may be implemented in many ways. For example, the methods and systems of the present disclosure may be implemented by software, hardware, firmware, or any combination of software, hardware, and firmware. The above order of steps for the methods is for illustrative purposes only, and the steps of the methods of the present disclosure are not limited to the specific order described above, unless otherwise specifically stated. In addition, in some embodiments, the present disclosure may also be implemented as a program recorded in a recording medium, and these programs include machine-readable instructions for implementing the methods according to the present disclosure. Thus, the present disclosure also covers a recording medium storing a program for executing the methods according to the present disclosure.

[0078] The description of the present disclosure has been presented for purposes of illustration and description, and is not intended to be exhaustive or to limit the present disclosure to the form disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art. The embodiments were chosen and described in order to best explain the principles of the present disclosure and its practical application, and to enable others of ordinary skill in the art to understand the present disclosure and design various embodiments with various modifications suited to particular purposes.

Claims

1. A database backup method, including: receiving a KV record modification request for modifying a KV record by an application; converting the KV record modification request into a KV record operation instruction and sending it to a primary KV database, so that the primary KV database executes the KV record operation instruction; generating modification version information corresponding to the KV record modification request based on the K value of the KV record; generating a KV record modification message corresponding to the KV record modification request; wherein, the KV record modification message includes: modification version information; saving and maintaining the status of the KV record modification message in a log message system based on a TCC transaction processing mechanism and the execution result of the KV record operation instruction; performing data backup processing in a standby KV database according to the KV record modification message in the log message system.

2. The method according to claim 1, wherein saving and maintaining the status of the KV record modification message in the log message system based on the TCC transaction processing mechanism and the execution result of the KV record operation instruction includes: sending the KV record modification message to the log message system based on the try method of the TCC transaction processing mechanism; in a state where the execution result is successful, sending a confirmation message corresponding to the KV record modification message to the log message system based on the confim method of the TCC transaction processing mechanism, so as to set the status of the KV record modification message to valid; in a state where the execution result is failed, sending a cancellation message corresponding to the KV record modification message to the log message system based on the cancle method of the TCC transaction processing mechanism, so as to set the status of the KV record modification message to invalid.

3. The method according to claim 2, further including: generating a feature value based on the K value; determining a corresponding partition in the log message system according to the feature value; wherein, sending the KV record modification message, the confirmation message and the cancellation message to the partition.

4. The method according to claim 2, further including: setting up a log message backup system corresponding to the log message system, so as to send the KV record modification message, the confirmation message and the cancellation message to the log message backup system after determining that the log message system fails.

5. The method according to claim 2, wherein performing data backup processing in a standby KV database according to the KV record modification message in the log message system includes: obtaining the KV record modification message from the log message system; if a confirmation message or a cancellation message corresponding to the KV record modification message can be obtained in the log message system, performing data backup processing in the standby KV database based on the KV record modification message.

6. The method according to claim 2, wherein performing data backup processing in a standby KV database according to the KV record modification message in the log message system includes: If an acknowledgement message or cancellation message corresponding to the KV record modification message cannot be obtained in the log message system, query the corresponding KV record in the primary KV database based on the KV record modification message; If the corresponding KV record can be obtained, perform data backup processing in the standby KV database based on the KV record modification message.

7. The method according to claim 1, further comprising: If it is determined that the same KEY value has been modified multiple times, perform data garbage collection processing based on the modification version information corresponding to this KEY value.

8. A database backup device, comprising: A modification request receiving module, configured to receive a KV record modification request for modifying a KV record by an application; A modification request processing module, configured to convert the KV record modification request into a KV record operation instruction and send it to the primary KV database, so that the primary KV database executes the KV record operation instruction; A modification version generation module, configured to generate modification version information corresponding to the KV record modification request based on the K value of the KV record; A modification message generation module, configured to generate a KV record modification message corresponding to the KV record modification request; wherein, the KV record modification message includes: modification version information; A modification message processing module, configured to save and maintain the status of the KV record modification message in the log message system based on the TCC transaction processing mechanism and the execution result of the KV record operation instruction; A data backup processing module, configured to perform data backup processing in the standby KV database according to the KV record modification message in the log message system.

9. A database backup device, comprising: A memory; And a processor coupled to the memory, the processor being configured to execute the method according to any one of claims 1 to 7 based on instructions stored in the memory.

10. A computer-readable storage medium, the computer-readable storage medium stores computer instructions, and the instructions are executed by a processor to perform the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and device of utilizing KV database to realize data uniformity

    CN106777321A

  • Distributed transaction processing method and device, medium and equipment

    CN112925614A