Data backup and storage method and device, computer device and storage medium

CN115495285BActive Publication Date: 2026-09-18SHANGHAI PUDONG DEVELOPMENT BANK
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202211213307.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-30
Publication Date
2026-09-18
Estimated Expiration
2042-09-30

AI Technical Summary

Technical Problem

[0004]然而,当业务出现恢复一致性的需求时,需要通过各个维度的数据核对才能完成一致性的恢复,效率较低

Benefits of technology

[0041] The aforementioned data backup method, apparatus, computer equipment, storage medium, and computer program product, after data storage, first obtain the target backup time, and based on the target backup time, query multiple transaction information corresponding to the target backup time; wherein, the transaction information includes transaction status. Then, for each transaction status, when the transaction status is normal, obtain the log file corresponding to the transaction information, query the log file based on the modification time, and obtain multiple transactions to be recovered. Further, based on the multiple transactions to be recovered, query multiple log file storage devices to obtain the transaction time order of the multiple transactions to be recovered in each log file storage device; the transaction time order is in the same direction as the time flow. Finally, for each log file storage device, based on the transaction time order, perform data backup one by one in reverse order of the transaction order. This application, by querying multiple log file storage devices to obtain multiple transactions to be processed before the target backup time in each log file storage device, can support multiple databases to perform consistent data backup simultaneously, and can improve the data's resilience to failure risks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115495285B_ABST
    Figure CN115495285B_ABST
Patent Text Reader

Abstract

The application relates to a data backup and storage method and device, computer equipment, a storage medium and a computer program product. The method comprises the following steps: after data storage, a target backup time is acquired, a plurality of transaction information corresponding to the target backup time is queried based on the target backup time, wherein the transaction information comprises a transaction state; when the transaction state is normal, a log file corresponding to the transaction information is acquired, the log file is queried based on a modification time, and a plurality of to-be-restored transactions are obtained; a plurality of log file storage devices are queried based on the plurality of to-be-restored transactions, and the transaction time sequence of the plurality of to-be-restored transactions in each log file storage device is obtained; and for each log file storage device, data backup is sequentially performed in the reverse order of the transaction sequence based on the transaction time sequence. The method can support the consistency backup of a plurality of databases at the same time, and can improve the fault risk resistance of data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of database technology, and in particular to a data backup and storage method, apparatus, computer equipment, storage medium and computer program product. Background Technology

[0002] With the rapid development of the Internet, data backup tasks have become more time-consuming due to the massive increase in data volume, leading to the emergence of distributed transactions.

[0003] In traditional distributed databases, transactions and queries are executed across multiple nodes. Therefore, traditional distributed databases typically back up the data on each storage device separately.

[0004] However, when a business needs to restore consistency, it requires data verification across various dimensions to complete the restoration, which is inefficient. Summary of the Invention

[0005] Therefore, it is necessary to provide a data backup and storage method, apparatus, computer equipment, computer-readable storage medium, and computer program product that can support simultaneous consistent backup of multiple databases and improve the data's resilience to failure risks, in order to address the aforementioned technical problems.

[0006] Firstly, this application provides a data backup method. The method includes:

[0007] After data storage, the target backup time is obtained, and based on the target backup time, multiple transaction information corresponding to the target backup time is queried; the transaction information includes the transaction status.

[0008] For each transaction status, when the transaction status is normal, obtain the log file corresponding to the transaction information, query the log file based on the modification time, and obtain multiple transactions to be recovered;

[0009] Based on multiple transactions to be recovered, multiple log file storage devices are queried to obtain the transaction time order of multiple transactions to be recovered in each log file storage device; the transaction time order is in the same direction as the time flow.

[0010] For each log file storage device, data backups are performed one by one in reverse order of transaction time sequence.

[0011] In one embodiment, based on the target backup time, multiple transaction information corresponding to the target backup time are queried, including:

[0012] Based on the target backup time, determine the query time period; wherein the target backup time is within the range of the query time period, and the time corresponding to the upper limit of the query time period range is later than the target backup time;

[0013] Based on the query time period, query multiple transaction information corresponding to the target backup time.

[0014] In one embodiment, the log file is queried based on the modification time to obtain multiple transactions to be recovered, including:

[0015] Based on the modification time, the log files are queried in the same direction as the time flow. When the number of transactions in the first branch is not equal to the number of log files, the transaction and the other unqueried transactions are treated as transactions to be recovered.

[0016] In one embodiment, multiple log file storage devices are queried based on multiple transactions to be recovered to obtain the transaction time order of multiple transactions to be recovered in each log file storage device, including:

[0017] Obtain the storage locations of multiple transactions to be recovered, and determine the list of transactions to be recovered for each log file storage device;

[0018] For each log file storage device, based on the list of transactions to be recovered, query the storage time of multiple transactions to be recovered;

[0019] The storage times of multiple transactions to be recovered are sorted in the same direction as the time flow, and the sorting result is used as the transaction time order of the multiple transactions to be recovered.

[0020] In one embodiment, the method further includes:

[0021] When a transaction is in an abnormal state, the transaction is rolled back based on the log file.

[0022] Secondly, this application also provides a data storage method. The method includes:

[0023] When entering the data storage state, obtain the transaction request;

