CN-117312456-B - Data synchronization method, device, equipment and storage medium
Abstract
The application discloses a data synchronization method, a device, equipment and a storage medium, and relates to the technical field of data synchronization. The method comprises the steps of obtaining a data synchronization request of a target service, generating a sending packet based on the data synchronization request, generating first tracking information according to a local service call path of the sending packet, adding the first tracking information into the sending packet to obtain the target sending packet, sending the target sending packet to a data synchronization system of a target terminal, obtaining a response packet fed back by the target terminal based on the target sending packet, extracting second tracking information from the response packet, and generating the second tracking information according to the service call path of the target sending packet by the target terminal. Path tracking in the data synchronization process can be realized.
Inventors
- ZHOU YONGXIANG
- XUE FEI
- HUANG GANG
- ZHOU SHENGQIANG
Assignees
- 苏州万店掌网络科技有限公司
Dates
- Publication Date
- 20260508
- Application Date
- 20231027
Claims (7)
- 1. A data synchronization method, applied to a data synchronization system, comprising: acquiring a data synchronization request of a target service, and generating a sending packet based on the data synchronization request, wherein the sending packet is stored on a data transmission carrier in a data synchronization system; Generating first tracking information according to a local service call path of the sending packet, adding the first tracking information into the sending packet to obtain a target sending packet, and sending the target sending packet to a data synchronization system of a target terminal; Acquiring a response packet fed back by the target terminal based on the target sending packet, and extracting second tracking information from the response packet, wherein the second tracking information is generated by the target terminal according to a service calling path of the target sending packet in a data synchronization system of the target terminal; generating a tracking information packet corresponding to the data synchronization request based on the first tracking information and the second tracking information; The generating the first tracking information according to the local service call path of the sending packet includes: the local service comprises command execution service, connection service, heartbeat service, sending service and encryption and decryption service; recording first transfer information and first persistence information related to the sending packet after calling the local service; recording second interface information called by the sending packet to an external interface; Generating the first tracking information based on the first interface information, the first relay information, the first persistence information, and the second interface information; before the data synchronization request of the target service is obtained, the method further comprises: Intercepting abstract syntax trees generated in the compiling process of all original services through probes, and extracting configuration information from the abstract syntax trees to obtain configuration information corresponding to each original service; Filtering the original service according to the configuration information, and screening out a target original service with a synchronous requirement; Adding a data synchronous calling program into a service code of the target original service by utilizing a byte code rewriting technology to obtain the target service; wherein the generating, based on the first trace information and the second trace information, a trace information packet corresponding to the data synchronization request includes: generating a tracking information packet corresponding to the data synchronization request by combining the first tracking information and the second tracking information; judging whether the data of the target service is successfully synchronized at the target terminal according to the calling result information in the second tracking information; And if the synchronization is successful, modifying the state of the sending packet into a finished state, otherwise, retransmitting the sending packet.
- 2. The data synchronization method according to claim 1, wherein the data synchronization system for transmitting the target transmission packet to the target terminal comprises: backing up the target sending packet; Encrypting the target sending packet by using an encryption and decryption service according to encryption and decryption rules locally agreed with the target terminal to obtain an encrypted sending packet; and transmitting the encrypted transmission packet to a data synchronization system of the target terminal by using network connection with the target terminal.
- 3. The data synchronization method according to claim 1, wherein after the data synchronization system that transmits the target transmission packet to the target terminal, further comprising: The data synchronization system of the target terminal analyzes the target sending packet by utilizing an analyzer to obtain a command to be executed stored in the target sending packet; And executing the command to be executed by calling a command execution service to execute data synchronization, and generating the response packet according to a data synchronization result.
- 4. The method of claim 1, wherein the second trace information includes third interface information invoked by the target sending packet for the target terminal service, second transit information and second persistence information related to the target sending packet after invoking the target terminal service, and fourth interface information invoked by the target sending packet for the external interface.
- 5. A data synchronization device, for use in a data synchronization system, comprising: the system comprises a sending packet generation module, a sending packet generation module and a sending packet generation module, wherein the sending packet generation module is used for acquiring a data synchronization request of a target service and generating a sending packet based on the data synchronization request; The tracking information generation module is used for generating first tracking information according to a local service call path of the sending packet, adding the first tracking information into the sending packet to obtain a target sending packet, and sending the target sending packet to a data synchronization system of a target terminal; The system comprises a tracking information extraction module, a target terminal and a target terminal, wherein the tracking information extraction module is used for acquiring a response packet fed back by the target terminal based on the target transmission packet and extracting second tracking information from the response packet; the tracking information packet generation module is used for generating a tracking information packet corresponding to the data synchronization request based on the first tracking information and the second tracking information; The tracking information generation module is used for recording first interface information called by the sending packet to local service, wherein the local service comprises command execution service, connection service, heartbeat service, sending service and encryption and decryption service, recording first transfer information and first persistence information related to the sending packet after the sending packet calls the local service, recording second interface information called by the sending packet to an external interface, and generating the first tracking information based on the first interface information, the first transfer information, the first persistence information and the second interface information; wherein the data synchronization device is further configured to, before acquiring the data synchronization request of the target service, Intercepting abstract syntax trees generated in the compiling process of all original services through probes, extracting configuration information from the abstract syntax trees to obtain configuration information corresponding to each original service, filtering the original services according to the configuration information, screening out target original services with synchronous requirements, adding a data synchronous calling program into service codes of the target original services by utilizing a byte code rewriting technology to obtain the target services, wherein the target services can call interfaces of the data synchronous system; The tracking information packet generation module is used for generating a tracking information packet corresponding to the data synchronization request by combining the first tracking information and the second tracking information, judging whether the data of the target service are successfully synchronized at the target terminal according to the calling result information in the second tracking information, and if so, modifying the state of the sending packet into a finished state, otherwise, resending the sending packet.
- 6. An electronic device, comprising: A memory for storing a computer program; A processor for executing the computer program to implement the data synchronization method of any one of claims 1 to 4.
- 7. A computer readable storage medium for storing a computer program, wherein the computer program when executed by a processor implements the data synchronization method according to any one of claims 1 to 4.
Description
Data synchronization method, device, equipment and storage medium Technical Field The present invention relates to the field of data synchronization technologies, and in particular, to a data synchronization method, apparatus, device, and storage medium. Background Currently, data synchronization is generally directly used for synchronization between databases, and in many cases, there is a need for data synchronization for services between different scenes or areas. In the prior art, the dubbo interface is used for calling interfaces of other areas to perform synchronization, but the tracing of the data synchronization process after the calling cannot be realized. Therefore, how to implement path tracing of data synchronization is a technical problem to be solved. Disclosure of Invention In view of the above, the present invention aims to provide a data synchronization method, apparatus, device and medium, which can implement path tracking in the data synchronization process. The specific scheme is as follows: in a first aspect, the present application discloses a data synchronization method, including: Acquiring a data synchronization request of a target service, and generating a sending packet based on the data synchronization request; Generating first tracking information according to a local service call path of the sending packet, adding the first tracking information into the sending packet to obtain a target sending packet, and sending the target sending packet to a data synchronization system of a target terminal; acquiring a response packet fed back by the target terminal based on the target sending packet, and extracting second tracking information from the response packet, wherein the second tracking information is generated by the target terminal according to a service calling path of the target sending packet at the target terminal; And generating a tracking information packet corresponding to the data synchronization request based on the first tracking information and the second tracking information. Optionally, before the obtaining the data synchronization request of the target service, the method includes: Intercepting abstract syntax trees generated in the compiling process of all original services through probes, and extracting configuration information from the abstract syntax trees to obtain configuration information corresponding to each original service; Filtering the original service according to the configuration information, and screening out a target original service with a synchronous requirement; And adding a data synchronization calling program into the service code of the target original service by utilizing the byte code rewriting technology to obtain the target service, wherein the target service can call an interface of the data synchronization system. Optionally, the data synchronization system for sending the target sending packet to the target terminal includes: backing up the target sending packet; Encrypting the target sending packet by using an encryption and decryption service according to encryption and decryption rules locally agreed with the target terminal to obtain an encrypted sending packet; and transmitting the encrypted transmission packet to a data synchronization system of the target terminal by using network connection with the target terminal. Optionally, after the data synchronization system that sends the target sending packet to the target terminal, the method further includes: The data synchronization system of the target terminal analyzes the target sending packet by utilizing an analyzer to obtain a command to be executed stored in the target sending packet; And executing the command to be executed by calling a command execution service to execute data synchronization, and generating the response packet according to a data synchronization result. Optionally, the generating the first trace information according to the service call path of the local sending packet includes: recording first interface information of the sending packet for calling the local service; recording first transfer information and first persistence information related to the sending packet after calling the local service; recording second interface information called by the sending packet to an external interface; The first tracking information is generated based on the first interface information, the first relay information, the first persistence information, and the second interface information. Optionally, the second tracking information comprises third interface information called by the target sending packet on the target terminal service, second transfer information and second persistence information related to the target sending packet after the target sending packet calls the target terminal service, and fourth interface information called by the target sending packet on an external interface. Optionally, the generating, based on the first trace information and the sec