Data synchronization task rollback method and device, electronic equipment and storage medium
By grouping and encapsulating data synchronization tasks, recording execution time and information, and automatically detecting and deleting data files in the target storage system, the problem of inefficiency caused by data synchronization write failures is solved, and efficient data rollback and database management are achieved. consistency.
Patent Information
- Application Number
- CN202410865181.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-09-13
AI Technical Summary
When existing data synchronization technology fails during the writing process, part of the data is written while another part is not completely written, resulting in inefficient manual rollback operations and affecting database consistency.
Use the data synchronization component to group and encapsulate the data to be synchronized, record the execution time and information of the encapsulation method, periodically detect the task status, and automatically delete the data files in the target storage system based on the recorded information in case of failure to improve the accuracy and accuracy of rollback. efficiency.
It realizes automated rollback of data synchronization tasks, improves the accuracy and efficiency of rollback, reduces the need for manual operations, and ensures the consistency of the database.
Smart Images

Figure CN118643101A
Abstract
Description
Background Art
[0002] Data synchronization is a technology that can update and transmit data between different systems or devices. It is widely used in various scenarios such as data synchronization in computer rooms and data migration. Currently, there are many data synchronization components, such as Spark, Flink, DataX, etc., which can realize the data synchronization process.
[0003] In related technologies, data synchronization often operates on multiple data at one time, for example, writing multiple data of a database into a distributed system in the form of at least one data file at one time, and the data writing process further includes multiple sub-processes, such as the creation of data files, the movement of data files, the renaming of data files, etc.
[0004] However, if a failure occurs during the data writing process, such as a network interruption, the same batch of data being written may be in different states when the failure occurs, resulting in some data being written while others not being written, or even a large amount of data not being completely written, but only executing some of the sub-steps of writing and then being forced to interrupt. At this time, in order to ensure the consistency of the database, the entire data synchronization process needs to be rolled back, that is, the data files that have been successfully written, as well as the intermediate files and temporary files generated due to the incomplete data writing, need to be deleted. At present, data rollback is done manually through database query statements, querying each table and deleting related files, which is inefficient. Summary of the invention
[0005] Embodiments of the present application provide a rollback method, device, electronic device, and storage medium for a data synchronization task, so as to improve the accuracy of the rollback of the data synchronization task.
[0006] An embodiment of the present application provides a method for rolling back a data synchronization task, including:
[0007] Based on the data synchronization component, at least one data to be synchronized obtained from the source database is grouped to obtain at least one data group to be synchronized; the target path of the data contained in each data group is the same;
[0008] For any data group, the data encapsulation method is called and executed based on the data synchronization component, wherein each execution of the data encapsulation method includes the following steps:
[0009] Recording the execution time of the data encapsulation method and data encapsulation information;
[0010] Encapsulating any one of the data groups into a corresponding data file, and based on a target path corresponding to the data in the data file, storing the data file in a target storage system;
[0011] Periodically detecting a data synchronization task status for the at least one data to be synchronized, and if the data synchronization task status indicates that the task has failed, reading the recorded execution time and data encapsulation information;
[0012] Based on the recorded execution time and data encapsulation information, a deletion operation is performed on the data files written into the target storage system.
[0013] An embodiment of the present application provides a data synchronization task rollback device, including:
[0014] A grouping unit, configured to group at least one data to be synchronized obtained from a source database based on a data synchronization component to obtain at least one data group to be synchronized; each data group contains data having the same target path;
[0015] The execution unit is used to call and execute the data encapsulation method based on the data synchronization component for any data group, wherein each execution of the data encapsulation method includes the following steps:
[0016] Recording the execution time of the data encapsulation method and data encapsulation information;
[0017] Encapsulating any one of the data groups into a corresponding data file, and based on a target path corresponding to the data in the data file, storing the data file in a target storage system;
[0018] a detection unit, configured to periodically detect a data synchronization task status for the at least one data to be synchronized, and read the recorded execution time and data encapsulation information if the data synchronization task status indicates that the task has failed;
[0019] The deleting unit is used to delete the data files written in the target storage system based on the recorded execution time and data encapsulation information.
[0020] Optionally, if the data synchronization component is a first data synchronization component, the data encapsulation information includes a target path of data included in the data group;
[0021] The execution unit is specifically used for:
[0022] Creating a data file corresponding to the arbitrary data group under the target path of the data included in the arbitrary data group;
[0023] The deleting unit is specifically used for:
[0024] Under the target path of the data included in each data group, based on the recorded execution time, a deletion operation is performed on the data files written in the target storage system.
[0025] Optionally, if the data synchronization component is a second data synchronization component, the data encapsulation information includes a target path and a temporary path of the data included in the data group;
[0026] The execution unit is specifically used for:
[0027] Creating a temporary file corresponding to the arbitrary data group under the temporary path of the data included in the arbitrary data group;
[0028] Moving the temporary file to the target path of the data contained in the one data group to obtain a data file corresponding to the arbitrary one data group;
[0029] The deleting unit is specifically used for:
[0030] Based on the recorded execution time, a deletion operation is performed on the data files written in the target storage system at the target path of the data contained in each data group, and a deletion operation is performed on the temporary files written in the target storage system at the temporary path of the data contained in each data group.
[0031] Optionally, if the data synchronization component is a third data synchronization component, the data encapsulation information includes a target path and a temporary path of the data included in the data group;
[0032] The execution unit is specifically used for:
[0033] Under the target path of the data included in the arbitrary data group, a data file corresponding to the arbitrary data group is created, and an intermediate calculation file generated when the encapsulation operation of the arbitrary data group is executed is stored under the temporary path of the data included in the arbitrary data group;
[0034] The deleting unit is specifically used for:
[0035] Based on the recorded execution time, a deletion operation is performed on the data files written in the target storage system at the target path of the data contained in each data group, and a deletion operation is performed on the intermediate calculation files written in the target storage system at the temporary path of the data contained in each data group.
[0036] Optionally, the deleting unit is further used for:
[0037] After the data file written in the target storage system is deleted, the recorded execution time and data encapsulation information is deleted.
[0038] An electronic device provided by an embodiment of the present application includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of the rollback method of any one of the above-mentioned data synchronization tasks.
[0039] An embodiment of the present application provides a computer-readable storage medium, which includes a computer program. When the computer program is executed on an electronic device, the computer program is used to enable the electronic device to execute the steps of the rollback method of any one of the above-mentioned data synchronization tasks.
[0040] An embodiment of the present application provides a computer program product, which includes a computer program, and the computer program is stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device performs the steps of the rollback method of any one of the above-mentioned data synchronization tasks.
[0041] The beneficial effects of this application are as follows:
[0042] An embodiment of the present application provides a rollback method, device, electronic device and storage medium for a data synchronization task. In the present application, a server can obtain at least one data to be synchronized from a source database based on a data synchronization component, and group at least one data to be synchronized to obtain at least one data group to be synchronized. After that, the server calls a data encapsulation method based on the data synchronization component, and before encapsulating a data group into a corresponding data file, first records the execution time of the data encapsulation method and the data encapsulation information, and then encapsulates the data group and stores it in a target path of the target storage system.
[0043] The server continuously detects the status of data synchronization tasks. When a data synchronization task fails and needs to be rolled back, the server can directly read the recorded execution time and data encapsulation information; then, based on the recorded execution time and data encapsulation information, it can directly find the written data files in the target storage system and delete them. Finding written data files based on execution time and data encapsulation information has higher accuracy, and the entire process is completed automatically, which improves rollback efficiency.
[0044] Other features and advantages of the present application will be described in the following description, and partly become apparent from the description, or be understood by practicing the present application. The purpose and other advantages of the present application can be realized and obtained by the structures specifically pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0046] Figure 1 A schematic diagram of an application scenario of a rollback method for a data synchronization task provided in an embodiment of the present application;
[0047] Figure 2 An overall flow chart of a rollback method for a data synchronization task provided in an embodiment of the present application;
[0048] Figure 3 A flowchart of an atomic maintenance service provided in an embodiment of the present application;
[0049] Figure 4 A logical diagram of a data synchronization task rollback provided in an embodiment of the present application;
[0050] Figure 5 A schematic diagram of the composition structure of a rollback device for a data synchronization task provided in an embodiment of the present application;
[0051] Figure 6 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the technical solution of the present application, rather than all of the embodiments. Based on the embodiments recorded in the application documents, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the technical solution of the present application.
[0053] The preferred embodiments of the present application are described below in conjunction with the drawings in the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the present application. In addition, the embodiments and features in the embodiments of the present application may be combined with each other if there is no conflict.
[0054] like Figure 1 As shown, it is a schematic diagram of an application scenario of an embodiment of the present application. The application scenario diagram includes a target storage system 110 and a server 120.
[0055] In the embodiment of the present application, the target storage system 110 includes but is not limited to a distributed database system, and may also be a centralized database system, etc.; the server 120 includes a source database and a data synchronization component; the server 120 may be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, content delivery networks (CDNs), as well as big data and artificial intelligence platforms.
[0056] It should be noted that the rollback method of the data synchronization task in each embodiment of the present application can be executed by an electronic device, which can be a server 120. When executed by the server 120, the server 120 groups at least one data to be synchronized obtained from the source database based on the data synchronization component to obtain at least one data group to be synchronized; for any data group, the server 120 calls and executes the data encapsulation method based on the data synchronization component. The specific execution process is that the server 120 records the execution time and data encapsulation information of the data encapsulation method, and encapsulates any data group into a corresponding data file, and based on the target path corresponding to the data in the data file, stores the data file to the target storage system 110. During data synchronization, the server 120 periodically detects the data synchronization task status for at least one data to be synchronized. If the data synchronization task fails, the server 120 reads the recorded execution time and data encapsulation information; based on the recorded execution time and data encapsulation information, the data file written in the target storage system 110 is deleted.
[0057] It should be noted that Figure 1 The figure is only an example. In fact, the number of servers is not limited and is not specifically limited in the embodiments of the present application.
[0058] In addition, the embodiments of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation and other scenarios.
[0059] The following describes the rollback method of the data synchronization task provided by the exemplary embodiment of the present application in combination with the application scenario described above and with reference to the accompanying drawings. It should be noted that the above application scenario is only shown to facilitate understanding of the spirit and principles of the present application, and the implementation of the present application is not limited in this respect.
[0060] See also Figure 2 As shown, it is an implementation flow chart of a rollback method of a data synchronization task provided in an embodiment of the present application. The specific implementation process of the method is as follows S201-S204:
[0061] S201: The server groups at least one data to be synchronized obtained from a source database based on a data synchronization component to obtain at least one data group to be synchronized.
[0062] In the above, the server extracts at least one data to be synchronized in the source database through the data synchronization component, that is, the data that needs to be written to the target storage system, and groups the extracted data. The target path of the data contained in each data group is the same, that is, the data under a data group are all data that need to be stored in the same path of the target storage system.
[0063] In addition, the data can be allocated and managed in the target storage system by static partitioning or dynamic partitioning. However, no matter which method is used, once the amount of data to be synchronized is too large, it is usually necessary to perform data synchronization operations in batches, that is, to write the data to the target storage system in batches. For example, one thousand data items are divided into ten batches, and 100 data items are written in each batch. Furthermore, in each batch, the server divides the 100 data items into one or more data groups according to the preset storage capacity of a data file and the size of each data item, and ensures that the target path of the data contained in each data group is the same.
[0064] That is, when the amount of data is too large, the data will be divided into multiple data files, especially dynamic partitions usually involve multiple data files, and writing multiple files to the target storage system is not an atomic operation, but the data synchronization task needs to ensure atomicity. Atomicity means that a task is either completed in full or not completed at all; if a task contains multiple operations, all operations are either executed successfully or failed. If any one or even part of the operations in the task fails, the entire system needs to roll back to the state before the task started to ensure data consistency. That is, the one thousand data mentioned above need to be successfully written or not written to the target storage system. If the writing fails midway, the written data, as well as the temporary files and intermediate files generated due to the writing of some data, need to be deleted.
[0065] It should be noted that the above-mentioned data volume and data batching are all examples. During specific implementation, the storage capacity of the data file, the storage space occupied by each data, the data volume, the batching method, etc. can be adaptively set based on actual needs. The size of each data is not necessarily the same, and this application does not make specific limitations.
[0066] In the above, the source database and the data synchronization component are both in the above-mentioned server. Optionally, the source database can also be installed separately on other servers. This application does not make specific limitations, but for the convenience of description, this application will hereinafter explain the source database and the data synchronization component in the same server as an example; the data file is obtained by encapsulating the data in the data group, and the specific encapsulation process will be described in S202 and will not be repeated here.
[0067] S202: For any data group, the server calls and executes a data encapsulation method based on a data synchronization component.
[0068] Each execution of the data encapsulation method includes steps S2021-S2022.
[0069] S2021: The server records the execution time of the data encapsulation method and the data encapsulation information.
[0070] S2022: The server encapsulates any data group into a corresponding data file, and stores the data file in a target storage system based on a target path corresponding to the data in the data file.
[0071] Taking the target storage system as a distributed file system (English: Hadoop Distributed File System, HDFS) as an example, the above encapsulation process can be specifically implemented by the Hadoop HDFS toolkit on the server. The Hadoop HDFS toolkit and the source database and data synchronization components are in the same server; the data encapsulation method can be a public base class method for HDFS encapsulation; the Hadoop HDFS toolkit provides interfaces and tools for interacting with HDFS, including data encapsulation operations such as file reading, writing, merging, and moving, and the method proposed in this application further improves the Hadoop HDFS toolkit on this basis. In addition to the above operations, the Hadoop HDFS toolkit can also perform information recording operations, that is, in this application, the execution of the encapsulation method is mainly divided into two parts: information recording and encapsulation of data groups.
[0072] Specifically, the data synchronization component first calls the Hadoop HDFS toolkit to implement the call of the HDFS encapsulation public base class method, and then the Hadoop HDFS toolkit completes information recording and data encapsulation, and finally stores the encapsulated data file in HDFS.
[0073] The information recorded mainly includes the method execution time and data encapsulation information. After the above information is recorded, encapsulation is performed to ensure that the execution time and data encapsulation information are recorded before the data group is encapsulated into a data file. The execution time and data encapsulation information can be recorded in a database in the server, such as a metadata database, with one record corresponding to each data file.
[0074] In the above, in addition to HDFS, the target storage system can also be a File Transfer Protocol (FTP) system, a Secure File Transfer Protocol (SFTP) system, etc. The above systems are all applicable to this application and are not specifically limited in this application.
[0075] Furthermore, there are multiple data synchronization components. For different data synchronization components, the information recording and data packaging processes are also different. In order to increase the scope of use, this application proposes different methods for different data synchronization components, which are explained below.
[0076] Method 1: If the data synchronization component is the first data synchronization component, the data encapsulation information includes the target path of the data included in the data group. Optionally, the encapsulation process includes: the server creates a data file corresponding to any data group under the target path of the data included in any data group.
[0077] This process is specifically completed by a toolkit in the server, such as a Hadoop HDFS toolkit, and the first data synchronization component may be Flink.
[0078] That is, Flink calls the Hadoop HDFS toolkit to create a data file corresponding to a data group directly under the target path of the target storage system to complete the write operation of the data in the data group. In addition, the newly created data file has a default name. Before completing the write, the data file needs to be renamed with the .part suffix.
[0079] Method 2: If the data synchronization component is the second data synchronization component, the data encapsulation information includes the target path and temporary path of the data contained in the data group. Optionally, the encapsulation process includes: the server creates a temporary file corresponding to any data group under the temporary path of the data contained in any data group; then moves the temporary file to the target path of the data contained in a data group to obtain a data file corresponding to any data group.
[0080] This process is specifically completed by a toolkit in the server, such as a Hadoop HDFS toolkit, and the second data synchronization component may be DataX.
[0081] That is, DataX calls the Hadoop HDFS toolkit, first creates a temporary file corresponding to a data group in the temporary path of the target storage system, and then moves the temporary file to the target path corresponding to the data group to complete the write operation of the data in the data group. Specifically, the temporary file can be transferred from the temporary path to the target path through the dynamic partition structured query language (English: Structured Query Language, SQL). In addition, the newly created temporary file has a default name. Before moving the temporary file, it needs to be renamed with the .tmp suffix.
[0082] Method 3: If the data synchronization component is a third data synchronization component, the data encapsulation information includes the target path and temporary path of the data contained in the data group. Optionally, the encapsulation process includes: the server creates a data file corresponding to any data group under the target path of the data contained in any data group, and stores the intermediate calculation file generated when performing the encapsulation operation of any data group under the temporary path of the data contained in any data group.
[0083] This process is specifically completed by a toolkit in the server, such as a Hadoop HDFS toolkit, and the second data synchronization component may be Spark.
[0084] That is, Spark calls the Hadoop HDFS toolkit to create a data file corresponding to a data group directly under the target path of the target storage system to complete the write operation of the data in the data group. In addition, the newly created data file has a default name. Before completing the write, the data file needs to be renamed with the .hive-staging suffix.
[0085] At the same time, Spark's data encapsulation process will also generate some intermediate calculation files, which are stored in a temporary path. These intermediate calculation files can be retained, or they can be deleted regularly to save storage space, or deleted after meeting preset conditions, or deleted manually.
[0086] In addition to the above-mentioned target path and temporary path, the data encapsulation information may also include the number identification of the data file corresponding to the data group, the corresponding data synchronization component type, the specific execution time of moving and renaming the data file, the status of the data synchronization task (successful or failed or running), etc. This application does not make specific limitations.
[0087] S203: The server periodically detects a data synchronization task status for at least one data to be synchronized, and if the data synchronization task status indicates that the task has failed, reads the recorded execution time and data encapsulation information.
[0088] S204: The server deletes the data files written into the target storage system based on the recorded execution time and data encapsulation information.
[0089] In this application, the server also includes an atomic maintenance service, which is responsible for periodically detecting the status of the data synchronization task, that is, success, failure or synchronization (running). It can obtain the status of the data synchronization task by periodically querying the data synchronization component. If one or more data file write errors occur, the data synchronization task fails. The atomic maintenance service reads records in the metadata database. Since the data groups are first recorded with corresponding information and then encapsulated, the atomic maintenance service can obtain the data encapsulation information corresponding to all data groups that have been written or are being written to the target storage system in this task, as well as the execution time of the encapsulation method. Afterwards, according to the execution time, the data files under the corresponding path are deleted. Specifically, the data files related to this task can be sorted from old to new according to the execution time, and the corresponding data files can be deleted under the corresponding path in this order.
[0090] The following is still a separate description of different data synchronization components.
[0091] If the data synchronization component is the first data synchronization component, such as Flink, the atomic maintenance service in the server deletes the data files written in the target storage system based on the recorded execution time under the target path of the data included in each data group.
[0092] Specifically, the atomic maintenance service can obtain the target path and execution time of the data contained in each data group that has executed or has started to execute the data encapsulation method. It can sort the data files corresponding to these data groups based on the execution time, and delete the data files that have been written (that is, the data files that have been renamed) and the data files that have not been written (that is, the data files that have just been created but not renamed) in order under the corresponding target path.
[0093] If the data synchronization component is a second data synchronization component, such as DataX, the atomic maintenance service in the server deletes the data files written in the target storage system at the target path of the data contained in each data group based on the recorded execution time. In addition, the atomic maintenance service also needs to delete the temporary files written in the target storage system at the temporary path of the data contained in each data group.
[0094] Specifically, the atomic maintenance service can obtain the target path and execution time of the data contained in each data group that has executed or has started to execute the data encapsulation method. It can still sort the data files and temporary files based on the execution time, and delete the temporary files that have started to execute the data encapsulation method but have not yet completed writing under the temporary path (that is, temporary files that have just been created and not renamed, and temporary files that have been renamed but have not yet been transferred), and the data files that have executed the data encapsulation method and completed writing under the target path in order.
[0095] If the data synchronization component is a second data synchronization component, such as Spark, the atomic maintenance service in the server deletes the data files written in the target storage system at the target path of the data contained in each data group based on the recorded execution time, and deletes the intermediate calculation files written in the target storage system at the temporary path of the data contained in each data group.
[0096] Specifically, the atomic maintenance service can obtain the target path and execution time of the data contained in each data group that has executed or has started to execute the data encapsulation method. It can still sort the data files and intermediate calculation files based on the execution time, and delete the data files that have been written (that is, the data files that have been renamed) and the data files that have not been written (that is, the data files that have just been created but not renamed) in the corresponding target path in order, and delete the intermediate calculation files that have been written in the target storage system under the corresponding temporary path.
[0097] In addition, if the intermediate calculation file has been deleted, the deleted file is an invalid file, and there is no need to perform the deletion operation of the intermediate calculation file again.
[0098] After completing the deletion operation of the data files, temporary files, and intermediate calculation files on the target storage system, the atomic maintenance service in the server also needs to delete the execution time and data encapsulation information recorded in this task in the metadata database.
[0099] In summary, if Figure 3As shown, it is a flowchart of an atomic maintenance service provided by an embodiment of the present application, and the steps are as follows:
[0100] Step 301: Detect the data synchronization task status for at least one data to be synchronized.
[0101] Step 302: Determine whether the data synchronization task is successful, if so, end, otherwise execute step 303.
[0102] Step 303: Read the recorded execution time and data encapsulation information in the metadata database.
[0103] The atomic maintenance service can only read valid files for this task. Valid files are files that have not been deleted. Deleted files, such as automatically deleted intermediate calculation files, can be ignored.
[0104] Step 304: Delete valid files based on the execution time and data encapsulation information.
[0105] Step 305: Delete the execution time and data encapsulation information recorded in this task in the metadata database.
[0106] like Figure 4 As shown, it is a logical schematic diagram of a data synchronization task rollback provided by an embodiment of the present application. Taking the target storage system as HDFS, the encapsulation method as the HDFS encapsulation common base class method, and the toolkit as the Hadoop HDFS toolkit as an example, data synchronization components such as Spark, Flink, DataX, etc. extract the data to be synchronized from the source database, and the source database may be MySQL, Oracle, DM, etc.; then, the data synchronization component calls the Hadoop HDFS toolkit to call the HDFS encapsulation common base class method, and specifically, the Hadoop HDFS toolkit executes the HDFS encapsulation common base class method, and first records the method execution time and data encapsulation information corresponding to the data group to the metadata database, which may be stored in the form of two data tables, such as a task status table and a task file table. The task status table may record the current status of the data file (success, failure, or being written), the task identifier, the data synchronization component type, etc., and the task file table may record the execution time, path, etc. Then, the data group is encapsulated, which may specifically include file creation, file movement, file renaming, file deletion, etc., and the Hadoop HDFS toolkit operates HDFS to write the encapsulated data file to the target path of HDFS.
[0107] The atomic maintenance service mainly includes detecting the task status and performing atomic maintenance after the task fails. Specifically, the atomic maintenance service periodically asks the data synchronization component about the execution status (success or failure) of the current data synchronization task. If it fails, the execution time and data encapsulation information recorded in the metadata database for this task are read, and the files in HDFS are rolled back according to the execution time and data encapsulation information, that is, the corresponding valid files are deleted (which may include data files, temporary files, and intermediate calculation files that have not been deleted), and finally the execution time and data encapsulation information recorded in this task in the metadata database are deleted.
[0108] Based on the same inventive concept, the present application embodiment also provides a rollback device for a data synchronization task. Figure 5 As shown, it is a structural schematic diagram of a rollback device for a data synchronization task, which may include:
[0109] A grouping unit 501 is used to group at least one data to be synchronized obtained from a source database based on a data synchronization component to obtain at least one data group to be synchronized; each data group contains data with the same target path;
[0110] The execution unit 502 is used to call and execute the data encapsulation method based on the data synchronization component for any data group, wherein the execution unit 502 includes: a recording subunit 5021 and an encapsulation subunit 5022. Each execution of the data encapsulation method includes the following steps:
[0111] The recording subunit 5021 is used to record the execution time of the data encapsulation method and the data encapsulation information;
[0112] The encapsulation subunit 5022 is used to encapsulate any data group into a corresponding data file, and store the data file in a target storage system based on a target path corresponding to the data in the data file;
[0113] The detection unit 503 is used to periodically detect the data synchronization task status for at least one data to be synchronized, and if the data synchronization task status indicates that the task has failed, read the recorded execution time and data encapsulation information;
[0114] The deleting unit 504 is used to delete the data files written into the target storage system based on the recorded execution time and data encapsulation information.
[0115] Optionally, if the data synchronization component is the first data synchronization component, the data encapsulation information includes a target path of the data included in the data group;
[0116] The encapsulation subunit 5022 is specifically used for:
[0117] Create a data file corresponding to any data group under the target path of the data contained in any data group;
[0118] The deleting unit 504 is specifically used for:
[0119] Under the target path of the data included in each data group, based on the recorded execution time, a deletion operation is performed on the data files written in the target storage system.
[0120] Optionally, if the data synchronization component is a second data synchronization component, the data encapsulation information includes a target path and a temporary path of the data included in the data group;
[0121] The encapsulation subunit 5022 is specifically used for:
[0122] Under the temporary path of the data contained in any data group, create a temporary file corresponding to any data group;
[0123] Move the temporary file to the target path of the data contained in a data group to obtain the data file corresponding to any data group;
[0124] The deleting unit 504 is specifically used for:
[0125] Based on the recorded execution time, the data files written in the target storage system are deleted at the target path of the data contained in each data group, and the temporary files written in the target storage system are deleted at the temporary path of the data contained in each data group.
[0126] Optionally, if the data synchronization component is a third data synchronization component, the data encapsulation information includes a target path and a temporary path of the data included in the data group;
[0127] The encapsulation subunit 5022 is specifically used for:
[0128] Under the target path of the data contained in any data group, a data file corresponding to any data group is created, and an intermediate calculation file generated when the encapsulation operation of any data group is executed is stored under the temporary path of the data contained in any data group;
[0129] The deleting unit 504 is specifically used for:
[0130] Based on the recorded execution time, the data files written in the target storage system are deleted at the target path of the data contained in each data group, and the intermediate calculation files written in the target storage system are deleted at the temporary path of the data contained in each data group.
[0131] Optionally, the deleting unit 504 is further configured to:
[0132] After the data file written in the target storage system is deleted, the recorded execution time and data encapsulation information are deleted.
[0133] After introducing the rollback method and device for a data synchronization task according to an exemplary embodiment of the present application, next, an electronic device according to another exemplary embodiment of the present application is introduced.
[0134] Those skilled in the art will appreciate that various aspects of the present application may be implemented as a system, method or program product. Therefore, various aspects of the present application may be specifically implemented in the following forms, namely: a complete hardware implementation, a complete software implementation (including firmware, microcode, etc.), or a combination of hardware and software, which may be collectively referred to as "circuit", "module" or "system" herein.
[0135] Based on the same inventive concept as the above method embodiment, an electronic device is also provided in the embodiment of the present application. In one embodiment, the electronic device may be a server, such as Figure 1 In this embodiment, the structure of the electronic device can be as follows: Figure 6 As shown, it includes a memory 601 , a communication module 603 and one or more processors 602 .
[0136] The memory 601 is used to store computer programs executed by the processor 602. The memory 601 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and programs required for running the instant messaging function, etc.; the data storage area may store various instant messaging information and operation instruction sets, etc.
[0137] The memory 601 may be a volatile memory, such as a random-access memory (RAM); the memory 601 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD); or the memory 601 may be any other medium that can be used to carry or store a desired computer program in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 601 may be a combination of the above memories.
[0138] The processor 602 may include one or more central processing units (CPU) or a digital processing unit, etc. The processor 602 is used to implement the rollback method of the above data synchronization task when calling the computer program stored in the memory 601 .
[0139] The communication module 603 is used to communicate with terminal devices and other servers.
[0140] The specific connection medium between the memory 601, the communication module 603 and the processor 602 is not limited in the embodiment of the present application. Figure 6 In the embodiment, the memory 601 and the processor 602 are connected via a bus 604. The bus 604 is connected to the processor 602 via a bus 604. Figure 6 The connections between the other components are only for illustration and are not intended to be limiting. The bus 604 can be divided into an address bus, a data bus, a control bus, etc. For ease of description, Figure 6 The diagram shows that only one thick line is used, but this does not mean that there is only one bus or only one type of bus.
[0141] The memory 601 stores a computer storage medium, and the computer storage medium stores computer executable instructions, and the computer executable instructions are used to implement the rollback method of the data synchronization task in the embodiment of the present application. The processor 602 is used to execute the rollback method of the data synchronization task, such as Figure 2 shown.
[0142] In some possible implementations, various aspects of the rollback method for a data synchronization task provided by the present application may also be implemented in the form of a program product, which includes a computer program. When the program product is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of the rollback method for a data synchronization task according to various exemplary implementations of the present application described above in this specification. For example, the electronic device may execute the following steps: Figure 2 Follow the steps shown in .
[0143] The program product may use any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of readable storage media (a non-exhaustive list) include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0144] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0145] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0146] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0147] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0148] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A rollback method for a data synchronization task. It is characterized in that The method comprises: Based on the data synchronization component, at least one data to be synchronized obtained from the source database is grouped to obtain at least one data group to be synchronized; the target path of the data contained in each data group is the same; For any data group, the data encapsulation method is called and executed based on the data synchronization component, wherein each execution of the data encapsulation method includes the following steps: Recording the execution time of the data encapsulation method and data encapsulation information; Encapsulating any one of the data groups into a corresponding data file, and based on a target path corresponding to the data in the data file, storing the data file in a target storage system; Periodically detect the data synchronization task status for the at least one data to be synchronized, and if the data synchronization task status indicates a task failure, read the recorded execution time and data encapsulation information; based on the recorded execution time and data encapsulation information, delete the data files written in the target storage system.
2. The method according to claim 1, It is characterized in that If the data synchronization component is the first data synchronization component, the data encapsulation information includes a target path of the data included in the data group; The encapsulating any one of the data groups into a corresponding data file, and storing the data file in a target storage system based on a target path corresponding to the data in the data file, comprises: Creating a data file corresponding to the arbitrary data group under the target path of the data included in the arbitrary data group; The deleting operation on the data file written in the target storage system based on the recorded execution time and data encapsulation information includes: Under the target path of the data included in each data group, based on the recorded execution time, a deletion operation is performed on the data files written in the target storage system.
3. The method according to claim 1, It is characterized in that If the data synchronization component is a second data synchronization component, the data encapsulation information includes a target path and a temporary path of the data included in the data group; The encapsulating any one of the data groups into a corresponding data file, and storing the data file in a target storage system based on a target path corresponding to the data in the data file, comprises: Creating a temporary file corresponding to the arbitrary data group under the temporary path of the data included in the arbitrary data group; Moving the temporary file to the target path of the data contained in the one data group to obtain a data file corresponding to the arbitrary one data group; The deleting operation on the data file written in the target storage system based on the recorded execution time and data encapsulation information includes: Based on the recorded execution time, a deletion operation is performed on the data files written in the target storage system at the target path of the data contained in each data group, and a deletion operation is performed on the temporary files written in the target storage system at the temporary path of the data contained in each data group.
4. The method according to claim 1, It is characterized in that If the data synchronization component is a third data synchronization component, the data encapsulation information includes a target path and a temporary path of the data included in the data group; The encapsulating any one of the data groups into a corresponding data file, and storing the data file in a target storage system based on a target path corresponding to the data in the data file, comprises: Under the target path of the data included in the arbitrary data group, a data file corresponding to the arbitrary data group is created, and an intermediate calculation file generated when the encapsulation operation of the arbitrary data group is executed is stored under the temporary path of the data included in the arbitrary data group; The deleting operation on the data file written in the target storage system based on the recorded execution time and data encapsulation information includes: Based on the recorded execution time, a deletion operation is performed on the data files written in the target storage system at the target path of the data contained in each data group, and a deletion operation is performed on the intermediate calculation files written in the target storage system at the temporary path of the data contained in each data group.
5. The method according to any one of claims 1 to 4, It is characterized in that After the data file written in the target storage system is deleted, the method further includes: The recorded execution time and data encapsulation information is deleted.
6. A rollback device for a data synchronization task, It is characterized in that include: A grouping unit, configured to group at least one data to be synchronized obtained from a source database based on a data synchronization component to obtain at least one data group to be synchronized; each data group contains data having the same target path; The execution unit is used to call and execute the data encapsulation method based on the data synchronization component for any data group, wherein each execution of the data encapsulation method includes the following steps: Recording the execution time of the data encapsulation method and data encapsulation information; Encapsulating any one of the data groups into a corresponding data file, and based on a target path corresponding to the data in the data file, storing the data file in a target storage system; a detection unit, configured to periodically detect a data synchronization task status for the at least one data to be synchronized, and read the recorded execution time and data encapsulation information if the data synchronization task status indicates that the task has failed; The deleting unit is used to delete the data files written in the target storage system based on the recorded execution time and data encapsulation information.
7. An electronic device, It is characterized in that It comprises a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor executes the steps of any one of the methods of claims 1 to 5.
8. A computer-readable storage medium, It is characterized in that It comprises a computer program. When the computer program is run on an electronic device, the computer program is used to enable the electronic device to execute the steps of any one of the methods of claims 1 to 5.
9. A computer program product, It is characterized in that The method comprises a computer program stored in a computer-readable storage medium; when a processor of an electronic device reads the computer program from the computer-readable storage medium, the processor executes the computer program, so that the electronic device executes the steps of any one of the methods described in claims 1 to 5.