[0024] Based on the transaction request, the transaction information storage location and the log file storage device are determined; wherein, the transaction information storage location stores the transaction information corresponding to the transaction request, and the log file storage device stores the log file corresponding to the transaction request.

[0025] The data storage method is determined based on the log file storage device, the data is stored based on the storage method, and the transaction information in the transaction information storage location is updated.

[0026] In one embodiment, updating the transaction information in the transaction information storage location includes:

[0027] Retrieve multiple log files stored on the log file storage device;

[0028] For each log file, if no exception occurs in the log file, obtain the transaction commit request from the log file storage device, generate the corresponding sequence based on the task commit request, and add the sequence to the transaction information corresponding to the transaction request; if an exception occurs in the log file, or the transaction status corresponding to the transaction information is abnormal, an error is reported.

[0029] Thirdly, this application also provides a data backup device. The device includes:

[0030] The transaction information query module is used to obtain the target backup time after data storage, and query multiple transaction information corresponding to the target backup time based on the target backup time; the transaction information includes the transaction status.

[0031] The module for determining transactions to be recovered is used to obtain the log file corresponding to the transaction information when the transaction status is normal, and query the log file based on the modification time to obtain multiple transactions to be recovered.

[0032] The transaction time sequence determination module is used to query multiple log file storage devices based on multiple transactions to be recovered, and obtain the transaction time sequence of multiple transactions to be recovered in each log file storage device; the transaction time sequence is in the same direction as the time flow.

[0033] The data backup module is used to back up data one by one for each log file storage device, based on the transaction time order and in reverse order of transaction sequence.

[0034] Fourthly, this application also provides a data storage device. The device includes:

[0035] The transaction request acquisition module is used to acquire transaction requests when entering the data storage state;

[0036] The storage location determination module is used to determine the transaction information storage location and the log file storage device based on the transaction request; wherein, the transaction information storage location stores the transaction information corresponding to the transaction request, and the log file storage device stores the log file corresponding to the transaction request;

[0037] The data storage module is used to determine the data storage method based on the log file storage device, store data based on the storage method, and update the transaction information in the transaction information storage location.

[0038] Fifthly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the steps of the method described in any of the above embodiments.

[0039] Sixthly, this application also provides a computer device readable storage medium. The computer device readable storage medium stores a computer program thereon, which, when executed by a processor, implements the steps of the method described in any of the above embodiments.

[0040] In a seventh aspect, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the steps of the method described in any of the above embodiments.

[0041] The aforementioned data backup method, apparatus, computer equipment, storage medium, and computer program product, after data storage, first obtain the target backup time, and based on the target backup time, query multiple transaction information corresponding to the target backup time; wherein, the transaction information includes transaction status. Then, for each transaction status, when the transaction status is normal, obtain the log file corresponding to the transaction information, query the log file based on the modification time, and obtain multiple transactions to be recovered. Further, based on the multiple transactions to be recovered, query multiple log file storage devices to obtain the transaction time order of the multiple transactions to be recovered in each log file storage device; the transaction time order is in the same direction as the time flow. Finally, for each log file storage device, based on the transaction time order, perform data backup one by one in reverse order of the transaction order. This application, by querying multiple log file storage devices to obtain multiple transactions to be processed before the target backup time in each log file storage device, can support multiple databases to perform consistent data backup simultaneously, and can improve the data's resilience to failure risks. Attached Figure Description

[0042] Figure 1 This is an application environment diagram of a data backup and storage method in one embodiment;

[0043] Figure 2 This is a flowchart illustrating a data backup method in one embodiment;

[0044] Figure 3 This is a schematic diagram of the data backup interaction process in one embodiment;

[0045] Figure 4 This is a flowchart illustrating a data storage method in one embodiment;

[0046] Figure 5 This is a flowchart illustrating the transaction commit interaction in one embodiment;

[0047] Figure 6 This is a structural block diagram of a data backup device in one embodiment;

[0048] Figure 7 This is a structural block diagram of a data storage device in one embodiment;

[0049] Figure 8 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0050] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0051] The data backup and storage method provided in this application embodiment can be applied to, for example... Figure 1 In the application environment shown, terminal 102 communicates with server 104 via a network. The data storage system stores the data that the analysis system needs to process. The data storage system can be integrated on a server, or it can be placed on a cloud or other network server. After data storage, firstly, server 104 can obtain the target backup time from terminal 102, and based on the target backup time, query multiple transaction information corresponding to the target backup time; the transaction information includes the transaction status. Then, for each transaction status, when the transaction status is normal, server 104 can obtain the log file (UNDOLOG) corresponding to the transaction information, query the log file based on the modification time, and obtain multiple transactions to be recovered. Then, server 104 can query multiple log file storage devices based on the multiple transactions to be recovered, obtaining the transaction time order of the multiple transactions to be recovered in each log file storage device; the transaction time order is in the same direction as the time flow. Finally, for each log file storage device, server 104 can perform data backup one by one in reverse order of transaction time order. Server 104 can be implemented using a standalone server or a server cluster composed of multiple servers.

[0052] The data backup and storage method provided in this application can be applied to a single-side implementation on a server or terminal device, or it can be applied to a system including a terminal device and a server, and implemented through the interaction between the terminal device and the server.

