A method and device for synchronizing data between network services
By realizing data synchronization at the network service level and using atomic transactions and token mechanisms, the data synchronization problem of heterogeneous storage solutions is solved, the atomicity and consistency of data is achieved, and resource occupation and business transformation costs are reduced.
Patent Information
- Application Number
- CN202211695813.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-28
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2042-12-28
AI Technical Summary
When synchronizing data between network services in the prior art, it is difficult to realize data synchronization of heterogeneous storage solutions, and the distributed transaction solutions have problems such as long resource occupation time and high service transformation costs.
By implementing data synchronization at the network service level, the service node and the trusted node each perform storage implementation, and data synchronization is performed using atomic transactions and token mechanisms to ensure that the data is updated synchronously in the trusted node after the service node is updated.
The data synchronization of heterogeneous data storage is realized, ensuring the atomicity and consistency of the data, and reducing resource occupation and business transformation costs.
Smart Images

Figure CN116132453B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method and device for synchronizing data between network services. Background Art
[0002] In the prior art, data synchronization between two network services is a very common requirement, and the atomicity and consistency of data synchronization need to be guaranteed. Existing data synchronization solutions include database synchronization solutions and distributed transaction solutions. For example, in the database synchronization solution, synchronization is performed directly at the database level. Almost every database has a corresponding data synchronization tool. However, the limitation of the database synchronization solution is that the two network services need to use the same type of database, and heterogeneous storage solutions are not supported. The synchronization party needs to be able to obtain read permissions for the two databases, and permission isolation cannot be performed. In the distributed transaction solution, distributed transaction solutions such as XA solution, TCC solution, 2PC solution, 3PC solution, etc. can also be used for data synchronization between services, but the XA solution is at the database level and requires both databases to implement the XA protocol. The 2PC / 3PC solution is also at the database level and takes a long time to occupy resources. The TCC solution has a large cost for business transformation on both sides and needs to implement Try, Commit and Cancel interfaces for one operation. Therefore, how to demand a method that can meet the data synchronization between network services has become the main research topic in the industry. Summary of the invention
[0003] One purpose of the present application is to provide a method and device for data synchronization between network services, which realizes data synchronization at the network service level. It is not targeted at a certain type of storage engine. The synchronized service nodes and trusted nodes can each perform storage implementation, and can achieve data synchronization of heterogeneous data storage, ensuring that data updated at the service node can be synchronously updated at the trusted node.
[0004] According to one aspect of the present application, a method for synchronizing data between network services is provided, which is applied to a service node, wherein the method includes:
[0005] In response to successful verification and authentication of the data change request initiated by the requesting end, executing a change operation corresponding to the operation-related data in the data change request in a function using an atomic transaction to obtain a change result;
[0006] In response to the successful execution of the change operation, the token corresponding to the operation-related data is carried and a data synchronization request is sent to the synchronization interface of the trusted node, so that the trusted node verifies whether the token is valid through the token consumption interface. If so, the stored operation-related data corresponding to the token is retrieved and then the synchronization operation corresponding to the retrieved operation-related data corresponding to the token is executed;
[0007] Receiving operation success response information returned by the trusted node in response to successful execution of the synchronization operation;
[0008] In response to the operation success response information, committing the change result as a transaction in the function using the atomic transaction;
[0009] Returning the operation success response information to the requesting end or the trusted node, so that the trusted node sends the operation success response information to the requesting end;
[0010] Wherein, the method further comprises:
[0011] Receiving operation failure response information returned by the trusted node in response to failure of executing the synchronization operation;
[0012] In response to the operation failure response information, performing a transaction rollback or compensation operation on the change operation in the function using the atomic transaction;
[0013] The operation failure response information is returned to the requesting end or the trusted node, so that the trusted node sends the operation success response information to the requesting end.
[0014] According to another aspect of the present application, a method for synchronizing data between network services is also provided, which is applied to a trusted node, wherein the method includes:
[0015] Receiving, through a synchronization interface, a data synchronization request initiated by a service node in response to a successful execution of a change operation and carrying a token corresponding to operation-related data, wherein the service node executes a change operation corresponding to the operation-related data in the data change request in response to successful verification and authentication of the data change request initiated by the requesting end;
[0016] Verify whether the token is valid. If so, retrieve the stored operation-related data corresponding to the token, delete the token or mark it invalid, and then execute the synchronization operation corresponding to the retrieved operation-related data corresponding to the token in the function using the atomic transaction;
[0017] In response to the synchronization operation being successfully executed, returning operation success response information to the service node, so that the service node returns the operation success response information to the request end after submitting the change result in the function using the atomic transaction in response to the operation success response information;
[0018] Wherein, the method further comprises:
[0019] In response to failure of the synchronization operation, operation failure response information is returned to the service node, so that the service node performs a transaction rollback or compensation operation on the change operation in the function using the atomic transaction in response to the operation failure response information.
[0020] According to another aspect of the present application, a method for synchronizing data between network services is also provided, which is applied to a trusted node, wherein the method includes:
[0021] Receiving, through a synchronization interface, a data synchronization request initiated by a service node in response to a successful execution of a change operation and carrying a token corresponding to operation-related data, wherein the service node executes a change operation corresponding to the operation-related data in the data change request in response to successful verification and authentication of the data change request initiated by the requesting end;
[0022] Verifying whether the token is valid, and if so, retrieving stored operation-related data corresponding to the token;
[0023] executing, in the function using the atomic transaction, a synchronization operation corresponding to the retrieved operation-related data corresponding to the token;
[0024] In response to the synchronization operation being successfully executed, returning operation success response information to the service node, so that the service node commits the change result as a transaction in the function using the atomic transaction in response to the operation success response information;
[0025] In response to receiving the operation success response information returned by the service node, sending the operation success response information to the requesting end;
[0026] Wherein, the method further comprises:
[0027] In response to failure of execution of the synchronization operation, returning operation failure response information to the service node, so that the service node performs a transaction rollback or compensation operation on the change operation in the function using the atomic transaction in response to the operation failure response information;
[0028] In response to receiving the operation failure response information returned by the service node, the operation failure response information is sent to the requesting end.
[0029] According to another aspect of the present application, a non-volatile storage medium is provided, on which computer-readable instructions are stored. When the computer-readable instructions can be executed by a processor, the processor implements the data synchronization method between network services as described above.
[0030] According to another aspect of the present application, a service node for data synchronization between network services is also provided, the service node comprising:
[0031] one or more processors;
[0032] A computer readable medium for storing one or more computer readable instructions,
[0033] When the one or more computer-readable instructions are executed by the one or more processors, the one or more processors implement the data synchronization method between network services at the service node end as described above.
[0034] According to another aspect of the present application, a trusted node for data synchronization between network services is also provided, the trusted node comprising:
[0035] one or more processors;
[0036] A computer readable medium for storing one or more computer readable instructions,
[0037] When the one or more computer-readable instructions are executed by the one or more processors, the one or more processors implement the above-mentioned data synchronization method between trusted node-side network services.
[0038] Compared with the prior art, the present application adopts the logical coordination between the requesting end, the trusted node and the service node. The service node responds to the successful verification and authentication of the data change request initiated by the requesting end, and executes the change operation corresponding to the operation-related data in the data change request in the function using the atomic transaction to obtain the change result; and in response to the successful execution of the change operation, the token corresponding to the operation-related data is carried, and a data synchronization request is sent to the synchronization interface of the trusted node, so that the trusted node verifies whether the token is valid through the token consumption interface. If so, the stored operation-related data corresponding to the token is retrieved, and the synchronization operation corresponding to the retrieved operation-related data corresponding to the token is executed, and an operation success response message is returned to the service node; the service node receives the operation success response message returned by the trusted node in response to the successful execution of the synchronization operation; and in response to the operation success response message, the change result is submitted as a transaction in the function using the atomic transaction, and the operation success response message is returned to the requesting end or the trusted node, so that the trusted node sends the operation success response message to the requesting end. It realizes data synchronization at the network service level, and can support the use of different storage engines by the synchronized service nodes and trusted nodes. Both can implement storage, and can achieve the purpose of data synchronization of heterogeneous data storage. At the same time, the atomic transaction function is used to ensure the atomicity and data consistency of the data updated at the service node can be synchronized with the trusted node. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Other features, objects and advantages of the present application will become more apparent by reading the detailed description of non-limiting embodiments made with reference to the following drawings:
[0040] Figure 1 A schematic flow chart of a method for synchronizing data between network services according to one aspect of the present application is shown.
[0041] The same or similar reference numerals in the drawings represent the same or similar components. DETAILED DESCRIPTION
[0042] The present application is described in further detail below in conjunction with the accompanying drawings.
[0043] In a typical configuration of the present application, the terminal, the device of the service network and the trusted party all include one or more processors (CPU), input / output interfaces, network interfaces and memories.
[0044] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0045] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include non-transitory media such as modulated data signals and carrier waves.
[0046] In all embodiments of a data synchronization method between network services provided by the present application, it is applied to a trusted node, a service node, and a requesting end with a requesting program installed, wherein the trusted node is another network service trusted by the requesting end corresponding to the requesting program and the service node of the network service to be accessed, and there is a trust of authority established between the service node and the trusted node, so that the trusted node can provide authorization for the network request initiated to the service node; the service node is the node where the target network service to access resources or perform operations is located; the requesting program can be a client program, a network service or a requesting script program, etc., a computer program with the ability to send network requests, and the requesting program can be triggered by a user operation to make a network request, or it can initiate a network request according to the program logic, and the requesting program is installed on the requesting end. It should be noted that the synchronization in all embodiments of the present application can be that the data in the data storage of the two synchronized parties is exactly the same, or it can be that for the data to be synchronized, it can ensure that the original data obtained by both parties is consistent, and both parties can perform different parsing, processing and storage of the data according to actual needs.
[0047] In a data synchronization method between network services provided in the present application, the trusted node provides at least a token production interface, a token consumption interface and a synchronization interface, wherein the token production interface is used to receive information parameters of a target network request, and stores and generates a token together with information such as the visitor's identity identification; the token consumption interface is used to receive a token, and retrieve the information parameters and identity identification of the target network request corresponding to the token from the storage; the trusted node needs to provide a corresponding synchronization request synchronization interface for all network requests that need to be synchronized, that is, the service node can be mapped to all requests that need to be synchronized. A corresponding synchronization interface of the synchronization operation is obtained through a mapping or function relationship. For example, assuming that the interface address of the service node is [S-API] and the interface address of the trusted node is [M-API], then: the change operation of adding a user: POST[S-API] / admin, the corresponding synchronization request can be POST[M-API] / add_admin, the change operation of changing user permissions: PATCH[S-API] / admin, the corresponding synchronization request can be POST[M-API] / alter_admin, so that the operation of the corresponding steps in the process of a data synchronization method between network services provided by this application is implemented through the synchronization interface of the trusted node. At the same time, the service node also has an interface for processing verification and authentication and a change interface for data change and synchronization. The service node needs to provide a change interface for each type of data that needs to be changed, such as an interface for adding users in the service node, an interface for changing user permissions, etc. If this type of data needs to be synchronized with the trusted node, it needs to be executed according to the corresponding steps in the process of a data synchronization method between network services provided by this application. All of the interfaces of the above trusted nodes and service nodes need to be open in the network and given an interface address so that a network request is sent to the interface address when requesting the corresponding interface involved in the embodiments of the present application.
[0048] The data synchronization method between network services provided by the embodiment of the present application has two implementation modes in different practical application scenarios, namely, non-proxy mode and proxy mode. First, no matter which implementation mode is adopted, the trusted node needs to provide a secure access protocol (such as HTTPS) to ensure that the requesting program and the service node can safely request it, and the trusted node needs to be able to authenticate the requesting program installed in the requesting end. The situation can be: if the requesting program is a user, the user has logged in at the trusted node, and the credentials of the logged-in user will be carried in the request sent to the trusted node, so that the trusted node can obtain the identity and authority of the requested user; if the requesting program is a service, the service identifier or the service identifier and key (in order to enhance security through the key) need to be carried in the request sent to the trusted node, so that the trusted node can obtain the identity and authority of the requested service. After these two conditions are met, the key or credentials carried in the request sent by the requesting program to the trusted node will be recognized by the trusted node as a valid visitor, and after the verification and authentication of the request are passed, the data is changed at the service node to initiate the synchronization of the corresponding data at the trusted node. In proxy mode, in some communication situations, the requester cannot establish a secure connection with the service node, such as the service node cannot provide secure protocol access, but the trusted node can access the service node; for example, the service node is in a local area network, but has no public network address, and the trusted node is also in the local area network but has a public network address. The requester with the request program installed is not connected to the local area network, so that the requester cannot access the service node. In these two cases, the trusted node can be used as a request agent for the requester with the request program installed, thereby ensuring the feasibility and security of the requester's request, but the proxy mode needs to satisfy the trusted node can access the service node. In other cases, non-proxy mode requests are used by default, but proxy mode can also be selected (or configured by the administrator) for requests.
[0049] Taking the non-proxy mode as an example, a data synchronization method between network services provided by the present application is further explained, including a service node, a trusted node and a requesting end with a requesting program installed, including steps S11 and S12 executed by the requesting end through the requesting program, steps S21 to S25 executed by the service node and steps S31 to S34 executed by the trusted node, specifically including the following steps:
[0050] Step S11 (not shown), the requesting end initiates a data change request in response to obtaining the change operation required by the visitor, so that the trusted node trusted by the requesting end and the corresponding service node verify and authenticate the data change request.
[0051] In step S21 (not shown), in response to successful authentication of the data change request initiated by the requesting end, the service node executes the change operation corresponding to the operation-related data in the data change request in the function using the atomic transaction to obtain the change result.
[0052] The function using the atomic transaction may be used to represent a series of steps, including but not limited to starting a transaction, committing a transaction, rolling back a transaction, or performing a compensation operation.
[0053] In step S22 (not shown), in response to the successful execution of the change operation, the service node carries the token corresponding to the operation-related data and sends a data synchronization request to the synchronization interface of the trusted node, so that the trusted node verifies whether the token is valid through the token consumption interface. If so, the stored operation-related data corresponding to the token is retrieved, and the synchronization operation corresponding to the retrieved operation-related data corresponding to the token is executed.
[0054] In step S31 (not shown), the trusted node receives, through the synchronization interface, a data synchronization request initiated by the service node in response to a successful execution of a change operation and carrying a token corresponding to the operation-related data, wherein the service node executes a change operation corresponding to the operation-related data in the data change request in response to successful verification and authentication of the data change request initiated by the requesting end.
[0055] Step S32 (not shown), the trusted node verifies whether the token is valid through the token consumption interface, and if so, retrieves the stored operation-related data corresponding to the token and returns it to the service node. Here, the trusted node only needs to directly execute the function logic of the token consumption interface.
[0056] Step S33 (not shown), the trusted node executes a synchronization operation corresponding to the retrieved operation-related data corresponding to the token in the function using the atomic transaction.
[0057] Step S34 (not shown), in response to the successful execution of the synchronization operation, the trusted node returns an operation success response message to the service node, so that the service node submits the change result as a transaction in the function using the atomic transaction in response to the operation success response message. Here, the issuance of the operation success response message is used to indicate that both the change operation of the service node and the synchronization operation of the trusted node are successful.
[0058] Step S23 (not shown), the service node receives operation success response information returned by the trusted node in response to successful execution of the synchronization operation.
[0059] Step S24 (not shown), in response to the operation success response information, the service node commits the change result in the function using the atomic transaction.
[0060] In step S25 (not shown), the service node returns the operation success response information to the requesting end.
[0061] Step S12 (not shown), the requesting end receives the operation success response information returned by the service node in response to submitting the change result in the function using the atomic transaction.
[0062] Through the above steps S11 to S12, S21 to S25 and S31 to S34, in non-proxy mode, after the service node successfully verifies and authenticates the initiated data synchronization request, the change operation corresponding to the operation-related data in the data change request is executed in the function using atomic transactions, and the operation of synchronized data change is also initiated to the trusted node, and when the synchronized change operation at the trusted node is also successful, the service node feeds back the operation success response information to the requesting end, so that the requesting end can understand that the data that needs to be changed has been synchronously changed in both the service node and the trusted node, thereby realizing data synchronization at the network service level, and can support the synchronized service node and the trusted node to use different storage engines, and can both perform storage, so as to achieve the purpose of data synchronization of heterogeneous data storage, and at the same time use the function of atomic transactions to ensure the atomicity and data consistency of the data updated at the service node that can be synchronized and updated at the trusted node.
[0063] In this embodiment, after the trusted node executes step S33 (not shown) to perform a synchronization operation corresponding to the operation-related data corresponding to the token retrieved in the function using the atomic transaction, the trusted node may also experience a synchronization operation failure. When the synchronization operation performed by the trusted node fails, the trusted node returns operation failure response information to the service node in response to the failure of the synchronization operation, so that the service node performs a transaction rollback or compensation operation on the change operation in the function using the atomic transaction in response to the operation failure response information. After receiving the operation failure response information returned by the trusted node in response to the failure of the synchronization operation, in order to ensure that the data between the service node and the trusted node can maintain data synchronization consistency, the service node responds to the operation failure response information and performs a transaction rollback or compensation operation on the change operation in the function using atomic transactions, thereby achieving the goal of restoring the service node and the trusted node to an unchanged state when the synchronization operation fails, further ensuring data consistency and the atomicity of the change, and returning the operation failure response information to the requesting end, so that the requesting end can understand the change and synchronization failure through the received operation failure response information returned by the service node in response to the transaction rollback or compensation operation on the change operation in the function using atomic transactions, thereby achieving the purpose of notifying the requesting end.
[0064] Taking the proxy mode as an example, the data synchronization method between network services provided by the present application is further explained below, including a service node, a trusted node and a requesting end with a requesting program installed, including steps S101 and S102 executed by the requesting end through the requesting program, steps S21 to S25 executed by the service node and steps S31 to S34 executed by the trusted node, specifically including the following steps:
[0065] Step S101 (not shown), the requesting end initiates a data change request to the trusted node in response to obtaining the change operation required by the visitor, so that the trusted node trusted by the requesting end and the corresponding service node verify and authenticate the data change request, and the trusted node sends the data change request to the service node on behalf of the requesting end.
[0066] Steps S201 (not shown), step S202 (not shown), step S301 (not shown), step S302 (not shown), step S303 (not shown), step S304 (not shown), step S203 (not shown) and step S204 (not shown) executed in sequence respectively correspond to steps S21 (not shown), step S22 (not shown), step S31 (not shown), step S32 (not shown), step S33 (not shown), step S34 (not shown), step S23 (not shown), and step S24 (not shown) executed in sequence above, and are not repeated here.
[0067] Step S205 (not shown), the service node returns the operation success response information to the trusted node, so that the trusted node sends the operation success response information to the requesting end.
[0068] Step S305 (not shown), in response to receiving the operation success response information returned by the service node, the trusted node sends the operation success response information to the requesting end.
[0069] Step S102 (not shown), the requesting end receives the operation success response information received by the trusted node from the service node, wherein the service node returns the operation success response information to the trusted node in response to submitting the change result as a transaction in a function using an atomic transaction.
[0070] Through the above steps S011 to S102, S201 to S205 and S301 to S305, in the proxy mode, after the service node successfully verifies and authenticates the initiated data synchronization request, the change operation corresponding to the operation-related data in the data change request is executed in the function using the atomic transaction, and the operation of synchronized data change is also initiated to the trusted node, and when the synchronized change operation at the trusted node is also successful, the service node feeds back the operation success response information to the trusted node, and the trusted node returns the operation success response information to the requesting end, so that the forwarding of the trusted node is realized, so that the requesting end can understand that the data that needs to be changed has been synchronously changed in both the service node and the trusted node, and realizes data synchronization at the network service level. It can support the synchronized service node and the trusted node to use different storage engines, and both can perform storage, which can achieve the purpose of data synchronization of heterogeneous data storage, and at the same time, the function of atomic transactions is used to ensure the atomicity and data consistency of the data updated at the service node that can be synchronized and updated at the trusted node.
[0071] In this embodiment, after the trusted node executes step S303 (not shown) to perform the synchronization operation corresponding to the operation-related data corresponding to the token in the function using the atomic transaction, the synchronization operation of the trusted node may fail. When the synchronization operation performed by the trusted node fails, the trusted node returns operation failure response information to the service node in response to the failure of the synchronization operation, so that the service node performs a transaction rollback or compensation operation on the change operation in the function using the atomic transaction in response to the operation failure response information. In order to ensure that the data between the service node and the trusted node can maintain data synchronization consistency, the service node receives the response from the trusted node. After the operation failure response information is returned when the synchronization operation fails, in response to the operation failure response information, a transaction rollback or compensation operation is performed on the change operation in the function using the atomic transaction, thereby achieving that when the synchronization operation fails, the service node and the trusted node can also be restored to the unchanged state, further ensuring data consistency and the atomicity of the change, and returning the operation failure response information to the trusted node; the trusted node forwards the operation failure response information to the requesting end, so that the requesting end can understand the change and synchronization failure through the operation failure response information received by the trusted node from the service node, thereby achieving the purpose of notifying the requesting end.
[0072] In the present application, whether in non-proxy mode or proxy mode, in an embodiment of the present application for network service management, a data synchronization method between network services, when performing data synchronization, some data needs to be stored in both the management node M (i.e., trusted node) and the service node S, and the consistency of the data needs to be maintained, such as the key and key information of the service node (such as the standard interface address of the service node, etc.). Among them, the addition, deletion, and change of information such as the key and key information of the service node need to achieve data synchronization and consistency between the management node M (i.e., trusted node) and the service node S, and there are at least the following change operations: service registration, administrator addition, administrator deletion, administrator modification, administrator authority change, administrator management scope change (such as from managing one service to managing multiple services, from managing all clusters to managing only a few clusters, etc.), project ownership transfer (transfer from one administrator to another) and partial deletion of a project (deletion of a node, a service or a cluster) or deletion of the entire project, etc. The reason for keeping the data of these change operations synchronized is that a request can be verified and authenticated not only before authorization by the management node (i.e., the trusted node), but also before execution by the service node. Each end of the trusted node and the service node has complete authentication capabilities, which can doubly guarantee the security of the request.
[0073] In an embodiment of the present application, all data synchronization requests that meet idempotence (for example, the effect of executing once is consistent with executing multiple times) can be safely retried if synchronization fails due to network problems to ensure the atomicity of each retry.
[0074] In one embodiment provided by the present application, a data synchronization method between network services can ensure the data consistency and atomicity of changes of all requests that need to synchronize metadata between service nodes and management nodes (i.e., trusted nodes). The service nodes and management nodes either complete the changes together or restore to the unchanged state together. Among them, the operation of changing the management scope is a special data synchronization operation, because it can always be converted into one or more general data synchronization operations. For example, since the actual management scope of the administrator can always be represented as a series of service nodes, that is, the administrator has the management authority of these nodes, such as service nodes: (N1, N2, N3), etc., if it is necessary to change the management scope of the administrator to service nodes: (N2, N4), and change the administrator's authority on the N2 node, then after sorting, it can be classified into the following operations that each service node needs to perform:
[0075] N1: Delete the administrator
[0076] N2: Change administrator permissions
[0077] N3: Delete the administrator
[0078] N4: Adding an administrator
[0079] These management-related change operations are all applicable to the process of a data synchronization method between network services in an embodiment provided by the present application, and can be executed in parallel. Since the present application can ensure the consistency of synchronization operations, no matter which of these operations succeed or fail, the actual management scope of the administrator stored on the management node (i.e., the trusted node) is consistent with whether the nodes within these scopes actually store the administrator's information. That is, for a target management scope and the current actual management scope, a set of change operations can always be generated so that the actual management scope approaches and becomes the target management scope (assuming that the synchronization operation will eventually succeed after multiple retries), thereby ensuring data synchronization between the management node (i.e., the trusted node) and the service node. More generally, all data synchronization requests that meet idempotence (the effect of executing once is consistent with executing multiple times) can be safely retried if synchronization fails due to network and other problems. The present application can ensure the atomicity of each retry.
[0080] Following the above-mentioned embodiment of the present application, whether in non-proxy mode or proxy mode, a data synchronization method between network services provided by an embodiment of the present application also includes: before performing the change operation of the service node and the synchronization operation of the trusted node, it is also necessary to verify and authenticate the data synchronization request initiated by the requesting end to ensure the security of the data synchronization request initiated by the requesting end. The following is to verify and authenticate the data synchronization request initiated by the requesting end from the two aspects of non-proxy mode and proxy mode:
[0081] On the one hand, taking the non-proxy mode as an example, the verification and authentication of the data synchronization request in a data synchronization method between network services provided in an embodiment of the present application is further explained, including a service node, a trusted node and a requesting end with a requesting program installed. The verification and authentication of the data synchronization request in the non-proxy mode includes the following steps:
[0082] The requesting end sends a first request carrying the identity and authority credentials of the visitor who is to initiate the data synchronization request, the information parameters of the data synchronization request, and the identifier of the requested service node to the token production interface of the trusted node, so that the trusted node verifies whether the visitor has the authority to execute the data synchronization request in the service node. If so, a token is generated and sent to the requesting end, and the information parameters and the identity and authority credentials of the visitor are stored accordingly; wherein the information parameters include complete operation-related data.
[0083] Here, the identity and permission credentials may include but are not limited to the visitor's identity identification, permission credentials or credentials for querying the corresponding user identification, etc. The information parameters of the data synchronization request include but are not limited to the URL, request body, request header, request method and path of the data synchronization request. The request body includes the operation-related data, which includes but is not limited to the operation type, the specific operation corresponding to the operation type, the target operation object, and the state data of the operation that needs to be changed (such as adding, changing, deleting, etc.). For example, if user A1 wants to operate the access rights of user A2, then user A2 is the target operation object, the operation data is the data representing the access rights of A2, and user A1 is the sender of the request.
[0084] The trusted node receives, through a token production interface, a first request from a requesting end carrying the identity and authority credentials of a visitor who is to initiate a data synchronization request, information parameters of the data synchronization request, and an identifier of a requested service node.
[0085] The trusted node verifies whether the visitor has the authority to execute the data synchronization request in the service node. If so, a token is generated and sent to the requesting end, and the information parameters and the identity and authority credentials of the visitor are stored accordingly; wherein, after receiving the token, the requesting end carries the token and the identifier of the trusted node to initiate a data synchronization request to the interface address of the service node, so that the service node carries the token to send a second request to the token consumption interface corresponding to the identifier of the trusted node.
[0086] After receiving the token, the requesting end sends a data synchronization request to the service node carrying the token and the identifier of the trusted node, so that the service node responds to the data synchronization request and sends a second request to the token consumption interface corresponding to the identifier of the trusted node carrying the token; wherein the trusted node verifies whether the token is valid through the token consumption interface, and if so, retrieves the stored information parameters corresponding to the token and the identity and authority credentials of the visitor and returns them to the service node, so that the service node performs verification and authentication based on the validity response result of the token, the corresponding information parameters and the identity and authority credentials of the visitor.
[0087] Here, the validity response result of the token includes success response information for indicating that the token is valid or failure response information for indicating that the token is invalid.
[0088] The service node receives a data synchronization request sent by a requesting end carrying the token and the identifier of the trusted node through an interface address, wherein the token is generated by the trusted node after receiving a first request from the requesting end carrying the identity authority credentials of a visitor to initiate the data synchronization request, information parameters of the data synchronization request and the identifier of the requested service node through a token production interface, and when verifying that the visitor has the authority to execute the data synchronization request in the service node, wherein the information parameters include the operation-related data.
[0089] The service node carries the token and sends a second request to the token consumption interface corresponding to the identifier of the trusted node, so that the trusted node verifies whether the token is valid through the token consumption interface.
[0090] The trusted node receives the second request initiated by the service node carrying the token through the token consumption interface, verifies whether the token is valid, and if so, retrieves the stored information parameters corresponding to the token and the identity and authority credentials of the visitor and returns them to the service node, so that the service node performs verification and authentication based on the validity response result of the token, the corresponding information parameters and the identity and authority credentials of the visitor.
[0091] The service node receives the validity response result of the token, the information parameters corresponding to the token, and the identity authority certificate of the visitor returned by the trusted node.
[0092] The service node verifies and authenticates the validity response result of the token, the information parameters returned by the trusted node, and the identity and authority credentials of the visitor.
[0093] In this embodiment, after a data synchronization request is directly initiated to a service node through the requesting end in non-proxy mode, the trusted node provides authorization for the initiated data synchronization request. Since both the trusted node and the service node store the authority to authenticate the data synchronization request, the service node implements verification and authentication of the requested data synchronization request. Only when the verification and authentication are successful can the change operation corresponding to the operation-related data in the data synchronization request be executed through the service node, and the success or failure of the execution of the operation is directly returned to the requesting end, thereby realizing tamper-proofing and execution of illegal requests, thereby ensuring the security of all network requests related to data synchronization requests, and can be suitable for practical application scenarios with higher security requirements.
[0094] On the other hand, taking the proxy mode as an example, the verification and authentication of data synchronization requests in a data synchronization method between network services provided in an embodiment of the present application is further explained and described, and also includes a service node, a trusted node and a request end with a request program installed. The verification and authentication of data synchronization requests in the proxy mode are roughly the same as the steps in the non-proxy mode. The difference is that in the proxy mode, a request is initiated by the request end to the trusted node so that the trusted node provides authorization for the initiated data synchronization request. Since the trusted node and the service node both store the authority to authenticate the data synchronization request, the service node implements the verification and authentication of the requested data synchronization request. Only when the verification and authentication are successful, the change operation corresponding to the operation-related data in the data synchronization request can be executed through the service node, and the success or failure of the execution of the operation is fed back to the trusted node of the request agent, and the trusted node forwards it to the request end, thereby realizing tamper-proofing and the execution of illegal requests, thereby ensuring the security of all network requests related to data synchronization requests, and can be applied to actual application scenarios with higher security requirements.
[0095] Following the above embodiment of the present application, in a data synchronization method between network services provided in the present application example, when verifying and authenticating a data synchronization request, whether in a non-proxy mode or in a proxy mode, the service node verifies and authenticates the validity response result of the token, the information parameters returned by the trusted node, and the identity and authority credentials of the visitor, specifically including the following three items:
[0096] Verifying whether the trusted node responds successfully through the validity response result of the token;
[0097] Verifying whether the data synchronization request matches the information parameters returned by the trusted node;
[0098] Verify whether the access rights corresponding to the identity authority credentials of the visitor returned by the trusted node allow the execution of the data synchronization request.
[0099] For example, the validity response result of the token returned by the trusted node includes a success response message indicating that the token is valid or a failure response message indicating that the token is invalid. When verifying whether the trusted node responds successfully (i.e., whether the token is valid or invalid) through the validity response result of the token, if the trusted node returns a success response message, the response of the trusted node is successful (i.e., the token is valid); if the trusted node returns a failure response message, the response of the trusted node fails (i.e., the token is invalid); when verifying whether the data synchronization request matches the information parameters returned by the trusted node, if they match, the verification is successful; if they do not match, the verification fails; when authenticating whether the access rights corresponding to the identity authority credentials of the visitor returned by the trusted node allow the execution of the data synchronization request, if allowed, the authentication is passed; if not allowed, the authentication fails. The three verification and authentication methods are used to verify and authenticate the validity response result of the token returned by the trusted node, the information parameters returned by the trusted node, and the identity and authority credentials of the visitor. Only when the three verification and authentication are successful, the service node will execute the change operation corresponding to the operation-related data in the data change request in the function using atomic transactions, thereby ensuring that the data synchronization request has not been tampered with, thereby ensuring the security of the data synchronization request.
[0100] Following the above-mentioned embodiment of the present application, when verifying and authenticating the data synchronization request in a data synchronization method between network services provided in the present application example, whether in non-proxy mode or proxy mode, the trusted node, while executing the fetching of the stored operation-related data corresponding to the token, also executes: deleting or marking the storage record of the token and its corresponding information parameters and the identity and authority credentials of the visitor as invalid. In all embodiments of the present application, whether in non-proxy mode or proxy mode, in order to prevent the token from being replayed, the trusted node, while taking out the stored operation-related data corresponding to the token and the identity and authority credentials of the visitor, also deletes or marks the storage record of the token and its corresponding information parameters and the identity and authority credentials of the visitor as invalid, that is, the token becomes invalid after being used, so that even if the attacker intercepts the token returned by the trusted node, it is impossible to initiate a replay of the data synchronization request, thereby effectively preventing the request replay attack and ensuring security.
[0101] Following the above-mentioned embodiment of the present application, when verifying and authenticating a data synchronization request in a data synchronization method between network services provided in the present application example, whether in a non-proxy mode or a proxy mode, the trusted node generates a token and stores the information parameters and the identity and authority credentials of the visitor, and also performs: configuring a validity period for the information parameters and the identity and authority credentials of the visitor corresponding to the stored token;
[0102] The trusted node verifies whether the token is valid, which specifically includes: verifying whether the token is valid within the validity period.
[0103] Here, after storing the corresponding information parameters and the visitor's identity and authority credentials and other information for the token, a validity period is also configured for the stored information so that when the trusted node verifies whether the token is valid, it can verify whether the token is valid within the validity period. If it is no longer within the validity period, the token is invalid. If it is within the validity period, it indicates that the token is valid. Among them, the expression form of the validity period may include but is not limited to the form of an expiration time, or the form of a maximum number of retrievals, etc. For example, the information corresponding to the storage token token can be set with an expiration time. Most cache components (such as Redis, etc.) support directly configuring an expiration time, or use other methods to store and record the storage time, and use background tasks to clean up expired records. The expiration time can be configurable, or it can be adjusted according to factors such as network environment delay, etc.; for example, in addition to setting the expiration time, the information corresponding to the storage token token can also be set with a maximum number of retrievals. For example, in the process of data synchronization, it can only be read twice (that is, the first time is retrieved from the request carrying token consumption initiated by the service node, and the second time is retrieved by the trusted node in the synchronization request initiated by the server node. All subsequent read operations are illegal. In implementation, a remaining number of retrievals can be set in the storage, which is set to the maximum number of retrievals of the record during initial writing. The remaining number of retrievals is reduced by 1 each time it is read, and the corresponding stored record is deleted when the remaining number of retrievals is 0.
[0104] Here, in different application scenarios, the maximum number of withdrawals can not only delete the corresponding record when it reaches 0 to prevent replay, but also verify the identity of the requester (initiator) at each withdrawal, that is, use the remaining number of withdrawals. If the identity of the requester does not match the corresponding request identity in the actual process, it will still be rejected. For example, the initiator of the first token consumption must be a service node, which can be verified based on the key of the service node. The initiator of the second token consumption must be a trusted node. If during the data synchronization process, when the number of withdrawals is 1 (it has been withdrawn once, that is, the remaining number of withdrawals is 1), the requester is still a service node, then the withdrawal operation will be rejected, because the executor of the second withdrawal should be a trusted node.
[0105] In a preferred embodiment of the present application, in non-proxy mode, a schematic diagram of the actual operation flow of a method for data synchronization between network services provided by the present application is as follows: Figure 1 As shown, a requesting program C is installed in the requesting end, and the service node of the network service for which the requesting program C initiates a data synchronization request is the service node S, and another network service trusted by the requesting program C and the service node S is the trusted node M. The following describes the specific steps of the actual application scenario of the data synchronization method between network services in the non-proxy mode around a change operation that requires data synchronization, assuming that the interface of the service node S for the change operation is S-1, and the synchronization interface of the trusted node M for the change operation is M-1:
[0106] Step 1: The data synchronization operation is initiated by the requesting program C, which carries all the operation-related data required for the operation, the visitor's identity and the identity of the service node S, and requests the token production interface of the trusted node M.
[0107] Step 2. After receiving the request initiated by the requesting program C, the trusted node M verifies whether the visitor has the authority to perform the change operation corresponding to the operation-related data of the data synchronization on the service node S. If not, the request is rejected and a failure response is returned. Otherwise, a token token of the credentials for storing information is generated, and at least the following information is stored: all the operation-related data and other information parameters required for the change operation and the identity of the visitor; the maximum number of retrieval times of the stored information is set to 2, and the token token of the stored information is returned to the requesting program C.
[0108] Step 3: The requesting program C carries the token returned by the trusted node M and the identifier of the trusted node M, and requests the service node S to change the interface S-1.
[0109] Step 4: The service node S carries the token token and initiates a request to retrieve information from the interface address of the token consumption interface corresponding to the identifier of the trusted node M, that is, requests the trusted node M.
[0110] Step 5. After receiving the request, the trusted node M detects whether the token initiated by the service node S carrying the token is valid (i.e., whether the token is stored in the storage and whether the corresponding information of the token is stored). If valid, the remaining number of retrievals corresponding to the stored information (i.e., all the operation-related data and other information parameters required for the change operation and the identity of the visitor) is reduced by 1, and all the operation-related data and other information parameters required for the change operation and the identity of the visitor are returned to S. Otherwise, a failed response is returned.
[0111] Step 6: After receiving the response information such as the validity response result of the token, the information parameters corresponding to the token, and the identity and authority credentials of the visitor returned by M, the service node S will at least perform the following verification:
[0112] Whether the response of the trusted node M is successful (i.e., whether the token is valid or invalid). If the trusted node M returns a successful response message, the response of the trusted node M is successful (i.e., the token is valid). If the trusted node M returns a failed response message, the response of the trusted node M fails (i.e., the token is invalid).
[0113] Verify whether the data synchronization request initiated by the requesting program C to the service node S matches the information parameters returned by the trusted node M. If they match, the verification succeeds; if not, the verification fails.
[0114] The authentication trusted node M determines whether the access rights corresponding to the visitor's identity identifier returned by the authentication trusted node M allow the execution of the data synchronization request. If so, the authentication is successful; otherwise, the authentication is unsuccessful.
[0115] Among them, if any one of the three items of verification and authentication performed by service node S is not met, service node S will refuse to execute the data synchronization request and return a response of request failure. If all the three items of verification and authentication performed by service node S are successfully verified, service node S will proceed to step 7.
[0116] Step 7. If the service node S verifies and authenticates the data change request initiated by the requesting end successfully, it executes the change operation corresponding to the operation-related data in the data change request in the function using the atomic transaction, obtains the change result, and if the change operation is executed successfully, it carries the token token corresponding to the operation-related data and requests the synchronization interface M-1 of the trusted node M.
[0117] Step 8: After receiving the request for the synchronization operation, the trusted node M detects whether the token carried in the request is valid. If valid, the stored operation-related data corresponding to the token is retrieved and deleted or marked as invalid, and the synchronization operation corresponding to the retrieved operation-related data corresponding to the token is executed in the function using the atomic transaction, and whether the synchronization operation performed by the trusted node M is successful is returned to the service node S as a response status;
[0118] Step 9. After receiving the response, if the response is a successful operation response message, the service node S commits the change result in the function using the atomic transaction. Otherwise, the change operation is rolled back or compensated in the function using the atomic transaction, and the success or failure of the execution is returned to the requesting program C as the response status.
[0119] In the actual application scenario of this embodiment, in order to ensure the atomic transaction between the trusted node and the service node, the function of using the atomic transaction includes two situations: First, the database itself supports atomic transactions, and controls the database operated by the execution to start the transaction at the beginning of the execution, controls the database operated by the execution to commit the transaction when the execution ends normally, and controls the database operated by the execution to roll back the transaction when the execution fails; Second, using transaction compensation operations, for the atomic change operations (T1, T2, ..., Tn) of the data, a series of compensation operations (C1, C2, ..., Cn) are provided to restore it to the state where the corresponding change operations are not executed. If an error occurs when executing the change operations T1, T2, ... to Ti (Ti is not executed successfully), Ci-1, Ci-2, etc. are executed in sequence to C1 to achieve compensation recovery of this series of operations. In the function using atomic transactions, not only the local data change operation needs to be performed, but also the request for synchronization operation needs to be sent and the response result needs to be waited for. The request is submitted when the response is successful, and rolled back when the response fails. In this way, when the change operation of the service node S in step 6 fails, it will roll back to the state where the service node S has not made this change, and will not request the trusted node M to synchronize. In this way, no data changes will occur between the trusted node M and the service node S; when the synchronization operation of the trusted node M in step 8 fails, the trusted node M will roll back to the state where this change has not been made, and return a failed response to the service node. At point S, after receiving the failure response, service node S also initiates a rollback to the state where service node S did not make this change. Neither the trusted node M nor the service node S will make any data changes. Step 6 of service node S and step 8 of trusted node M are both successful. After trusted node M returns a successful response, service node S commits the change as a transaction to ensure that both trusted node M and service node S have completed the data change, achieving atomic consistency between trusted node M and service node S, and ensuring that trusted node M and service node S are either changed to the same state together, or restored to the unchanged state together.
[0120] In a preferred embodiment of the present application, in a non-proxy mode, a schematic diagram of the actual operation flow of a method for synchronizing data between network services provided by an embodiment of the present application is as follows: Figure 1 As shown, a requesting program C is installed in the requesting end, and the service node of the network service to which the requesting program C initiates the data synchronization request is the service node S, and another network service trusted by the requesting program C and the service node S is the trusted node M. The following is a description of a specific embodiment of the actual application scenario of the data synchronization method between network services in the non-proxy mode.
[0121] The specific scenario is that user A1 needs to initiate a request to adjust the access rights of user A2 to ["log_query", "data_query", "data_delete"]. The specific implementation process is as follows:
[0122] The requesting program C sends a request to the token generation interface of the trusted node M, carrying the information parameters of the complete request for this operation (including operation-related data) and the identifier of the service node S. The specific implementation code is:
[0123]
[0124] X-User-Token and Cookie indicate that the identity credentials of user A1 can be carried in different ways.
[0125] The trusted node adds the identity of the requesting user A1 and the remaining withdrawal times to the received information parameters and stores them, generates a token and returns the token (assuming it is QWER) to the requesting program C;
[0126] The requesting program C carries the token and the identity of the trusted node M to request the service node S. The pseudo code for the specific implementation of the declarative style is as follows, which only shows the necessary information:
[0127]
[0128]
[0129] There is no need to send the operation data, because the data required for the operation has been stored by the trusted node M. After receiving the request, the service node S carries the token and the service key of the service node S to send a request to retrieve the data to the trusted node M. The specific implementation code is:
[0130]
[0131] The trusted node M checks whether the token carried in the request is valid. If not, it returns a failed response. Otherwise, it retrieves the corresponding storage information (i.e., the information parameters containing the operation-related data and the identity of A1), and reduces the remaining retrieval times corresponding to the storage information by 1, and returns the retrieved storage information to the service node S. For this example, the retrieved data is identified by the following code
[0132]
[0133] The service node S can verify the request method, path, request header, request body and other information parameters. If the verification fails, the request will be rejected. Otherwise, the change operation will be performed in the function using the atomic transaction, and a synchronization request will be initiated to the trusted node M. The pseudo code example of the specific implementation is as follows:
[0134]
[0135]
[0136] The corresponding operation-related data is the retrieved data, which is represented as follows:
[0137]
[0138] That is, the operation permissions of the user identified as A1 are changed to ["log_query", "data_query", "data_delete"]. After the change is successful, a synchronization request for this operation is sent to the trusted node M. Assuming that the subpath of the synchronization operation for changing the user is alter_admin, the implementation code is as follows:
[0139]
[0140] After receiving the request, the trusted node uses the token to retrieve the synchronization data of the operation from the storage, and performs the corresponding synchronization operation in the function using the atomic transaction, that is, changing the operation permissions of the user identified as A2 to ["log_query", "data_query", "data_delete"], which is consistent with the data of the service node S.
[0141] If the trusted node M fails to execute the synchronization operation successfully, since the trusted node M uses the atomic transaction function, it will roll back to a state where no changes have occurred and return a failed response. After receiving the failed response, the service node S will also roll back the changes and also restore to a state where no changes have occurred. It will return a failed response to the requesting program C, indicating that the synchronization change operation has failed.
[0142] If the trusted node M successfully executes the operation and returns a successful response, the service node S will commit the transaction, so that both parties have completed the consistent change of the permissions of user A2, and return a successful response to the requesting program C, indicating that the synchronization change operation is successful.
[0143] Next, in the above-mentioned embodiments of the present application, an embodiment of a method for data synchronization between network services provided by an embodiment of the present application, although it can ensure the data consistency between the service node and the trusted node, there may be some small probability situations that may cause data inconsistency, for example, the maintainer of the service node mistakenly cleans up or changes the data that should be synchronized with the trusted node, and does not use the synchronization process in the embodiment of a method for data synchronization between network services provided by an embodiment of the present application; the maintainer of the trusted node mistakenly cleans up or changes the data that should be synchronized with the service node, and does not use the synchronization process in the embodiment of a method for data synchronization between network services provided by an embodiment of the present application; the participants in the above-mentioned synchronization operation mistakenly fail to respond or change correctly according to the synchronization operation, or the service instance or storage system crashes or disconnects when one party confirms the submission. In order to deal with these situations where inconsistencies may exist, an embodiment of a method for data synchronization between network services provided in one embodiment of the present application can also recover data inconsistencies between trusted nodes and service nodes. For example, when the maintainer of the service node finds any data inconsistency, he can initiate a synchronization operation for the inconsistent data again. After the synchronization operation process of an embodiment of a method for data synchronization between network services provided in one embodiment of the present application, if the operation is successful, the data of the service node and the trusted node are restored to consistency, and the data consistency between the service node and the trusted node is further ensured.
[0144] In an embodiment of the present application, the requesting end constructs data and hopes that the same data can be stored in both the service node and the trusted node, and the entire storage operation can ensure atomicity, either all of which are saved successfully or all of which are unchanged; in another case, the service node also acts as a requesting end and needs to save a copy of the data to its own storage and synchronize it to the trusted node, and needs to ensure the atomicity of the synchronization operation. Then the service node executes the requesting program in the request and all the processes in the service node, and assumes two roles in the process. In this case, there is no concept of proxy mode, because the generator and requesting party of the data are both service nodes, and there is no need for the trusted node to act as an agent. It is only necessary to ensure that the service node can access the trusted node; in another case, the trusted node acts as a requesting end and needs to save a copy of the data to its own storage and synchronize it to the service node, and needs to ensure the atomicity of the synchronization operation. Then, the trusted node executes all the processes in the requesting program and the trusted node in the request, and assumes two roles in the process. In this case, the processes of the proxy mode and the non-proxy mode are the same, and the trusted node needs to initiate a change request to the service node.
[0145] According to another aspect of the present application, a non-volatile storage medium is provided, on which computer-readable instructions are stored. When the computer-readable instructions can be executed by a processor, the processor implements the data synchronization method between network services as described above.
[0146] According to another aspect of the present application, a service node for data synchronization between network services is also provided, the service node comprising:
[0147] one or more processors;
[0148] A computer readable medium for storing one or more computer readable instructions,
[0149] When the one or more computer-readable instructions are executed by the one or more processors, the one or more processors implement the data synchronization method between network services at the service node end as described above.
[0150] Here, for the detailed contents of each embodiment of the service node for data synchronization between network services, please refer to the corresponding part of the embodiment of the method for data synchronization between network services at the service node end, which will not be described in detail here.
[0151] According to another aspect of the present application, a trusted node for data synchronization between network services is also provided, the trusted node comprising:
[0152] one or more processors;
[0153] A computer readable medium for storing one or more computer readable instructions,
[0154] When the one or more computer-readable instructions are executed by the one or more processors, the one or more processors implement the above-mentioned data synchronization method between trusted node-side network services.
[0155] Here, for the detailed contents of each embodiment of the trusted node for data synchronization between network services, please refer to the corresponding part of the embodiment of the method for data synchronization between network services at the trusted node end, which will not be described in detail here.
[0156] In summary, the present application adopts the logical cooperation between the requesting end, the trusted node and the service node. The service node responds to the successful verification and authentication of the data change request initiated by the requesting end, and executes the change operation corresponding to the operation-related data in the data change request in the function using the atomic transaction to obtain the change result; and in response to the successful execution of the change operation, the token corresponding to the operation-related data is carried, and a data synchronization request is sent to the synchronization interface of the trusted node, so that the trusted node verifies whether the token is valid through the token consumption interface. If so, the stored operation-related data corresponding to the token is retrieved, and the synchronization operation corresponding to the retrieved operation-related data corresponding to the token is executed, and an operation success response message is returned to the service node; the service node receives the operation success response message returned by the trusted node in response to the successful execution of the synchronization operation; and in response to the operation success response message, the change result is submitted as a transaction in the function using the atomic transaction, and the operation success response message is returned to the requesting end or the trusted node, so that the trusted node sends the operation success response message to the requesting end. It realizes data synchronization at the network service level, and can support the use of different storage engines by the synchronized service nodes and trusted nodes. Both can implement storage, and can achieve the purpose of data synchronization of heterogeneous data storage. At the same time, the atomic transaction function is used to ensure the atomicity and data consistency of the data updated at the service node can be synchronized with the trusted node.
[0157] It should be noted that the present application can be implemented in software and / or a combination of software and hardware, for example, can be implemented using an application specific integrated circuit (ASIC), a general purpose computer or any other similar hardware device. In one embodiment, the software program of the present application can be executed by a processor to implement the steps or functions described above. Similarly, the software program of the present application (including relevant data structures) can be stored in a computer-readable recording medium, for example, a RAM memory, a magnetic or optical drive or a floppy disk and similar devices. In addition, some steps or functions of the present application can be implemented using hardware, for example, as a circuit that cooperates with a processor to perform each step or function.
[0158] In addition, a part of the present application may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present application through the operation of the computer. The program instruction for calling the method of the present application may be stored in a fixed or removable recording medium, and / or transmitted through a data stream in a broadcast or other signal-bearing medium, and / or stored in a working memory of a computer device that runs according to the program instruction. Here, according to an embodiment of the present application, a device is included, the device including a memory for storing computer program instructions and a processor for executing program instructions, wherein, when the computer program instruction is executed by the processor, the device is triggered to run the method and / or technical solution based on the aforementioned multiple embodiments according to the present application.
[0159] It is obvious to those skilled in the art that the present application is not limited to the details of the above exemplary embodiments, and that the present application can be implemented in other specific forms without departing from the spirit or basic features of the present application. Therefore, from any point of view, the embodiments should be regarded as exemplary and non-restrictive, and the scope of the present application is limited by the attached claims rather than the above description, so it is intended to include all changes that fall within the meaning and scope of the equivalent elements of the claims in the present application. Any figure mark in the claims should not be regarded as limiting the claims involved. In addition, it is obvious that the word "comprising" does not exclude other units or steps, and the singular does not exclude the plural. Multiple units or devices stated in the device claim can also be implemented by one unit or device through software or hardware. The words first, second, etc. are used to indicate names, and do not indicate any particular order.
Claims
1. A data synchronization method between network services, applied to a service node, wherein: The method comprises: In response to successful verification and authentication of the data change request initiated by the requesting end, executing a change operation corresponding to the operation-related data in the data change request in a function using an atomic transaction to obtain a change result; In response to the successful execution of the change operation, the token corresponding to the operation-related data is carried and a data synchronization request is sent to the synchronization interface of the trusted node, so that the trusted node verifies whether the token is valid through the token consumption interface. If so, the stored operation-related data corresponding to the token is retrieved and then the synchronization operation corresponding to the retrieved operation-related data corresponding to the token is executed; Receiving operation success response information returned by the trusted node in response to successful execution of the synchronization operation; In response to the operation success response information, committing the change result as a transaction in the function using the atomic transaction; Returning the operation success response information to the requesting end or the trusted node includes: in a non-proxy mode, returning the operation success response information to the requesting end, so that the requesting end can understand that the data that needs to be changed has been synchronously changed in both the service node and the trusted node; or, in a proxy mode, sending the operation success response information to the trusted node, so that the trusted node forwards the operation success response information to the requesting end, so that the requesting end can understand that the data that needs to be changed has been synchronously changed in both the service node and the trusted node; Wherein, the method further comprises: Receiving operation failure response information returned by the trusted node in response to failure of executing the synchronization operation; In response to the operation failure response information, performing a transaction rollback or compensation operation on the change operation in the function using the atomic transaction; The operation failure response information is returned to the requesting end or the trusted node, including: in non-proxy mode, the operation failure response information is returned to the requesting end, so that the requesting end learns about the change and synchronization failure through the received operation failure response information returned by the service node in response to the transaction rollback or compensation operation on the change operation in the function using atomic transactions, so as to achieve the purpose of notifying the requesting end; or, in proxy mode, the operation failure response information is returned to the trusted node, and the trusted node forwards the operation failure response information to the requesting end by proxy, so that the requesting end learns about the change and synchronization failure through the received trusted node, so as to achieve the purpose of notifying the requesting end.
2. The method according to claim 1, wherein: The method further comprises: Receiving a data synchronization request sent by a requesting end or a trusted node through an interface address, wherein the data synchronization request includes the token and the identifier of the trusted node; the token is generated by the trusted node after receiving a first request from the requesting end carrying the identity and authority credentials of a visitor to initiate the data synchronization request, information parameters of the data synchronization request, and the identifier of the requested service node through a token production interface, and when verifying that the visitor has the authority to execute the data synchronization request in the service node, wherein the information parameters include the operation-related data; Sending a second request carrying the token to the token consumption interface corresponding to the identifier of the trusted node, so that the trusted node verifies whether the token is valid through the token consumption interface; Receiving the validity response result of the token, the information parameters corresponding to the token and the identity authority certificate of the visitor returned by the trusted node; The validity response result of the token, the information parameters returned by the trusted node and the identity and authority credentials of the visitor are verified and authenticated.
3. A data synchronization method between network services, applied to a trusted node, wherein: The method comprises: Receiving, through a synchronization interface, a data synchronization request initiated by a service node in response to a successful execution of a change operation and carrying a token corresponding to operation-related data, wherein the service node executes a change operation corresponding to the operation-related data in the data change request in response to successful verification and authentication of the data change request initiated by the requesting end; Verify whether the token is valid. If so, retrieve the stored operation-related data corresponding to the token, delete the token or mark it invalid, and then execute the synchronization operation corresponding to the retrieved operation-related data corresponding to the token in the function using the atomic transaction; In response to the synchronization operation being successfully executed, returning operation success response information to the service node, so that the service node returns the operation success response information to the request end after submitting the change result in the function using the atomic transaction in response to the operation success response information; Wherein, the method further comprises: In response to failure of the synchronization operation, operation failure response information is returned to the service node, so that the service node performs a transaction rollback or compensation operation on the change operation in the function using the atomic transaction in response to the operation failure response information.
4. The method according to claim 3, wherein: The method further comprises: Receiving, through a token production interface, a first request from a requesting end carrying the identity authority credentials of a visitor who is to initiate a data synchronization request, information parameters of the data synchronization request, and an identifier of a requested service node, wherein the information parameters include the operation-related data; Verify whether the visitor has the authority to execute the data synchronization request in the service node. If so, generate a token and send it to the requesting end, and store the information parameters and the identity and authority credentials of the visitor accordingly; wherein, after receiving the token, the requesting end carries the token and the identifier of the trusted node to initiate a data synchronization request to the interface address of the service node, so that the service node carries the token to send a second request to the token consumption interface corresponding to the identifier of the trusted node; A second request initiated by the service node carrying the token is received through the token consumption interface to verify whether the token is valid. If so, the stored information parameters corresponding to the token including the target operation data and the identity and authority credentials of the visitor are retrieved and returned to the service node, so that the service node performs verification and authentication based on the validity response result of the token, the corresponding information parameters and the identity and authority credentials of the visitor, and performs change operations through the operation-related data in the information parameters.
5. A method for synchronizing data between network services, applied to a trusted node, wherein: The method comprises: Receiving, through a synchronization interface, a data synchronization request initiated by a service node in response to a successful execution of a change operation and carrying a token corresponding to operation-related data, wherein the service node executes a change operation corresponding to the operation-related data in the data change request in response to successful verification and authentication of the data change request initiated by the requesting end; Verifying whether the token is valid, and if so, retrieving stored operation-related data corresponding to the token; executing, in the function using the atomic transaction, a synchronization operation corresponding to the retrieved operation-related data corresponding to the token; In response to the synchronization operation being successfully executed, returning operation success response information to the service node, so that the service node commits the change result as a transaction in the function using the atomic transaction in response to the operation success response information; In response to receiving the operation success response information returned by the service node, sending the operation success response information to the requesting end; Wherein, the method further comprises: In response to failure of execution of the synchronization operation, returning operation failure response information to the service node, so that the service node performs a transaction rollback or compensation operation on the change operation in the function using the atomic transaction in response to the operation failure response information; In response to receiving the operation failure response information returned by the service node, the operation failure response information is sent to the requesting end.
6. The method according to claim 5, wherein: The method further comprises: A first request is received from a requesting end, which carries the identity and authority credentials of a visitor who is to initiate a data synchronization request, information parameters of the data synchronization request, and an identifier of a requested service node; wherein the information parameters include the operation-related data; Verify whether the visitor has the authority to execute the data synchronization request in the service node, and if so, generate a token and store the information parameters and the identity and authority credentials of the visitor accordingly; Sending a data synchronization request to the service node carrying the token and the identifier of the trusted node; The second request initiated by the service node carrying the token is received through the token consumption interface to verify whether the token is valid. If so, the stored information parameters corresponding to the token and the identity and authority credentials of the visitor are retrieved and returned to the service node, so that the service node performs verification and authentication based on the validity response result of the token, the corresponding information parameters and the identity and authority credentials of the visitor.
7. A non-volatile storage medium having computer-readable instructions stored thereon, wherein when the computer-readable instructions are executable by a processor, the processor is enabled to implement the method according to any one of claims 1 to 6.
8. A service node for data synchronization between network services, the service node comprising: one or more processors; A computer readable medium for storing one or more computer readable instructions, When the one or more computer-readable instructions are executed by the one or more processors, the one or more processors implement the method as claimed in claim 1 or 2.
9. A trusted node for data synchronization between network services, the trusted node comprising: one or more processors; A computer readable medium for storing one or more computer readable instructions, When the one or more computer-readable instructions are executed by the one or more processors, the one or more processors implement the method according to any one of claims 3 to 6.
Citation Information
Patent Citations
High-availability framework system with single-point heterogeneous data storage function and realizing method thereof
CN106357452A
Universal multi-source heterogeneous large-scale data synchronizing system
CN107729366A