Data processing method and device, storage medium and electronic device
By coordinating nodes in a distributed system to synchronously adjust the status of network devices, the data inconsistency problem caused by the 2PC protocol is solved, and the consistency of node status and the improvement of system performance are achieved.
Patent Information
- Application Number
- CN202110378952.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-08
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2041-04-08
AI Technical Summary
In distributed systems, the two-phase commit protocol (2PC) can cause system congestion and data inconsistency when nodes remain unresponsive for extended periods of time, impacting system performance and resource utilization.
The first coordination node receives the transaction processing request, determines the status of the network device, and sends a notification message to synchronize the status adjustment, ensuring the status consistency of all network devices and avoiding data inconsistency caused by using the 2PC protocol alone.
It achieves flexible control and consistency of data at each node in the distributed system, avoids system congestion and data inconsistency, and improves system performance and resource utilization.
Smart Images

Figure CN115203215B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computers, and in particular to a data processing method and device, a storage medium, and an electronic device. Background Art
[0002] In distributed systems, database transaction commits, leader elections, and sequence number generation often encounter consistency issues. Among related technologies, the most widely used atomic commit protocols are the two-phase commit protocol (2PC). 2PC is a commonly used, eventually consistent, centralized atomic commit protocol. Centralization here refers to the fact that there are two types of nodes in the protocol: a centralized coordinator node and N participant nodes. The 2PC protocol is a distributed consensus protocol that is often used in distributed systems to ensure the atomicity of distributed transactions, that is, all participants in a distributed transaction must either commit or roll back.
[0003] The two-phase commit protocol (2PC) extends local transaction processing to distributed transactions, resolving the issue of atomicity in distributed transaction commits. Its implementation is also relatively simple and reliable. However, 2PC still has some inherent flaws: if a site or node in the system remains unresponsive for an extended period due to issues with the site or poor communication lines, the entire transaction cannot be committed, blocking the entire system. Furthermore, if the coordinator node times out, meaning that a participant node is deemed to have timed out if it has not waited for commands from the coordinator for an extended period, this flaw severely impacts the performance of distributed systems and the utilization of system resources. It also can cause data inconsistencies across nodes in the system.
[0004] To address the above-mentioned problems, no effective solutions have been proposed so far. Summary of the Invention
[0005] Embodiments of the present invention provide a data processing method and apparatus, a storage medium, and an electronic device to at least solve the technical problem that all nodes in a distributed system cannot ensure data consistency.
[0006] According to one aspect of an embodiment of the present invention, a data processing method is provided, comprising: a first coordination node receiving a transaction processing request triggered by a first network device configured in a first proxy node, wherein the transaction processing request is used to request processing of a target transaction; in response to the transaction processing request, the first coordination node determining a current transaction processing status of the first network device through a database in a distributed transaction processing network; when the current transaction processing status of the first network device is a prepare state, the first coordination node sending a first notification message to other reference network devices in the distributed transaction processing network other than the first network device, wherein the first notification message is used to instruct the reference network devices to synchronously change the current transaction processing status of the first network device stored in a local storage space to the prepare state; when receiving a response confirmation message returned by the reference network device based on the first notification message, the first coordination node determining that the target transaction has completed a prepare stage; when the current transaction processing status of the first network device in the database is adjusted from the prepare state to the commit state, the first coordination node sending a second notification message to the reference network device, wherein the second notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the commit state.
[0007] According to another aspect of an embodiment of the present invention, a data processing method is provided, comprising: a first proxy node receives a transaction processing request triggered by a configured first network device, and sends the transaction processing request to an associated first coordination node, wherein the transaction processing request is used to request processing of a target transaction; in response to the transaction processing request, the first proxy node determines the current transaction processing status of the first network device through a database in a distributed transaction processing network; when the current transaction processing status of the first network device is a ready state, the first proxy node sends a first notification message to other reference network devices in the distributed transaction processing network except the first network device through the first coordination node, wherein The first notification message is used to instruct the above-mentioned reference network device to synchronously change the current transaction processing status of the above-mentioned first network device stored in the local storage space to the above-mentioned ready state; upon receiving the response confirmation message returned by the above-mentioned reference network device based on the above-mentioned first notification message, the above-mentioned first proxy node determines that the above-mentioned target transaction has completed the preparation stage; when the current transaction processing status of the above-mentioned first network device in the above-mentioned database is adjusted from the above-mentioned ready state to the submitted state, the above-mentioned first proxy node sends a second notification message to the above-mentioned reference network device, wherein the above-mentioned second notification message is used to instruct the above-mentioned reference network device to synchronously change the current transaction processing status of the above-mentioned first network device stored in the local storage space to the above-mentioned submitted state.
[0008] According to another aspect of an embodiment of the present invention, a data processing device is further provided, including: a receiving unit, for a first coordination node to receive a transaction processing request triggered by a first network device configured in a first proxy node, wherein the transaction processing request is used to request processing of a target transaction; a first determination unit, for responding to the transaction processing request, the first coordination node determining the current transaction processing status of the first network device through a database in a distributed transaction processing network; a first sending unit, for, when the current transaction processing status of the first network device is a ready state, the first coordination node sending a first notification message to other reference network devices in the distributed transaction processing network except the first network device, wherein the first notification message is used to indicate The second determining unit is used to indicate that the reference network device synchronously changes the current transaction processing status of the first network device stored in the local storage space to the prepared state; the second determining unit is used to determine that the first coordination node determines that the target transaction completes the preparation stage when receiving the response confirmation message returned by the reference network device based on the first notification message; the second sending unit is used to send the second notification message to the reference network device by the first coordination node when the current transaction processing status of the first network device in the database is adjusted from the prepared state to the committed state, wherein the second notification message is used to indicate that the reference network device synchronously changes the current transaction processing status of the first network device stored in the local storage space to the committed state.
[0009] According to another aspect of an embodiment of the present invention, a data processing device is also provided, including: a receiving unit, for a first agent node to receive a transaction processing request triggered by a configured first network device, and send the above transaction processing request to an associated first coordination node, wherein the above transaction processing request is used to request processing of a target transaction; a first determination unit, for responding to the above transaction processing request, the above first agent node determines the current transaction processing status of the above first network device through a database in a distributed transaction processing network; a first sending unit, for when the current transaction processing status of the above first network device is a ready state, the above first agent node sends a first notification message to other reference network devices in the above distributed transaction processing network except the above first network device through the above first coordination node, wherein The first notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the prepared state; the second determination unit is used to, upon receipt of a response confirmation message returned by the reference network device based on the first notification message, the first proxy node determines that the target transaction has completed the preparation stage; the second sending unit is used to, upon the current transaction processing status of the first network device in the database is adjusted from the prepared state to the submitted state, the first proxy node sends a second notification message to the reference network device, wherein the second notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the submitted state.
[0010] According to another aspect of the embodiments of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the above-mentioned data processing method when running.
[0011] According to another aspect of an embodiment of the present invention, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the data processing method through the computer program.
[0012] In an embodiment of the present invention, a first coordinating node receives a transaction processing request for processing a target transaction, triggered by a first network device configured in a first proxy node; in response to the transaction processing request, determines the current transaction processing state of the first network device through a database in a distributed transaction processing network; and, if the current transaction processing state of the first network device is in a prepared state, sends a first notification message to reference network devices other than the first network device in the distributed transaction processing network, wherein the first notification message is used to instruct the reference network devices to synchronously change the current transaction processing state of the first network device stored in a local storage space to the prepared state. Then, upon receiving a response confirmation message returned by the reference network devices based on the first notification message, the first coordinating node determines that the target transaction has completed the preparation phase; and, if the current transaction processing state of the first network device in the database is adjusted from the prepared state to the committed state, the first coordinating node sends a second notification message to the reference network devices, wherein the second notification message is used to instruct the reference network devices to synchronously change the current transaction processing state of the first network device stored in the local storage space to the committed state. By determining the current transaction processing status of the first network device from the database in the above-mentioned distributed transaction processing network through the first coordination node, and referring to the current transaction processing status of the network device, the preparation stage and submission status of the target transaction are further determined, thereby achieving the purpose of avoiding data inconsistency of each node caused by the use of the 2PC protocol alone in the distributed system, thereby achieving the technical effect of flexibly controlling the data of each node in the distributed system to maintain consistency, and thus solving the technical problem that all nodes in the distributed system cannot ensure data consistency. BRIEF DESCRIPTION OF THE DRAWINGS
[0013] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0014] Figure 1 is a schematic diagram of an application environment of an optional data processing method according to an embodiment of the present invention;
[0015] Figure 2 is a flow chart of an optional data processing method according to an embodiment of the present invention;
[0016] Figure 3 is a structural diagram of an optional data processing method according to an embodiment of the present invention;
[0017] Figure 4is a flowchart of an optional data processing method in related technology according to an embodiment of the present invention;
[0018] Figure 5 is a structural diagram of another optional data processing method in related technology according to an embodiment of the present invention;
[0019] Figure 6 It is a structural diagram of an optional data processing method according to the relevant technology;
[0020] Figure 7 is a structural diagram of another optional data processing method according to an embodiment of the present invention;
[0021] Figure 8 is a structural diagram of another optional data processing method according to an embodiment of the present invention;
[0022] Figure 9 is a structural diagram of another optional data processing method according to an embodiment of the present invention;
[0023] Figure 10 It is a structural diagram of an optional data processing method according to the relevant technology;
[0024] Figure 11 is a structural diagram of another optional data processing method according to the relevant technology;
[0025] Figure 12 is a structural diagram of another optional data processing method according to an embodiment of the present invention;
[0026] Figure 13 is a schematic structural diagram of an optional data processing device according to an embodiment of the present invention;
[0027] Figure 14 is a schematic structural diagram of another optional data processing device according to an embodiment of the present invention;
[0028] Figure 15 is a schematic structural diagram of an optional electronic device according to an embodiment of the present invention;
[0029] Figure 16 FIG. 4 is a schematic structural diagram of another optional electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0030] In order to enable those skilled in the art to better understand the solutions of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts should fall within the scope of protection of the present invention.
[0031] It should be noted that the terms "first", "second", etc. in the description and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that the numbers used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0032] In the embodiments of the present invention, the following technical terms may be used, but are not limited to:
[0033] TbusppMesh: Tbuspp combines the concept of cloud native to connect Tbuspp to Kubernetes, which is the next-generation game service mesh technology.
[0034] 2PC: Two-Phase Commit Protocol (2PC). 2PC is a commonly used, eventually consistent, centralized atomic commit protocol. Centralization here refers to the two types of nodes in the protocol: a centralized coordinator node and N participant nodes. The 2PC protocol is a distributed consensus protocol, commonly used in distributed systems to ensure the atomicity of distributed transactions. This means that all participants in a distributed transaction must either commit or roll back.
[0035] TbusppNs: Equivalent to the coordinator in the 2PC process;
[0036] Client / Server: Equivalent to the participant in the 2PC process;
[0037] Agent: a proxy node that communicates between the Client and Server messages and TbusppNs;
[0038] According to one aspect of an embodiment of the present invention, a data processing method is provided. Optionally, as an optional implementation, the data processing method can be applied to, but is not limited to, Figure 1 In the application environment shown. The application environment may include but is not limited to: a terminal device 102 for human-computer interaction with a user, a network 110, and a server 112. A data processing application client is running in the terminal device 102. The terminal device 102 includes a display 108, a processor 106, and a memory 104. The display 108 is used to present a first notification message and a second notification message. The processor 106 is used to receive a transaction processing request triggered by a first network device, and to determine whether the target transaction has completed the preparation stage. The memory 104 is used to store the first notification message and the second notification message. In addition, the server 112 includes a database 114 and a processing engine 116, and the database is used to store the preparation status and submission status of the target transaction. The processing engine 116 is used to send status information of the target processing transaction after receiving the first notification message and the second notification message.
[0039] The specific process is as follows: Assume that Figure 1 The terminal device 102 shown runs a distributed transaction processing client. In steps S102-S110, a first coordinating node receives a transaction processing request triggered by a first network device configured in a first proxy node. In response to the transaction processing request, the first coordinating node determines the current transaction processing status of the first network device through a database in the distributed transaction processing network. If the current transaction processing status of the first network device is in the prepared state, the first coordinating node sends a first notification message to other reference network devices in the distributed transaction processing network, excluding the first network device. Upon receiving a response confirmation message returned by the reference network device based on the first notification message, the first coordinating node determines that the target transaction has completed the preparation phase. If the current transaction processing status of the first network device in the database is adjusted from the prepared state to the committed state, the first coordinating node sends a second notification message to the reference network device, wherein the second notification message is used to instruct the reference network device to synchronize the current transaction processing status of the first network device stored in the local storage space to the committed state. Step S110 is then executed to send the first and second notification messages via the network 110 to the server 112. In step S112, the server sends the status information of the target transaction.
[0040] Optionally, in this embodiment, the terminal device 102 may be a terminal device configured with a target client, which may include but is not limited to at least one of the following: a mobile phone (such as an Android phone, an iOS phone, etc.), a laptop computer, a tablet computer, a PDA, an MID (Mobile Internet Devices), a PAD, a desktop computer, a smart TV, etc. The target client may be a video client, an instant messaging client, a browser client, an education client, etc. The network may include but is not limited to: a wired network, a wireless network, wherein the wired network includes: a local area network, a metropolitan area network, and a wide area network, and the wireless network includes: Bluetooth, WIFI, and other networks that implement wireless communication. The server 112 may be a single server, or a server cluster consisting of multiple servers, or a cloud server. The above is only an example, and this embodiment does not impose any limitation on this.
[0041] Optionally, as an optional implementation, the data processing method is applied to a coordination node, such as Figure 2 As shown, the above data processing method includes:
[0042] S202: The first coordinating node receives a transaction processing request triggered by a first network device configured in the first proxy node, wherein the transaction processing request is used to request processing of a target transaction;
[0043] S204, in response to the transaction processing request, the first coordination node determines the current transaction processing status of the first network device through a database in the distributed transaction processing network;
[0044] S206: When the current transaction processing state of the first network device is the ready state, the first coordinating node sends a first notification message to other reference network devices in the distributed transaction processing network except the first network device, wherein the first notification message is used to instruct the reference network devices to synchronously change the current transaction processing state of the first network device stored in the local storage space to the ready state;
[0045] S208, upon receiving a response confirmation message returned by the reference network device based on the first notification message, the first coordination node determines that the target transaction completes the preparation phase;
[0046] S210, when the current transaction processing status of the first network device in the database is adjusted from the prepare status to the commit status, the first coordination node sends a second notification message to the reference network device, wherein the second notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the commit status.
[0047] In this embodiment, the above-described data processing method can be applied, but is not limited to, to distributed transaction processing. The distributed transaction processing phases herein may include, but are not limited to, using the above-described two-phase commit protocol (hereinafter referred to as 2PC). The two-phase distributed transaction processing process involves two roles: a coordinator and a participant. The two phases include a preparation phase and a commit phase. The preparation phase includes: 1) The coordinator node queries all participant nodes whether a commit operation can be performed and begins waiting for responses from each participant node. 2) The participant nodes execute all transaction operations up to the query initiation and write undo and redo information to the log. 3) Each participant node responds to the query initiated by the coordinator node. If the participant node's transaction operation is successfully executed, it returns an "approved" message; if the participant node's transaction operation fails, it returns an "aborted" message. The commit phase includes: if the coordinator receives a failure message from a participant or a timeout occurs, it directly sends a rollback message to each participant; otherwise, it sends a commit message. The participants execute the commit or rollback operation according to the coordinator's instructions, releasing all lock resources used during the transaction processing.
[0048] Here, the above data processing method can be applied to, but not limited to, Figure 3 In the distributed transaction processing architecture shown in FIG, the architecture may include but is not limited to: a database TcaplusDb, a coordination node TbusppNs, an agent node Agent, and a client Client. Figure 3 As shown, in the case where the first coordination node is TbusppNs3, the first agent node may be Agent4, the first network device may be server Server3, and the reference network device may include but is not limited to the second network device configured in the first agent node (such as Figure 3 Server1, Server2, Server3 in Agent4 shown), a third network device configured in the second agent node associated with the first coordination node (such as Figure 3 The fourth network device configured in the third agent node associated with the second coordination node (such as Client4 configured in the agent node Agent3 in TbusppNs2 associated with TbusppNs3, or Client1 and Client2 configured in the agent node Agent1 in TbusppNs1 associated with TbusppNs3, and Client3 configured in the agent node Agent2 in TbusppNs1). Figure 3 The architecture shown is an example and is not limited in this embodiment.
[0049] It should be noted that in step S202, the first coordination node may be a coordination node in the 2PC protocol, responsible for managing the commit and rollback of multiple transactions in the distributed transaction processing system, and ensuring the consistency of data in the distributed transaction processing system.
[0050] For example, Figure 3 The illustrated architecture is used as an example for illustration. Assuming the first coordination node, TbusppNs3, is configured between the database and proxy nodes, the first network device may include, but is not limited to, a server or client configured in a proxy node associated with the first coordination node in a distributed transaction processing system. The server may be a single server, a server cluster consisting of multiple servers, or a cloud server. The client may be a video client, an instant messaging client, a browser client, an education client, or the like.
[0051] Optionally, in this embodiment, the transaction processing request may include, but is not limited to, a request to go online or offline from the network device (e.g., a server or client). The database in the distributed transaction processing network may, but is not limited to, store the transaction processing status of the first network device and other network devices. The transaction processing status may include, but is not limited to, a prepare state and a commit state. The prepare state may, but is not limited to, refer to a state that has entered the prepare phase, and the commit state refers to a state that has entered the commit phase.
[0052] It should be noted that in step S204, the reference network device may be another client or server node in the distributed transaction processing system that is different from the first network device. Here, the state of the first network device stored in other nodes (i.e., other clients or servers such as client1) in the distributed transaction processing network is synchronously updated through the first notification message. For example, Figure 3 As shown, assuming that the first network device Server3 is still used as an example for explanation, assuming that the current transaction processing status of the first network device Server3 is the ready state, in the 2PC two-stage distributed transaction processing network, it can correspond to the state of the first network device Server3 preparing to go online or preparing to go offline. Here, the ready state can be represented by a state value. For example, when the first network device is ready to go online, the current state value of the first network device is set to 1 in the database in the distributed transaction processing network; when the first network device Server3 is ready to go offline, the current state value of the first network device Server3 is set to 0 in the database in the distributed transaction processing network.
[0053] It should be noted that in step S206, when the first coordinating node receives the preparation status information of other network devices in the distributed transaction processing system, it can determine that the target transaction is in the preparation stage. Figure 3 As shown, when the first coordination node is TbusppNs3, the first coordination node TbusppNs3 adjusts the state of preparing for network connection with the first network device after determining that the first network device Server3 is in the online state and other network devices in the distributed transaction processing network (such as Client1 and Client2) receive the online or offline information of the first network device Server3; at this time, it can be determined that the target transaction is the online operation of the first network device Server3, and other network devices in the distributed transaction processing network (such as Client1 and Client2) are ready to establish a connection and data interaction relationship with the first network device Server3.
[0054] It should be noted that in step S208, when the first network device in the database of the distributed transaction processing network is in the commit state, the first coordination node notifies other network devices to synchronize the commit state. In this embodiment, the commit state may include but is not limited to the execution state of the target transaction. Here, the commit state can be represented by a state value. For example, when the online operation of the first network device is in the commit state, the current state value of the first network device is set to 01 in the database of the distributed transaction processing network; when the offline operation of the first network device Server3 is in the commit state, the current state value of the first network device Server3 is set to 10 in the database of the distributed transaction processing network; for example, Figure 3 As shown, when the first coordination node is TbusppNs3, the first coordination node TbusppNs3 adjusts the state of the network connection with the first network device Server3 after determining that the first network device Server3 is in the online submission state and other network devices in the distributed transaction processing network (such as Client1 and Client2) receive the online submission status information of the first network device Server3; at this time, it can be determined that the target transaction is the formal online operation of the first network device Server3, and other network devices in the distributed transaction processing network (such as Client1 and Client2) establish a connection and data interaction relationship with the first network device Server3.
[0055] Through the embodiment provided by the present application, a first coordination node is used to receive a transaction processing request triggered by a first network device configured in a first proxy node, wherein the transaction processing request is used to request processing of a target transaction; in response to the transaction processing request, the first coordination node determines the current transaction processing status of the first network device through a database in a distributed transaction processing network; when the current transaction processing status of the first network device is a ready state, the first coordination node sends a first notification message to other reference network devices in the distributed transaction processing network except the first network device, wherein the first notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the ready state; upon receiving a response confirmation message returned by the reference network device based on the first notification message, the first coordination node determines whether the target transaction is ready to be completed. Preparation stage; when the current transaction processing status of the above-mentioned first network device in the above-mentioned database is adjusted from the above-mentioned preparation state to the submission state, the above-mentioned first coordination node sends a second notification message to the above-mentioned reference network device, wherein the above-mentioned second notification message is used to instruct the above-mentioned reference network device to synchronously change the current transaction processing status of the above-mentioned first network device stored in the local storage space to the above-mentioned submission state. The first coordination node determines the current transaction processing status of the first network device and the current transaction processing status of the reference network device from the database in the above-mentioned distributed transaction processing network, and further determines the preparation stage and submission state of the target transaction, thereby achieving the purpose of avoiding data inconsistency of each node caused by the use of the 2PC protocol alone in the distributed system, thereby achieving the technical effect of flexibly controlling the data of each node in the distributed system to remain consistent, and thus solving the technical problem that all nodes in the distributed system cannot ensure data consistency.
[0056] In one embodiment, in step S202, in response to the transaction processing request, the first coordinating node determines the current transaction processing status of the first network device through a database in the distributed transaction processing network, including:
[0057] The first coordination node generates a status search request for the first network device based on the device identifier of the first network device carried in the transaction processing request, wherein the status search request is used to request to search for the current transaction processing status of the first network device stored in the database;
[0058] The first coordination node sends a status search request to the database and obtains the current transaction processing status of the first network device returned by the database. When it is found in the database that the current transaction processing status of the first network device is in a non-ready state, the current transaction processing status of the first network device is adjusted from a non-ready state to a ready state, and the current transaction processing status is returned to the first network device as a ready state; when it is found in the database that the current transaction processing status of the first network device is in a ready state or a running state, the first network device is instructed to stop processing the target transaction.
[0059] It should be noted that, in this embodiment, the device identification of the above-mentioned first network device may include but is not limited to one of the following: the model of the device, MAC address, IP address or serial number, etc., which are not limited here. In addition, in this embodiment, the non-ready state here refers to the state before entering the preparation stage. For example, assuming that the status value of the field corresponding to the preparation state in the database can be set to 1, and the status value of the non-ready state can be set to 0, then if it is found in the database that the current transaction processing state of the first network device is the non-ready state, then the current transaction processing state of the first network device is adjusted from the non-ready state to the ready state, and the status value of the first network device can be set from 0 to 1.
[0060] like Figure 3 As shown, the database TcaplusDb shows that the current transaction processing status of the first network device Server3 is not ready. In other words, Server3 is not currently online and is not connected to or interacting with other reference network devices (e.g., Client1). This means that Server3 has not yet been connected to the current distributed transaction processing network. When the current transaction processing status of the first network device Server3 is ready, Server3 is already connected to the distributed transaction processing network and is currently processing a transaction. It is ready to go online and can connect to and interact with other network devices (e.g., Client1 and Client2) at any time. When the current transaction processing status of the first network device Server3 is running, it indicates that Server3 is online and has established connections with other different network devices (e.g., Client1 and Client2) and can interact with data. Here, assuming that the target transaction is the online operation of the first network device Server3, if the database TcaplusDb shows that the current transaction processing status of Server3 is ready or running, the first network device Server3 is instructed to stop online operation.
[0061] Through the embodiments provided by this application, the first coordination node can generate a status query request based on the device identifier of the first network device carried in the transaction processing request, so as to forward the status query request to the database, so as to obtain the transaction processing status corresponding to the found first network device from the database, thereby avoiding inconsistent processing of the same network device. In other words, if the first network device is found in the database to be in a non-ready state, it is adjusted to a ready state; if the first network device is found in the database to be in a ready state or a running state, the current processing of the first network device is stopped. This prevents the problem of wasting system computing resources caused by repeated operations on the same network device.
[0062] In one embodiment, after the first coordination node determines that the target transaction has completed the preparation phase, the process further includes: the first coordination node sends a status update request to the database, so that the database adjusts the current transaction processing status of the first network device from the preparation state to the submission state.
[0063] In this embodiment, after each node in the distributed transaction processing system completes preparation work, the current transaction processing status of the first network device can be updated in the database.
[0064] For example, Figure 3 As shown, when all nodes in the distributed transaction processing system have completed the preparation work, that is, when other network devices in the current distributed transaction processing network (such as Client1 and Client2) are ready to interact with the first network device Server3 for data, the first network device Server3 can go online and update the online status or offline status of the first network device Server3 in real time in the database TcaplusDb.
[0065] Through the embodiments provided in the present application, by updating the current transaction processing status of the first network device in the database as mentioned above, the current network device in the distributed transaction processing network can obtain the real-time status information of other network devices in a timely manner, and avoid system congestion caused by network failures in the distributed transaction processing network and inconsistent data among various nodes in the system.
[0066] In one embodiment, step S204 includes: the above-mentioned first coordination node notifies the second network device configured in the above-mentioned first agent node of the returned current transaction processing status of the above-mentioned first network device, the third network device configured in the second agent node other than the above-mentioned first agent node associated with the above-mentioned first coordination node, and the fourth network device configured in the third agent node associated with the second coordination node in the above-mentioned distributed transaction processing network.
[0067] For example, combined with Figure 3 The content shown is used to illustrate that the first coordination node TbusppNs3 notifies the second network devices Client1 and Client2 configured in the first agent node Agent1 of the current transaction processing status of the returned first network device Server3, the third network device Client3 configured in the second agent node Agent2 associated with the first coordination node, and the fourth network device Client4 configured in the third agent node Agent3. The first coordination node and the second coordination node may include but are not limited to transaction management servers responsible for processing agent nodes and other coordination nodes connected thereto. The first coordination node TbusppNs3 and the second coordination node TbusppNs1 are responsible for managing the commit and rollback of multiple transactions in the current distributed transaction processing system, and ensuring the consistency of data in the distributed transaction processing system.
[0068] Step S206 includes: when the second network device configured in the first proxy node, the third network device configured in the second proxy node other than the first proxy node associated with the first coordination node, and the fourth network device configured in the third proxy node associated with the second coordination node in the distributed transaction processing network all return the response confirmation message, the first coordination node determines that the target transaction completes the preparation stage.
[0069] like Figure 3 As shown, when the second network devices Client1 and Client2 configured in the first agent node Agent1, the third network device Client3 configured in the second agent node Agent1 other than the first agent node associated with the first coordination node TbusppNs3, and the fourth network device Client4 configured in the third agent node Agent3 associated with the second coordination node TbusppNS2 in the distributed transaction processing network all return the above-mentioned response confirmation message, the first coordination node TbusppNs3 determines that the above-mentioned target transaction has completed the above-mentioned preparation stage; for example, after the third network device Client3 and the fourth network device Client4 both return a response to the notification issued by the first coordination node TbusppNs3 that the first network device Server3 is ready to go online, they return a confirmation message confirming receipt of the notification, and the first coordination node TbusppNs3 determines that the current target transaction has completed the preparation stage, that is, the clients of the server in the current distributed management system have the conditions to connect to each other and exchange data.
[0070] Step S208 includes: the above-mentioned first coordination node sends the above-mentioned second notification message to the above-mentioned second network device configured in the above-mentioned first agent node, the above-mentioned third network device configured in the above-mentioned second agent node other than the above-mentioned first agent node associated with the above-mentioned first coordination node, and the above-mentioned fourth network device configured in the above-mentioned third agent node associated with the above-mentioned second coordination node in the above-mentioned distributed transaction processing network.
[0071] like Figure 3 As shown, the first coordination node TbusppNs3 sends the second notification message to the second network devices Client1 and Client2 configured in the first agent node, the third network device Client3 configured in the second agent node Agent2 associated with the first coordination node TbusppNs3, and the fourth network device Client4 configured in the third agent node Agent2 associated with the second coordination node TbusppNs2 in the distributed transaction processing network.
[0072] Through the embodiments provided in the present application, in a distributed transaction processing network, the above-mentioned interactive notification messages enable the current network device to obtain the real-time status information of other network devices in a timely manner, and also avoid system congestion caused by network failures in the distributed transaction processing network and inconsistent data among various nodes in the system.
[0073] In one embodiment, the above-mentioned data processing method also includes: when at least one reference network device does not return a response confirmation message, the first coordination node sends a third notification message to the reference network device, wherein the third notification message is used to notify the reference network device that the target transaction processing has failed; when at least one reference network device returns a response rejection message, the first coordination node sends a fourth notification message to the reference network device, wherein the fourth notification message is used to notify the reference network device that the target transaction processing has failed.
[0074] Alternatively, as Figure 3As shown, the third notification message and the fourth notification message may be messages indicating that the first network device Sever1 has failed to go online. In this embodiment, for example, when either the reference network device Client1 or Client2 does not return a corresponding confirmation message (e.g., when Client1 or Client2 is down), the first coordination node TbusppNs3 sends a message to Client1 or Client2 indicating that the first network device Server3 has failed to go online. When either the reference network device Client1 or Client2 returns a response rejection message (refusing to interact with Server3), the first coordination node TbusppNs3 sends a message to Client1 or Client2 indicating that the first network device Server3 has failed to go online.
[0075] Through the embodiments provided by the present application, when at least one reference network device in a distributed transaction processing network does not return a response confirmation message, or when at least one reference network device returns a response rejection message, the first coordination node is used to notify other reference network devices that the target transaction processing has failed, thereby solving the problem of system resource locking caused by a single point failure in the system when the distributed transaction processing network solely adopts a 2PC architecture, facilitating rapid coordination and notification of various network devices in the distributed transaction processing network, and improving the efficiency of distributed transaction processing.
[0076] In one embodiment, after the first coordination node receives a transaction processing request triggered by the first network device configured in the first proxy node, it also includes: the first coordination node receives fault information reported by the first proxy node and the second proxy node associated with the first coordination node; the first coordination node identifies the faulty network device based on the fault information, and terminates the transaction processing operation of the faulty network device.
[0077] In this embodiment, if Figure 3 As shown, the first coordination node TbusppNs3 receives fault information reported by the first agent node Agent1 and the second agent node Agent2. The fault information may include the machine identifier of the client (such as Client1 or Client2) or server (Server2 or Server3), such as the serial number or media access control MAC address. The specific cause of the fault may include machine downtime or restart, or network data loss. After the first coordination node TbusppNs3 identifies the faulty network device through the fault information, it terminates the transaction processing operation of the network device in the current distributed transaction processing network.
[0078] Through the embodiments provided herein, the first coordinating node can also identify faulty network devices in the distributed transaction processing network based on fault information received from associated nodes, and promptly terminate transaction processing operations on the faulty network devices. This avoids the problem of reduced processing efficiency caused by the inability to continue transaction processing during a fault, thereby improving fault repair efficiency and transaction processing efficiency.
[0079] In one embodiment, after the first coordination node receives the transaction processing request triggered by the first network device configured in the first proxy node, it also includes: when the first coordination node fails and the target coordination node in the distributed processing network receives the transaction processing request sent by the first proxy node, the target coordination node sends a status lookup request to the database according to the transaction processing request; when the current transaction processing status of the first network device returned by the database is a ready state, the target coordination node replaces the first coordination node to process the target transaction.
[0080] For example, still using the above Figure 3 As shown in the example, when the first coordination node TbusppNs3 fails and the target coordination node (such as TbusppNs2) in the distributed processing network receives a transaction processing request sent by the first agent node Agent1, the target coordination node TbusppNs2 sends a status search request to the database TcaplusDb according to the transaction processing request; when the current transaction processing status of the first network device Server returned by the database TcaplusDb is the ready state, the target coordination node TbusppNs2 replaces the first coordination node TbusppNs1 to process the target transaction.
[0081] Through the embodiments provided in the present application, when the first coordination node fails and the target coordination node receives a transaction processing request, the target coordination node continues to process the transaction instead of the first coordination node to ensure the normal processing of distributed transaction processing, thereby avoiding the impact of the coordination node failure on the distributed transaction processing process.
[0082] According to another aspect of the embodiment of the present invention, a data processing method is also provided, which is applied in an agent node. Figure 4 As shown, the above data processing method includes:
[0083] S402: The first proxy node receives a transaction processing request triggered by the configured first network device, and sends the transaction processing request to the associated first coordination node, wherein the transaction processing request is used to request processing of a target transaction;
[0084] S404, in response to the transaction processing request, the first proxy node determines the current transaction processing status of the first network device through a database in the distributed transaction processing network;
[0085] S406: When the current transaction processing state of the first network device is the ready state, the first proxy node sends a first notification message to other reference network devices in the distributed transaction processing network except the first network device through the first coordinator node, wherein the first notification message is used to instruct the reference network devices to synchronously change the current transaction processing state of the first network device stored in the local storage space to the ready state.
[0086] S408, upon receiving a response confirmation message returned by the reference network device based on the first notification message, the first proxy node determines that the target transaction completes the preparation phase;
[0087] S410, when the current transaction processing status of the first network device in the database is adjusted from the preparation status to the submission status, the first proxy node sends a second notification message to the reference network device, wherein the second notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the submission status.
[0088] In this embodiment, the above data processing method can be applied to, but not limited to, distributed transaction processing. The distributed transaction processing stages here can include, but are not limited to, using the above two-phase commit protocol (hereinafter referred to as 2PC). Here, the above data processing method can be as follows: Figure 5 Distributed transaction processing architecture in Figure 5 As shown, when the first coordination node is TbusppNs3, the first agent node can be Agent1, the first network device can be Server3, the database in the distributed transaction processing network can be TcaplusDb, and the reference network devices can be Client1, Client2, Client3, and Client4, Server1, or Server2. The reference network devices include a second network device, a third network device, and a fourth network device. The second network device can be Client1 and Client2, the second agent node can be Agent2, the third agent node can be Agent3, the third network device can be Client3, the fourth network device can be Client4, and the second coordination node can be TbusppNs2. The above description is only an example and is not intended to be limiting.
[0089] It should be noted that, in step S402, the first proxy node may be responsible for receiving transaction processing requests from the first network device and receiving communication messages sent to the first network device by other network devices. The first network device may include but is not limited to a server or a client.
[0090] In step S404, the first proxy node may determine the transaction processing status of the first network device through the distributed transaction processing network database. The transaction processing status may include but is not limited to a prepare state and a commit state.
[0091] In step S406, when the transaction processing status of the first network device is in the ready state, the first proxy node can send the first notification message to other reference network devices participating in the transaction processing through the first coordination node, so that the transaction processing status of each node in the distributed transaction processing network remains consistent.
[0092] In step S408 , when the reference network device receives the preparation status information sent by the first network device and feeds back its own status information, the first proxy node may determine that the target transaction is in the completion preparation state.
[0093] In step S410, when the transaction processing status of the first network device in the database is the committed status, the first proxy node notifies other network devices to synchronize to the committed status to keep the data of each node in the distributed transaction processing system consistent.
[0094] Through the embodiment provided by the present application, the first proxy node receives a transaction processing request triggered by the configured first network device for requesting the processing of a target transaction, and responds to the transaction processing request, and determines the current transaction processing status of the first network device through the database in the distributed transaction processing network. Then, when the current transaction processing status of the first network device is in the ready state, the first coordination node sends a first notification message to other reference network devices in the distributed transaction processing network except the first network device, to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the ready state. Further, when a response confirmation message is received, it is determined in the first proxy node that the target transaction has completed the preparation stage. When the current transaction processing status of the first network device in the database is adjusted from the ready state to the committed state, a second notification message is sent to the reference network device to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the committed state. That is, the first proxy node cooperates with the first coordination node to complete the preparation stage and submission status of the distributed transaction, thereby avoiding the data inconsistency of each node caused by the use of the 2PC protocol alone in the distributed system, thereby achieving the technical effect of flexibly controlling the data of each node in the distributed system to maintain consistency, and thus solving the technical problem that all nodes in the distributed system cannot guarantee data consistency.
[0095] In one embodiment, step S404, the first proxy node receives a transaction processing request triggered by the configured first network device and sends the transaction processing request to the associated first coordination node, including: the first proxy node sends a status query request to a database through the first coordination node, wherein the status query request is used to request to query the current transaction processing status of the first network device stored in the database;
[0096] The first proxy node obtains the current transaction processing status of the first network device returned by the database, wherein, if it is found in the database that the current transaction processing status of the first network device is in a non-ready state, the current transaction processing status of the first network device is adjusted from a non-ready state to a ready state, and the current transaction processing status is returned to the first network device as a ready state; if it is found in the database that the current transaction processing status of the first network device is in a ready state or a running state, the first network device is instructed to stop processing the target transaction.
[0097] In this embodiment, if Figure 5As shown, for example, the first agent node Agent1 obtains that the current transaction processing status of the first network device Server3 in the database TcaplusDb is unprepared. Assuming that the current first network device is in an offline state, the status value of the field corresponding to the ready state in the database TcaplusDb can be set to 1, and the status value of the unprepared state can be set to 0. Then, if it is found in the database TcaplusDb that the current transaction processing status of the first network device Server3 is unprepared, the current transaction processing status of the first network device is adjusted from unprepared to prepared, and the status value of the first network device Server3 can be set from 0 to 1. Here, the ready state may be that the first network device is in the current transaction processing of Server3, for example, it is in the ready-to-go-on state, but has not interacted with other network devices (such as Client1 and Client2) for data; the running state may be that the first network device Server3 has been online and has established associations with other network devices (such as Client1 and Client2) and is interacting with data; when it is found in the database TcaplusDb that the current transaction processing state of the first network device Server3 is the ready state or the running state, the first network device can be stopped from processing the target transaction, for example, the first network device can be stopped from going online or offline again.
[0098] Through the embodiments provided herein, the first proxy node can send a status query request to retrieve the transaction processing status corresponding to the first network device from the database, thereby avoiding conflicting processing for the same network device. Specifically, if the database finds the first network device in a non-ready state, it is adjusted to a ready state; if the database finds the first network device in a ready or running state, the current processing of the first network device is stopped. This prevents the waste of system computing resources caused by repeated operations on the same network device.
[0099] In one embodiment, after the first proxy node receives the transaction processing request triggered by the configured first network device and sends the transaction processing request to the associated first coordination node, the method further includes:
[0100] In the event that the first coordination node fails, the first proxy node reselects a target coordination node from the distributed processing network; after a first time interval is reached, the first proxy node sends a transaction processing request to the target coordination node; when the target coordination node confirms that the current transaction processing status of the first network device is in the ready state, the first proxy node sends a first notification message to the reference network device through the target coordination node; when the current transaction processing status of the first network device in the database is adjusted from the ready state to the committed state, the first proxy node sends a second notification message to the reference network device through the target coordination node.
[0101] In this embodiment, if Figure 5 As shown, when the first coordination node TbusppNs3 fails, the first agent node Agent1 selects other coordination nodes (such as TbusppNs2) as alternative nodes. When the first coordination node TbusppNs3 has not returned to normal after the first time interval, TbusppNs2 can be replaced by the first coordination node TbusppNs3 to process transactions in the current distributed transaction processing network.
[0102] Through the embodiments provided by the present application, in the event that the first coordination node fails, the first proxy node can reselect a target coordination node from the distributed processing network, and then continue to process transactions through the target coordination node instead of the first coordination node to ensure the normal processing of distributed transaction processing, thereby avoiding the impact of the coordination node failure on the distributed transaction processing process.
[0103] In one embodiment, after the first proxy node sends the second notification message to the reference network device, it also includes: when at least one reference network device does not receive the second notification message, the first proxy node sends a reconciliation request to the first coordination node; the first proxy node obtains the latest routing information of the first network device returned by the first coordination node.
[0104] Optionally, in this embodiment, if Figure 5As shown, the reconciliation request may include, but is not limited to, a request from the first agent node Agent1 to the first coordination node TbusppNs3 to obtain the latest status information of the first network device Server3. Specifically, when reference network devices (such as Client1 and Client2) change to the ready state and proceed to the next process, namely, the submission operation, and do not receive submission status information from at least one reference network device within a preset time period, the first agent node Agent1 may obtain the latest status information of the first network device Server3 from the first coordination node TbusppNs3 via the first agent node Agent1. For example, after the first agent node Agent1 sends a notification message that Server3 is online, due to network delays or data transmission failures, the reference network devices Client1 or Client2 do not receive the online notification message. In this case, the first agent node Agent1 sends a reconciliation request to the first coordination node TbusppNs3 to verify whether Server3 is online. Specifically, the first agent node Agent1 obtains the routing connection information of the first network device Server3 returned by the first coordination node TbusppNs3. In other words, the first agent node obtains the current online status information of the first network device Server3.
[0105] According to the embodiments provided herein, if at least one reference network device has not received the second notification message, the first proxy node sends a reconciliation request to the first coordinator node to obtain the latest routing information of the first network device returned by the first coordinator node. This allows for timely updates of the communication links of each node in the distributed transaction processing system, ensuring data consistency across all nodes.
[0106] In one embodiment, after the first proxy node sends the first notification message to other reference network devices other than the first network device in the distributed transaction processing network through the first coordination node, it also includes: when the reference network device is included in the first proxy node, a status node is created for the first network device in the hash ring of the reference network device, and the status value corresponding to the status node is synchronously configured to a ready state.
[0107] In order to ensure the load balancing of client requests to access the server, a consistent hash algorithm can be used, but is not limited to it. Figure 6As shown in the figure, there are two servers in the current routing table, Server-1 and Server-2. When clients Client-1, Client-2, and Client-3 access data with the key PIC1, they calculate the hash formula Hash(PIC1)%2=1, and the content they obtain is on Server-1. However, if a new server, Server-3, is added to the current server cluster, the hash formula Hash(PIC1)%3=2 will be used, and the content accessed by the client through the hash algorithm will be on Server-2. This will cause data inconsistency when the client accesses the server.
[0108] In order to solve the above problem, in this embodiment, a hash ring is used to map the relationship between the client accessing the server. It should be noted that the above hash ring can be, but is not limited to, a ring built based on the Hash consistency algorithm to record the status of each node (such as Server1, Server2) in the distributed transaction processing network in order to ensure the load balancing of the client requesting to access the server; there are 2 32 Node locations.
[0109] For example, Figure 3 As shown, before adding Server-3, the IP addresses or server names of Server-1 and Server-2 are hashed and evenly mapped to the corresponding server nodes or virtual nodes on the hash ring. Server-1 corresponds to server node 302, virtual node 306, and virtual node 310 on the hash ring; Server-2 corresponds to server node 304, virtual node 308, and virtual node 312 on the hash ring. The key value of the data key is calculated using the same hash function to obtain a hash value. The position on the hash ring can be determined based on the hash value. The server node encountered at this position along the hash ring clockwise is the server corresponding to the data key. The hash algorithm calculates the formula Hash(PIC1)%2 32 =1, the content is all on Server-1; if a new server Server-3 is added to the current server cluster, the Hash algorithm is used to calculate the formula Hash(PIC1)%2 32 The result is still 1, so the content accessed by the client through the hash algorithm is still on Server-1. This avoids the problem of inconsistent data when the client accesses the server.
[0110] In this embodiment, the hash ring can be used to record the node status of the reference network device connected to other network devices. Figure 3As shown, the server node 302 on the hash ring can be a state node that records the Server-1 state; and the state value corresponding to the state node is synchronously configured as a ready state. Figure 5 As shown, a corresponding server node 502 and a virtual node 504 are created for the server Server3, and the state values of the state nodes corresponding to the server node 502 and the virtual node 504 are synchronously configured to be in the ready state.
[0111] Alternatively, as Figure 7 As shown, it is also possible to create only the corresponding server node 702 for the server Server3, and synchronously configure the state value of the state node corresponding to the server node 702 to be in the ready state.
[0112] Through the embodiments provided by the present application, when the first proxy node includes a reference network device, a status node is created for the first network device in the hash ring of the reference network device, and the status value corresponding to the status node is synchronously configured to a ready state. That is, in a distributed transaction processing network, each network device can obtain the status information of the current server in real time based on the hash ring, and also avoids data inconsistency when the client accesses the server.
[0113] In one embodiment, after the first proxy node sends the second notification message to the reference network device, it also includes: when the reference network device is included in the first proxy node, the status value corresponding to the status node of the first network device stored in the hash ring of the reference network device is synchronously changed from the ready state to the submitted state.
[0114] In this embodiment, if Figure 7 As shown, for example, when the first network device Server3 comes online, the state value of Server3 in the server node 702 corresponding to the first network device Server3 in the hash ring of the reference network device Client1 can be synchronously changed from the ready state to the committed state. For example, it can be queried in the server node 702 that the first network device Server3 has come online.
[0115] Through the embodiments provided in the present application, the status values of the status nodes of the hash records in each reference network device are synchronously changed, thereby ensuring the consistency of the data of each node in the distributed transaction processing network, thereby avoiding the situation where the transaction processing fails due to inconsistency and has to be rolled back.
[0116] In one embodiment, after the first proxy node determines that the target transaction has completed the preparation stage, it also includes: when the current transaction processing status of the first network device in the database has not been adjusted from the preparation state to the submission state, the first proxy node sends a third notification message to the reference network device, wherein the third notification message is used to notify the reference network device that the target transaction processing has failed.
[0117] In this embodiment, if Figure 7 For example, when the current transaction processing status of the first network device Server3 in the database TcaplusDb has not been adjusted from the ready-to-go-online state to the online state, the first agent node Agent1 sends a message to the reference network devices (such as Client1 and Client2) to notify them of the target transaction failure. This technology allows for real-time notification of any abnormality at any node in the distributed system to other nodes, thereby preventing system resource consumption caused by other nodes locking system resources.
[0118] In one embodiment, after the first proxy node sends the third notification message to the reference network device, the method further includes: when the first proxy node includes the reference network device, removing the status node configured for the first network device in the hash ring of the reference network device.
[0119] like Figure 7 As shown, when the current transaction processing status of the first network device Server3 in the database has not been adjusted from the ready-to-go-online status to the online status, the status node 702 corresponding to the first network device Server3 is deleted from the hash ring to obtain the following: Figure 8 The hash ring 802 is shown. Through the above technical means, the data of each node in the distributed transaction processing network can be guaranteed to be consistent.
[0120] In one embodiment, the reference network device includes: a second network device configured in the first agent node, a third network device configured in a second agent node other than the first agent node associated with the first coordination node, and a fourth network device configured in a third agent node associated with the second coordination node in the distributed transaction processing network.
[0121] It should be noted that for the aforementioned method embodiments, for simplicity of description, they are all expressed as a series of action combinations. However, those skilled in the art should be aware that the present invention is not limited by the order of the actions described, because according to the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0122] The following application examples are specifically described: Figure 7 As shown in the figure, assuming that the timing process of Server 3 requesting to go online is used as an example, the steps may include:
[0123] S1, Server3 submits an online request to TbusppNs3 through Agent4.
[0124] S2. After receiving the online request from Server3, TbusppNs3 checks the status of Server3 in the database Tcaplusdb (cache) to view the current 2PC status of Server3. If it is not in the prepare stage, the status in TcaplusDb is changed to prepare (if it is already in prepare or online, the online process is stopped and the online failure is returned). The above technical means can avoid wasting system resources by online agents for multiple times on the same server.
[0125] In step S3, after modifying the status of Server3 in Tcaplusdbdb, TbusppNs3 sends a prepare notification (phase one) to Agent4 and other coordinating nodes (such as TbusppNs1) for Server3 to come online. TbusppNs3 then waits for responses from all Prepare nodes and for the first phase of the prepare process to complete.
[0126] S4, other agent nodes Agent1-N receive the online notification and pre-online route of Server3, add the status point of Server3 to the routing hash ring of the client (such as Client1 and Client2), and return Prepare success to TbusppNs3.
[0127] S5: Server3 completes the prepare online process and stores Tcaplusdb online information in the data.
[0128] Further Figure 7 As shown, assuming that the timing process of the second stage (commit stage) of Server 3 preparing to go online is used as an example, it can include the following steps: S1, when all nodes (such as Client1 or Client3) return the Prepare notification of preparation success, TbusppNs3 first writes the status of Server 3 to the database TcaplusDb as commit submission success, that is, the online success.
[0129] S2 then sends a Commit notification of Server3 coming online to Agent4 and other coordination nodes (such as TbusppNs2) to notify them of a successful submission.
[0130] S3, after other network devices receive the successful commit from Server 3, the nodes on the hash ring take effect, and Server 3 is successfully online.
[0131] like Figure 9 As shown in the figure, let's take the timing process of Server 3 failing to go online as an example. The steps may include:
[0132] S1: If some client nodes (such as Client1 and Client2) return Prepare failure, or the waiting for Prepare response times out, TbusppNs3 sends an Abort notification to Agent4 and other coordination nodes (such as TbusppNs2) to cancel Server3's online process.
[0133] In step S2, after other network devices receive the Abort notification from Server 3, the Prepare node on the hash ring is removed, and Server 3 fails to go online.
[0134] In such Figure 10 The 2PC two-phase commit shown in the figure includes two phases. The first phase is as follows Figure 10 As shown in (a), one party first proposes, such as Figure 10 As shown in (b), the node collects feedback (votes) from other nodes and then decides to commit or abort the transaction based on the feedback. The node that proposes the transaction can be called the coordinator, and the other nodes that participate in the decision are called participants (or cohorts).
[0135] Phase 1 (Preparation) of 2PC: The coordinator sends a "Prepare commit" message to all participants and waits for their responses. Upon receiving the coordinator's "Prepare commit," the participant performs operations such as persisting undolog undo and redolog redo until a commit or rollback is possible. Local operations performed by the participant after receiving the "Prepare commit" message may succeed or fail. If successful, the participant responds with an "OK" message; if unsuccessful, the participant responds with a "notOK" message.
[0136] like Figure 11 As shown, the second phase of 2PC is divided into the following two cases:
[0137] 1. Commit status:
[0138] If the coordinator receives OK from all participants, it will send a Commit message to all participants; each participant performs a local commit and releases the locks and other related resources held by the transaction.
[0139] 2. Rollback situation:
[0140] If the coordinator receives a failure message from any participant (or coordinatorPrepare times out), the coordinator sends a Rollback message to all participants.
[0141] When using the 2PC protocol alone in a distributed system, the following situations may occur, and the embodiments provided in this application can overcome the related defects:
[0142] The first case: Coordinator Crash (coordinator node crash) before the Prepare phase: Before the message is sent, the coordinator may crash, that is, the coordinator may crash.
[0143] like Figure 3 As shown, because the 2PC process has not started and the 2PC protocol has not been initiated, TbusppNs3 (coordinator) crashes and Server3 is in an online failure state. The coordinator node and the agent node will not be involved in the processing method provided in this embodiment.
[0144] Case 2: Coordinator crash after the Prepare phase: If some, but not all, proposals from the first phase have been sent, the coordinator crashes. However, some participants have already received the proposals and started the 2PC process, while others are in a waiting state. If the coordinator doesn't recover for a long time, the participants who started the 2PC process will be blocked waiting for notifications from the second phase of the 2PC process.
[0145] In order to overcome the defects in the second case, Figure 3As shown, through the embodiment provided by the present application, when the first coordination node TbusppNs3 initiates the Prepare Phase and then crashes or restarts, the proxy node Agent4 can choose to connect to a new coordination node (such as TbusppNs2). After 5 seconds, the PreparePhase of Server3 will be unlocked, and TbusppNs2 will re-initiate the online request of Server3, thereby solving the technical problem that the system cannot operate normally due to the failure of a single coordination node in the distributed transaction processing network.
[0146] The third case: Coordinator Crash after Prepare phase: When the coordinator crashes at this time, another participant can take over the work of the coordinator. That is, when a coordination node times out, the node can be forced to complete the protocol started by the main coordinator. Like the message sent in the first phase, the node can contact all other participants and find out the results of their votes. This requires that all nodes participating in 2PC keep the results of the execution in a persistently stored database until all participants know that all other nodes have committed or aborted; otherwise, if all nodes forget the operations performed for a given execution, the new coordinator node will not be able to recover the transaction state after taking over from the previous coordinator.
[0147] In order to overcome the defects in the third case, Figure 3 As shown, when the first coordination node TbusppNs3 crashes, the agent node Agent4 will actively connect to a new coordination node (such as TbusppNs2) and re-initiate the Server online request after 5 seconds. At this time, TbusppNs2 queries the local cache Cache and database TcaplusDb to determine whether the current stage status is Prepare. If so, TbusppNs2 will automatically take over the current Server3's online transaction and take over the last online transaction processed by TbusppNs3, and then re-initiate the new Server3's 2PC online process.
[0148] The fourth case: Participant Crash after Prepare phase: If the coordinator receives Prepare responses from all participants and then initiates the second-phase commit operation to all participants, but the second-phase message of 2PC is not received due to network jitter or participant restart, then the participant currently in the transaction failure state will remain in the voting phase and will continue to occupy system resources.
[0149] In order to overcome the defects in the fourth case, Figure 3 As shown in the figure, if during the 2PC phase when Server3 is online, the commit / abort notification of the second phase is lost due to network jitter, then the agent node Agent1 does not receive the commit notification from Server3. After a 1.5s timeout, it will proactively initiate a reconciliation process to the coordination node TbusppNs 3, that is, obtain the latest routing information of Server3 and further obtain the latest status information of Server3, thereby achieving consistency of various data in the distributed transaction processing network.
[0150] The fifth case: Participant confusion: If some participant codes have bugs, they may send arbitrary data to the coordinator or not reply to the coordinator, causing system confusion and the system cannot recover.
[0151] In order to overcome the defects in the fifth case, Figure 3 As shown, if Server3 or Client1 has a bug and a Byzantine failure occurs, for example, if Client1 continues to report errors through Agent1 or fails to report information to TbusppNs1, TbusppNs1 will proactively identify this and remove Client1 from the current distributed transaction processing network. Subsequent 2PC processes will not notify Client1 of the Byzantine failure. This method allows faulty node devices to be removed from the network in a timely manner, saving system resources.
[0152] In an application embodiment, if Figure 12As shown, to address the low efficiency of serial execution of the 2PC process, TbusppMesh has optimized concurrency performance. It supports multiple instances initiating the 2PC Prepare phase simultaneously. The client will concurrently process the online logic of multiple instances. The coordination nodes TbusppNs1 to TbusppNsN will periodically query all instances that have successfully completed the Prepare phase and batch submit the server online or offline commit / abort, thereby completing the batch online and offline of multiple servers. The 2PC combined with busppMesh distributed system has the ability to support batch node online and offline.
[0153] The embodiments of the present invention combine the disaster recovery, high performance, and reconciliation capabilities of the existing components of TbusppMesh to make up for the shortcomings of the traditional 2PC process, ensuring the consistency of the game background stateful service in extreme situations, thereby preventing users from being disconnected and shortening user queue times.
[0154] In addition, the 2PC transaction mechanism has been optimized, the serial logic of 2PC transactions has been optimized, and a technical solution for parallel online and offline operations has been proposed, which has significantly improved the performance and provided higher availability for batch online and offline operations in the game production environment.
[0155] According to another aspect of the embodiment of the present invention, a data processing device for implementing the above data processing method is also provided. Figure 13 As shown, the device includes:
[0156] A receiving unit 1302 is configured to receive, by the first coordinating node, a transaction processing request triggered by a first network device configured in the first proxy node, wherein the transaction processing request is used to request processing of a target transaction;
[0157] A first determining unit 1304 is configured to respond to the transaction processing request by the first coordinating node and determine the current transaction processing status of the first network device through a database in the distributed transaction processing network;
[0158] A first sending unit 1306 is configured to, when the current transaction processing state of the first network device is a ready state, send, by the first coordinating node, a first notification message to other reference network devices in the distributed transaction processing network except the first network device, wherein the first notification message is used to instruct the reference network devices to synchronously change the current transaction processing state of the first network device stored in a local storage space to the ready state;
[0159] The second determining unit 1308 is configured to, upon receiving a response confirmation message returned by the reference network device based on the first notification message, determine that the target transaction has completed the preparation phase;
[0160] The second sending unit 1310 is used to send a second notification message to the reference network device by the first coordination node when the current transaction processing status of the first network device in the database is adjusted from the preparation status to the submission status, wherein the second notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the submission status.
[0161] In an embodiment of the present invention, a first coordination node is used to receive a transaction processing request triggered by a first network device configured in a first proxy node, wherein the transaction processing request is used to request processing of a target transaction; in response to the transaction processing request, the first coordination node determines the current transaction processing status of the first network device through a database in a distributed transaction processing network; when the current transaction processing status of the first network device is a preparation status, the first coordination node sends a first notification message to other reference network devices in the distributed transaction processing network except the first network device, wherein the first notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the preparation status; upon receiving a response confirmation message returned by the reference network device based on the first notification message, the first coordination node determines that the target transaction has completed the preparation stage; and updates the database When the current transaction processing status of the first network device is adjusted from the preparation status to the submission status, the first coordination node sends a second notification message to the reference network device, wherein the second notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the submission status. The first coordination node determines the current transaction processing status of the first network device and the current transaction processing status of the reference network device from the database in the distributed transaction processing network, and further determines the preparation stage and submission status of the target transaction, thereby achieving the purpose of avoiding data inconsistency of each node caused by the use of the 2PC protocol alone in the distributed system, thereby realizing the technical effect of flexibly controlling the data of each node in the distributed system to remain consistent, and further solving the technical problem that all nodes in the distributed system cannot ensure data consistency due to network congestion or node communication abnormality when using the 2PC protocol.
[0162] According to another aspect of the embodiment of the present invention, a data processing device for implementing the above data processing method is also provided. Figure 14 As shown, the device includes:
[0163] Receiving unit 1402, configured for the first proxy node to receive a transaction processing request triggered by the configured first network device, and send the transaction processing request to the associated first coordination node, wherein the transaction processing request is used to request processing of a target transaction;
[0164] A first determining unit 1404 is configured to respond to the transaction processing request by the first proxy node and determine the current transaction processing status of the first network device through a database in the distributed transaction processing network;
[0165] A first sending unit 1406 is configured to, when the current transaction processing state of the first network device is the ready state, send, by the first proxy node, a first notification message to other reference network devices in the distributed transaction processing network other than the first network device through the first coordinating node, wherein the first notification message is used to instruct the reference network devices to synchronously change the current transaction processing state of the first network device stored in the local storage space to the ready state;
[0166] The second determining unit 1408 is configured to determine, when the first proxy node receives a response confirmation message returned by the reference network device based on the first notification message, that the target transaction completes the preparation phase;
[0167] The second sending unit 1410 is used to send a second notification message to the reference network device by the first proxy node when the current transaction processing status of the first network device in the database is adjusted from the preparation status to the submission status, wherein the second notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the submission status.
[0168] In an embodiment of the present invention, a first coordination node is used to receive a transaction processing request triggered by a first network device configured in a first proxy node, wherein the transaction processing request is used to request processing of a target transaction; in response to the transaction processing request, the first coordination node determines the current transaction processing status of the first network device through a database in a distributed transaction processing network; when the current transaction processing status of the first network device is a preparation status, the first coordination node sends a first notification message to other reference network devices in the distributed transaction processing network except the first network device, wherein the first notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the preparation status; upon receiving a response confirmation message returned by the reference network device based on the first notification message, the first coordination node determines that the target transaction has completed the preparation stage; and updates the database When the current transaction processing status of the first network device is adjusted from the preparation status to the submission status, the first coordination node sends a second notification message to the reference network device, wherein the second notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the submission status. The first coordination node determines the current transaction processing status of the first network device and the current transaction processing status of the reference network device from the database in the distributed transaction processing network, and further determines the preparation stage and submission status of the target transaction, thereby achieving the purpose of avoiding data inconsistency of each node caused by the use of the 2PC protocol alone in the distributed system, thereby realizing the technical effect of flexibly controlling the data of each node in the distributed system to remain consistent, and further solving the technical problem that all nodes in the distributed system cannot ensure data consistency due to network congestion or node communication abnormality when using the 2PC protocol.
[0169] According to another aspect of the embodiment of the present invention, an electronic device for implementing the above data processing method is also provided. The electronic device may be Figure 1 The terminal device or server shown in FIG. This embodiment is described by taking the electronic device as a terminal device as an example. Figure 15 As shown, the electronic device includes a memory 1502 and a processor 1504. The memory 1502 stores a computer program, and the processor 1504 is configured to execute the steps in any of the above method embodiments through the computer program.
[0170] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
[0171] Optionally, in this embodiment, the processor may be configured to execute the following steps through a computer program:
[0172] S10, the first coordinating node receives a transaction processing request triggered by a first network device configured in the first proxy node, wherein the transaction processing request is used to request processing of a target transaction;
[0173] S20, in response to the transaction processing request, the first coordination node determines the current transaction processing status of the first network device through a database in the distributed transaction processing network;
[0174] S30, when the current transaction processing state of the first network device is the ready state, the first coordinating node sends a first notification message to other reference network devices in the distributed transaction processing network except the first network device, wherein the first notification message is used to instruct the reference network devices to synchronously change the current transaction processing state of the first network device stored in the local storage space to the ready state;
[0175] S40, upon receiving a response confirmation message returned by the reference network device based on the first notification message, the first coordination node determines that the target transaction completes the preparation phase;
[0176] S50, when the current transaction processing status of the first network device in the database is adjusted from the prepare status to the commit status, the first coordination node sends a second notification message to the reference network device, wherein the second notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the commit status.
[0177] Alternatively, those skilled in the art will appreciate that Figure 15 The structure shown is for illustration only, and the electronic device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (MID), a PAD, or other terminal devices. Figure 15 It does not limit the structure of the electronic device. For example, the electronic device may also include Figure 15 More or fewer components (such as network interfaces, etc.) as shown in, or with Figure 15 Different configurations shown.
[0178] Among them, the memory 1502 can be used to store software programs and modules, such as program instructions / modules corresponding to the data processing method and device in the embodiment of the present invention. The processor 1504 executes various functional applications and data processing by running the software programs and modules stored in the memory 1502, that is, realizes the above-mentioned data processing method. The memory 1502 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1502 may further include a memory remotely located relative to the processor 1504, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include but are not limited to the Internet, corporate intranets, local area networks, mobile communication networks and combinations thereof. Among them, the memory 1502 can be used to store information such as the status of network equipment, but is not limited to it. As an example, if Figure 15 As shown, the memory 1502 may include, but is not limited to, the receiving unit 1302, the first determining unit 1304, the first sending unit 1306, the second determining unit 1308, and the second sending unit 1310 in the distributed transaction processing apparatus. Furthermore, the memory 1502 may also include, but is not limited to, other module units in the distributed transaction processing apparatus, which will not be described in detail in this example.
[0179] Optionally, the transmission device 1506 is used to receive or send data via a network. Specific examples of the network may include a wired network and a wireless network. In one embodiment, the transmission device 1506 includes a network interface controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In one embodiment, the transmission device 1506 is a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0180] In addition, the electronic device further includes: a display 1508 for displaying the status of the network device; and a connection bus 1510 for connecting various module components in the electronic device.
[0181] According to another aspect of the embodiment of the present invention, an electronic device for implementing the above data processing method is also provided. The electronic device may be Figure 1 The terminal device or server shown in FIG. This embodiment is described by taking the electronic device as a terminal device as an example. Figure 16 As shown, the electronic device includes a memory 1602 and a processor 1604. The memory 1602 stores a computer program, and the processor 1604 is configured to execute the steps in any of the above method embodiments through the computer program.
[0182] Optionally, in this embodiment, the electronic device may be located in at least one network device among a plurality of network devices of a computer network.
[0183] Optionally, in this embodiment, the processor may be configured to execute the following steps through a computer program:
[0184] S11, a first proxy node receives a transaction processing request triggered by a configured first network device, and sends the transaction processing request to an associated first coordination node, wherein the transaction processing request is used to request processing of a target transaction;
[0185] S21, in response to the transaction processing request, the first proxy node determines the current transaction processing status of the first network device through a database in the distributed transaction processing network;
[0186] S31: When the current transaction processing state of the first network device is the ready state, the first proxy node sends a first notification message to other reference network devices in the distributed transaction processing network except the first network device through the first coordinating node, wherein the first notification message is used to instruct the reference network devices to synchronously change the current transaction processing state of the first network device stored in the local storage space to the ready state;
[0187] S41, upon receiving a response confirmation message returned by the reference network device based on the first notification message, the first proxy node determines that the target transaction has completed the preparation phase;
[0188] S51, when the current transaction processing status of the first network device in the database is adjusted from the preparation status to the submission status, the first proxy node sends a second notification message to the reference network device, wherein the second notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the submission status.
[0189] Alternatively, those skilled in the art will appreciate that Figure 16 The structure shown is for illustration only, and the electronic device may also be a smart phone (such as an Android phone, an iOS phone, etc.), a tablet computer, a PDA, a mobile Internet device (Mobile Internet Devices, MID), a PAD, and other terminal devices. Figure 16 It does not limit the structure of the electronic device. For example, the electronic device may also include Figure 16 More or fewer components (such as network interfaces, etc.) as shown in, or with Figure 16Different configurations shown.
[0190] Among them, the memory 1602 can be used to store software programs and modules, such as program instructions / modules corresponding to the data processing method and device in the embodiment of the present invention. The processor 1604 executes various functional applications and data processing by running the software programs and modules stored in the memory 1602, that is, realizes the above-mentioned data processing method. The memory 1602 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 1602 may further include a memory remotely located relative to the processor 1604, and these remote memories may be connected to the terminal via a network. Examples of the above-mentioned networks include but are not limited to the Internet, corporate intranets, local area networks, mobile communication networks and combinations thereof. Among them, the memory 1602 can be used to store information such as the status of network equipment, but is not limited to it. As an example, if Figure 16 As shown, the memory 1602 may include, but is not limited to, the receiving unit 1402, the first determining unit 1404, the first sending unit 1406, the second determining unit 1406, and the second sending unit 1410 in the distributed transaction processing apparatus. Furthermore, the memory 1602 may also include, but is not limited to, other module units in the distributed transaction processing apparatus, which will not be described in detail in this example.
[0191] Optionally, the transmission device 1606 is configured to receive or send data via a network. Specific examples of the network may include a wired network and a wireless network. In one embodiment, the transmission device 1606 includes a network interface controller (NIC), which can be connected to other network devices and a router via a network cable to communicate with the Internet or a local area network. In one embodiment, the transmission device 1606 is a radio frequency (RF) module, which is configured to communicate with the Internet wirelessly.
[0192] In addition, the electronic device further includes: a display 1608 for displaying the status of the network device; and a connection bus 1610 for connecting various module components in the electronic device.
[0193] In other embodiments, the terminal device or server may be a node in a distributed system, wherein the distributed system may be a blockchain system, and the blockchain system may be a distributed system formed by connecting multiple nodes through network communication. The nodes may form a peer-to-peer (P2P) network, and any computing device, such as a server, terminal, or other electronic device, may become a node in the blockchain system by joining the peer-to-peer network.
[0194] According to another aspect of the embodiments of the present invention, a computer-readable storage medium is provided, in which a computer program is stored. The computer program is configured to execute the steps of any of the above method embodiments when run.
[0195] Optionally, in this embodiment, the computer-readable storage medium may be configured to store a computer program for performing the following steps:
[0196] S10, the first coordinating node receives a transaction processing request triggered by a first network device configured in the first proxy node, wherein the transaction processing request is used to request processing of a target transaction;
[0197] S20, in response to the transaction processing request, the first coordination node determines the current transaction processing status of the first network device through a database in the distributed transaction processing network;
[0198] S30, when the current transaction processing state of the first network device is the ready state, the first coordinating node sends a first notification message to other reference network devices in the distributed transaction processing network except the first network device, wherein the first notification message is used to instruct the reference network devices to synchronously change the current transaction processing state of the first network device stored in the local storage space to the ready state;
[0199] S40, upon receiving a response confirmation message returned by the reference network device based on the first notification message, the first coordination node determines that the target transaction completes the preparation phase;
[0200] S50, when the current transaction processing status of the first network device in the database is adjusted from the prepare status to the commit status, the first coordination node sends a second notification message to the reference network device, wherein the second notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the commit status.
[0201] Alternatively, in this embodiment, the computer-readable storage medium may be configured to store a computer program for executing the following steps:
[0202] S11, a first proxy node receives a transaction processing request triggered by a configured first network device, and sends the transaction processing request to an associated first coordination node, wherein the transaction processing request is used to request processing of a target transaction;
[0203] S21, in response to the transaction processing request, the first proxy node determines the current transaction processing status of the first network device through a database in the distributed transaction processing network;
[0204] S31: When the current transaction processing state of the first network device is the ready state, the first proxy node sends a first notification message to other reference network devices in the distributed transaction processing network except the first network device through the first coordinating node, wherein the first notification message is used to instruct the reference network devices to synchronously change the current transaction processing state of the first network device stored in the local storage space to the ready state;
[0205] S41, upon receiving a response confirmation message returned by the reference network device based on the first notification message, the first proxy node determines that the target transaction has completed the preparation phase;
[0206] S51, when the current transaction processing status of the first network device in the database is adjusted from the preparation status to the submission status, the first proxy node sends a second notification message to the reference network device, wherein the second notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the submission status.
[0207] Optionally, in this embodiment, a person of ordinary skill in the art may understand that all or part of the steps in the various methods of the above embodiments may be completed by instructing the hardware related to the terminal device through a program, and the program may be stored in a computer-readable storage medium, which may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.
[0208] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.
[0209] If the integrated units in the above embodiments are implemented in the form of software functional units and sold or used as independent products, they can be stored in the above-mentioned computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the existing technology, or all or part of the technical solution can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes a number of instructions for causing one or more computer devices (such as personal computers, servers, or network devices) to execute all or part of the steps of the methods described in various embodiments of the present invention.
[0210] In the above embodiments of the present invention, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0211] In the several embodiments provided in this application, it should be understood that the disclosed client can be implemented in other ways. Among them, the device embodiments described above are merely illustrative. For example, the division of the units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, and can be electrical or other forms.
[0212] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0213] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0214] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A data processing method, characterized in that: include: The first coordination node receives a transaction processing request triggered by a first network device configured in the first proxy node, wherein the transaction processing request is used to request processing of a target transaction; In response to the transaction processing request, the first coordination node determines a current transaction processing state of the first network device through a database in the distributed transaction processing network; When the current transaction processing state of the first network device is a ready state, the first coordination node sends a first notification message to other reference network devices in the distributed transaction processing network except the first network device, wherein the first notification message is used to instruct the reference network devices to synchronously change the current transaction processing state of the first network device stored in a local storage space to the ready state; Upon receiving a response confirmation message returned by the reference network device based on the first notification message, the first coordinating node determines that the target transaction completes the preparation phase; When the current transaction processing status of the first network device in the database is adjusted from the prepare status to the commit status, the first coordination node sends a second notification message to the reference network device, wherein the second notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the commit status.
2. The method according to claim 1, characterized in that In response to the transaction processing request, the first coordination node determines, through a database in the distributed transaction processing network, a current transaction processing status of the first network device, including: The first coordination node generates a status search request for the first network device based on the device identifier of the first network device carried in the transaction processing request, wherein the status search request is used to request to search for a current transaction processing status of the first network device stored in the database; The first coordination node sends the status search request to the database and obtains the current transaction processing status of the first network device returned by the database. When it is found in the database that the current transaction processing status of the first network device is in a non-ready state, the current transaction processing status of the first network device is adjusted from the non-ready state to the ready state, and the current transaction processing status is returned to the first network device as the ready state; when it is found in the database that the current transaction processing status of the first network device is in a ready state or a running state, the first network device is instructed to stop processing the target transaction.
3. The method according to claim 2, characterized in that After the first coordinating node determines that the target transaction completes the preparation phase, the method further includes: The first coordination node sends a status update request to the database, so that the database adjusts the current transaction processing status of the first network device from the prepare state to the commit state.
4. The method according to claim 1, wherein The first coordinating node sending the first notification message to other reference network devices in the distributed transaction processing network except the first network device includes: the first coordinating node notifying the second network device configured in the first proxy node, the third network device configured in the second proxy node associated with the first coordinating node, and the fourth network device configured in the third proxy node associated with the second coordinating node in the distributed transaction processing network of the returned current transaction processing status of the first network device; The first coordination node determines, upon receiving a response confirmation message returned by the reference network device based on the first notification message, that the preparation phase of the target transaction is completed, including: when the second network device configured in the first proxy node, the third network device configured in the second proxy node associated with the first coordination node, and the fourth network device configured in the third proxy node associated with the second coordination node in the distributed transaction processing network all return the response confirmation message, the first coordination node determines that the preparation phase of the target transaction is completed; The first coordination node sending the second notification message to the reference network device includes: the first coordination node sending the second notification message to the second network device configured in the first agent node, the third network device configured in the second agent node associated with the first coordination node, and the fourth network device configured in the third agent node associated with the second coordination node in the distributed transaction processing network.
5. The method according to claim 1, wherein After the first coordination node sends the first notification message to other reference network devices in the distributed transaction processing network except the first network device, the method further includes: In a case where at least one of the reference network devices does not return the response confirmation message, the first coordination node sends a third notification message to the reference network device, wherein the third notification message is used to notify the reference network device that the target transaction processing has failed; In a case where at least one of the reference network devices returns a response rejection message, the first coordination node sends a fourth notification message to the reference network device, wherein the fourth notification message is used to notify the reference network device that the target transaction processing has failed.
6. The method according to claim 4, characterized in that After the first coordinating node receives the transaction processing request triggered by the first network device configured in the first proxy node, the method further includes: The first coordinating node receives fault information reported by the first agent node and the second agent node associated with the first coordinating node; The first coordination node identifies the faulty network device according to the fault information and terminates the transaction processing operation of the faulty network device.
7. A data processing method, characterized in that: include: The first proxy node receives a transaction processing request triggered by the configured first network device, and sends the transaction processing request to the associated first coordination node, wherein the transaction processing request is used to request processing of a target transaction; In response to the transaction processing request, the first proxy node determines a current transaction processing status of the first network device through a database in the distributed transaction processing network; When the current transaction processing state of the first network device is a ready state, the first proxy node sends a first notification message to other reference network devices in the distributed transaction processing network except the first network device through the first coordinator node, wherein the first notification message is used to instruct the reference network devices to synchronously change the current transaction processing state of the first network device stored in the local storage space to the ready state; Upon receiving a response confirmation message returned by the reference network device based on the first notification message, the first proxy node determines that the target transaction completes the preparation phase; When the current transaction processing status of the first network device in the database is adjusted from the preparation status to the submission status, the first proxy node sends a second notification message to the reference network device, wherein the second notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the submission status.
8. The method according to claim 7, characterized in that In response to the transaction processing request, the first proxy node determines, through a database in the distributed transaction processing network, a current transaction processing status of the first network device, including: The first proxy node sends a status search request to the database through the first coordination node, wherein the status search request is used to request to search for the current transaction processing status of the first network device stored in the database; The first proxy node obtains the current transaction processing status of the first network device returned by the database, wherein if it is found in the database that the current transaction processing status of the first network device is in a non-ready state, the current transaction processing status of the first network device is adjusted from the non-ready state to the ready state, and the current transaction processing status is returned to the first network device as the ready state; if it is found in the database that the current transaction processing status of the first network device is in a ready state or a running state, the first network device is instructed to stop processing the target transaction.
9. The method according to claim 7, characterized in that After the first proxy node receives the transaction processing request triggered by the configured first network device and sends the transaction processing request to the associated first coordination node, the method further includes: In the event that the first coordinating node fails, the first proxy node reselects a target coordinating node from the distributed processing network; After a first time interval is reached, the first proxy node sends the transaction processing request to the target coordination node; When the target coordination node confirms that the current transaction processing state of the first network device is a ready state, the first proxy node sends the first notification message to the reference network device through the target coordination node; In a case where the current transaction processing state of the first network device in the database is adjusted from the prepare state to the commit state, the first proxy node sends the second notification message to the reference network device through the target coordination node.
10. The method according to claim 7, characterized in that After the first proxy node sends the second notification message to the reference network device, the method further includes: In a case where at least one of the reference network devices does not receive the second notification message, the first proxy node sends a reconciliation request to the first coordination node; The first proxy node obtains the latest routing information of the first network device returned by the first coordination node.
11. The method according to claim 7, characterized in that After the first proxy node sends the first notification message to other reference network devices in the distributed transaction processing network except the first network device through the first coordination node, the method further includes: In the case where the first proxy node includes the reference network device, a state node is created for the first network device in the hash ring of the reference network device, and a state value corresponding to the state node is synchronously configured as the ready state.
12. A data processing device, characterized in that: include: A receiving unit, configured for the first coordinating node to receive a transaction processing request triggered by a first network device configured in the first proxy node, wherein the transaction processing request is used to request processing of a target transaction; a first determining unit, configured to respond to the transaction processing request, and determine, by the first coordinating node, a current transaction processing state of the first network device through a database in the distributed transaction processing network; a first sending unit, configured to, when the current transaction processing state of the first network device is a ready state, send, by the first coordinating node, a first notification message to other reference network devices in the distributed transaction processing network except the first network device, wherein the first notification message is used to instruct the reference network devices to synchronously change the current transaction processing state of the first network device stored in a local storage space to the ready state; a second determining unit, configured to, upon receiving a response confirmation message returned by the reference network device based on the first notification message, determine, by the first coordinating node, that the target transaction has completed the preparation phase; A second sending unit is configured to cause the first coordination node to send a second notification message to the reference network device when the current transaction processing status of the first network device in the database is adjusted from the preparation status to the submission status, wherein the second notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the submission status.
13. A data processing device, characterized in that: include: A receiving unit, configured for a first proxy node to receive a transaction processing request triggered by a configured first network device, and to send the transaction processing request to an associated first coordination node, wherein the transaction processing request is used to request processing of a target transaction; a first determining unit, configured to respond to the transaction processing request, and determine, by the first proxy node, a current transaction processing status of the first network device through a database in the distributed transaction processing network; a first sending unit, configured to, when the current transaction processing state of the first network device is a ready state, send, by the first proxy node, a first notification message to other reference network devices in the distributed transaction processing network except the first network device through the first coordinating node, wherein the first notification message is used to instruct the reference network devices to synchronously change the current transaction processing state of the first network device stored in a local storage space to the ready state; a second determining unit, configured to, upon receiving a response confirmation message returned by the reference network device based on the first notification message, determine, by the first proxy node, that the target transaction has completed the preparation phase; A second sending unit is configured to, when the current transaction processing status of the first network device in the database is adjusted from the preparation status to the submission status, send a second notification message by the first proxy node to the reference network device, wherein the second notification message is used to instruct the reference network device to synchronously change the current transaction processing status of the first network device stored in the local storage space to the submission status.
14. A computer-readable storage medium, characterized in that The computer-readable storage medium includes a stored program, wherein the program executes the method described in any one of claims 1 to 6 or the method described in any one of claims 7 to 11 when the program is executed.
15. An electronic device comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and the processor is configured to execute the method according to any one of claims 1 to 6 or claims 7 to 11 through the computer program.
Citation Information
Patent Citations
Decoration management cloud system based on distributed system
CN106056321A
Distributed blockchain transaction system
WO2021022369A1