[0053] In one embodiment, such as Figure 2 As shown, a data backup method is provided, which can be applied to... Figure 1 The following steps are used as an example of the server side in the example, including steps 202 to 210.

[0054] Step 202: After data storage, obtain the target backup time, and based on the target backup time, query multiple transaction information corresponding to the target backup time; wherein, the transaction information includes the transaction status.

[0055] In this embodiment, data storage is achieved by managing multiple Resource Managers (RMs) through a Transaction Manager (TM). Using a two-phase commit method, information about distributed transactions is recorded in the Transaction Manager Database (TM DB), and UNDOLOG (log files) of business operation data is recorded in the Resource Manager Database (RM DB).

[0056] In this embodiment, the server can obtain the target backup time entered by the user on the terminal device, which is a moment.

[0057] In this embodiment, the server can determine the query time period based on the target backup time and obtain multiple transaction information within the query time period.

[0058] In this embodiment, transaction information can be stored in a transaction resource manager. The server can query the transaction resource manager in reverse order (in the opposite direction of the time flow of the storage time) based on the storage time of the transaction information in the transaction resource manager to obtain multiple transaction information within the query time period.

[0059] Step 204: For each transaction status, when the transaction status is normal, obtain the log file corresponding to the transaction information, query the log file based on the modification time, and obtain multiple transactions to be recovered.

[0060] In this embodiment, the transaction status may include, but is not limited to: normal and abnormal.

[0061] In this embodiment, abnormal transaction statuses may include, but are not limited to: NEW (new), ROLLBACKING (rolling back), ROLLBACKED (rollback completed), ROLLBACK_DIRTY (rollback exception), etc.

[0062] In this embodiment, the transaction status can include, but is not limited to, COMMITING and COMMITED. A COMMITED status indicates that the transaction data has been stored in the database (such as a log file storage device or a distributed transaction manager), while a COMMITING status indicates that the transaction data is being transferred to the database or is being stored but not yet completed.

[0063] In this embodiment, when the transaction status is normal, the server can obtain the log file corresponding to the transaction information and the latest modification time of the log file. Based on the latest modification time of the log file, multiple log files are queried in the same or opposite order as the time flow to obtain multiple transactions to be recovered.

[0064] Step 206: Query multiple log file storage devices based on multiple transactions to be recovered to obtain the transaction time order of multiple transactions to be recovered in each log file storage device; the transaction time order is in the same direction as the time flow.

[0065] In this embodiment, for each transaction to be recovered, the server can query the log file storage device corresponding to that transaction.

[0066] In this embodiment, after the server queries multiple log file storage devices based on multiple transactions to be recovered, it can obtain multiple transactions to be recovered corresponding to each log file storage device. Based on the transaction time of the multiple transactions to be recovered, the transaction time order of the multiple transactions to be recovered in each log file storage device can be obtained.

[0067] Step 208, as follows Figure 3 As shown, for each log file storage device, data backup is performed one by one in reverse order of transaction time sequence.

[0068] In this embodiment, for each log file storage device, the server queries the last transaction in the transaction time sequence of that log file storage device as the initial transaction.

[0069] In this embodiment, the server queries the transaction times of multiple transactions to be recovered in all log file storage devices based on the transaction time of the initial transaction. When there is a transaction to be recovered whose transaction time is later than that of the initial transaction, the transaction to be recovered whose transaction time is later than that of the initial transaction is taken as the initial transaction. The above steps are repeated until there are no transactions to be recovered in all log file storage devices whose transaction time is later than that of the initial transaction.

[0070] In this embodiment, when there are no transactions to be recovered in all log file storage devices whose transaction times are later than the initial transaction, the server performs data backup of the initial transaction.

[0071] In the aforementioned data backup method, after data storage, the target backup time is first obtained. Based on the target backup time, multiple transaction information corresponding to the target backup time is queried; the transaction information includes the transaction status. Then, for each transaction status, when the transaction status is normal, the log file corresponding to the transaction information is obtained. The log file is queried based on the modification time to obtain multiple transactions to be recovered. Further, based on the multiple transactions to be recovered, multiple log file storage devices are queried to obtain the transaction time order of the multiple transactions to be recovered in each log file storage device; the transaction time order is in the same direction as the time flow. Finally, for each log file storage device, data is backed up one by one in reverse order of transaction time order. This application, by querying multiple log file storage devices to obtain multiple transactions to be processed before the target backup time in each log file storage device, can support multiple databases to perform consistent data backup simultaneously, thereby improving the data's resilience to failure risks.

[0072] In some embodiments, querying multiple transaction information corresponding to a target backup time based on a target backup time may include: determining a query time period based on the target backup time; wherein the target backup time is within the range of the query time period, and the time corresponding to the upper limit endpoint of the query time period is later than the target backup time; and querying multiple transaction information corresponding to the target backup time based on the query time period.

[0073] In this embodiment, the server can obtain the target backup time and the target time difference input by the user on the terminal device. The target backup time is a moment, and the target time difference is a time length (e.g., 3 seconds, 1 minute 1 second, 0.2 seconds, etc.).

[0074] In this embodiment, the server can determine the query time period based on the target backup time and the target time difference. For example, when the target backup time is T2 and the target time difference is ΔT, the query time period is [T2-ΔT, T2+ΔT], where ΔT is a value not less than 0.

[0075] In this embodiment, the server can simultaneously query multiple transaction information from multiple databases (such as log file storage devices) within the aforementioned query time period. The transaction information from multiple databases within the aforementioned query time period is the transaction information corresponding to the target backup time.

[0076] In some embodiments, querying log files based on modification time to obtain multiple transactions to be recovered may include: querying log files based on modification time in the same direction as the time flow; when the number of transactions in the first branch is not equal to the number of log files, the transaction and the remaining unqueried transactions are taken as transactions to be recovered.

[0077] In this embodiment, each transaction can have multiple branch transactions, and each branch transaction corresponds to a log file.

[0078] In this embodiment, transaction information may include, but is not limited to: multiple branch transactions, the branch transaction time of each branch transaction, etc.

[0079] In this embodiment, transaction information may include, but is not limited to, modification time and branch modification time for each branch transaction. The modification time refers to the moment when the transaction begins storage or is successfully stored in the database, and the branch modification time of a branch transaction is the moment when the branch transaction begins storage or is successfully stored in the database.

[0080] In this embodiment, the modification time of each transaction is uniformly set to either the moment the transaction begins to be stored in the database or the moment the transaction is successfully stored in the database.

[0081] In this embodiment, the branch modification time of each branch transaction is uniformly set to either the moment when the branch transaction begins to be stored in the database or the moment when the branch transaction is successfully stored in the database.

[0082] In this embodiment, the modification time of a transaction and the branch modification time of a branch transaction can both be unified as the moment when the data is first stored in the database or as the moment when the data is successfully stored in the database.

[0083] In another embodiment, the modification time of a transaction may not be the same as the determination point of the branch modification time of a branch transaction (the moment when it begins to be stored in the database or is successfully stored in the database).

[0084] In this embodiment, the server sorts multiple transactions in ascending order (in the same direction as the time flow) based on their modification time. Furthermore, for each of the sorted transactions, the server can sort its multiple branch transactions in ascending order based on their branch modification time to obtain a query sort.

[0085] In this embodiment, the server queries multiple transactions according to the above query order. For each transaction, when the transaction status is normal (e.g., COMMITING, COMMITED, etc.), the number of log files corresponding to the transaction information can be obtained first. Simultaneously, the distributed transaction manager is queried to obtain the number of branch transactions corresponding to the transaction. Then, the number of log files for the transaction is compared with the number of branch transactions. When the first transaction whose number of branch transactions does not match the number of log files is found, this transaction and the remaining unqueried transactions are designated as transactions to be recovered. The remaining unqueried transactions refer to the transactions following the first transaction whose number of branch transactions does not match the number of log files in the above query order.

[0086] In some embodiments, querying multiple log file storage devices based on multiple transactions to be recovered to obtain the transaction time order of multiple transactions to be recovered in each log file storage device may include: obtaining the storage location of multiple transactions to be recovered and determining the list of transactions to be recovered for each log file storage device; for each log file storage device, querying the storage time of multiple transactions to be recovered based on the list of transactions to be recovered; sorting the storage times of multiple transactions to be recovered in the same direction as the time flow, and using the sorting result as the transaction time order of multiple transactions to be recovered.

[0087] In this embodiment, the server queries the log file storage device where the multiple log files corresponding to each transaction to be recovered are located, as well as the database (e.g., a distributed transaction manager) where each transaction to be recovered is located, based on multiple transactions to be recovered.

[0088] In this embodiment, the server sorts multiple transactions in ascending order (in the same direction as the time flow) based on their modification time. Further, for each of the sorted transactions, the server can sort its multiple branch transactions in ascending order based on their branch modification time to obtain a query sort. Furthermore, the server can determine the recovery order of multiple transactions to be recovered based on the query sort. For example, when the query sort is transaction 1, transaction 2, transaction 3, transaction 4, and transactions 1 and 3 are transactions to be recovered, while transactions 2 and 4 are not, the recovery order is transaction 1, transaction 3.

[0089] In this embodiment, for each transaction to be recovered in the recovery order, the server can determine the branch recovery order of multiple branch transactions within each transaction based on the query sorting. For example, when the recovery order is transaction 1, transaction 4, and the query sorting of the branch transactions in transaction 1 is: branch transaction 11, branch transaction 12, and the query sorting of the branch transactions in transaction 4 is branch transaction 41, branch transaction 42, then the branch recovery order for transaction 1 is: branch transaction 11, branch transaction 12, and the branch recovery order for transaction 4 is: branch transaction 41, branch transaction 42.

[0090] In this embodiment, the server sequentially queries multiple transactions to be recovered based on the recovery order and branch recovery order to determine the log file storage device where the log file corresponding to each branch transaction in each transaction to be recovered is located.

[0091] In this embodiment, the server can determine the list of transactions to be recovered for each log file storage device based on the recovery order and the branch recovery order. For example, when the recovery order is transaction 1, transaction 4, the branch recovery order for transaction 1 is: branch transaction 11, branch transaction 12, and the branch recovery order for transaction 4 is: branch transaction 41, branch transaction 42, and the log files of branch transaction 11 and branch transaction 42 are stored in the first log file storage device, and the log files of branch transaction 12 and branch transaction 41 are stored in the second log file storage device, then the list of transactions to be recovered in the first log file storage device is: branch transaction 11, branch transaction 42, and the list of transactions to be recovered in the second log file storage device is: branch transaction 12, branch transaction 41.

[0092] In this embodiment, for each log file storage device, the server can query the storage time of multiple transactions to be recovered based on the list of transactions to be recovered; sort the storage times of multiple transactions to be recovered in the same direction as the time flow, and use the sorting result as the transaction time order of multiple transactions to be recovered.

[0093] In another embodiment, the server can directly use the recovery order of the transactions to be recovered as the transaction time order of multiple transactions to be recovered.

[0094] In this embodiment, for each log file storage device, the server queries the last transaction in the transaction time sequence within that log file storage device and designates it as the initial transaction. Based on the transaction time of the initial transaction, the server queries the transaction times of multiple recoverable transactions in all log file storage devices. If there is a recoverable transaction with a transaction time later than the initial transaction, that recoverable transaction with a later transaction time is designated as the initial transaction. This process is repeated until there are no recoverable transactions with transaction times later than the initial transaction in any of the log file storage devices.

[0095] In this embodiment, the server restores the initial transaction when there are no transactions to be restored in all log file storage devices whose transaction times are later than the initial transaction.

[0096] In another embodiment, the server can restore multiple transactions to be restored in reverse order based on their transaction time sequence. For example, when the restoration order is transaction 1, transaction 4, and the branch restoration order for transaction 1 is: branch transaction 11, branch transaction 12, and the branch restoration order for transaction 4 is: branch transaction 41, branch transaction 42, and the log files of branch transactions 11 and 42 are stored in the first log file storage device, the log file of branch transaction 12 is stored in the second log file storage device, and the log file of branch transaction 41 is stored in the third log file storage device, the transaction time sequence is: branch transaction 11, branch transaction 12, branch transaction 41, branch transaction 42. In this case, the server can restore the branch transactions by calling the log file storage device where the log file corresponding to each branch transaction is located in reverse order based on the transaction time sequence (i.e., in the order of branch transaction 42, branch transaction 41, branch transaction 12, branch transaction 11), thereby realizing the restoration of multiple transactions to be restored.

[0097] In some embodiments, the above method may further include: when a transaction is in an abnormal state, rolling back the transaction with the abnormal state based on the log file.

[0098] In this embodiment, abnormal transaction statuses may include, but are not limited to: NEW (new), ROLLBACKING (rolling back), ROLLBACKED (rollback completed), ROLLBACK_DIRTY (rollback exception), etc.

[0099] In this embodiment, when the transaction status is NEW (new), ROLLBACKING (rolling back), ROLLBACK_DIRTY (rollback exception), etc., multiple log files corresponding to the transaction are queried, the transaction is rolled back based on the log files, and the transaction status is changed to ROLLBACKED (rollback completed) after the rollback is completed.

[0100] In one embodiment, such as Figure 4 As shown, a data storage method is provided, including the following steps 402 to 406.

[0101] Step 402: When entering the data storage state, obtain the transaction request.

[0102] In this embodiment, the log file storage device may be an RM (Resource Manager, Transaction Resource Manager).

[0103] In this embodiment, when entering the data storage state, the server can obtain the transaction request sent by the terminal device and assign the transaction request to one or more log file storage devices for processing. For example, when the APP (Application) initiates transaction request 1, the request can be processed by RM1 and RM2 simultaneously. RM1 will start a distributed transaction, and the TM DB (Transaction Manager Database) will select an RM using the hash value of the distributed transaction sequence. Assuming that a distributed transaction information is recorded in TM DB1, multiple RMs record log files of the operation data corresponding to the transaction request.

[0104] Step 404: Based on the transaction request, determine the transaction information storage location and the log file storage device; wherein, the transaction information storage location stores the transaction information corresponding to the transaction request, and the log file storage device stores the log file corresponding to the transaction request.

[0105] In this embodiment, the TM DB can determine the TM corresponding to multiple branch transactions of each transaction based on the hash value remainder. For example, when there are TM1, TM2, and TM3, and TM1 corresponds to remainder 1, TM2 corresponds to remainder 2, and TM3 corresponds to remainder 3, if the TMDB takes the remainder of the hash value corresponding to the branch transaction as 1, then it determines that TM1 is the TM corresponding to that branch transaction.

[0106] In this embodiment, the log file storage devices corresponding to multiple branches of a transaction may be different.

[0107] Step 406: Determine the data storage method based on the log file storage device, store data based on the storage method, and update the transaction information at the transaction information storage location.

[0108] In some embodiments, such as Figure 5 As shown, updating transaction information at the transaction information storage location includes: obtaining multiple log files stored on the log file storage device; for each log file, if no abnormality occurs in the log file, obtaining the transaction commit request from the log file storage device, generating a corresponding sequence based on the task commit request, and adding the sequence to the transaction information corresponding to the transaction request; when an abnormality occurs in the log file, or the transaction status corresponding to the transaction information is abnormal, an error is reported.

[0109] In this embodiment, the RM will not request a sequence (distributed sequence) from the TM under the following three processing conditions:

[0110] (1) The log file recording the operation data of RM is blocked, and the distributed transaction in the TM where the transaction corresponding to the log file is located is in the state of NEW (new);

[0111] (2) The log file recording the operation data of RM is abnormal. The distributed transaction in the TM where the transaction corresponding to the log file is located is in the state of ROLLBACKING (rolling back);

[0112] (3) When the RM initiates a transaction rollback, the transaction status in the TM is ROLLBACKED (rollback completed) after the rollback is completed. After the rollback fails, the transaction status in the TM is ROLLBACK_DIRTY (rollback failure).

[0113] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0114] Based on the same inventive concept, this application also provides a data backup apparatus for implementing the data backup method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more data backup apparatus embodiments provided below can be found in the limitations of the data backup method described above, and will not be repeated here.

[0115] In one embodiment, such as Figure 6 As shown, a data backup device is provided, including: a transaction information query module 602, a transaction to be recovered determination module 604, a transaction time sequence determination module 606, and a data backup module 608, wherein:

[0116] The transaction information query module 602 is used to obtain the target backup time after data storage, and query multiple transaction information corresponding to the target backup time based on the target backup time; wherein, the transaction information includes the transaction status.

[0117] The module 604 for determining transactions to be recovered is used to obtain the log file corresponding to the transaction information when the transaction status is normal, and query the log file based on the modification time to obtain multiple transactions to be recovered.

[0118] The transaction time sequence determination module 606 is used to query multiple log file storage devices based on multiple transactions to be recovered, and obtain the transaction time sequence of multiple transactions to be recovered in each log file storage device; the transaction time sequence is in the same direction as the time flow.

[0119] The data backup module 608 is used to back up data one by one for each log file storage device, based on the transaction time order and in reverse order of the transaction order.

[0120] In one embodiment, the transaction information query module 602 may include:

[0121] The query time period determination submodule is used to determine the query time period based on the target backup time; wherein, the target backup time is within the range of the query time period, and the time corresponding to the upper limit endpoint of the query time period range is later than the target backup time.

[0122] The transaction information query submodule is used to query multiple transaction information corresponding to the target backup time based on the query time period.

[0123] In one embodiment, the transaction to be recovered determination module 604 may include:

[0124] The "Transactions to be Recovered" submodule is used to query the log files based on the modification time in the same direction as the time flow. When the first branch transaction count is not equal to the number of log files, the transaction and the remaining unqueried transactions are identified as transactions to be recovered.

[0125] In one embodiment, the transaction time sequence determination module 606 may include:

[0126] The "Transactions to be Recovered List Determination" submodule is used to obtain the storage locations of multiple transactions to be recovered and determine the list of transactions to be recovered for each log file storage device.

[0127] The storage time query submodule is used to query the storage time of multiple transactions to be recovered for each log file storage device, based on the list of transactions to be recovered.

[0128] The transaction time order determination submodule is used to sort the storage times of multiple transactions to be recovered in the same direction as the time flow, and use the sorting result as the transaction time order of the multiple transactions to be recovered.

[0129] In one embodiment, the above-described apparatus further includes:

[0130] The abnormal state rollback module is used to roll back transactions with abnormal states based on log files when the transaction state is abnormal.

[0131] Based on the same inventive concept, this application also provides a data storage device for implementing the data storage method described above. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations in one or more data storage device embodiments provided below can be found in the limitations of the data storage method described above, and will not be repeated here.

[0132] In one embodiment, such as Figure 7 As shown, a data storage device is provided, including: a transaction request acquisition module 702, a storage location determination module 704, and a data storage module 706, wherein:

[0133] The transaction request acquisition module 702 is used to acquire transaction requests when entering the data storage state.

[0134] The storage location determination module 704 is used to determine the transaction information storage location and the log file storage device based on the transaction request; wherein, the transaction information storage location stores the transaction information corresponding to the transaction request, and the log file storage device stores the log file corresponding to the transaction request.

[0135] The data storage module 706 is used to determine the data storage method based on the log file storage device, store data based on the storage method, and update the transaction information at the transaction information storage location.

[0136] In one embodiment, the data storage module 706 may include:

[0137] The log file retrieval submodule is used to retrieve multiple log files stored on the log file storage device.

[0138] The transaction information update submodule is used to obtain the transaction commit request of the log file storage device for each log file when there is no abnormality in the log file, generate the corresponding sequence based on the task commit request, and add the sequence to the transaction information corresponding to the transaction request; when there is an abnormality in the log file or the transaction status corresponding to the transaction information is abnormal, an error is reported.

[0139] Each module in the aforementioned data storage and backup device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device, or stored in the memory of a computer device as software, so that the processor can call and execute the operations corresponding to each module.

[0140] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 8As shown, this computer device includes a processor, memory, input / output interfaces (I / O), and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media. The database stores data such as recovery order and branch recovery order. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a data backup method.

[0141] Those skilled in the art will understand that Figure 8 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0142] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to perform the following steps: after data storage, a target backup time is obtained; based on the target backup time, multiple transaction information corresponding to the target backup time is queried; wherein, the transaction information includes a transaction status; for each transaction status, when the transaction status is normal, the log file corresponding to the transaction information is obtained; the log file is queried based on the modification time to obtain multiple transactions to be recovered; multiple log file storage devices are queried based on the multiple transactions to be recovered to obtain the transaction time order of the multiple transactions to be recovered in each log file storage device; the transaction time order is in the same direction as the time flow; for each log file storage device, data is backed up one by one in reverse order of the transaction time order.

[0143] In one embodiment, when the processor executes the computer program, it further implements querying multiple transaction information corresponding to the target backup time based on the target backup time, which may include: determining a query time period based on the target backup time; wherein the target backup time is within the interval of the query time period, and the time corresponding to the upper limit endpoint of the query time period interval is later than the target backup time; and querying multiple transaction information corresponding to the target backup time based on the query time period.

[0144] In one embodiment, when the processor executes the computer program, it further implements querying the log file based on the modification time to obtain multiple transactions to be recovered. This may include: querying the log file based on the modification time in the same direction as the time flow; when the number of the first branch transactions is not equal to the number of log files, the transaction and the remaining unqueried transactions are taken as transactions to be recovered.

[0145] In one embodiment, when the processor executes the computer program, it further implements querying multiple log file storage devices based on multiple transactions to be recovered, and obtaining the transaction time order of multiple transactions to be recovered in each log file storage device. This may include: obtaining the storage location of multiple transactions to be recovered, and determining the list of transactions to be recovered for each log file storage device; for each log file storage device, querying the storage time of multiple transactions to be recovered based on the list of transactions to be recovered; sorting the storage times of multiple transactions to be recovered in the same direction as the time flow, and using the sorting result as the transaction time order of multiple transactions to be recovered.

[0146] In one embodiment, when the processor executes the computer program, it also performs the following steps: when the transaction state is abnormal, roll back the transaction with the abnormal transaction state based on the log file.

[0147] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, it performs the following steps: after data storage, a target backup time is obtained; based on the target backup time, multiple transaction information corresponding to the target backup time is queried; wherein, the transaction information includes transaction status; for each transaction status, when the transaction status is normal, the log file corresponding to the transaction information is obtained; the log file is queried based on the modification time to obtain multiple transactions to be recovered; based on the multiple transactions to be recovered, multiple log file storage devices are queried to obtain the transaction time order of the multiple transactions to be recovered in each log file storage device; the transaction time order is in the same direction as the time flow; for each log file storage device, data is backed up one by one in reverse order of the transaction time order.

[0148] In one embodiment, when the computer program is executed by the processor, it further implements querying multiple transaction information corresponding to the target backup time based on the target backup time, which may include: determining a query time period based on the target backup time; wherein the target backup time is within the interval of the query time period, and the time corresponding to the upper limit endpoint of the query time period interval is later than the target backup time; and querying multiple transaction information corresponding to the target backup time based on the query time period.

[0149] In one embodiment, when the computer program is executed by the processor, it further implements querying the log file based on the modification time to obtain multiple transactions to be recovered. This may include: querying the log file based on the modification time in the same direction as the time flow; when the number of the first branch transactions is not equal to the number of log files, the transaction and the remaining unqueried transactions are taken as transactions to be recovered.

[0150] In one embodiment, when the computer program is executed by the processor, it further implements querying multiple log file storage devices based on multiple transactions to be recovered, and obtaining the transaction time order of multiple transactions to be recovered in each log file storage device. This may include: obtaining the storage location of multiple transactions to be recovered, and determining the list of transactions to be recovered for each log file storage device; for each log file storage device, querying the storage time of multiple transactions to be recovered based on the list of transactions to be recovered; sorting the storage times of multiple transactions to be recovered in the same direction as the time flow, and using the sorting result as the transaction time order of multiple transactions to be recovered.

[0151] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: when the transaction state is abnormal, roll back the transaction with the abnormal transaction state based on the log file.

[0152] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps: after data storage, obtaining a target backup time; based on the target backup time, querying multiple transaction information corresponding to the target backup time; wherein, the transaction information includes transaction status; for each transaction status, when the transaction status is normal, obtaining the log file corresponding to the transaction information, querying the log file based on the modification time to obtain multiple transactions to be recovered; querying multiple log file storage devices based on the multiple transactions to be recovered to obtain the transaction time order of the multiple transactions to be recovered in each log file storage device; the transaction time order is in the same direction as the time flow; for each log file storage device, backing up the data one by one in reverse order of the transaction time order.

[0153] In one embodiment, when the computer program is executed by the processor, it further implements querying multiple transaction information corresponding to the target backup time based on the target backup time, which may include: determining a query time period based on the target backup time; wherein the target backup time is within the interval of the query time period, and the time corresponding to the upper limit endpoint of the query time period interval is later than the target backup time; and querying multiple transaction information corresponding to the target backup time based on the query time period.

[0154] In one embodiment, when the computer program is executed by the processor, it further implements querying the log file based on the modification time to obtain multiple transactions to be recovered. This may include: querying the log file based on the modification time in the same direction as the time flow; when the number of the first branch transactions is not equal to the number of log files, the transaction and the remaining unqueried transactions are taken as transactions to be recovered.

[0155] In one embodiment, when the computer program is executed by the processor, it further implements querying multiple log file storage devices based on multiple transactions to be recovered, and obtaining the transaction time order of multiple transactions to be recovered in each log file storage device. This may include: obtaining the storage location of multiple transactions to be recovered, and determining the list of transactions to be recovered for each log file storage device; for each log file storage device, querying the storage time of multiple transactions to be recovered based on the list of transactions to be recovered; sorting the storage times of multiple transactions to be recovered in the same direction as the time flow, and using the sorting result as the transaction time order of multiple transactions to be recovered.

[0156] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: when the transaction state is abnormal, roll back the transaction with the abnormal transaction state based on the log file.

[0157] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0158] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0159] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0160] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A data backup method, characterized in that, The method includes: After data storage, the target backup time is obtained, and based on the target backup time, multiple transaction information corresponding to the target backup time is queried; wherein, the transaction information includes the transaction status; the transaction status includes normal and abnormal. For each transaction state, when the transaction state is normal, obtain the log file corresponding to the transaction information and the latest modification time of the log file, query the log file based on the modification time, and obtain multiple transactions to be recovered; Based on the multiple transactions to be recovered, multiple log file storage devices are queried to obtain the transaction time order of the multiple transactions to be recovered in each log file storage device; the transaction time order is in the same direction as the time flow. For each log file storage device, data backups are performed one by one in reverse order of the transaction time sequence.

2. The method according to claim 1, characterized in that, The step of querying multiple transaction information corresponding to the target backup time based on the target backup time includes: Based on the target backup time, a query time period is determined; wherein the target backup time is within the range of the query time period, and the time corresponding to the upper limit endpoint of the query time period is later than the target backup time; Based on the query time period, query multiple transaction information corresponding to the target backup time.

3. The method according to claim 1, characterized in that, The process of querying the log file based on the modification time yields multiple transactions to be recovered, including: Based on the modification time, the log files are queried in the same direction as the time flow. When the number of transactions in the first branch is not equal to the number of log files, the transaction and the other unqueried transactions are treated as transactions to be recovered.

4. The method according to claim 1, characterized in that, The step of querying multiple log file storage devices based on multiple transactions to be recovered, to obtain the transaction time order of multiple transactions to be recovered in each log file storage device, includes: Obtain the storage locations of multiple transactions to be recovered, and determine the list of transactions to be recovered for each log file storage device; For each log file storage device, based on the list of transactions to be recovered, query the storage time of multiple transactions to be recovered; The storage times of the multiple transactions to be recovered are sorted in the same direction as the time flow, and the sorting result is used as the transaction time order of the multiple transactions to be recovered.

5. The method according to claim 1, characterized in that, The method further includes: When the transaction status is abnormal, the transaction with the abnormal status is rolled back based on the log file.

6. A data storage method, characterized in that, include: When entering the data storage state, obtain the transaction request; Based on the transaction request, a transaction information storage location and a log file storage device are determined; wherein, the transaction information storage location stores the transaction information corresponding to the transaction request, and the log file storage device stores the log file corresponding to the transaction request; the transaction information includes the transaction status; The data storage method is determined based on the log file storage device, the data is stored based on the storage method, the transaction information at the transaction information storage location is updated, and the data backup method according to any one of claims 1-5 is executed.

7. The method according to claim 6, characterized in that, Updating the transaction information at the transaction information storage location includes: Obtain multiple log files stored on the log file storage device; For each log file, if no abnormality occurs in the log file, the transaction commit request of the log file storage device is obtained, a corresponding sequence is generated based on the transaction commit request, and the sequence is added to the transaction information corresponding to the transaction request; if an abnormality occurs in the log file, or the transaction status corresponding to the transaction information is abnormal, an error is reported.

8. A data backup device, characterized in that, The device includes: The transaction information query module is used to obtain the target backup time after data storage, and query multiple transaction information corresponding to the target backup time based on the target backup time; wherein, the transaction information includes the transaction status; the transaction status includes normal and abnormal. The module for determining transactions to be recovered is used to, for each transaction state, when the transaction state is normal, obtain the log file corresponding to the transaction information and the latest modification time of the log file, query the log file based on the modification time, and obtain multiple transactions to be recovered; The transaction time sequence determination module is used to query multiple log file storage devices based on multiple transactions to be recovered, and obtain the transaction time sequence of multiple transactions to be recovered in each log file storage device; the transaction time sequence is in the same direction as the time flow. The data backup module is used to back up data one by one for each log file storage device, based on the transaction time order and in reverse order of the transaction time order.

9. A data storage device, characterized in that, The device includes: The transaction request acquisition module is used to acquire transaction requests when entering the data storage state; A storage location determination module is used to determine the transaction information storage location and the log file storage device based on the transaction request; wherein, the transaction information storage location stores the transaction information corresponding to the transaction request, and the log file storage device stores the log file corresponding to the transaction request; the transaction information includes the transaction status; A data storage module is configured to determine a data storage method based on the log file storage device, store data based on the storage method, update the transaction information at the transaction information storage location, and execute the data backup method according to any one of claims 1-5.

10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

12. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Transaction rollback method and device, database, system and computer storage medium

    CN112256656A

  • Data processing method and device, electronic equipment and computer storage medium

    CN112306743A

  • Time series data storage method and device, computer equipment and storage medium

    CN113342284A

  • Data processing method and device, electronic equipment and storage medium

    CN114265900A