WO2022199229A1 - Suspended transaction inspection method and apparatus, electronic device and storage medium - Google Patents

Suspended transaction inspection method and apparatus, electronic device and storage medium Download PDF

Info

Publication number
WO2022199229A1
WO2022199229A1 PCT/CN2022/072050 CN2022072050W WO2022199229A1 WO 2022199229 A1 WO2022199229 A1 WO 2022199229A1 CN 2022072050 W CN2022072050 W CN 2022072050W WO 2022199229 A1 WO2022199229 A1 WO 2022199229A1
Authority
WO
WIPO (PCT)
Prior art keywords
target
transaction
branch
global
database
Prior art date
Application number
PCT/CN2022/072050
Other languages
French (fr)
Chinese (zh)
Inventor
张健
Original Assignee
北京金山云网络技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京金山云网络技术有限公司 filed Critical 北京金山云网络技术有限公司
Publication of WO2022199229A1 publication Critical patent/WO2022199229A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/466Transaction processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/465Distributed object oriented systems

Definitions

  • the present application relates to the field of data processing, and in particular, to a method and device for inspection of suspended affairs, an electronic device and a storage medium.
  • a distributed database can have various architectures, for example, a sharding architecture based on middleware routing, and a distributed architecture based on spanner (a database system).
  • a distributed transaction mechanism can be introduced to ensure the atomic property of modifying data across multiple nodes to achieve the ACID property of the database.
  • suspending transaction inspections can be used to be compatible with local faults (such as node downtime, network failure, etc.) in a distributed environment.
  • suspending transactions refer to the initiator (master node) of the global transaction Failure before the global transaction is committed, resulting in the failure of the global transaction and its corresponding branch transaction to proceed.
  • the suspension transaction inspection generally adopts the suspension transaction management mechanism based on the global transaction manager.
  • the suspended transaction management mechanism (scheme) based on the global transaction manager can realize the automatic inspection of suspended transactions and promote the commit and rollback of transactions according to the set strategy through centralized global transaction state management.
  • the scale of the cluster is large and the data is scattered and multi-sharded, the number of global transactions and branch transactions managed by the global transaction manager will increase significantly, resulting in the problem of low efficiency of suspending transactions.
  • Embodiments of the present application provide a method and apparatus for inspecting suspended transactions, an electronic device, and a storage medium, so as to at least solve the problem in the control mode of suspended transactions in the related art that due to the large number of global transactions and branch transactions managed by the manager The hanging transaction processing inefficiency problem.
  • a method for inspecting suspended transactions including: receiving target topology information through a target database, where the target topology information is a target global transaction and a multiplicity of data corresponding to the target global transaction topology information between target branch transactions; save the target topology information into a target storage object, wherein the target storage object is used to record each global transaction in multiple global transactions and the relationship with each global transaction.
  • topology information between multiple branch transactions corresponding to a transaction the target database is used to process one branch transaction in the multiple branch transactions corresponding to each global transaction; according to the data recorded in the target storage object topology information, and each global transaction is separately inspected for suspended transactions through the target database.
  • receiving the target topology information through the target database includes: receiving, through the target database, a target transaction message sent by a target server, wherein the target server is a transaction coordinator of the target global transaction,
  • the target transaction message carries the target topology information and the pending branch transaction information corresponding to the target database, and the pending branch transaction information is used to indicate that among the multiple target branch transactions, the target Branch transactions handled by the database.
  • the target storage object respectively performing a suspended transaction inspection on the global transactions through the target database includes: according to the target topology recorded in the target storage object. information, first state information corresponding to the target global transaction is determined through the target database; if it is determined according to the first state information that the target global transaction is abnormal before submission, the target global transaction is The transaction is determined to be a pending transaction.
  • determining the first state information corresponding to the target global transaction by using the target database includes: according to the target topology information, The target heartbeat information is detected by the target database, wherein the first state information includes the target heartbeat information, and the target heartbeat information is the heartbeat information between the target database and the target server, and the target server is the same as the target server.
  • the method further includes: In the case where the transaction is determined to be a suspended transaction, obtain second state information corresponding to each target branch transaction in the plurality of target branch transactions; Each branch transaction executes a target transaction operation, wherein the target transaction operation includes one of the following: transaction commit and transaction rollback.
  • controlling the execution of the target transaction operation on the respective branch transactions according to the second state information corresponding to the respective target branch transactions includes: When it is determined from the second state information that each target branch transaction has been pre-committed successfully, control to perform transaction submission on each target branch transaction; according to the second state information corresponding to each target branch transaction When it is determined that there is a branch transaction that fails to pre-commit, the control is to perform transaction rollback on each target branch transaction.
  • the method further includes: in the target global transaction If the submission is successful, the target topology information is deleted from the target storage object.
  • a suspended transaction inspection device including: a receiving unit configured to receive target topology information through a target database, wherein the target topology information is the target global transaction and the the topology information between the multiple target branch transactions corresponding to the target global transaction; the storage unit is configured to save the target topology information into the target storage object, wherein the target storage object is used to record the multiple global transactions. topology information between each global transaction of the A branch transaction; an inspection unit, configured to perform inspection of suspended transactions on each global transaction through the target database according to the topology information recorded in the target storage object.
  • the receiving unit includes: a receiving module configured to receive, through the target database, a target transaction message sent by a target server, wherein the target server is the transaction coordinator of the target global transaction, and the target server is the transaction coordinator of the target global transaction.
  • the target transaction message carries the target topology information and to-be-processed branch transaction information corresponding to the target database, and the to-be-processed branch transaction information is used to indicate that among the multiple target branch transactions, to be processed by the target database branch transaction.
  • the inspection unit includes: a first determination module, configured to determine, through the target database, the first determination module corresponding to the target global transaction according to the target topology information recorded in the target storage object. a state information; a second determination module configured to determine the target global transaction as a suspended transaction when it is determined according to the first state information that an exception occurs before the target global transaction is committed.
  • the first determining module includes: a determining sub-module
  • the apparatus further includes: a determining unit, wherein the determining sub-module is configured to detect through the target database according to the target topology information
  • Target heartbeat information wherein the first state information includes the target heartbeat information, the target heartbeat information is the heartbeat information between the target database and the target server, and the target server corresponds to the target global transaction
  • the transaction coordinator the determining unit is configured to, after detecting the target heartbeat information through the target database according to the target topology information, when it is detected that the target heartbeat information stops updating, determine the target heartbeat information. An exception occurred before the target global transaction was committed.
  • the device further includes: an acquisition unit, configured to perform a suspended transaction inspection on each global transaction through the target database according to the topology information recorded in the target storage object, and then perform a pending transaction inspection on the global transactions respectively.
  • an acquisition unit configured to perform a suspended transaction inspection on each global transaction through the target database according to the topology information recorded in the target storage object, and then perform a pending transaction inspection on the global transactions respectively.
  • the target global transaction is determined to be a suspending transaction
  • the control unit is set to correspond to each target branch transaction according to the The second state information controls the execution of target transaction operations on the respective branch transactions, wherein the target transaction operations include one of the following: transaction commit and transaction rollback.
  • control unit includes: a first control module, configured to determine, according to the second state information corresponding to the respective target branch transactions, that each target branch transaction has been pre-committed successfully. In this case, control the transaction submission of each target branch transaction; the second control module is configured to determine that there is a branch transaction that fails to pre-commit according to the second state information corresponding to each target branch transaction. Next, control the transaction rollback of each target branch transaction.
  • the device further includes: a deletion unit, configured to perform a suspended transaction inspection on each global transaction through the target database according to the topology information recorded in the target storage object, and then delete the transaction in the target database. If the target global transaction is successfully submitted, the target topology information is deleted from the target storage object.
  • a deletion unit configured to perform a suspended transaction inspection on each global transaction through the target database according to the topology information recorded in the target storage object, and then delete the transaction in the target database. If the target global transaction is successfully submitted, the target topology information is deleted from the target storage object.
  • an electronic device including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; wherein, a memory for storing a computer program; and a processor for executing the method steps in any of the foregoing embodiments by running the computer program stored in the memory.
  • a computer-readable storage medium is also provided, where a computer program is stored in the storage medium, wherein the computer program is configured to execute the method in any of the foregoing embodiments when running step.
  • the method of suspending transaction management performed by the participants of the transaction is adopted, and the target topology information is received through the target database, wherein the target topology information is the target global transaction and the multiple target global transactions corresponding to the target global transaction. topology information between target branch transactions; save the target topology information into a target storage object, wherein the target storage object is used to record each global transaction in multiple global transactions and the relationship with each global transaction topology information between corresponding multiple branch transactions, the target database is used to process one branch transaction among the multiple branch transactions corresponding to each global transaction; according to the topology recorded in the target storage object information, through the target database, the suspended transaction inspection is carried out for the various global transactions.
  • each global transaction and its corresponding branch transaction It can be registered in at least one associated database instance, and different global transactions and their corresponding branch transactions are registered in different database instances, instead of unified global transaction management by the global transaction manager, which can realize distributed global transactions and
  • the purpose of branch transaction registration management achieves the technical effect of reducing the processing pressure of the manager and improving the processing efficiency of suspended transactions, thereby solving the existence of the suspension transaction control method in the related art due to the number of global transactions and branch transactions managed by the manager The problem of low efficiency of hanging transaction processing caused by more.
  • FIG. 1 is a schematic diagram of a hardware environment of a method for inspecting a suspended transaction according to an embodiment of the present application
  • FIG. 2 is a schematic flowchart of a method for inspecting a suspended transaction according to an embodiment of the present application
  • FIG. 3 is a schematic diagram of a method for inspecting a suspension transaction according to an embodiment of the present application.
  • FIG. 4 is a schematic flowchart of another method for inspecting a suspended transaction according to an embodiment of the present application.
  • FIG. 5 is a schematic flowchart of another method for inspecting a suspended transaction according to an embodiment of the present application.
  • FIG. 6 is a structural block diagram of a device for inspecting suspended affairs according to an embodiment of the present application.
  • FIG. 7 is a structural block diagram of an electronic device according to an embodiment of the present application.
  • ACID characteristics refer to the following four characteristics: Atomicity, Consistency, Isolation, Durability;
  • Global transaction refers to the master control transaction that initiates data modification
  • Branch transaction refers to a transaction in which the data modified by the global transaction is distributed to several nodes, and the data modification on each node is encapsulated into a transaction.
  • a method for inspecting a suspended transaction is provided.
  • the above-mentioned method for inspecting suspended transactions may be applied to a distributed storage system including a plurality of nodes (eg, database servers) as shown in FIG. 1 , for example, including the first node 102 . and the hardware environment of the second node 104 .
  • the first node 102 is connected with the second node 104 through a network, and can be used to provide services (eg, transaction processing services, etc.) for the terminal or the client installed on the terminal.
  • the first node 102 may be the coordinator of the transaction processing and may be used to process the global transaction
  • the second node 104 may be a participant of the transaction processing and may be used to process the branch transaction.
  • the above network may include, but is not limited to, at least one of the following: wired network, wireless network.
  • the above wired network may include, but is not limited to, at least one of the following: a wide area network, a metropolitan area network, and a local area network
  • the above wireless network may include but not limited to at least one of the following: WIFI (Wireless Fidelity, wireless fidelity), Bluetooth.
  • the terminal 102 may not be limited to a PC, a mobile phone, a tablet computer, or the like.
  • the suspended transaction inspection method in this embodiment of the present application may be executed by the first node 102 , may also be executed by the second node 104 , or may be executed jointly by the first node 102 and the second node 104 .
  • the first node 102 and/or the second node 104 may execute the suspended transaction inspection method according to the embodiment of the present application, and may also be executed by a client installed thereon.
  • FIG. 2 is a schematic flowchart of a method for inspecting suspended transactions according to an embodiment of the present application. As shown in FIG. The process can include the following steps:
  • Step S202 receiving target topology information through the target database, wherein the target topology information is the topology information between the target global transaction and multiple target branch transactions corresponding to the target global transaction.
  • the suspended transaction inspection method in the embodiment of the present application may be applied to the scenario of suspended transaction inspection in a distributed storage system.
  • the distributed storage system may include: a client APP (Application), a master node (coordinator), and a data node (participant), wherein the master node may be a distributed database agent DS (Data Server, data server). ), the data node can be DB (Data Base, database, database instance). Clients can be connected to the master node through the network, different clients can be connected to the same or different master nodes, and the same master node can be connected to multiple clients.
  • the master node can be connected to the data nodes through the network, different data nodes can be connected to the same or different master nodes, and the same master node can be connected to multiple data nodes.
  • the client can initiate a global transaction to the DS, that is, initiate a general control transaction for data modification.
  • the target client may send a target global transaction to the target server (DS), which is used to perform the target processing operation on the target object.
  • DS target server
  • the target server can determine multiple target branch transactions corresponding to the target global transaction, that is, determine the database nodes where the data modified by the above target processing operations are scattered, and encapsulate the data modification on each database node into a corresponding target branch transaction, get multiple target branch transactions. After obtaining the multiple target branch transactions, the target server may send each target branch transaction among the multiple target branch transactions to the corresponding database node.
  • an implementation scheme is: reuse the transaction timeout automatic commit/rollback strategy of the database itself. This scheme relies on the database kernel to autonomously detect the overtime pending branch transaction, and commit/rollback according to the branch transaction characteristics, which cannot guarantee the global ACID characteristics of transactions, and less efficient.
  • the global transaction and the branch transaction are registered in the database instance in a decentralized manner, and a global transaction and the corresponding branch transaction can be registered in a certain database instance that processes the branch transaction, or, the processing branch Multiple database instances of transactions to enable global transaction and branch transaction state self-management.
  • the target server can generate target topology information corresponding to the target global transaction, and the above target topology information is the topology information between the target global transaction and multiple target branch transactions corresponding to the target global transaction, and can be used to represent Topological relationship between the target global transaction and multiple target branch transactions corresponding to the target global transaction, for example, the corresponding relationship between the target global transaction and the target server processing the target global transaction, each target branch transaction and processing each target branch transaction The corresponding relationship between the database nodes.
  • the target topology information may also include other information, for example, the initiation time of the target global transaction, etc., which is not limited in this embodiment of the present application.
  • the target server can also select the target database from the database nodes that process each target branch transaction, that is, the database node to which the target global transaction and multiple target branch transactions are to be registered, and send the target topology information to the selected target database.
  • the number of target databases may be one or more, and the selection method may be: random selection, or according to the order of target branch transactions, or other selection methods, which are not limited in this embodiment.
  • the target database may be a database node that processes a branch transaction of a plurality of target branch transactions.
  • the target database can also receive target topology information sent by the target database.
  • Step S204 save the target topology information in the target storage object, wherein the target storage object is used to record the topology information between each global transaction in the multiple global transactions and the multiple branch transactions corresponding to each global transaction,
  • the target database is used to process one of the branch transactions corresponding to each global transaction.
  • a storage object can be stored in each database instance, and the storage object can be used to record the topological relationship between the global transaction registered in this database instance and the corresponding branch transaction, and can also be used to record the global transaction registered in this database instance. status information.
  • a system table may be added to each database instance, and the system table may be used to record the topology relationship and state information of the global transaction registered in the database instance and the corresponding branch transaction.
  • the target database may save a target storage object (eg, target system table), and the target storage object may be used to record each of multiple global transactions (multiple global transactions registered with the target database, including the target global transaction)
  • the topology information between each global transaction and multiple branch transactions corresponding to each global transaction can also be used to record the state information of each global transaction.
  • the target database After receiving the target topology information, the target database can save the target topology information to the target storage object, and the saving method can be: save the target topology information to the target storage object in the order of reception, for example, save it to the end of the target storage object.
  • the above-mentioned storage object is a storage unit/storage module used to record the topology information between the global transaction registered in this database instance and the multiple branch transactions corresponding to the global transaction.
  • the specific form of the storage object is not limited.
  • step S206 according to the topology information recorded in the target storage object, each global transaction is inspected by the target database for suspending transactions.
  • the target database can perform suspension transaction inspection on each global transaction.
  • the inspection method can be as follows: according to each topology information recorded in the target storage object, determine whether the master control node corresponding to each global transaction is faulty, if a fault occurs, determine that the global transaction is a suspended transaction; if no fault occurs, Then it is determined that the global transaction is not a dangling transaction.
  • the target database can train the target global transaction with suspending transactions, determine whether the target server fails, if a failure occurs, determine that the target global transaction is a suspending transaction, and if no failure occurs, determine that the target global transaction is not Suspended business.
  • each transaction can be processed based on the submission process in the related technology.
  • the coordinator feeds back the pre-commit results; the coordinator determines to commit or roll back the transaction based on the pre-commit results: if the branch transactions of each participant have been pre-committed successfully, each participant will be controlled to formally commit the branch transaction. If the branch transaction pre-commit fails, each participant is controlled to roll back the branch transaction.
  • the target topology information is received through the target database, wherein the target topology information is the topology information between the target global transaction and multiple target branch transactions corresponding to the target global transaction;
  • the target topology information is stored in the target storage object, wherein the target storage object is used to record the topology information between each global transaction in the multiple global transactions and the multiple branch transactions corresponding to the each global transaction,
  • the target database is used to process one branch transaction in the plurality of branch transactions corresponding to each global transaction; according to the topology information recorded in the target storage object, each global transaction is processed by the target database.
  • Transactions are inspected separately for suspending transactions, which solves the problem of low suspending transaction processing efficiency caused by the large number of global transactions and branch transactions managed by the manager in the suspending transaction control method in the related art, and reduces the processing of the manager. pressure and improve the efficiency of suspension transaction processing.
  • receiving the target topology information through the target database includes:
  • the target server is the transaction coordinator of the target global transaction
  • the target transaction message carries the target topology information and the pending branch transaction information corresponding to the target database.
  • the branch transaction information is used to indicate a branch transaction to be processed by the target database among the multiple target branch transactions.
  • the target server may separately send the branch transaction and target topology information to be processed by the target database.
  • the target server may first send to the target database the branch transaction information to be processed corresponding to the target database, and the to-be-processed branch transaction information may be used to indicate the branch transaction to be processed by the target database among the multiple target branch transactions; then, the target server may Send target topology information to the target database.
  • the target server can send the target topology information and the branch transaction information to be processed to the target database together, for example, send the two together to the target database through the target transaction message. target database.
  • the target database can receive the above-mentioned target transaction message sent by the target server, extract the branch transaction information to be processed and the target topology information respectively, save the target topology information in the target storage object, and execute the branch indicated by the above-mentioned branch transaction information to be processed.
  • the pre-commit, commit, etc. of the transaction are not limited in this embodiment of the present application.
  • the suspension transaction inspection of each global transaction through the target database includes:
  • the target database can determine the first state information corresponding to the target global transaction according to the target topology information, and the first state information can be used to represent the current state of the target global transaction, for example , normal state, abnormal state.
  • the first state information may be determined periodically, for example, according to the target topology information, the target database may periodically/timely determine the first state information corresponding to the target global transaction.
  • the first state information corresponding to the target global transaction can be used to indicate the running state of the target server that processes the target global transaction. If the target server is running normally, the first state information is used to indicate that the target global transaction is in normal state. state, if the target server operates abnormally (for example, fails), the first state information is used to indicate that the target global transaction is in an abnormal state.
  • the target database can transfer the target global transaction Determined as a pending transaction.
  • the status information of the global transaction is acquired according to the topology information, and whether the global transaction is abnormal before being submitted is determined based on the status information, which can improve the efficiency of the inspection of the suspended transaction.
  • determining the first state information corresponding to the target global transaction through the target database includes:
  • the target heartbeat information detects the target heartbeat information through the target database, wherein the first state information includes the target heartbeat information, the target heartbeat information is the heartbeat information between the target database and the target server, and the target server is corresponding to the target global transaction.
  • transaction coordinator
  • the above method further includes:
  • the state information of the global transaction may include heartbeat information between the database instance and the data server.
  • Heartbeat information can be added to each global transaction and branch transaction.
  • the data server can periodically send heartbeat packets to all or part of the database instances connected to it.
  • the database instance can update the saved heartbeat information according to the received heartbeat packets.
  • the heartbeat information can be Including the time of the heartbeat packet.
  • the suspended transaction inspection module in the database instance can automatically detect global transactions with abnormal heartbeats.
  • the heartbeat information of the global transaction will be updated in real time.
  • the heartbeat information of the global transaction will stop updating. Therefore, according to whether the heartbeat information is updated, the global transaction can be determined. Whether the transaction (or branch transaction) is normal.
  • the target server may periodically send heartbeat packets to the target database, where the target server may be a distributed database agent DS, which is the transaction coordinator corresponding to the target global transaction.
  • the target database can update the heartbeat information between the target database and the target server according to the received heartbeat packet, that is, the target heartbeat information.
  • the target database can detect the target heartbeat information. If it is detected that the target heartbeat information has not been updated within a period of time, it indicates that the heartbeat packet sent by the target server has not been received within a period of time, and the target server has failed. The target database can determine that the target global transaction is abnormal before committing.
  • the target server may send a commit completion message to the target database after the target global transaction is committed to indicate that the target global transaction of the target database has completed the commit.
  • the target heartbeat information stops updating and the commit completion message sent by the target server is not received
  • it is determined that the target global transaction is abnormal before the commit and the commit completion message is used to indicate that the target global transaction has been submitted. .
  • the server corresponding to the global transaction is faulty according to the heartbeat information, which can ensure the accuracy of the abnormal determination of the global transaction, and at the same time, can reduce the occupation of network resources (the data volume of the heartbeat packet is small).
  • the above method further includes:
  • the target database can take over the suspended transaction, and can push the suspended transaction to commit or roll back according to the status of all branch transactions corresponding to the suspended transaction.
  • the global transaction can be pushed to continue to complete the subsequent process of submitting; otherwise, all branch transactions corresponding to the global transaction are pushed to roll back. operate.
  • the target database can obtain the second state information corresponding to each target branch transaction among the multiple target branch transactions, that is, the target database can correspond to each target branch transaction
  • the database instance interacts with each other to determine the current processing status of each target branch transaction, for example, pre-commit success, pre-commit failure, commit success, commit failure, and so on.
  • the target database can control to perform subsequent transaction operations on each branch transaction, such as transaction commit and transaction rollback.
  • the target database to which each global transaction is registered takes over the submission task of the suspended transaction, which can improve the efficiency of transaction processing.
  • controlling the execution of the target transaction operation on each branch transaction according to the second state information corresponding to each target branch transaction includes:
  • the target database can control the forward execution of the suspended transaction, which can ensure the timeliness of transaction processing while ensuring the ACID property of the global transaction.
  • the target database can control the transaction submission of each target branch transaction, for example, to the database corresponding to each target branch transaction Nodes send commit instructions, instructing to formally commit each branch transaction.
  • the target database can control the transaction rollback of each target branch transaction, for example, send back to the database instance corresponding to each target branch transaction. Rollback instructions, instructing each target branch transaction to roll back.
  • the database instance controls the branch transaction corresponding to the suspended transaction to commit or roll back according to the processing state of each branch transaction, which can ensure the timeliness of transaction processing.
  • the above method further includes:
  • the database instance can delete its corresponding topology information from the target storage object. If the target global transaction commits successfully, the target database can delete the target topology information from the target storage object.
  • the deletion of topology information may be triggered when the target global transaction is successfully submitted, or may be triggered by a background process of periodically clearing expired topology information in the target storage object, which is not limited in this embodiment of the present application.
  • the trigger conditions for deletion can be configured according to whether the target server is abnormal or not.
  • the target server can send a delete message to the target database to instruct the target database to delete the target topology information.
  • the target database deletes the target topology information in the target storage object; or, the target database can also delete the target topology information in the target storage object after all branch transactions corresponding to the global transaction are successfully submitted.
  • the target database deletes the target topology information in the target storage object; or, after instructing other database instances to submit the corresponding After the target branch transaction, the target database deletes the target topology information in the target storage object, and the other database instances are database instances other than the target database among the multiple database instances that process multiple target branch transactions.
  • the topology information corresponding to the global transaction stored in the database instance to which the global transaction is registered is deleted, which can reduce the occupation of the storage space of the database instance and improve the utilization of storage space. rationality.
  • the storage object is a relational table.
  • the suspended transaction inspection method in this example can be applied to the network architecture shown in FIG. 3 , the network architecture includes: an application end, a distributed database agent, and a database instance, wherein,
  • the application side is used for transaction submission
  • Distributed database agent which can be used as the coordinator of the transaction to receive the global transaction initiated by the application and send the branch transaction to the corresponding database instance;
  • the database instance can be used as a participant in the transaction to process the corresponding branch transaction.
  • This example provides a distributed database suspension transaction inspection optimization solution, which adopts the mechanism of global transaction and branch transaction status self-management: the global transaction and branch transaction are distributed in the database instance, and a new one is added to each database instance.
  • the system table is used to record the topological relationship and status information of global transactions and branch transactions; heartbeat information is added to each global transaction and branch transaction. Under normal circumstances, the heartbeat information of global transactions and branch transactions will be updated in real time. Or the heartbeat information of the branch transaction will stop updating; the suspended transaction inspection module in the database instance automatically detects the global transaction with abnormal heartbeat, and promotes the commit/rollback of the branch transaction corresponding to the global transaction.
  • the flow of the method for inspecting suspended transactions in this example may include the following steps:
  • Step S402 the application terminal 1 connects to the distributed database agent 1, and initiates a global transaction 1.
  • Step S404 the distributed database agent 1 sends the branch transaction 1 and the branch transaction 2 corresponding to the global transaction 1 to the database instance 1 and the database instance 2, respectively.
  • the distributed database agent 1 can determine the branch transaction 1 and the branch transaction 2 corresponding to the global transaction 1, send the branch transaction 1 to the database instance 1, and send the branch transaction 2 to the database instance 2.
  • Step S406 the distributed database agent 1 records the topology information of the global transaction 1 and its branch transaction 1 and branch transaction 2 in the system table of the database instance 1, and updates the heartbeat information of the global transaction 1 recorded by the database instance 1 in real time.
  • the topology information and heartbeat information recorded in the system table of database instance 1 may include:
  • the distributed database agent 1 can also determine the topology information of the global transaction 1 and its branch transaction 1 and branch transaction 2, and send the determined topology information to the database instance 1 to record it in the system table of the database instance 1.
  • Instance 1 sends a heartbeat packet to update the heartbeat information of global transaction 1 recorded by database instance 1.
  • Step S408 the suspended transaction inspection module in the database instance 1 scans the system table, finds that the global transaction 1 has an abnormal heartbeat, takes over the global transaction 1, and continues to commit/roll back the transaction according to the status of the branch transaction 1 and the branch transaction 2.
  • the global transaction 1 has not yet completed the commit, and becomes a suspended transaction.
  • the suspended transaction inspection module in database instance 1 scans the system table and finds that the heartbeat of global transaction 1 is abnormal. Then, database instance 1 takes over global transaction 1 and determines the status of branch transaction 1 and branch transaction 2.
  • the status of branch transaction can include but not Restricted to at least one of the following: INIT (initialization), PREPARED (pre-commit), COMMIT (commit). According to the status of branch transaction 1 and branch transaction 2, database instance 1 can continue to commit or roll back the transaction.
  • branch transaction 1 and branch transaction 2 are in the INIT state, they are controlled to roll back; both branch transaction 1 and branch transaction 2 have been pre-committed successfully, then branch transaction 1 and branch transaction 2 are controlled to commit; if branch transaction 1 and branch transaction 2 are both pre-committed successfully If the branch transaction 2 is partially submitted successfully, and part of it has not been submitted successfully, the submission will continue. If a branch transaction is not successfully processed at a certain stage, the control branch transaction 1 and branch transaction 2 are rolled back.
  • the process of the suspended transaction inspection method in this example may also include the following steps:
  • Step S502 the application terminal 2 connects to the distributed database agent 2 and initiates a global transaction 2 .
  • Step S504 the distributed database agent 2 sends the branch transaction 3 and the branch transaction 4 corresponding to the global transaction 2 to the database instance 2 and the database instance 3, respectively.
  • the distributed database agent 2 can determine the branch transaction 3 and the branch transaction 4 corresponding to the global transaction 2, send the branch transaction 3 to the database instance 2, and send the branch transaction 4 to the database instance 3.
  • Step S506 the distributed database agent 2 records the topology information of the global transaction 2 and its branch transaction 3 and branch transaction 4 in the system table of the database instance 2, and updates the heartbeat information of the global transaction 2 recorded by the database instance 2 in real time.
  • the distributed database agent 2 can also determine the topology information of the global transaction 2 and its branch transaction 3 and branch transaction 4, and send the determined topology information to the database instance 2 to record it in the system table of the database instance 2.
  • Instance 2 sends a heartbeat packet to update the heartbeat information of global transaction 2 recorded by database instance 2.
  • the topology information and heartbeat information recorded in the system table of the database instance 2 may include:
  • Step S508 the suspended transaction inspection module in the database instance 2 scans the system table, finds that the global transaction 2 has an abnormal heartbeat, takes over the global transaction 2, and continues to commit/roll back the transaction according to the status of the branch transaction 3 and the branch transaction 4.
  • the suspended transaction inspection module in database instance 2 scans the system table and finds that the heartbeat of global transaction 2 is abnormal. Then, database instance 2 takes over global transaction 2 and determines the status of branch transaction 3 and branch transaction 4.
  • the status of branch transaction can include but not Limited to at least one of the following: INIT, PREPARED, COMMIT. According to the status of branch transaction 3 and branch transaction 4, database instance 2 can continue to commit or roll back the transaction.
  • branch transaction 3 and branch transaction 4 are in the INIT state, and both are controlled to be rolled back; both branch transaction 3 and branch transaction 4 have been pre-committed successfully, then branch transaction 3 and branch transaction 4 are controlled to commit; if branch transaction 3 and branch transaction 4 are both pre-committed successfully Part 4 of the branch transaction is successfully submitted, and part of it has not been submitted successfully, then continue to advance the submission. If a branch transaction is not successfully processed at a certain stage, the control branch transaction 3 and branch transaction 4 are rolled back.
  • system table of database instance 3 may also record topology information of some global transactions and their branch transactions, and heartbeat information of these global transactions.
  • topology information and heartbeat information recorded in the system table of database instance 3 may be:
  • the pressure of transaction inspection can be reduced; through distributed parallel suspended transaction inspection, the efficiency of suspended transaction inspection can be improved; through distributed parallel suspended transaction inspection, the efficiency of suspended transaction inspection can be improved; Parallel processing can also improve the processing efficiency of suspended transactions.
  • Fig. 6 is a structural block diagram of an apparatus for inspecting suspended affairs according to an embodiment of the present application. As shown in Fig. 6 , the apparatus may include:
  • a receiving unit 602 configured to receive target topology information through the target database, wherein the target topology information is the topology information between the target global transaction and a plurality of target branch transactions corresponding to the target global transaction;
  • the saving unit 604 is connected to the receiving unit 602, and is configured to save the target topology information into the target storage object, wherein the target storage object is used to record each global transaction in the multiple global transactions and the relationship with each global transaction.
  • the topology information between the corresponding multiple branch transactions, and the target database is used to process one branch transaction among the multiple branch transactions corresponding to each global transaction;
  • the inspection unit 606 is connected to the storage unit 604, and is configured to perform an inspection of suspended transactions for each global transaction through the target database according to the topology information recorded in the target storage object.
  • the receiving unit 602 in this embodiment may be configured to execute the above step S202
  • the saving unit 604 in this embodiment may be configured to execute the above step S204
  • the inspection unit 606 in this embodiment may be configured to execute the above step S204.
  • the above step S206 may be configured to execute the above step S202
  • the target topology information is received through the target database, wherein the target topology information is the topology information between the target global transaction and a plurality of target branch transactions corresponding to the target global transaction; the target topology information is saved into a target storage object, wherein the target storage object is used to record topology information between each global transaction in multiple global transactions and multiple branch transactions corresponding to each global transaction, and the target database for processing one branch transaction in the plurality of branch transactions corresponding to each global transaction; according to the topology information recorded in the target storage object, the global transactions are respectively suspended through the target database
  • the transaction inspection solves the problem of low efficiency of suspended transaction processing caused by the large number of global transactions and branch transactions managed by the manager in the suspension transaction control method in the related art, reduces the processing pressure of the manager, and improves the Hang transaction efficiency.
  • the receiving unit 602 includes:
  • the receiving module is configured to receive the target transaction message sent by the target server through the target database, wherein the target server is the transaction coordinator of the target global transaction, and the target transaction message carries the target topology information and the pending branch transaction information corresponding to the target database. , the branch transaction information to be processed is used to indicate the branch transaction to be processed by the target database among the multiple target branch transactions.
  • the inspection unit 606 includes:
  • the first determining module is configured to determine the first state information corresponding to the target global transaction through the target database according to the target topology information recorded in the target storage object;
  • the second determining module is configured to determine the target global transaction as a suspended transaction when it is determined according to the first state information that the target global transaction is abnormal before committing.
  • the first determination module includes: a determination sub-module, and the above-mentioned apparatus further includes: a determination unit, wherein:
  • the determination submodule is set to detect the target heartbeat information through the target database according to the target topology information, wherein the first state information includes the target heartbeat information, the target heartbeat information is the heartbeat information between the target database and the target server, and the target server is the heartbeat information between the target database and the target server.
  • the transaction coordinator corresponding to the global transaction;
  • the determining unit is configured to, after detecting the target heartbeat information through the target database according to the target topology information, when it is detected that the target heartbeat information stops updating, determine that the target global transaction is abnormal before committing.
  • the above-mentioned device further includes:
  • the acquiring unit is set to, according to the topology information recorded in the target storage object, after the suspending transaction inspection is performed on each global transaction through the target database, and the target global transaction is determined as a suspending transaction, the target global transaction is determined as a suspended transaction, and multiple target branches are obtained. second state information corresponding to each target branch transaction in the transaction;
  • the control unit is configured to control the execution of the target transaction operation on each branch transaction according to the second state information corresponding to each target branch transaction, wherein the target transaction operation includes one of the following: transaction commit and transaction rollback.
  • control unit includes:
  • the first control module is configured to control the transaction submission to each target branch transaction when it is determined that each target branch transaction has been pre-submitted successfully according to the second state information corresponding to each target branch transaction;
  • the second control module is configured to control the transaction rollback of each target branch transaction when it is determined according to the second state information corresponding to each target branch transaction that there is a branch transaction that fails to pre-commit.
  • the above-mentioned device further includes:
  • the deletion unit is set to perform a suspended transaction inspection of each global transaction through the target database according to the topology information recorded in the target storage object, and when the target global transaction is successfully submitted, remove the target topology information from the target storage object. delete.
  • the above modules may run in the hardware environment as shown in FIG. 1 , and may be implemented by software or hardware, wherein the hardware environment includes a network environment.
  • an electronic device for implementing the above method for inspecting suspended transactions, where the electronic device may be a server, a terminal, or a combination thereof.
  • FIG. 7 is a structural block diagram of an electronic device according to an embodiment of the present application. As shown in FIG. 7 , it includes a processor 702 , a communication interface 704 , a memory 706 and a communication bus 708 , wherein the processor 702 , the communication interface 704 and the memory 706 communicates with each other through the communication bus 708, wherein,
  • memory 706 for storing computer programs
  • target topology information is the topology information between the target global transaction and multiple target branch transactions corresponding to the target global transaction;
  • the target storage object is used to record the topology information between each global transaction in the multiple global transactions and the multiple branch transactions corresponding to each global transaction, and the target The database is used to process one of the branch transactions corresponding to each global transaction;
  • each global transaction is respectively inspected for suspended transactions.
  • the above-mentioned communication bus may be a PCI (Peripheral Component Interconnect, Peripheral Component Interconnect Standard) bus, or an EISA (Extended Industry Standard Architecture, Extended Industry Standard Architecture) bus or the like.
  • the communication bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of presentation, only one thick line is used in FIG. 7, but it does not mean that there is only one bus or one type of bus.
  • the communication interface is used for communication between the above electronic device and other devices.
  • the memory may include RAM and may also include non-volatile memory, such as at least one disk memory.
  • the memory may also be at least one storage device located remotely from the aforementioned processor.
  • the above-mentioned memory 706 may include, but is not limited to, the receiving unit 602 , the saving unit 604 and the inspection unit 606 in the above-mentioned suspended transaction inspection device. In addition, it may also include, but is not limited to, other module units in the above-mentioned suspended transaction inspection device, which will not be repeated in this example.
  • the above-mentioned processor can be a general-purpose processor, which can include but is not limited to: CPU (Central Processing Unit, central processing unit), NP (Network Processor, network processor), etc.; can also be DSP (Digital Signal Processing, digital signal processor) ), ASIC (Application Specific Integrated Circuit, Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array, Field Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
  • CPU Central Processing Unit, central processing unit
  • NP Network Processor, network processor
  • DSP Digital Signal Processing, digital signal processor
  • ASIC Application Specific Integrated Circuit
  • FPGA Field-Programmable Gate Array, Field Programmable Gate Array
  • other programmable logic devices discrete gate or transistor logic devices, discrete hardware components.
  • FIG. 7 is for illustration only, and the device implementing the above-mentioned method for inspecting suspended affairs can also be a terminal device, and the terminal device can be a smart phone (such as an Android mobile phone, an iOS mobile phone, etc.), Tablet PCs, PDAs, Mobile Internet Devices (MIDs, MIDs), PADs and other terminal devices.
  • FIG. 7 does not limit the structure of the above electronic device.
  • the electronic device may also include more or fewer components than those shown in FIG. 7 (eg, network interfaces, display devices, etc.), or have a different configuration than that shown in FIG. 7 .
  • a storage medium is also provided.
  • the above-mentioned storage medium may be used to execute the program code of any one of the above-mentioned suspended transaction inspection methods in the embodiment of the present application.
  • the above-mentioned storage medium may be located on at least one network device among multiple network devices in the network shown in the above-mentioned embodiment.
  • the storage medium is configured to store program codes for executing the following steps:
  • target topology information is the topology information between the target global transaction and multiple target branch transactions corresponding to the target global transaction;
  • the target storage object is used to record the topology information between each global transaction in the multiple global transactions and the multiple branch transactions corresponding to each global transaction, and the target The database is used to process one of the branch transactions corresponding to each global transaction;
  • each global transaction is respectively inspected for suspended transactions.
  • the above-mentioned storage medium may include, but is not limited to, various media that can store program codes, such as U disk, ROM, RAM, removable hard disk, magnetic disk, or optical disk.
  • the integrated units in the above-mentioned embodiments are implemented in the form of software functional units and sold or used as independent products, they may be stored in the above-mentioned computer-readable storage medium.
  • the technical solutions of the present application can be embodied in the form of software products in essence, or the parts that contribute to the related technologies, or all or part of the technical solutions.
  • the computer software products are stored in the storage medium, including Several instructions are used to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
  • the disclosed client may be implemented in other manners.
  • the apparatus embodiments described above are only illustrative, for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation, for example, multiple units or components may be combined or Integration into another system, or some features can be ignored, or not implemented.
  • the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of units or modules, and may be in electrical or other forms.
  • the units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place or distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution provided in this embodiment.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units.
  • the embodiments of the present application provide a method and device, an electronic device, and a storage medium for inspecting a suspended transaction.
  • Target topology information is received through a target database, and the target topology information is a combination of a target global transaction and multiple target branch transactions corresponding to the target global transaction.
  • the topology information between the two; save the target topology information into the target storage object, and the target storage object is used to record the topology information between each global transaction in the multiple global transactions and the multiple branch transactions corresponding to each global transaction,
  • the target database is used to process one branch transaction among the multiple branch transactions corresponding to each global transaction; according to the topology information recorded in the target storage object, each global transaction is inspected by the target database.
  • each global transaction and its corresponding branch transaction can be registered in at least one associated database instance, different global transactions and their corresponding branches Transactions are registered in different database instances, instead of the global transaction manager for unified global transaction management, so that the purpose of distributed global transaction and branch transaction registration management can be achieved, which can reduce the processing pressure of the manager and improve the suspension.
  • the technical effect of transaction processing efficiency further solves the problem of low hanging transaction processing efficiency caused by the large number of global transactions and branch transactions managed by the manager in the suspended transaction control method in the related art.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Computing Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

Provided in the present application are a suspended transaction inspection method and apparatus, an electronic device and a storage medium. The method comprises: receiving target topological information by means of a target database, wherein the target topological information is topological information between a target global transaction and a plurality of target branch transactions which correspond to the target global transaction; storing the target topological information in a target storage object, wherein the target storage object is used for recording topological information between each of a plurality of global transactions and a plurality of branch transactions which correspond to each global transaction, and the target database is used for processing one of the plurality of branch transactions which correspond to each global transaction; and according to the topological information recorded in the target storage object, performing suspended transaction inspection on each global transaction by means of the target database. By means of the present application, the problem of a suspended transaction control manner having low suspended transaction processing efficiency due to a larger number of global transactions and branch transactions managed by a manager is solved.

Description

悬挂事务巡检方法和装置、电子设备和存储介质Suspended transaction inspection method and device, electronic device and storage medium
本申请要求于2021年3月25日提交中国专利局、申请号为202110317349.8、发明名称为“悬挂事务巡检方法和装置、电子设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application filed on March 25, 2021 with the application number 202110317349.8 and the invention titled "Hanging affairs inspection method and device, electronic equipment and storage medium", the entire content of which is approved by Reference is incorporated in this application.
技术领域technical field
本申请涉及数据处理领域,尤其涉及一种悬挂事务巡检方法和装置、电子设备和存储介质。The present application relates to the field of data processing, and in particular, to a method and device for inspection of suspended affairs, an electronic device and a storage medium.
背景技术Background technique
事务作为数据库保证数据原子性的核心能力,在分布式数据库的设计中也是需要重点关注的点。分布式数据库可以有多种架构,例如,基于中间件路由的分片(sharding)架构,基于spanner(一种数据库系统)的分布式架构。在分布式数据库架构中,可以引入分布式事务机制来保证跨多节点修改数据的原子特性,以实现数据库的ACID特性。As the core ability of the database to ensure the atomicity of data, transaction is also a point that needs to be paid attention to in the design of distributed database. A distributed database can have various architectures, for example, a sharding architecture based on middleware routing, and a distributed architecture based on spanner (a database system). In a distributed database architecture, a distributed transaction mechanism can be introduced to ensure the atomic property of modifying data across multiple nodes to achieve the ACID property of the database.
在处理分布式事务时,可以通过悬挂事务巡检来兼容分布式环境下的局部故障(如节点宕机、网络故障等)场景,这里,悬挂事务是指全局事务的发起者(主控节点)在全局事务提交前故障,导致全局事务和其对应的分支事务无法继续推进。相关技术中,悬挂事务巡检采用的一般是基于全局事务管理器的悬挂事务管理机制。When dealing with distributed transactions, suspending transaction inspections can be used to be compatible with local faults (such as node downtime, network failure, etc.) in a distributed environment. Here, suspending transactions refer to the initiator (master node) of the global transaction Failure before the global transaction is committed, resulting in the failure of the global transaction and its corresponding branch transaction to proceed. In the related art, the suspension transaction inspection generally adopts the suspension transaction management mechanism based on the global transaction manager.
基于全局事务管理器的悬挂事务管理机制(方案)通过集中的全局事务状态管理,可以实现悬挂事务的自动巡检并按照设定的策略推进事务的提交和回滚。然而,当集群规模较大,数据分散多分片时,全局事务管理器所管理的全局事务和分支事务的数量会大幅增加,导致存在悬挂事务处理效率低的问题。The suspended transaction management mechanism (scheme) based on the global transaction manager can realize the automatic inspection of suspended transactions and promote the commit and rollback of transactions according to the set strategy through centralized global transaction state management. However, when the scale of the cluster is large and the data is scattered and multi-sharded, the number of global transactions and branch transactions managed by the global transaction manager will increase significantly, resulting in the problem of low efficiency of suspending transactions.
发明内容SUMMARY OF THE INVENTION
本申请实施例提供了一种悬挂事务巡检方法和装置、电子设备和存储介质,以至少解决相关技术中的悬挂事务控制方式存在由于管理器所管理的全局事务和分支事务的数量较多导致的悬挂事务处理效率低的问题。Embodiments of the present application provide a method and apparatus for inspecting suspended transactions, an electronic device, and a storage medium, so as to at least solve the problem in the control mode of suspended transactions in the related art that due to the large number of global transactions and branch transactions managed by the manager The hanging transaction processing inefficiency problem.
根据本申请实施例的一个方面,提供了一种悬挂事务巡检方法,包括:通过目标数据库接收目标拓扑信息,其中,所述目标拓扑信息是目标全局事务和与所述目标全局事务对应的多个目标分支事务之间的拓扑信息;将所述目标拓扑信息保存到目标存储对象中,其中,所述目标存储对象用于记录多个全局事务中的每个全局事务和与所述每个全局事务对应的多个分支事务之间的拓扑信息,所述目 标数据库用于处理与所述每个全局事务对应的所述多个分支事务中的一个分支事务;按照所述目标存储对象中记录的拓扑信息,通过所述目标数据库对所述各个全局事务分别进行悬挂事务巡检。According to an aspect of the embodiments of the present application, there is provided a method for inspecting suspended transactions, including: receiving target topology information through a target database, where the target topology information is a target global transaction and a multiplicity of data corresponding to the target global transaction topology information between target branch transactions; save the target topology information into a target storage object, wherein the target storage object is used to record each global transaction in multiple global transactions and the relationship with each global transaction. topology information between multiple branch transactions corresponding to a transaction, the target database is used to process one branch transaction in the multiple branch transactions corresponding to each global transaction; according to the data recorded in the target storage object topology information, and each global transaction is separately inspected for suspended transactions through the target database.
在一实施方式中,通过所述目标数据库接收所述目标拓扑信息包括:通过所述目标数据库接收目标服务器发送的目标事务消息,其中,所述目标服务器为所述目标全局事务的事务协调者,所述目标事务消息中携带有所述目标拓扑信息和与所述目标数据库对应的待处理分支事务信息,所述待处理分支事务信息用于指示所述多个目标分支事务中,待所述目标数据库处理的分支事务。In one embodiment, receiving the target topology information through the target database includes: receiving, through the target database, a target transaction message sent by a target server, wherein the target server is a transaction coordinator of the target global transaction, The target transaction message carries the target topology information and the pending branch transaction information corresponding to the target database, and the pending branch transaction information is used to indicate that among the multiple target branch transactions, the target Branch transactions handled by the database.
在一实施方式中,按照所述目标存储对象中记录的拓扑信息,通过所述目标数据库对所述各个全局事务分别进行悬挂事务巡检包括:按照所述目标存储对象中记录的所述目标拓扑信息,通过所述目标数据库确定与所述目标全局事务对应的第一状态信息;在根据所述第一状态信息确定出所述目标全局事务在提交之前发生异常的情况下,将所述目标全局事务确定为悬挂事务。In one embodiment, according to the topology information recorded in the target storage object, respectively performing a suspended transaction inspection on the global transactions through the target database includes: according to the target topology recorded in the target storage object. information, first state information corresponding to the target global transaction is determined through the target database; if it is determined according to the first state information that the target global transaction is abnormal before submission, the target global transaction is The transaction is determined to be a pending transaction.
在一实施方式中,按照所述目标存储对象中记录的所述目标拓扑信息,通过所述目标数据库确定与所述目标全局事务对应的所述第一状态信息包括:按照所述目标拓扑信息,通过所述目标数据库检测目标心跳信息,其中,所述第一状态信息包含所述目标心跳信息,所述目标心跳信息为所述目标数据库与目标服务器之间的心跳信息,所述目标服务器为与所述目标全局事务对应的事务协调者;在按照所述目标拓扑信息,通过所述目标数据库检测所述目标心跳信息之后,所述方法还包括:在检测到所述目标心跳信息停止更新的情况下,确定出所述目标全局事务在提交之前发生异常。In an embodiment, according to the target topology information recorded in the target storage object, determining the first state information corresponding to the target global transaction by using the target database includes: according to the target topology information, The target heartbeat information is detected by the target database, wherein the first state information includes the target heartbeat information, and the target heartbeat information is the heartbeat information between the target database and the target server, and the target server is the same as the target server. The transaction coordinator corresponding to the target global transaction; after detecting the target heartbeat information through the target database according to the target topology information, the method further includes: after detecting that the target heartbeat information stops updating Next, it is determined that an exception occurs before the target global transaction is committed.
在一实施方式中,在按照所述目标存储对象中记录的拓扑信息,通过所述目标数据库对所述各个全局事务分别进行悬挂事务巡检之后,所述方法还包括:在将所述目标全局事务确定为悬挂事务的情况下,获取与所述多个目标分支事务中的各个目标分支事务对应的第二状态信息;按照与所述各个目标分支事务对应的所述第二状态信息控制对所述各个分支事务执行目标事务操作,其中,所述目标事务操作包括以下之一:事务提交,事务回滚。In one embodiment, after performing the suspended transaction inspection on each of the global transactions through the target database according to the topology information recorded in the target storage object, the method further includes: In the case where the transaction is determined to be a suspended transaction, obtain second state information corresponding to each target branch transaction in the plurality of target branch transactions; Each branch transaction executes a target transaction operation, wherein the target transaction operation includes one of the following: transaction commit and transaction rollback.
在一实施方式中,按照与所述各个目标分支事务对应的所述第二状态信息控制对所述各个分支事务执行所述目标事务操作包括:在根据与所述各个目标分支事务对应的所述第二状态信息确定出所述各个目标分支事务均已预提交成功的情况下,控制对所述各个目标分支事务进行事务提交;在根据与所述各个目标分支事务对应的所述第二状态信息确定出存在预提交失败的分支事务的情况下,控制对所述各个目标分支事务进行事务回滚。In one embodiment, controlling the execution of the target transaction operation on the respective branch transactions according to the second state information corresponding to the respective target branch transactions includes: When it is determined from the second state information that each target branch transaction has been pre-committed successfully, control to perform transaction submission on each target branch transaction; according to the second state information corresponding to each target branch transaction When it is determined that there is a branch transaction that fails to pre-commit, the control is to perform transaction rollback on each target branch transaction.
在一实施方式中,在按照所述目标存储对象中记录的拓扑信息,通过所述目标数据库对所述各个全局事务分别进行悬挂事务巡检之后,所述方法还包括:在所述目标全局事务提交成功的情况下,将所述目标拓扑信息从所述目标存储对象 中删除。In one embodiment, after performing the suspended transaction inspection on each global transaction through the target database according to the topology information recorded in the target storage object, the method further includes: in the target global transaction If the submission is successful, the target topology information is deleted from the target storage object.
根据本申请实施例的另一个方面,还提供了一种悬挂事务巡检装置,包括:接收单元,设置为通过目标数据库接收目标拓扑信息,其中,所述目标拓扑信息是目标全局事务和与所述目标全局事务对应的多个目标分支事务之间的拓扑信息;保存单元,设置为将所述目标拓扑信息保存到目标存储对象中,其中,所述目标存储对象用于记录多个全局事务中的每个全局事务和与所述每个全局事务对应的多个分支事务之间的拓扑信息,所述目标数据库用于处理与所述每个全局事务对应的所述多个分支事务中的一个分支事务;巡检单元,设置为按照所述目标存储对象中记录的拓扑信息,通过所述目标数据库对所述各个全局事务分别进行悬挂事务巡检。According to another aspect of the embodiments of the present application, there is also provided a suspended transaction inspection device, including: a receiving unit configured to receive target topology information through a target database, wherein the target topology information is the target global transaction and the the topology information between the multiple target branch transactions corresponding to the target global transaction; the storage unit is configured to save the target topology information into the target storage object, wherein the target storage object is used to record the multiple global transactions. topology information between each global transaction of the A branch transaction; an inspection unit, configured to perform inspection of suspended transactions on each global transaction through the target database according to the topology information recorded in the target storage object.
在一实施方式中,所述接收单元包括:接收模块,设置为通过所述目标数据库接收目标服务器发送的目标事务消息,其中,所述目标服务器为所述目标全局事务的事务协调者,所述目标事务消息中携带有所述目标拓扑信息和与所述目标数据库对应的待处理分支事务信息,所述待处理分支事务信息用于指示所述多个目标分支事务中,待所述目标数据库处理的分支事务。In one embodiment, the receiving unit includes: a receiving module configured to receive, through the target database, a target transaction message sent by a target server, wherein the target server is the transaction coordinator of the target global transaction, and the target server is the transaction coordinator of the target global transaction. The target transaction message carries the target topology information and to-be-processed branch transaction information corresponding to the target database, and the to-be-processed branch transaction information is used to indicate that among the multiple target branch transactions, to be processed by the target database branch transaction.
在一实施方式中,所述巡检单元包括:第一确定模块,设置为按照所述目标存储对象中记录的所述目标拓扑信息,通过所述目标数据库确定与所述目标全局事务对应的第一状态信息;第二确定模块,设置为在根据所述第一状态信息确定出所述目标全局事务在提交之前发生异常的情况下,将所述目标全局事务确定为悬挂事务。In one embodiment, the inspection unit includes: a first determination module, configured to determine, through the target database, the first determination module corresponding to the target global transaction according to the target topology information recorded in the target storage object. a state information; a second determination module configured to determine the target global transaction as a suspended transaction when it is determined according to the first state information that an exception occurs before the target global transaction is committed.
在一实施方式中,所述第一确定模块包括:确定子模块,所述装置还包括:确定单元,其中,所述确定子模块,设置为按照所述目标拓扑信息,通过所述目标数据库检测目标心跳信息,其中,所述第一状态信息包含所述目标心跳信息,所述目标心跳信息为所述目标数据库与目标服务器之间的心跳信息,所述目标服务器为与所述目标全局事务对应的事务协调者;所述确定单元,设置为在按照所述目标拓扑信息,通过所述目标数据库检测所述目标心跳信息之后,在检测到所述目标心跳信息停止更新的情况下,确定出所述目标全局事务在提交之前发生异常。In one embodiment, the first determining module includes: a determining sub-module, and the apparatus further includes: a determining unit, wherein the determining sub-module is configured to detect through the target database according to the target topology information Target heartbeat information, wherein the first state information includes the target heartbeat information, the target heartbeat information is the heartbeat information between the target database and the target server, and the target server corresponds to the target global transaction The transaction coordinator; the determining unit is configured to, after detecting the target heartbeat information through the target database according to the target topology information, when it is detected that the target heartbeat information stops updating, determine the target heartbeat information. An exception occurred before the target global transaction was committed.
在一实施方式中,所述装置还包括:获取单元,设置为在按照所述目标存储对象中记录的拓扑信息,通过所述目标数据库对所述各个全局事务分别进行悬挂事务巡检之后,在将所述目标全局事务确定为悬挂事务的情况下,获取与所述多个目标分支事务中的各个目标分支事务对应的第二状态信息;控制单元,设置为按照与所述各个目标分支事务对应的所述第二状态信息控制对所述各个分支事务执行目标事务操作,其中,所述目标事务操作包括以下之一:事务提交,事务回滚。In one embodiment, the device further includes: an acquisition unit, configured to perform a suspended transaction inspection on each global transaction through the target database according to the topology information recorded in the target storage object, and then perform a pending transaction inspection on the global transactions respectively. In the case where the target global transaction is determined to be a suspending transaction, obtain second state information corresponding to each target branch transaction in the plurality of target branch transactions; the control unit is set to correspond to each target branch transaction according to the The second state information controls the execution of target transaction operations on the respective branch transactions, wherein the target transaction operations include one of the following: transaction commit and transaction rollback.
在一实施方式中,所述控制单元包括:第一控制模块,设置为在根据与所述 各个目标分支事务对应的所述第二状态信息确定出所述各个目标分支事务均已预提交成功的情况下,控制对所述各个目标分支事务进行事务提交;第二控制模块,设置为在根据与所述各个目标分支事务对应的所述第二状态信息确定出存在预提交失败的分支事务的情况下,控制对所述各个目标分支事务进行事务回滚。In one embodiment, the control unit includes: a first control module, configured to determine, according to the second state information corresponding to the respective target branch transactions, that each target branch transaction has been pre-committed successfully. In this case, control the transaction submission of each target branch transaction; the second control module is configured to determine that there is a branch transaction that fails to pre-commit according to the second state information corresponding to each target branch transaction. Next, control the transaction rollback of each target branch transaction.
在一实施方式中,所述装置还包括:删除单元,设置为在按照所述目标存储对象中记录的拓扑信息,通过所述目标数据库对所述各个全局事务分别进行悬挂事务巡检之后,在所述目标全局事务提交成功的情况下,将所述目标拓扑信息从所述目标存储对象中删除。In one embodiment, the device further includes: a deletion unit, configured to perform a suspended transaction inspection on each global transaction through the target database according to the topology information recorded in the target storage object, and then delete the transaction in the target database. If the target global transaction is successfully submitted, the target topology information is deleted from the target storage object.
根据本申请实施例的又一个方面,还提供了一种电子设备,包括处理器、通信接口、存储器和通信总线,其中,处理器、通信接口和存储器通过通信总线完成相互间的通信;其中,存储器,用于存储计算机程序;处理器,用于通过运行所述存储器上所存储的所述计算机程序来执行上述任一实施例中的方法步骤。According to another aspect of the embodiments of the present application, an electronic device is also provided, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; wherein, a memory for storing a computer program; and a processor for executing the method steps in any of the foregoing embodiments by running the computer program stored in the memory.
根据本申请实施例的又一个方面,还提供了一种计算机可读的存储介质,该存储介质中存储有计算机程序,其中,该计算机程序被设置为运行时执行上述任一实施例中的方法步骤。According to yet another aspect of the embodiments of the present application, a computer-readable storage medium is also provided, where a computer program is stored in the storage medium, wherein the computer program is configured to execute the method in any of the foregoing embodiments when running step.
在本申请实施例中,采用由事务的参与者进行悬挂事务管理的方式,通过目标数据库接收目标拓扑信息,其中,所述目标拓扑信息是目标全局事务和与所述目标全局事务对应的多个目标分支事务之间的拓扑信息;将所述目标拓扑信息保存到目标存储对象中,其中,所述目标存储对象用于记录多个全局事务中的每个全局事务和与所述每个全局事务对应的多个分支事务之间的拓扑信息,所述目标数据库用于处理与所述每个全局事务对应的所述多个分支事务中的一个分支事务;按照所述目标存储对象中记录的拓扑信息,通过所述目标数据库对所述各个全局事务分别进行悬挂事务巡检,由于数据库实例(数据库节点)通过系统表保存与本数据库实例关联的拓扑信息,每个全局事务及其对应的分支事务可以注册到至少一个关联的数据库实例中,不同的全局事务及其对应的分支事务注册到不同的数据库实例中,而不是由全局事务管理器统一进行全局事务管理,可以实现分布式的全局事务和分支事务注册管理的目的,达到了减少管理器的处理压力、提高悬挂事务处理效率的技术效果,进而解决了相关技术中的悬挂事务控制方式存在由于管理器所管理的全局事务和分支事务的数量较多导致的悬挂事务处理效率低的问题。In the embodiment of the present application, the method of suspending transaction management performed by the participants of the transaction is adopted, and the target topology information is received through the target database, wherein the target topology information is the target global transaction and the multiple target global transactions corresponding to the target global transaction. topology information between target branch transactions; save the target topology information into a target storage object, wherein the target storage object is used to record each global transaction in multiple global transactions and the relationship with each global transaction topology information between corresponding multiple branch transactions, the target database is used to process one branch transaction among the multiple branch transactions corresponding to each global transaction; according to the topology recorded in the target storage object information, through the target database, the suspended transaction inspection is carried out for the various global transactions. Since the database instance (database node) saves the topology information associated with the database instance through the system table, each global transaction and its corresponding branch transaction It can be registered in at least one associated database instance, and different global transactions and their corresponding branch transactions are registered in different database instances, instead of unified global transaction management by the global transaction manager, which can realize distributed global transactions and The purpose of branch transaction registration management achieves the technical effect of reducing the processing pressure of the manager and improving the processing efficiency of suspended transactions, thereby solving the existence of the suspension transaction control method in the related art due to the number of global transactions and branch transactions managed by the manager The problem of low efficiency of hanging transaction processing caused by more.
附图说明Description of drawings
此处的附图被并入说明书中并构成本说明书的一部分,示出了符合本申请的实施例,并与说明书一起用于解释本申请的原理。The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the application and together with the description serve to explain the principles of the application.
为了更清楚地说明本申请实施例或相关技术中的技术方案,下面将对实施例或相关技术描述中所需要使用的附图作简单地介绍,显而易见地,对于本领域普 通技术人员而言,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the accompanying drawings required for describing the embodiments or related technologies will be briefly introduced below. Obviously, for those skilled in the art, On the premise of no creative labor, other drawings can also be obtained from these drawings.
图1是根据本申请实施例的一种悬挂事务巡检方法的硬件环境的示意图;1 is a schematic diagram of a hardware environment of a method for inspecting a suspended transaction according to an embodiment of the present application;
图2是根据本申请实施例的一种悬挂事务巡检方法的流程示意图;2 is a schematic flowchart of a method for inspecting a suspended transaction according to an embodiment of the present application;
图3是根据本申请实施例的一种悬挂事务巡检方法的示意图;3 is a schematic diagram of a method for inspecting a suspension transaction according to an embodiment of the present application;
图4是根据本申请实施例的另一种悬挂事务巡检方法的流程示意图;4 is a schematic flowchart of another method for inspecting a suspended transaction according to an embodiment of the present application;
图5是根据本申请实施例的又一种悬挂事务巡检方法的流程示意图;FIG. 5 is a schematic flowchart of another method for inspecting a suspended transaction according to an embodiment of the present application;
图6是根据本申请实施例的一种悬挂事务巡检装置的结构框图;FIG. 6 is a structural block diagram of a device for inspecting suspended affairs according to an embodiment of the present application;
图7是根据本申请实施例的一种电子设备的结构框图。FIG. 7 is a structural block diagram of an electronic device according to an embodiment of the present application.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本申请方案,下面将结合本申请实施例中的附图,对本申请实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本申请一部分的实施例,而不是全部的实施例。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都应当属于本申请保护的范围。In order to make those skilled in the art better understand the solutions of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only The embodiments are part of the present application, but not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative work shall fall within the scope of protection of the present application.
需要说明的是,本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包含,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。It should be noted that the terms "first", "second", etc. in the description and claims of the present application and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific sequence or sequence. It is to be understood that data so used may be interchanged under appropriate circumstances so that the embodiments of the application described herein can be practiced in sequences other than those illustrated or described herein. Furthermore, the terms "comprising" and "having" and any variations thereof, are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those expressly listed Rather, those steps or units may include other steps or units not expressly listed or inherent to these processes, methods, products or devices.
首先,在对本申请实施例进行描述的过程中出现的部分名词或者术语适用于如下解释:First of all, some nouns or terms that appear in the process of describing the embodiments of the present application are suitable for the following explanations:
1、ACID特性,指以下四个特性:原子性(Atomicity)、一致性(Consistency)、隔离性(Isolation)、持久性(Durability);1. ACID characteristics refer to the following four characteristics: Atomicity, Consistency, Isolation, Durability;
2、全局事务,是指发起数据修改的总控事务;2. Global transaction refers to the master control transaction that initiates data modification;
3、分支事务,是指全局事务修改的数据分散到若干个节点,对每个节点上的数据修改封装成的事务。3. Branch transaction refers to a transaction in which the data modified by the global transaction is distributed to several nodes, and the data modification on each node is encapsulated into a transaction.
根据本申请实施例的一个方面,提供了一种悬挂事务巡检方法。在一实施方式中,在本实施例中,上述悬挂事务巡检方法可以应用于如图1所示的包含多个 节点(例如,数据库服务器)的分布式存储系统,例如,包含第一节点102和第二节点104的硬件环境中。如图1所示,第一节点102通过网络与第二节点104进行连接,可用于为终端或终端上安装的客户端提供服务(例如,事务处理服务等)。在进行事务处理时,第一节点102可以是事务处理的协调者,可以用于处理全局事务,第二节点104可以是事务处理的参与者,用于处理分支事务。According to an aspect of the embodiments of the present application, a method for inspecting a suspended transaction is provided. In one embodiment, in this embodiment, the above-mentioned method for inspecting suspended transactions may be applied to a distributed storage system including a plurality of nodes (eg, database servers) as shown in FIG. 1 , for example, including the first node 102 . and the hardware environment of the second node 104 . As shown in FIG. 1 , the first node 102 is connected with the second node 104 through a network, and can be used to provide services (eg, transaction processing services, etc.) for the terminal or the client installed on the terminal. When performing transaction processing, the first node 102 may be the coordinator of the transaction processing and may be used to process the global transaction, and the second node 104 may be a participant of the transaction processing and may be used to process the branch transaction.
上述网络可以包括但不限于以下至少之一:有线网络,无线网络。上述有线网络可以包括但不限于以下至少之一:广域网,城域网,局域网,上述无线网络可以包括但不限于以下至少之一:WIFI(Wireless Fidelity,无线保真),蓝牙。终端102可以并不限定于为PC、手机、平板电脑等。The above network may include, but is not limited to, at least one of the following: wired network, wireless network. The above wired network may include, but is not limited to, at least one of the following: a wide area network, a metropolitan area network, and a local area network, and the above wireless network may include but not limited to at least one of the following: WIFI (Wireless Fidelity, wireless fidelity), Bluetooth. The terminal 102 may not be limited to a PC, a mobile phone, a tablet computer, or the like.
本申请实施例的悬挂事务巡检方法可以由第一节点102来执行,也可以由第二节点104来执行,还可以是由第一节点102和第二节点104共同执行。其中,第一节点102和/或第二节点104执行本申请实施例的悬挂事务巡检方法也可以是由安装在其上的客户端来执行。The suspended transaction inspection method in this embodiment of the present application may be executed by the first node 102 , may also be executed by the second node 104 , or may be executed jointly by the first node 102 and the second node 104 . Wherein, the first node 102 and/or the second node 104 may execute the suspended transaction inspection method according to the embodiment of the present application, and may also be executed by a client installed thereon.
以由第二节点104来执行本实施例中的悬挂事务巡检方法为例,图2是根据本申请实施例的一种悬挂事务巡检方法的流程示意图,如图2所示,该方法的流程可以包括以下步骤:Taking the second node 104 to execute the method for inspecting suspended transactions in this embodiment as an example, FIG. 2 is a schematic flowchart of a method for inspecting suspended transactions according to an embodiment of the present application. As shown in FIG. The process can include the following steps:
步骤S202,通过目标数据库接收目标拓扑信息,其中,目标拓扑信息是目标全局事务和与目标全局事务对应的多个目标分支事务之间的拓扑信息。Step S202, receiving target topology information through the target database, wherein the target topology information is the topology information between the target global transaction and multiple target branch transactions corresponding to the target global transaction.
本申请实施例中的悬挂事务巡检方法可以应用于分布式存储系统中的悬挂事务巡检的场景中。分布式存储系统可以包括:客户端APP(Application,应用端),主控节点(协调者),数据节点(参与者),其中,主控节点可以是分布式数据库代理DS(Data Server,数据服务器),数据节点可以是DB(Data Base,数据库,数据库实例)。客户端可以通过网络与主控节点相连,不同的客户端可以连接到相同或者不同的主控节点,同一主控节点可以连接多个客户端。主控节点可以通过网络与数据节点相连,不同的数据节点可以连接到相同或者不同的主控节点,同一主控节点可以连接多个数据节点。The suspended transaction inspection method in the embodiment of the present application may be applied to the scenario of suspended transaction inspection in a distributed storage system. The distributed storage system may include: a client APP (Application), a master node (coordinator), and a data node (participant), wherein the master node may be a distributed database agent DS (Data Server, data server). ), the data node can be DB (Data Base, database, database instance). Clients can be connected to the master node through the network, different clients can be connected to the same or different master nodes, and the same master node can be connected to multiple clients. The master node can be connected to the data nodes through the network, different data nodes can be connected to the same or different master nodes, and the same master node can be connected to multiple data nodes.
在有数据修改需求或者其他需求时,客户端可以向DS发起全局事务,即,发起数据修改的总控事务。例如,对于目标客户端,目标客户端可以向目标服务器(DS)发送目标全局事务,该目标全局事务用于对目标对象执行目标处理操作。When there is a data modification requirement or other requirements, the client can initiate a global transaction to the DS, that is, initiate a general control transaction for data modification. For example, for a target client, the target client may send a target global transaction to the target server (DS), which is used to perform the target processing operation on the target object.
目标服务器可以确定与目标全局事务对应的多个目标分支事务,也就是,确定上述目标处理操作所修改的数据分散在的数据库节点,并对每个数据库节点上的数据修改封装成对应的目标分支事务,得到多个目标分支事务。在得到多个目标分支事务之后,目标服务器可以将多个目标分支事务中的各个目标分支事务发送到对应的数据库节点上。The target server can determine multiple target branch transactions corresponding to the target global transaction, that is, determine the database nodes where the data modified by the above target processing operations are scattered, and encapsulate the data modification on each database node into a corresponding target branch transaction, get multiple target branch transactions. After obtaining the multiple target branch transactions, the target server may send each target branch transaction among the multiple target branch transactions to the corresponding database node.
为了避免由于全局事务的发起者在全局事务提交前故障导致全局事务和其 对应的分支事务无法继续推进,同时避免由于管理器所管理的全局事务和分支事务的数量较多导致的悬挂事务处理效率低,一种实现方案为:复用数据库本身的事务超时自动提交/回滚策略,该方案依赖数据库内核自主检测超时的悬挂的分支事务,并根据分支事务特征进行提交/回滚,无法保证全局事务的ACID特征,且效率较低。In order to avoid the failure of the initiator of the global transaction before the global transaction is committed, the global transaction and its corresponding branch transaction cannot continue to advance, and at the same time to avoid the hanging transaction processing efficiency caused by the large number of global transactions and branch transactions managed by the manager Low, an implementation scheme is: reuse the transaction timeout automatic commit/rollback strategy of the database itself. This scheme relies on the database kernel to autonomously detect the overtime pending branch transaction, and commit/rollback according to the branch transaction characteristics, which cannot guarantee the global ACID characteristics of transactions, and less efficient.
在一实施方式中,在本申请实施例中,将全局事务和分支事务分散注册到数据库实例中,一个全局事务和对应的分支事务可以注册到处理分支事务的某一个数据库实例,或者,处理分支事务的多个数据库实例,以实现全局事务和分支事务状态自管理。In one embodiment, in the embodiment of the present application, the global transaction and the branch transaction are registered in the database instance in a decentralized manner, and a global transaction and the corresponding branch transaction can be registered in a certain database instance that processes the branch transaction, or, the processing branch Multiple database instances of transactions to enable global transaction and branch transaction state self-management.
对于目标全局事务,目标服务器可以生成与该目标全局事务对应的目标拓扑信息,上述目标拓扑信息是目标全局事务和与目标全局事务对应的多个目标分支事务之间的拓扑信息,可以用于表示目标全局事务和与目标全局事务对应的多个目标分支事务之间的拓扑关系,例如,目标全局事务与处理目标全局事务的目标服务器之间的对应关系、各个目标分支事务与处理各个目标分支事务的数据库节点之间的对应关系。目标拓扑信息还可以包含其他信息,例如,目标全局事务的发起时间等等,本申请实施例中对此不作限定。For a target global transaction, the target server can generate target topology information corresponding to the target global transaction, and the above target topology information is the topology information between the target global transaction and multiple target branch transactions corresponding to the target global transaction, and can be used to represent Topological relationship between the target global transaction and multiple target branch transactions corresponding to the target global transaction, for example, the corresponding relationship between the target global transaction and the target server processing the target global transaction, each target branch transaction and processing each target branch transaction The corresponding relationship between the database nodes. The target topology information may also include other information, for example, the initiation time of the target global transaction, etc., which is not limited in this embodiment of the present application.
目标服务器还可以从处理各个目标分支事务的数据库节点中选取出目标数据库,也就是,该目标全局事务和多个目标分支事务所要注册到的数据库节点,并将目标拓扑信息发送给选取的目标数据库。目标数据库的数量可以为一个或多个,选取的方式可以是:随机选取,也可以是按照目标分支事务由先到后的顺序,还可以是其他选取方式,本实施例中对此不作限定。The target server can also select the target database from the database nodes that process each target branch transaction, that is, the database node to which the target global transaction and multiple target branch transactions are to be registered, and send the target topology information to the selected target database. . The number of target databases may be one or more, and the selection method may be: random selection, or according to the order of target branch transactions, or other selection methods, which are not limited in this embodiment.
对于一个目标数据库,该目标数据库可以是处理多个目标分支事务中的一个分支事务的数据库节点。除了接收到本数据库所需处理的目标分支事务以外,该目标数据库还可以接收目标数据库发送的目标拓扑信息。For a target database, the target database may be a database node that processes a branch transaction of a plurality of target branch transactions. In addition to receiving the target branch transaction to be processed by this database, the target database can also receive target topology information sent by the target database.
步骤S204,将目标拓扑信息保存到目标存储对象中,其中,目标存储对象用于记录多个全局事务中的每个全局事务和与每个全局事务对应的多个分支事务之间的拓扑信息,目标数据库用于处理与每个全局事务对应的多个分支事务中的一个分支事务。Step S204, save the target topology information in the target storage object, wherein the target storage object is used to record the topology information between each global transaction in the multiple global transactions and the multiple branch transactions corresponding to each global transaction, The target database is used to process one of the branch transactions corresponding to each global transaction.
在每个数据库实例中可以保存有一个存储对象,该存储对象可以用来记录注册到本数据库实例的全局事务和对应的分支事务的拓扑关系,还可以用来记录注册到本数据库实例的全局事务的状态信息。例如,在每个数据库实例中可以新增一张系统表,该系统表可以用于记录注册到本数据库实例中的全局事务和对应的分支事务的拓扑关系和状态信息。A storage object can be stored in each database instance, and the storage object can be used to record the topological relationship between the global transaction registered in this database instance and the corresponding branch transaction, and can also be used to record the global transaction registered in this database instance. status information. For example, a system table may be added to each database instance, and the system table may be used to record the topology relationship and state information of the global transaction registered in the database instance and the corresponding branch transaction.
对于目标数据库,目标数据库可以保存有目标存储对象(例如,目标系统表),目标存储对象可以用于记录多个全局事务(注册到目标数据库的多个全局事务, 包括目标全局事务)中的每个全局事务和与每个全局事务对应的多个分支事务之间的拓扑信息,还可以用于记录各个全局事务的状态信息。For the target database, the target database may save a target storage object (eg, target system table), and the target storage object may be used to record each of multiple global transactions (multiple global transactions registered with the target database, including the target global transaction) The topology information between each global transaction and multiple branch transactions corresponding to each global transaction can also be used to record the state information of each global transaction.
在接收到目标拓扑信息之后,目标数据库可以将目标拓扑信息保存到目标存储对象中,保存的方式可以是:按照接收的顺序依次保存到目标存储对象,比如,保存到目标存储对象的最后。After receiving the target topology information, the target database can save the target topology information to the target storage object, and the saving method can be: save the target topology information to the target storage object in the order of reception, for example, save it to the end of the target storage object.
需要说明的是,上述存储对象是用于记录注册到本数据库实例的全局事务和与该全局事务对应的多个分支事务之间的拓扑信息的一种存储单元/存储模块,本申请实施例中对于该存储对象的具体形式不作限定。It should be noted that the above-mentioned storage object is a storage unit/storage module used to record the topology information between the global transaction registered in this database instance and the multiple branch transactions corresponding to the global transaction. The specific form of the storage object is not limited.
步骤S206,按照目标存储对象中记录的拓扑信息,通过目标数据库对各个全局事务分别进行悬挂事务巡检。In step S206, according to the topology information recorded in the target storage object, each global transaction is inspected by the target database for suspending transactions.
按照目标存储对象中记录的各个拓扑信息,目标数据库可以对各个全局事务分别进行悬挂事务巡检。巡检的方式可以是:按照目标存储对象中记录的各个拓扑信息,分别确定与各个全局事务对应的主控节点是否发生故障,如果发生故障,确定该全局事务为悬挂事务;如果未发生故障,则确定该全局事务不为悬挂事务。According to each topology information recorded in the target storage object, the target database can perform suspension transaction inspection on each global transaction. The inspection method can be as follows: according to each topology information recorded in the target storage object, determine whether the master control node corresponding to each global transaction is faulty, if a fault occurs, determine that the global transaction is a suspended transaction; if no fault occurs, Then it is determined that the global transaction is not a dangling transaction.
例如,对于目标拓扑信息,目标数据库可以对目标全局事务进行悬挂事务进行训练,确定目标服务器是否发生故障,如果发生故障,确定目标全局事务为悬挂事务,如果不发生故障,确定目标全局事务不为悬挂事务。For example, for the target topology information, the target database can train the target global transaction with suspending transactions, determine whether the target server fails, if a failure occurs, determine that the target global transaction is a suspending transaction, and if no failure occurs, determine that the target global transaction is not Suspended business.
对于各个全局事务,如果对应的主控节点未发生故障,那么,各个事务可以基于相关技术中的提交过程进行处理,比如,先由执行各个分支事务的参与者进行分支事务预提交,并向协调者反馈预提交结果;协调者基于预提交结果确定进行事务提交或者回滚:如果各个参与者的分支事务均已预提交成功,则控制各个参与者进行分支事务的正式提交,如果有参与者的分支事务预提交失败,则控制各个参与者进行分支事务的回滚。For each global transaction, if the corresponding master node does not fail, then each transaction can be processed based on the submission process in the related technology. The coordinator feeds back the pre-commit results; the coordinator determines to commit or roll back the transaction based on the pre-commit results: if the branch transactions of each participant have been pre-committed successfully, each participant will be controlled to formally commit the branch transaction. If the branch transaction pre-commit fails, each participant is controlled to roll back the branch transaction.
通过上述步骤S202至步骤S206,通过目标数据库接收目标拓扑信息,其中,所述目标拓扑信息是目标全局事务和与所述目标全局事务对应的多个目标分支事务之间的拓扑信息;将所述目标拓扑信息保存到目标存储对象中,其中,所述目标存储对象用于记录多个全局事务中的每个全局事务和与所述每个全局事务对应的多个分支事务之间的拓扑信息,所述目标数据库用于处理与所述每个全局事务对应的所述多个分支事务中的一个分支事务;按照所述目标存储对象中记录的拓扑信息,通过所述目标数据库对所述各个全局事务分别进行悬挂事务巡检,解决了相关技术中的悬挂事务控制方式存在由于管理器所管理的全局事务和分支事务的数量较多导致的悬挂事务处理效率低的问题,减少了管理器的处理压力,提高了悬挂事务处理效率。Through the above steps S202 to S206, the target topology information is received through the target database, wherein the target topology information is the topology information between the target global transaction and multiple target branch transactions corresponding to the target global transaction; The target topology information is stored in the target storage object, wherein the target storage object is used to record the topology information between each global transaction in the multiple global transactions and the multiple branch transactions corresponding to the each global transaction, The target database is used to process one branch transaction in the plurality of branch transactions corresponding to each global transaction; according to the topology information recorded in the target storage object, each global transaction is processed by the target database. Transactions are inspected separately for suspending transactions, which solves the problem of low suspending transaction processing efficiency caused by the large number of global transactions and branch transactions managed by the manager in the suspending transaction control method in the related art, and reduces the processing of the manager. pressure and improve the efficiency of suspension transaction processing.
在一实施方式中,通过目标数据库接收目标拓扑信息包括:In one embodiment, receiving the target topology information through the target database includes:
S11,通过目标数据库接收目标服务器发送的目标事务消息,其中,目标服务器为目标全局事务的事务协调者,目标事务消息中携带有目标拓扑信息和与目标数据库对应的待处理分支事务信息,待处理分支事务信息用于指示多个目标分支事务中,待目标数据库处理的分支事务。S11, receiving a target transaction message sent by the target server through the target database, wherein the target server is the transaction coordinator of the target global transaction, and the target transaction message carries the target topology information and the pending branch transaction information corresponding to the target database. The branch transaction information is used to indicate a branch transaction to be processed by the target database among the multiple target branch transactions.
对于目标数据库,目标服务器可以将该目标数据库所需处理的分支事务和目标拓扑信息分别进行发送。例如,目标服务器可以先向目标数据库发送与目标数据库对应的待处理分支事务信息,待处理分支事务信息可以用于指示多个目标分支事务中,待目标数据库处理的分支事务;然后,目标服务器可以向目标数据库发送目标拓扑信息。For the target database, the target server may separately send the branch transaction and target topology information to be processed by the target database. For example, the target server may first send to the target database the branch transaction information to be processed corresponding to the target database, and the to-be-processed branch transaction information may be used to indicate the branch transaction to be processed by the target database among the multiple target branch transactions; then, the target server may Send target topology information to the target database.
在一实施方式中,为了简化数据传输过程,提高系统资源的利用效率,目标服务器可以将目标拓扑信息和待处理分支事务信息一起发送给目标数据库,例如,通过目标事务消息将两者一起发送给目标数据库。In one embodiment, in order to simplify the data transmission process and improve the utilization efficiency of system resources, the target server can send the target topology information and the branch transaction information to be processed to the target database together, for example, send the two together to the target database through the target transaction message. target database.
目标数据库可以接收目标服务器发送的上述目标事务消息,从中分别提取出待处理分支事务信息和目标拓扑信息,将目标拓扑信息保存到目标存储对象中,以及执行上述待处理分支事务信息所指示的分支事务的预提交、提交等等,本申请实施例中对此不作限定。The target database can receive the above-mentioned target transaction message sent by the target server, extract the branch transaction information to be processed and the target topology information respectively, save the target topology information in the target storage object, and execute the branch indicated by the above-mentioned branch transaction information to be processed. The pre-commit, commit, etc. of the transaction are not limited in this embodiment of the present application.
通过本实施例,通过将拓扑信息和事务信息一起发送给数据库实例,可以简化数据传输过程,提高系统资源的利用效率。With this embodiment, by sending topology information and transaction information to the database instance together, the data transmission process can be simplified and the utilization efficiency of system resources can be improved.
在一实施方式中,按照目标存储对象中记录的拓扑信息,通过目标数据库对各个全局事务分别进行悬挂事务巡检包括:In one embodiment, according to the topology information recorded in the target storage object, the suspension transaction inspection of each global transaction through the target database includes:
S21,按照目标存储对象中记录的目标拓扑信息,通过目标数据库确定与目标全局事务对应的第一状态信息;S21, according to the target topology information recorded in the target storage object, determine the first state information corresponding to the target global transaction through the target database;
S22,在根据第一状态信息确定出目标全局事务在提交之前发生异常的情况下,将目标全局事务确定为悬挂事务。S22 , in the case where it is determined according to the first state information that the target global transaction is abnormal before committing, determine the target global transaction as a suspended transaction.
在对悬挂事务进行巡检时,对于目标全局事务,目标数据库可以按照目标拓扑信息,确定与目标全局事务对应的第一状态信息,第一状态信息可以用于表示目标全局事务的当前状态,例如,正常状态,异常状态。第一状态信息可以是周期性确定,例如,按照目标拓扑信息,目标数据库可以周期性地/定时确定与目标全局事务对应的第一状态信息。When inspecting the suspended transaction, for the target global transaction, the target database can determine the first state information corresponding to the target global transaction according to the target topology information, and the first state information can be used to represent the current state of the target global transaction, for example , normal state, abnormal state. The first state information may be determined periodically, for example, according to the target topology information, the target database may periodically/timely determine the first state information corresponding to the target global transaction.
需要说明的是,与目标全局事务对应的第一状态信息可以用于表示处理该目标全局事务的目标服务器的运行状态,如果目标服务器运行正常,则第一状态信息用于表示目标全局事务处于正常状态,如果目标服务器运行异常(例如,发生故障),则第一状态信息用于表示目标全局事务处于异常状态。It should be noted that the first state information corresponding to the target global transaction can be used to indicate the running state of the target server that processes the target global transaction. If the target server is running normally, the first state information is used to indicate that the target global transaction is in normal state. state, if the target server operates abnormally (for example, fails), the first state information is used to indicate that the target global transaction is in an abnormal state.
如果根据第一状态信息确定出目标全局事务在提交之前发生异常,例如,在 目标全局事务在提交之前目标服务器发生故障,那么,目标全局事务将无法完成提交,因此,目标数据库可以将目标全局事务确定为悬挂事务。If it is determined according to the first state information that the target global transaction is abnormal before committing, for example, the target server fails before the target global transaction is committed, then the target global transaction will not be able to complete the commit. Therefore, the target database can transfer the target global transaction Determined as a pending transaction.
通过本申请实施例,按照拓扑信息获取全局事务的状态信息,基于状态信息确定全局事务在提交之前是否异常,可以提高悬挂事务巡检的效率。Through the embodiments of the present application, the status information of the global transaction is acquired according to the topology information, and whether the global transaction is abnormal before being submitted is determined based on the status information, which can improve the efficiency of the inspection of the suspended transaction.
在一实施方式中,按照目标存储对象中记录的目标拓扑信息,通过目标数据库确定与目标全局事务对应的第一状态信息包括:In one embodiment, according to the target topology information recorded in the target storage object, determining the first state information corresponding to the target global transaction through the target database includes:
S31,按照目标拓扑信息,通过目标数据库检测目标心跳信息,其中,第一状态信息包含目标心跳信息,目标心跳信息为目标数据库与目标服务器之间的心跳信息,目标服务器为与目标全局事务对应的事务协调者;S31, according to the target topology information, detect the target heartbeat information through the target database, wherein the first state information includes the target heartbeat information, the target heartbeat information is the heartbeat information between the target database and the target server, and the target server is corresponding to the target global transaction. transaction coordinator;
在按照目标拓扑信息,通过目标数据库检测目标心跳信息之后,上述方法还包括:After detecting the target heartbeat information through the target database according to the target topology information, the above method further includes:
S32,在检测到目标心跳信息停止更新的情况下,确定出目标全局事务在提交之前发生异常。S32 , when it is detected that the target heartbeat information stops updating, it is determined that an exception occurs before the target global transaction is committed.
全局事务的状态信息可以包括数据库实例与数据服务器之间的心跳信息。可以对每个全局事务和分支事务增加心跳信息,比如,数据服务器可以定时向与其相连的全部或者部分数据库实例发送心跳包,数据库实例可以根据收到的心跳包更新保存的心跳信息,心跳信息可以包括心跳包的时间。数据库实例中的悬挂事务巡检模块可以自动检测心跳异常的全局事务。The state information of the global transaction may include heartbeat information between the database instance and the data server. Heartbeat information can be added to each global transaction and branch transaction. For example, the data server can periodically send heartbeat packets to all or part of the database instances connected to it. The database instance can update the saved heartbeat information according to the received heartbeat packets. The heartbeat information can be Including the time of the heartbeat packet. The suspended transaction inspection module in the database instance can automatically detect global transactions with abnormal heartbeats.
正常情况下,全局事务(和/或分支事务)的心跳信息会实时更新,异常情况下全局事务(和/或分支事务)的心跳信息会停止更新,因此,按照心跳信息是否更新,可以确定全局事务(或者分支事务)是否正常。Under normal circumstances, the heartbeat information of the global transaction (and/or branch transaction) will be updated in real time. In abnormal cases, the heartbeat information of the global transaction (and/or branch transaction) will stop updating. Therefore, according to whether the heartbeat information is updated, the global transaction can be determined. Whether the transaction (or branch transaction) is normal.
对于目标全局事务,目标服务器可以定时向目标数据库发送心跳包,这里的目标服务器可以是分布式数据库代理DS,为与目标全局事务对应的事务协调者。目标数据库可以根据接收到的心跳包更新目标数据库与目标服务器之间的心跳信息,即,目标心跳信息。For the target global transaction, the target server may periodically send heartbeat packets to the target database, where the target server may be a distributed database agent DS, which is the transaction coordinator corresponding to the target global transaction. The target database can update the heartbeat information between the target database and the target server according to the received heartbeat packet, that is, the target heartbeat information.
按照目标拓扑信息,目标数据库可以检测目标心跳信息。如果检测到在一段时间内目标心跳信息未发生更新,表明在一段时间内未收到目标服务器发送的心跳包,目标服务器发生故障,目标数据库可以确定目标全局事务在提交之前发生异常。According to the target topology information, the target database can detect the target heartbeat information. If it is detected that the target heartbeat information has not been updated within a period of time, it indicates that the heartbeat packet sent by the target server has not been received within a period of time, and the target server has failed. The target database can determine that the target global transaction is abnormal before committing.
为了保证异常确定的准确性,目标服务器在目标全局事务在提交之后可以向目标数据库发送提交完成消息,以指示目标数据库目标全局事务已完成提交。对应地,在检测到目标心跳信息停止更新、且未收到目标服务器发送的提交完成消息的情况下,确定出目标全局事务在提交之前发生异常,提交完成消息用于指示目标全局事务已完成提交。In order to ensure the accuracy of the exception determination, the target server may send a commit completion message to the target database after the target global transaction is committed to indicate that the target global transaction of the target database has completed the commit. Correspondingly, when it is detected that the target heartbeat information stops updating and the commit completion message sent by the target server is not received, it is determined that the target global transaction is abnormal before the commit, and the commit completion message is used to indicate that the target global transaction has been submitted. .
通过本申请实施例,根据心跳信息确定与全局事务对应的服务器是否发生故障,可以保证全局事务异常确定的准确性,同时,可以减少对网络资源的占用(心跳包的数据量较少)。Through the embodiment of the present application, it is determined whether the server corresponding to the global transaction is faulty according to the heartbeat information, which can ensure the accuracy of the abnormal determination of the global transaction, and at the same time, can reduce the occupation of network resources (the data volume of the heartbeat packet is small).
在一实施方式中,在按照目标存储对象中记录的拓扑信息,通过目标数据库对各个全局事务分别进行悬挂事务巡检之后,上述方法还包括:In one embodiment, after performing the suspended transaction inspection on each global transaction through the target database according to the topology information recorded in the target storage object, the above method further includes:
S41,在将目标全局事务确定为悬挂事务的情况下,获取与多个目标分支事务中的各个目标分支事务对应的第二状态信息;S41, in the case where the target global transaction is determined to be a suspended transaction, obtain second state information corresponding to each target branch transaction in the multiple target branch transactions;
S42,按照与各个目标分支事务对应的第二状态信息控制对各个分支事务执行目标事务操作,其中,目标事务操作包括以下之一:事务提交,事务回滚。S42 , executing the target transaction operation on each branch transaction according to the second state information corresponding to each target branch transaction, wherein the target transaction operation includes one of the following: transaction commit and transaction rollback.
如果注册到目标数据库的全局事务成为悬挂事务,那么,目标数据库可以接管该悬挂事务,可根据悬挂事务对应的所有分支事务的状态推动悬挂事务进行提交或回滚。在一实施方式中,若全局事务对应的所有分支事务的状态为预提交/提交中/已提交的状态,可推动全局事务继续完成提交后续流程;否则推动全局事务对应的所有分支事务进行回滚操作。If the global transaction registered with the target database becomes a suspended transaction, the target database can take over the suspended transaction, and can push the suspended transaction to commit or roll back according to the status of all branch transactions corresponding to the suspended transaction. In one embodiment, if the state of all branch transactions corresponding to the global transaction is pre-submitted/committed/submitted, the global transaction can be pushed to continue to complete the subsequent process of submitting; otherwise, all branch transactions corresponding to the global transaction are pushed to roll back. operate.
对于目标全局事务,如果将目标全局事务确定为悬挂事务,目标数据库可以获取多个目标分支事务中的各个目标分支事务对应的第二状态信息,也就是,该目标数据库可以与各个目标分支事务对应的数据库实例进行交互,确定各个目标分支事务当前的处理状态,例如,预提交成功,预提交失败,提交成功,提交失败等等。For the target global transaction, if the target global transaction is determined to be a suspended transaction, the target database can obtain the second state information corresponding to each target branch transaction among the multiple target branch transactions, that is, the target database can correspond to each target branch transaction The database instance interacts with each other to determine the current processing status of each target branch transaction, for example, pre-commit success, pre-commit failure, commit success, commit failure, and so on.
按照各个目标分支事务对应的第二状态信息,目标数据库可以控制对各个分支事务执行后续的事务操作,比如,事务提交,事务回滚。According to the second state information corresponding to each target branch transaction, the target database can control to perform subsequent transaction operations on each branch transaction, such as transaction commit and transaction rollback.
通过本申请实施例,由各个全局事务注册到的目标数据库接管悬挂事务的提交任务,可以提高事务处理的效率。Through the embodiments of the present application, the target database to which each global transaction is registered takes over the submission task of the suspended transaction, which can improve the efficiency of transaction processing.
在一实施方式中,按照与各个目标分支事务对应的第二状态信息控制对各个分支事务执行目标事务操作包括:In one embodiment, controlling the execution of the target transaction operation on each branch transaction according to the second state information corresponding to each target branch transaction includes:
S51,在根据与各个目标分支事务对应的第二状态信息确定出各个目标分支事务均已预提交成功的情况下,控制对各个目标分支事务进行事务提交;S51, when it is determined that each target branch transaction has been pre-committed successfully according to the second state information corresponding to each target branch transaction, control the transaction submission of each target branch transaction;
S52,在根据与各个目标分支事务对应的第二状态信息确定出存在预提交失败的分支事务的情况下,控制对各个目标分支事务进行事务回滚。S52, if it is determined according to the second state information corresponding to each target branch transaction that there is a branch transaction that fails to pre-commit, control to perform transaction rollback on each target branch transaction.
在接管目标全局事务的提交任务时,不管目标服务器是否从异常中恢复,目标数据库均可以控制推动悬挂事务的向前执行,可以在保证全局事务的ACID属性的同时,保证事务处理的及时性。When taking over the submission task of the target global transaction, regardless of whether the target server recovers from the exception, the target database can control the forward execution of the suspended transaction, which can ensure the timeliness of transaction processing while ensuring the ACID property of the global transaction.
如果根据与各个目标分支事务对应的第二状态信息确定出各个目标分支事 务均已预提交成功,那么,目标数据库可以控制对各个目标分支事务进行事务提交,比如,向各个目标分支事务对应的数据库节点发送提交指示,指示正式提交各个分支事务。If it is determined according to the second state information corresponding to each target branch transaction that each target branch transaction has been pre-committed successfully, then the target database can control the transaction submission of each target branch transaction, for example, to the database corresponding to each target branch transaction Nodes send commit instructions, instructing to formally commit each branch transaction.
如果根据与各个目标分支事务对应的第二状态信息确定出存在预提交失败的分支事务,目标数据库可以控制对各个目标分支事务进行事务回滚,比如,向各个目标分支事务对应的数据库实例发送回滚指示,指示各个目标分支事务进行回滚。If it is determined according to the second state information corresponding to each target branch transaction that there is a branch transaction that fails to pre-commit, the target database can control the transaction rollback of each target branch transaction, for example, send back to the database instance corresponding to each target branch transaction. Rollback instructions, instructing each target branch transaction to roll back.
通过本申请实施例,由数据库实例按照各个分支事务的处理状态控制悬挂事务对应的分支事务进行提交或回滚,可以保证事务处理的及时性。Through the embodiment of the present application, the database instance controls the branch transaction corresponding to the suspended transaction to commit or roll back according to the processing state of each branch transaction, which can ensure the timeliness of transaction processing.
在一实施方式中,在按照目标存储对象中记录的拓扑信息,通过目标数据库对各个全局事务分别进行悬挂事务巡检之后,上述方法还包括:In one embodiment, after performing the suspended transaction inspection on each global transaction through the target database according to the topology information recorded in the target storage object, the above method further includes:
S61,在目标全局事务提交成功的情况下,将目标拓扑信息从目标存储对象中删除。S61, in the case that the target global transaction is successfully submitted, delete the target topology information from the target storage object.
为了保证数据库实例中存储空间的合理利用,对于已成功提交的全局事务,数据库实例可以将其对应的拓扑信息从目标存储对象中删除。如果目标全局事务提交成功,目标数据库可以将目标拓扑信息从目标存储对象中删除。删除拓扑信息可以是在目标全局事务提交成功时触发的,也可以是后台周期性清理目标存储对象中已失效拓扑信息的进程触发的,本申请实施例中对此不作限定。In order to ensure the reasonable utilization of the storage space in the database instance, for the global transaction that has been successfully submitted, the database instance can delete its corresponding topology information from the target storage object. If the target global transaction commits successfully, the target database can delete the target topology information from the target storage object. The deletion of topology information may be triggered when the target global transaction is successfully submitted, or may be triggered by a background process of periodically clearing expired topology information in the target storage object, which is not limited in this embodiment of the present application.
删除目标拓扑信息的时机可以有多种,可以针对目标服务器是否发生异常分别配置删除的触发条件。There are various timings for deleting the target topology information, and the trigger conditions for deletion can be configured according to whether the target server is abnormal or not.
如果目标服务器未发生异常,也就是,目标数据库未接管该目标全局事务,在目标全局事务提交成功时,目标服务器可以向目标数据库发送删除消息,以指示目标数据库删除目标拓扑信息,按照删除消息,目标数据库将目标存储对象中的目标拓扑信息删除;或者,也可以由目标数据库在全局事务对应的所有分支事务提交成功之后,将目标存储对象中的目标拓扑信息删除。If no exception occurs on the target server, that is, the target database has not taken over the target global transaction, when the target global transaction is successfully submitted, the target server can send a delete message to the target database to instruct the target database to delete the target topology information. According to the delete message, The target database deletes the target topology information in the target storage object; or, the target database can also delete the target topology information in the target storage object after all branch transactions corresponding to the global transaction are successfully submitted.
如果目标服务器发生异常,也就是,目标数据库接管可该目标全局事务,那么,在目标全局事务提交成功时,目标数据库将目标存储对象中的目标拓扑信息删除;或者,在指示其他数据库实例提交对应的目标分支事务之后,目标数据库将目标存储对象中的目标拓扑信息删除,其他数据库实例为处理多个目标分支事务的多个数据库实例中除了目标数据库以外的数据库实例。If an exception occurs on the target server, that is, the target database takes over the target global transaction, then, when the target global transaction is successfully submitted, the target database deletes the target topology information in the target storage object; or, after instructing other database instances to submit the corresponding After the target branch transaction, the target database deletes the target topology information in the target storage object, and the other database instances are database instances other than the target database among the multiple database instances that process multiple target branch transactions.
通过本申请实施例,在全局事务提交成功之后删除该全局事务注册到的数据库实例中所保存的、与该全局事务对应的拓扑信息,可以减少对数据库实例存储空间的占用,提高存储空间利用的合理性。Through the embodiment of the present application, after the global transaction is successfully submitted, the topology information corresponding to the global transaction stored in the database instance to which the global transaction is registered is deleted, which can reduce the occupation of the storage space of the database instance and improve the utilization of storage space. rationality.
下面结合示例对本申请实施例中的悬挂事务巡检方法进行解释说明。在本示 例中,存储对象为关系表。The method for inspecting a suspension transaction in the embodiment of the present application will be explained below with reference to an example. In this example, the storage object is a relational table.
本示例中的悬挂事务巡检方法可以应用到如图3所示的网络架构中,该网络架构包括:应用端,分布式数据库代理、以及数据库实例,其中,The suspended transaction inspection method in this example can be applied to the network architecture shown in FIG. 3 , the network architecture includes: an application end, a distributed database agent, and a database instance, wherein,
应用端,用于进行事务提交;The application side is used for transaction submission;
分布式数据库代理,可以作为事务的协调者,用于接收应用端发起的全局事务,并将分支事务发送给对应的数据库实例;Distributed database agent, which can be used as the coordinator of the transaction to receive the global transaction initiated by the application and send the branch transaction to the corresponding database instance;
数据库实例,可以作为事务的参与者,用于处理对应的分支事务。The database instance can be used as a participant in the transaction to process the corresponding branch transaction.
本示例提供了一种分布式数据库悬挂事务巡检优化方案,采用全局事务和分支事务状态自管理的机制:将全局事务和分支事务分散注册到数据库实例中,每个数据库实例中新增一张系统表,用于记录全局事务和分支事务的拓扑关系和状态信息;对每个全局事务和分支事务增加心跳信息,正常情况下全局事务和分支事务的心跳信息会实时更新,异常情况下全局事务或分支事务的心跳信息会停止更新;由数据库实例中的悬挂事务巡检模块自动检测心跳异常的全局事务,并推动全局事务对应分支事务的提交/回滚。This example provides a distributed database suspension transaction inspection optimization solution, which adopts the mechanism of global transaction and branch transaction status self-management: the global transaction and branch transaction are distributed in the database instance, and a new one is added to each database instance. The system table is used to record the topological relationship and status information of global transactions and branch transactions; heartbeat information is added to each global transaction and branch transaction. Under normal circumstances, the heartbeat information of global transactions and branch transactions will be updated in real time. Or the heartbeat information of the branch transaction will stop updating; the suspended transaction inspection module in the database instance automatically detects the global transaction with abnormal heartbeat, and promotes the commit/rollback of the branch transaction corresponding to the global transaction.
结合图3和图4所示,本示例中的悬挂事务巡检方法的流程可以包括以下步骤:With reference to Figures 3 and 4, the flow of the method for inspecting suspended transactions in this example may include the following steps:
步骤S402,应用端1连接分布式数据库代理1,发起全局事务1。Step S402, the application terminal 1 connects to the distributed database agent 1, and initiates a global transaction 1.
步骤S404,分布式数据库代理1将全局事务1对应的分支事务1和分支事务2分别发送到数据库实例1和数据库实例2。Step S404, the distributed database agent 1 sends the branch transaction 1 and the branch transaction 2 corresponding to the global transaction 1 to the database instance 1 and the database instance 2, respectively.
分布式数据库代理1可以确定与全局事务1对应的分支事务1和分支事务2,将分支事务1发送给数据库实例1,将分支事务2发送给数据库实例2。The distributed database agent 1 can determine the branch transaction 1 and the branch transaction 2 corresponding to the global transaction 1, send the branch transaction 1 to the database instance 1, and send the branch transaction 2 to the database instance 2.
步骤S406,分布式数据库代理1将全局事务1及其分支事务1和分支事务2的拓扑信息记录到数据库实例1的系统表中,并实时更新数据库实例1记录的全局事务1的心跳信息。Step S406, the distributed database agent 1 records the topology information of the global transaction 1 and its branch transaction 1 and branch transaction 2 in the system table of the database instance 1, and updates the heartbeat information of the global transaction 1 recorded by the database instance 1 in real time.
示例性地,数据库实例1的系统表所记录的拓扑信息以及心跳信息可以包括:Exemplarily, the topology information and heartbeat information recorded in the system table of database instance 1 may include:
Figure PCTCN2022072050-appb-000001
Figure PCTCN2022072050-appb-000001
分布式数据库代理1还可以确定全局事务1及其分支事务1和分支事务2的 拓扑信息,将确定的拓扑信息发送给数据库实例1,以记录到数据库实例1的系统表中,同时通过向数据库实例1发送心跳包来更新数据库实例1记录的全局事务1的心跳信息。The distributed database agent 1 can also determine the topology information of the global transaction 1 and its branch transaction 1 and branch transaction 2, and send the determined topology information to the database instance 1 to record it in the system table of the database instance 1. Instance 1 sends a heartbeat packet to update the heartbeat information of global transaction 1 recorded by database instance 1.
步骤S408,数据库实例1中的悬挂事务巡检模块扫描系统表,发现全局事务1心跳异常,接管全局事务1,并根据分支事务1和分支事务2的状态进行事务的继续提交/回滚。Step S408, the suspended transaction inspection module in the database instance 1 scans the system table, finds that the global transaction 1 has an abnormal heartbeat, takes over the global transaction 1, and continues to commit/roll back the transaction according to the status of the branch transaction 1 and the branch transaction 2.
如果分布式数据库代理1发生故障,此时全局事务1还未完成提交,成为悬挂事务。数据库实例1中的悬挂事务巡检模块扫描系统表,发现全局事务1心跳异常,那么,数据库实例1接管全局事务1,确定分支事务1和分支事务2的状态,分支事务的状态可以包括但不限于以下至少之一:INIT(初始化),PREPARED(预提交),COMMIT(提交)。根据分支事务1和分支事务2的状态,数据库实例1可以进行事务的继续提交或回滚。If the distributed database agent 1 fails, the global transaction 1 has not yet completed the commit, and becomes a suspended transaction. The suspended transaction inspection module in database instance 1 scans the system table and finds that the heartbeat of global transaction 1 is abnormal. Then, database instance 1 takes over global transaction 1 and determines the status of branch transaction 1 and branch transaction 2. The status of branch transaction can include but not Restricted to at least one of the following: INIT (initialization), PREPARED (pre-commit), COMMIT (commit). According to the status of branch transaction 1 and branch transaction 2, database instance 1 can continue to commit or roll back the transaction.
比如,分支事务1和分支事务2处于INIT状态,控制两者进行回滚;分支事务1和分支事务2均已预提交成功,则控制分支事务1和分支事务2进行提交;如果分支事务1和分支事务2部分提交成功,部分还未提交成功,则继续推进提交。如果在某一个阶段有分支事务未成功处理,则控制分支事务1和分支事务2进行回滚。For example, if branch transaction 1 and branch transaction 2 are in the INIT state, they are controlled to roll back; both branch transaction 1 and branch transaction 2 have been pre-committed successfully, then branch transaction 1 and branch transaction 2 are controlled to commit; if branch transaction 1 and branch transaction 2 are both pre-committed successfully If the branch transaction 2 is partially submitted successfully, and part of it has not been submitted successfully, the submission will continue. If a branch transaction is not successfully processed at a certain stage, the control branch transaction 1 and branch transaction 2 are rolled back.
结合图3和图5所示,本示例中的悬挂事务巡检方法的流程也可以包括以下步骤:With reference to FIG. 3 and FIG. 5 , the process of the suspended transaction inspection method in this example may also include the following steps:
步骤S502,应用端2连接分布式数据库代理2,发起全局事务2。Step S502 , the application terminal 2 connects to the distributed database agent 2 and initiates a global transaction 2 .
步骤S504,分布式数据库代理2将全局事务2对应的分支事务3和分支事务4分别发送到数据库实例2和数据库实例3。Step S504, the distributed database agent 2 sends the branch transaction 3 and the branch transaction 4 corresponding to the global transaction 2 to the database instance 2 and the database instance 3, respectively.
分布式数据库代理2可以确定与全局事务2对应的分支事务3和分支事务4,将分支事务3发送给数据库实例2,将分支事务4发送给数据库实例3。The distributed database agent 2 can determine the branch transaction 3 and the branch transaction 4 corresponding to the global transaction 2, send the branch transaction 3 to the database instance 2, and send the branch transaction 4 to the database instance 3.
步骤S506,分布式数据库代理2将全局事务2及其分支事务3和分支事务4的拓扑信息记录到数据库实例2的系统表中,并实时更新数据库实例2记录的全局事务2的心跳信息。Step S506, the distributed database agent 2 records the topology information of the global transaction 2 and its branch transaction 3 and branch transaction 4 in the system table of the database instance 2, and updates the heartbeat information of the global transaction 2 recorded by the database instance 2 in real time.
分布式数据库代理2还可以确定全局事务2及其分支事务3和分支事务4的拓扑信息,将确定的拓扑信息发送给数据库实例2,以记录到数据库实例2的系统表中,同时通过向数据库实例2发送心跳包来更新数据库实例2记录的全局事务2的心跳信息。The distributed database agent 2 can also determine the topology information of the global transaction 2 and its branch transaction 3 and branch transaction 4, and send the determined topology information to the database instance 2 to record it in the system table of the database instance 2. Instance 2 sends a heartbeat packet to update the heartbeat information of global transaction 2 recorded by database instance 2.
示例性地,数据库实例2的系统表所记录的拓扑信息以及心跳信息可以包括:Exemplarily, the topology information and heartbeat information recorded in the system table of the database instance 2 may include:
Figure PCTCN2022072050-appb-000002
Figure PCTCN2022072050-appb-000002
Figure PCTCN2022072050-appb-000003
Figure PCTCN2022072050-appb-000003
步骤S508,数据库实例2中的悬挂事务巡检模块扫描系统表,发现全局事务2心跳异常,接管全局事务2,并根据分支事务3和分支事务4的状态进行事务的继续提交/回滚。Step S508, the suspended transaction inspection module in the database instance 2 scans the system table, finds that the global transaction 2 has an abnormal heartbeat, takes over the global transaction 2, and continues to commit/roll back the transaction according to the status of the branch transaction 3 and the branch transaction 4.
如果分布式数据库代理2发生故障,此时全局事务2还未完成提交,成为悬挂事务。数据库实例2中的悬挂事务巡检模块扫描系统表,发现全局事务2心跳异常,那么,数据库实例2接管全局事务2,确定分支事务3和分支事务4的状态,分支事务的状态可以包括但不限于以下至少之一:INIT,PREPARED,COMMIT。根据分支事务3和分支事务4的状态,数据库实例2可以进行事务的继续提交或回滚。If the distributed database agent 2 fails, at this time, the global transaction 2 has not completed the commit, and becomes a suspended transaction. The suspended transaction inspection module in database instance 2 scans the system table and finds that the heartbeat of global transaction 2 is abnormal. Then, database instance 2 takes over global transaction 2 and determines the status of branch transaction 3 and branch transaction 4. The status of branch transaction can include but not Limited to at least one of the following: INIT, PREPARED, COMMIT. According to the status of branch transaction 3 and branch transaction 4, database instance 2 can continue to commit or roll back the transaction.
比如,分支事务3和分支事务4处于INIT状态,控制两者进行回滚;分支事务3和分支事务4均已预提交成功,则控制分支事务3和分支事务4进行提交;如果分支事务3和分支事务4部分提交成功,部分还未提交成功,则继续推进提交。如果在某一个阶段有分支事务未成功处理,则控制分支事务3和分支事务4进行回滚。For example, branch transaction 3 and branch transaction 4 are in the INIT state, and both are controlled to be rolled back; both branch transaction 3 and branch transaction 4 have been pre-committed successfully, then branch transaction 3 and branch transaction 4 are controlled to commit; if branch transaction 3 and branch transaction 4 are both pre-committed successfully Part 4 of the branch transaction is successfully submitted, and part of it has not been submitted successfully, then continue to advance the submission. If a branch transaction is not successfully processed at a certain stage, the control branch transaction 3 and branch transaction 4 are rolled back.
需要说明的是,数据库实例3的系统表也可以记录有部分全局事务及其分支事务的拓扑信息、以及这些全局事务的心跳信息。示例性地,数据库实例3的系统表所记录的拓扑信息以及心跳信息可以是:It should be noted that the system table of database instance 3 may also record topology information of some global transactions and their branch transactions, and heartbeat information of these global transactions. Exemplarily, the topology information and heartbeat information recorded in the system table of database instance 3 may be:
Figure PCTCN2022072050-appb-000004
Figure PCTCN2022072050-appb-000004
由上述可以看出,不同的全局事务及其对应的分支事务可以注册到处理该全局事务的一个分支事务的数据库实例中,每个数据库实例可以注册多个全局事务及其对应的分支事务,同时,数据库实例内部可以自主完成悬挂事务的巡检和接管处理。既可以保留集中式的事务管理的优点,即,保证全局事务的ACID属性,同时避免由于全局事务和分支事务都需要注册到全局事务管理器中导致的集中式的事务管理成为整集群的性能瓶颈的问题。It can be seen from the above that different global transactions and their corresponding branch transactions can be registered in the database instance of a branch transaction processing the global transaction, and each database instance can register multiple global transactions and their corresponding branch transactions, and at the same time , the database instance can independently complete the inspection and takeover of suspended transactions. It can not only retain the advantages of centralized transaction management, that is, ensure the ACID properties of global transactions, but also avoid centralized transaction management caused by the need to register both global transactions and branch transactions in the global transaction manager. The performance bottleneck of the entire cluster The problem.
通过本示例,通过分布式的全局事务和分布式事务的注册模式,可以减少事务巡检的压力;通过分布式并行悬挂事务巡检,可以提高悬挂事务巡检的效率;通过分布式并行悬挂事务并行处理,也可以提高悬挂事务的处理效率。Through this example, through the distributed global transaction and distributed transaction registration mode, the pressure of transaction inspection can be reduced; through distributed parallel suspended transaction inspection, the efficiency of suspended transaction inspection can be improved; through distributed parallel suspended transaction inspection, the efficiency of suspended transaction inspection can be improved; Parallel processing can also improve the processing efficiency of suspended transactions.
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请并不受所描述的动作顺序的限制,因为依据本申请,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例均属于优选实施例,所涉及的动作和模块并不一定是本申请所必须的。It should be noted that, for the sake of simple description, the foregoing method embodiments are all expressed as a series of action combinations, but those skilled in the art should know that the present application is not limited by the described action sequence. Because in accordance with the present application, certain steps may be performed in other orders or concurrently. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present application.
通过以上的实施方式的描述,本领域的技术人员可以清楚地了解到根据上述实施例的方法可借助软件加必需的通用硬件平台的方式来实现,当然也可以通过硬件,但很多情况下前者是更佳的实施方式。基于这样的理解,本申请的技术方案本质上或者说对相关技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质(如ROM(Read-Only Memory,只读存储器)/RAM(Random Access Memory,随机存取存储器)、磁碟、光盘)中,包括若干指令用以使得一台终端设备(可以是手机,计算机,服务器,或者网络设备等)执行本申请各个实施例所述的方法。From the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is better implementation. Based on this understanding, the technical solution of the present application can be embodied in the form of a software product in essence or the part that contributes to the related technology, and the computer software product is stored in a storage medium (such as ROM (Read-Only Memory, only read memory)/RAM (Random Access Memory), magnetic disk, optical disk), including several instructions to make a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute this application The methods described in the various examples.
根据本申请实施例的另一个方面,还提供了一种用于实施上述悬挂事务巡检方法的悬挂事务巡检装置。图6是根据本申请实施例的一种悬挂事务巡检装置的结构框图,如图6所示,该装置可以包括:According to another aspect of the embodiments of the present application, there is also provided a suspension transaction inspection device for implementing the above suspension transaction inspection method. Fig. 6 is a structural block diagram of an apparatus for inspecting suspended affairs according to an embodiment of the present application. As shown in Fig. 6 , the apparatus may include:
(1)接收单元602,设置为通过目标数据库接收目标拓扑信息,其中,目标拓扑信息是目标全局事务和与目标全局事务对应的多个目标分支事务之间的拓扑信息;(1) a receiving unit 602, configured to receive target topology information through the target database, wherein the target topology information is the topology information between the target global transaction and a plurality of target branch transactions corresponding to the target global transaction;
(2)保存单元604,与接收单元602相连,设置为将目标拓扑信息保存到目标存储对象中,其中,目标存储对象用于记录多个全局事务中的每个全局事务和与每个全局事务对应的多个分支事务之间的拓扑信息,目标数据库用于处理与每个全局事务对应的多个分支事务中的一个分支事务;(2) The saving unit 604 is connected to the receiving unit 602, and is configured to save the target topology information into the target storage object, wherein the target storage object is used to record each global transaction in the multiple global transactions and the relationship with each global transaction. The topology information between the corresponding multiple branch transactions, and the target database is used to process one branch transaction among the multiple branch transactions corresponding to each global transaction;
(3)巡检单元606,与保存单元604相连,设置为按照目标存储对象中记录的拓扑信息,通过目标数据库对各个全局事务分别进行悬挂事务巡检。(3) The inspection unit 606 is connected to the storage unit 604, and is configured to perform an inspection of suspended transactions for each global transaction through the target database according to the topology information recorded in the target storage object.
需要说明的是,该实施例中的接收单元602可以设置为执行上述步骤S202,该实施例中的保存单元604可以设置为执行上述步骤S204,该实施例中的巡检单元606可以设置为执行上述步骤S206。It should be noted that the receiving unit 602 in this embodiment may be configured to execute the above step S202, the saving unit 604 in this embodiment may be configured to execute the above step S204, and the inspection unit 606 in this embodiment may be configured to execute the above step S204. The above step S206.
通过上述单元,通过目标数据库接收目标拓扑信息,其中,所述目标拓扑信息是目标全局事务和与所述目标全局事务对应的多个目标分支事务之间的拓扑信息;将所述目标拓扑信息保存到目标存储对象中,其中,所述目标存储对象用于记录多个全局事务中的每个全局事务和与所述每个全局事务对应的多个分支事务之间的拓扑信息,所述目标数据库用于处理与所述每个全局事务对应的所述多个分支事务中的一个分支事务;按照所述目标存储对象中记录的拓扑信息,通 过所述目标数据库对所述各个全局事务分别进行悬挂事务巡检,解决了相关技术中的悬挂事务控制方式存在由于管理器所管理的全局事务和分支事务的数量较多导致的悬挂事务处理效率低的问题,减少了管理器的处理压力,提高了悬挂事务处理效率。Through the above unit, the target topology information is received through the target database, wherein the target topology information is the topology information between the target global transaction and a plurality of target branch transactions corresponding to the target global transaction; the target topology information is saved into a target storage object, wherein the target storage object is used to record topology information between each global transaction in multiple global transactions and multiple branch transactions corresponding to each global transaction, and the target database for processing one branch transaction in the plurality of branch transactions corresponding to each global transaction; according to the topology information recorded in the target storage object, the global transactions are respectively suspended through the target database The transaction inspection solves the problem of low efficiency of suspended transaction processing caused by the large number of global transactions and branch transactions managed by the manager in the suspension transaction control method in the related art, reduces the processing pressure of the manager, and improves the Hang transaction efficiency.
在一实施方式中,接收单元602包括:In one embodiment, the receiving unit 602 includes:
接收模块,设置为通过目标数据库接收目标服务器发送的目标事务消息,其中,目标服务器为目标全局事务的事务协调者,目标事务消息中携带有目标拓扑信息和与目标数据库对应的待处理分支事务信息,待处理分支事务信息用于指示多个目标分支事务中,待目标数据库处理的分支事务。The receiving module is configured to receive the target transaction message sent by the target server through the target database, wherein the target server is the transaction coordinator of the target global transaction, and the target transaction message carries the target topology information and the pending branch transaction information corresponding to the target database. , the branch transaction information to be processed is used to indicate the branch transaction to be processed by the target database among the multiple target branch transactions.
在一实施方式中,巡检单元606包括:In one embodiment, the inspection unit 606 includes:
第一确定模块,设置为按照目标存储对象中记录的目标拓扑信息,通过目标数据库确定与目标全局事务对应的第一状态信息;The first determining module is configured to determine the first state information corresponding to the target global transaction through the target database according to the target topology information recorded in the target storage object;
第二确定模块,设置为在根据第一状态信息确定出目标全局事务在提交之前发生异常的情况下,将目标全局事务确定为悬挂事务。The second determining module is configured to determine the target global transaction as a suspended transaction when it is determined according to the first state information that the target global transaction is abnormal before committing.
在一实施方式中,第一确定模块包括:确定子模块,上述装置还包括:确定单元,其中,In one embodiment, the first determination module includes: a determination sub-module, and the above-mentioned apparatus further includes: a determination unit, wherein:
确定子模块,设置为按照目标拓扑信息,通过目标数据库检测目标心跳信息,其中,第一状态信息包含目标心跳信息,目标心跳信息为目标数据库与目标服务器之间的心跳信息,目标服务器为与目标全局事务对应的事务协调者;The determination submodule is set to detect the target heartbeat information through the target database according to the target topology information, wherein the first state information includes the target heartbeat information, the target heartbeat information is the heartbeat information between the target database and the target server, and the target server is the heartbeat information between the target database and the target server. The transaction coordinator corresponding to the global transaction;
确定单元,设置为在按照目标拓扑信息,通过目标数据库检测目标心跳信息之后,在检测到目标心跳信息停止更新的情况下,确定出目标全局事务在提交之前发生异常。The determining unit is configured to, after detecting the target heartbeat information through the target database according to the target topology information, when it is detected that the target heartbeat information stops updating, determine that the target global transaction is abnormal before committing.
在一实施方式中,上述装置还包括:In one embodiment, the above-mentioned device further includes:
获取单元,设置为在按照目标存储对象中记录的拓扑信息,通过目标数据库对各个全局事务分别进行悬挂事务巡检之后,在将目标全局事务确定为悬挂事务的情况下,获取与多个目标分支事务中的各个目标分支事务对应的第二状态信息;The acquiring unit is set to, according to the topology information recorded in the target storage object, after the suspending transaction inspection is performed on each global transaction through the target database, and the target global transaction is determined as a suspending transaction, the target global transaction is determined as a suspended transaction, and multiple target branches are obtained. second state information corresponding to each target branch transaction in the transaction;
控制单元,设置为按照与各个目标分支事务对应的第二状态信息控制对各个分支事务执行目标事务操作,其中,目标事务操作包括以下之一:事务提交,事务回滚。The control unit is configured to control the execution of the target transaction operation on each branch transaction according to the second state information corresponding to each target branch transaction, wherein the target transaction operation includes one of the following: transaction commit and transaction rollback.
在一实施方式中,控制单元包括:In one embodiment, the control unit includes:
第一控制模块,设置为在根据与各个目标分支事务对应的第二状态信息确定出各个目标分支事务均已预提交成功的情况下,控制对各个目标分支事务进行事 务提交;The first control module is configured to control the transaction submission to each target branch transaction when it is determined that each target branch transaction has been pre-submitted successfully according to the second state information corresponding to each target branch transaction;
第二控制模块,设置为在根据与各个目标分支事务对应的第二状态信息确定出存在预提交失败的分支事务的情况下,控制对各个目标分支事务进行事务回滚。The second control module is configured to control the transaction rollback of each target branch transaction when it is determined according to the second state information corresponding to each target branch transaction that there is a branch transaction that fails to pre-commit.
在一实施方式中,上述装置还包括:In one embodiment, the above-mentioned device further includes:
删除单元,设置为在按照目标存储对象中记录的拓扑信息,通过目标数据库对各个全局事务分别进行悬挂事务巡检之后,在目标全局事务提交成功的情况下,将目标拓扑信息从目标存储对象中删除。The deletion unit is set to perform a suspended transaction inspection of each global transaction through the target database according to the topology information recorded in the target storage object, and when the target global transaction is successfully submitted, remove the target topology information from the target storage object. delete.
此处需要说明的是,上述模块与对应的步骤所实现的示例和应用场景相同,但不限于上述实施例所公开的内容。需要说明的是,上述模块作为装置的一部分可以运行在如图1所示的硬件环境中,可以通过软件实现,也可以通过硬件实现,其中,硬件环境包括网络环境。It should be noted here that the examples and application scenarios implemented by the foregoing modules and corresponding steps are the same, but are not limited to the contents disclosed in the foregoing embodiments. It should be noted that, as a part of the device, the above modules may run in the hardware environment as shown in FIG. 1 , and may be implemented by software or hardware, wherein the hardware environment includes a network environment.
根据本申请实施例的又一个方面,还提供了一种用于实施上述悬挂事务巡检方法的电子设备,该电子设备可以是服务器、终端、或者其组合。According to yet another aspect of the embodiments of the present application, there is also provided an electronic device for implementing the above method for inspecting suspended transactions, where the electronic device may be a server, a terminal, or a combination thereof.
图7是根据本申请实施例的一种电子设备的结构框图,如图7所示,包括处理器702、通信接口704、存储器706和通信总线708,其中,处理器702、通信接口704和存储器706通过通信总线708完成相互间的通信,其中,FIG. 7 is a structural block diagram of an electronic device according to an embodiment of the present application. As shown in FIG. 7 , it includes a processor 702 , a communication interface 704 , a memory 706 and a communication bus 708 , wherein the processor 702 , the communication interface 704 and the memory 706 communicates with each other through the communication bus 708, wherein,
存储器706,用于存储计算机程序; memory 706 for storing computer programs;
处理器702,用于执行存储器706上所存放的计算机程序时,实现如下步骤:When the processor 702 is used to execute the computer program stored in the memory 706, the following steps are implemented:
S1,通过目标数据库接收目标拓扑信息,其中,目标拓扑信息是目标全局事务和与目标全局事务对应的多个目标分支事务之间的拓扑信息;S1, receiving target topology information through the target database, wherein the target topology information is the topology information between the target global transaction and multiple target branch transactions corresponding to the target global transaction;
S2,将目标拓扑信息保存到目标存储对象中,其中,目标存储对象用于记录多个全局事务中的每个全局事务和与每个全局事务对应的多个分支事务之间的拓扑信息,目标数据库用于处理与每个全局事务对应的多个分支事务中的一个分支事务;S2, save the target topology information into the target storage object, where the target storage object is used to record the topology information between each global transaction in the multiple global transactions and the multiple branch transactions corresponding to each global transaction, and the target The database is used to process one of the branch transactions corresponding to each global transaction;
S3,按照目标存储对象中记录的拓扑信息,通过目标数据库对各个全局事务分别进行悬挂事务巡检。S3, according to the topology information recorded in the target storage object, through the target database, each global transaction is respectively inspected for suspended transactions.
在一实施方式中,在本申请实施例中,上述的通信总线可以是PCI(Peripheral Component Interconnect,外设部件互连标准)总线、或EISA(Extended Industry Standard Architecture,扩展工业标准结构)总线等。该通信总线可以分为地址总线、数据总线、控制总线等。为便于表示,图7中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。通信接口用于上述 电子设备与其他设备之间的通信。In one embodiment, in the embodiment of the present application, the above-mentioned communication bus may be a PCI (Peripheral Component Interconnect, Peripheral Component Interconnect Standard) bus, or an EISA (Extended Industry Standard Architecture, Extended Industry Standard Architecture) bus or the like. The communication bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of presentation, only one thick line is used in FIG. 7, but it does not mean that there is only one bus or one type of bus. The communication interface is used for communication between the above electronic device and other devices.
存储器可以包括RAM,也可以包括非易失性存储器(non-volatile memory),例如,至少一个磁盘存储器。在一实施方式中,存储器还可以是至少一个位于远离前述处理器的存储装置。The memory may include RAM and may also include non-volatile memory, such as at least one disk memory. In one embodiment, the memory may also be at least one storage device located remotely from the aforementioned processor.
作为一种示例,上述存储器706中可以但不限于包括上述悬挂事务巡检装置中的接收单元602、保存单元604以及巡检单元606。此外,还可以包括但不限于上述悬挂事务巡检装置中的其他模块单元,本示例中不再赘述。As an example, the above-mentioned memory 706 may include, but is not limited to, the receiving unit 602 , the saving unit 604 and the inspection unit 606 in the above-mentioned suspended transaction inspection device. In addition, it may also include, but is not limited to, other module units in the above-mentioned suspended transaction inspection device, which will not be repeated in this example.
上述处理器可以是通用处理器,可以包含但不限于:CPU(Central Processing Unit,中央处理器)、NP(Network Processor,网络处理器)等;还可以是DSP(Digital Signal Processing,数字信号处理器)、ASIC(Application Specific Integrated Circuit,专用集成电路)、FPGA(Field-Programmable Gate Array,现场可编程门阵列)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。The above-mentioned processor can be a general-purpose processor, which can include but is not limited to: CPU (Central Processing Unit, central processing unit), NP (Network Processor, network processor), etc.; can also be DSP (Digital Signal Processing, digital signal processor) ), ASIC (Application Specific Integrated Circuit, Application Specific Integrated Circuit), FPGA (Field-Programmable Gate Array, Field Programmable Gate Array) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
在一实施方式中,本申请实施例中的具体示例可以参考上述实施例中所描述的示例,本实施例在此不再赘述。In an implementation manner, for specific examples in the embodiments of the present application, reference may be made to the examples described in the foregoing embodiments, and details are not described herein again in this embodiment.
本领域普通技术人员可以理解,图7所示的结构仅为示意,实施上述悬挂事务巡检方法的设备也可以是终端设备,该终端设备可以是智能手机(如Android手机、iOS手机等)、平板电脑、掌上电脑以及移动互联网设备(Mobile Internet Devices,MID)、PAD等终端设备。图7其并不对上述电子设备的结构造成限定。例如,电子设备还可包括比图7中所示更多或者更少的组件(如网络接口、显示装置等),或者具有与图7所示的不同的配置。Those of ordinary skill in the art can understand that the structure shown in FIG. 7 is for illustration only, and the device implementing the above-mentioned method for inspecting suspended affairs can also be a terminal device, and the terminal device can be a smart phone (such as an Android mobile phone, an iOS mobile phone, etc.), Tablet PCs, PDAs, Mobile Internet Devices (MIDs, MIDs), PADs and other terminal devices. FIG. 7 does not limit the structure of the above electronic device. For example, the electronic device may also include more or fewer components than those shown in FIG. 7 (eg, network interfaces, display devices, etc.), or have a different configuration than that shown in FIG. 7 .
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令终端设备相关的硬件来完成,该程序可以存储于一计算机可读存储介质中,存储介质可以包括:闪存盘、ROM、RAM、磁盘或光盘等。Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a computer-readable storage medium, and the storage medium can Including: flash disk, ROM, RAM, magnetic disk or CD, etc.
根据本申请实施例的又一个方面,还提供了一种存储介质。在一实施方式中,在本申请实施例中,上述存储介质可以用于执行本申请实施例中上述任一项悬挂事务巡检方法的程序代码。According to yet another aspect of the embodiments of the present application, a storage medium is also provided. In one embodiment, in the embodiment of the present application, the above-mentioned storage medium may be used to execute the program code of any one of the above-mentioned suspended transaction inspection methods in the embodiment of the present application.
在一实施方式中,在本申请实施例中,上述存储介质可以位于上述实施例所示的网络中的多个网络设备中的至少一个网络设备上。In an implementation manner, in this embodiment of the present application, the above-mentioned storage medium may be located on at least one network device among multiple network devices in the network shown in the above-mentioned embodiment.
在一实施方式中,在本申请实施例中,存储介质被设置为存储用于执行以下步骤的程序代码:In one embodiment, in this embodiment of the present application, the storage medium is configured to store program codes for executing the following steps:
S1,通过目标数据库接收目标拓扑信息,其中,目标拓扑信息是目标全局事务和与目标全局事务对应的多个目标分支事务之间的拓扑信息;S1, receiving target topology information through the target database, wherein the target topology information is the topology information between the target global transaction and multiple target branch transactions corresponding to the target global transaction;
S2,将目标拓扑信息保存到目标存储对象中,其中,目标存储对象用于记录多个全局事务中的每个全局事务和与每个全局事务对应的多个分支事务之间的拓扑信息,目标数据库用于处理与每个全局事务对应的多个分支事务中的一个分支事务;S2, save the target topology information into the target storage object, where the target storage object is used to record the topology information between each global transaction in the multiple global transactions and the multiple branch transactions corresponding to each global transaction, and the target The database is used to process one of the branch transactions corresponding to each global transaction;
S3,按照目标存储对象中记录的拓扑信息,通过目标数据库对各个全局事务分别进行悬挂事务巡检。S3, according to the topology information recorded in the target storage object, through the target database, each global transaction is respectively inspected for suspended transactions.
在一实施方式中,本申请实施例中的具体示例可以参考上述实施例中所描述的示例,本实施例中对此不再赘述。In an implementation manner, for specific examples in the embodiments of the present application, reference may be made to the examples described in the foregoing embodiments, which will not be repeated in this embodiment.
在一实施方式中,在本申请实施例中,上述存储介质可以包括但不限于:U盘、ROM、RAM、移动硬盘、磁碟或者光盘等各种可以存储程序代码的介质。In one embodiment, in the embodiments of the present application, the above-mentioned storage medium may include, but is not limited to, various media that can store program codes, such as U disk, ROM, RAM, removable hard disk, magnetic disk, or optical disk.
上述本申请实施例序号仅仅为了描述,不代表实施例的优劣。The above-mentioned serial numbers of the embodiments of the present application are only for description, and do not represent the advantages or disadvantages of the embodiments.
上述实施例中的集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在上述计算机可读取的存储介质中。基于这样的理解,本申请的技术方案本质上或者说对相关技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在存储介质中,包括若干指令用以使得一台或多台计算机设备(可为个人计算机、服务器或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。If the integrated units in the above-mentioned embodiments are implemented in the form of software functional units and sold or used as independent products, they may be stored in the above-mentioned computer-readable storage medium. Based on this understanding, the technical solutions of the present application can be embodied in the form of software products in essence, or the parts that contribute to the related technologies, or all or part of the technical solutions. The computer software products are stored in the storage medium, including Several instructions are used to cause one or more computer devices (which may be personal computers, servers, or network devices, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present application.
在本申请的上述实施例中,对各个实施例的描述都各有侧重,某个实施例中没有详述的部分,可以参见其他实施例的相关描述。In the above-mentioned embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference may be made to related descriptions of other embodiments.
在本申请所提供的几个实施例中,应该理解到,所揭露的客户端,可通过其它的方式实现。其中,以上所描述的装置实施例仅仅是示意性的,例如所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,单元或模块的间接耦合或通信连接,可以是电性或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed client may be implemented in other manners. The apparatus embodiments described above are only illustrative, for example, the division of the units is only a logical function division, and there may be other division methods in actual implementation, for example, multiple units or components may be combined or Integration into another system, or some features can be ignored, or not implemented. On the other hand, the shown or discussed mutual coupling or direct coupling or communication connection may be through some interfaces, indirect coupling or communication connection of units or modules, and may be in electrical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例中所提供的方案的目的。The units described as separate components may or may not be physically separated, and components displayed as units may or may not be physical units, that is, may be located in one place or distributed to multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution provided in this embodiment.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit. The above-mentioned integrated units may be implemented in the form of hardware, or may be implemented in the form of software functional units.
以上所述仅是本申请的优选实施方式,应当指出,对于本技术领域的普通技 术人员来说,在不脱离本申请原理的前提下,还可以做出若干改进和润饰,这些改进和润饰也应视为本申请的保护范围。The above are only the preferred embodiments of the present application. It should be pointed out that for those skilled in the art, without departing from the principles of the present application, several improvements and modifications can also be made. It should be regarded as the protection scope of this application.
工业实用性Industrial Applicability
本申请实施例提供了一种悬挂事务巡检方法和装置、电子设备和存储介质,通过目标数据库接收目标拓扑信息,目标拓扑信息是目标全局事务和与目标全局事务对应的多个目标分支事务之间的拓扑信息;将目标拓扑信息保存到目标存储对象中,目标存储对象用于记录多个全局事务中的每个全局事务和与每个全局事务对应的多个分支事务之间的拓扑信息,目标数据库用于处理与每个全局事务对应的多个分支事务中的一个分支事务;按照目标存储对象中记录的拓扑信息,通过目标数据库对各个全局事务分别进行悬挂事务巡检。由于数据库实例(数据库节点)通过系统表保存与本数据库实例关联的拓扑信息,每个全局事务及其对应的分支事务可以注册到至少一个关联的数据库实例中,不同的全局事务及其对应的分支事务注册到不同的数据库实例中,而不是由全局事务管理器统一进行全局事务管理,以此可以实现分布式的全局事务和分支事务注册管理的目的,达到了减少管理器的处理压力、提高悬挂事务处理效率的技术效果,进而解决了相关技术中的悬挂事务控制方式存在由于管理器所管理的全局事务和分支事务的数量较多导致的悬挂事务处理效率低的问题。The embodiments of the present application provide a method and device, an electronic device, and a storage medium for inspecting a suspended transaction. Target topology information is received through a target database, and the target topology information is a combination of a target global transaction and multiple target branch transactions corresponding to the target global transaction. The topology information between the two; save the target topology information into the target storage object, and the target storage object is used to record the topology information between each global transaction in the multiple global transactions and the multiple branch transactions corresponding to each global transaction, The target database is used to process one branch transaction among the multiple branch transactions corresponding to each global transaction; according to the topology information recorded in the target storage object, each global transaction is inspected by the target database. Since the database instance (database node) saves the topology information associated with the database instance through the system table, each global transaction and its corresponding branch transaction can be registered in at least one associated database instance, different global transactions and their corresponding branches Transactions are registered in different database instances, instead of the global transaction manager for unified global transaction management, so that the purpose of distributed global transaction and branch transaction registration management can be achieved, which can reduce the processing pressure of the manager and improve the suspension. The technical effect of transaction processing efficiency further solves the problem of low hanging transaction processing efficiency caused by the large number of global transactions and branch transactions managed by the manager in the suspended transaction control method in the related art.

Claims (10)

  1. 一种悬挂事务巡检方法,包括:A suspension transaction inspection method, comprising:
    通过目标数据库接收目标拓扑信息,其中,所述目标拓扑信息是目标全局事务和与所述目标全局事务对应的多个目标分支事务之间的拓扑信息;Receive target topology information through a target database, wherein the target topology information is topology information between a target global transaction and a plurality of target branch transactions corresponding to the target global transaction;
    将所述目标拓扑信息保存到目标存储对象中,其中,所述目标存储对象用于记录多个全局事务中的每个全局事务和与所述每个全局事务对应的多个分支事务之间的拓扑信息,所述目标数据库用于处理与所述每个全局事务对应的所述多个分支事务中的一个分支事务;The target topology information is stored in a target storage object, wherein the target storage object is used to record the relationship between each global transaction in multiple global transactions and multiple branch transactions corresponding to each global transaction. topology information, the target database is used to process a branch transaction in the plurality of branch transactions corresponding to each global transaction;
    按照所述目标存储对象中记录的拓扑信息,通过所述目标数据库对所述各个全局事务分别进行悬挂事务巡检。According to the topology information recorded in the target storage object, the suspended transaction inspection is performed on each global transaction through the target database.
  2. 根据权利要求1所述的方法,其中,通过所述目标数据库接收所述目标拓扑信息包括:The method of claim 1, wherein receiving the target topology information via the target database comprises:
    通过所述目标数据库接收目标服务器发送的目标事务消息,其中,所述目标服务器为所述目标全局事务的事务协调者,所述目标事务消息中携带有所述目标拓扑信息和与所述目标数据库对应的待处理分支事务信息,所述待处理分支事务信息用于指示所述多个目标分支事务中,待所述目标数据库处理的分支事务。The target transaction message sent by the target server is received through the target database, wherein the target server is the transaction coordinator of the target global transaction, and the target transaction message carries the target topology information and the target database. Corresponding branch transaction information to be processed, the to-be-processed branch transaction information is used to indicate the branch transaction to be processed by the target database among the multiple target branch transactions.
  3. 根据权利要求1所述的方法,其中,按照所述目标存储对象中记录的拓扑信息,通过所述目标数据库对所述各个全局事务分别进行悬挂事务巡检包括:The method according to claim 1, wherein, according to the topology information recorded in the target storage object, respectively performing suspended transaction inspection on each global transaction through the target database comprises:
    按照所述目标存储对象中记录的所述目标拓扑信息,通过所述目标数据库确定与所述目标全局事务对应的第一状态信息;According to the target topology information recorded in the target storage object, determine the first state information corresponding to the target global transaction through the target database;
    在根据所述第一状态信息确定出所述目标全局事务在提交之前发生异常的情况下,将所述目标全局事务确定为悬挂事务。If it is determined according to the first state information that the target global transaction is abnormal before committing, the target global transaction is determined to be a suspended transaction.
  4. 根据权利要求3所述的方法,其中,按照所述目标存储对象中记录的所述目标拓扑信息,通过所述目标数据库确定与所述目标全局事务对应的所述第一状态信息包括:The method according to claim 3, wherein, according to the target topology information recorded in the target storage object, determining the first state information corresponding to the target global transaction through the target database comprises:
    按照所述目标拓扑信息,通过所述目标数据库检测目标心跳信息,其中,所述第一状态信息包含所述目标心跳信息,所述目标心跳信息为所述目标数据库与目标服务器之间的心跳信息,所述目标服务器为与所述目标全局事务对应的事务协调者;According to the target topology information, the target heartbeat information is detected through the target database, wherein the first state information includes the target heartbeat information, and the target heartbeat information is the heartbeat information between the target database and the target server , the target server is the transaction coordinator corresponding to the target global transaction;
    在按照所述目标拓扑信息,通过所述目标数据库检测所述目标心跳信息之后,所述方法还包括:在检测到所述目标心跳信息停止更新的情况下,确定出所述目标全局事务在提交之前发生异常。After detecting the target heartbeat information through the target database according to the target topology information, the method further includes: in the case where it is detected that the target heartbeat information stops updating, determining that the target global transaction is being submitted An exception occurred before.
  5. 根据权利要求1至4中任一项所述的方法,其中,在按照所述目标存储对象中记录的拓扑信息,通过所述目标数据库对所述各个全局事务分别进行悬挂事务巡检之后,所述方法还包括:The method according to any one of claims 1 to 4, wherein after each global transaction is inspected for suspended transactions through the target database according to the topology information recorded in the target storage object, the The method also includes:
    在将所述目标全局事务确定为悬挂事务的情况下,获取与所述多个目标分支事务中的各个目标分支事务对应的第二状态信息;In the case where the target global transaction is determined to be a suspending transaction, acquiring second state information corresponding to each target branch transaction in the plurality of target branch transactions;
    按照与所述各个目标分支事务对应的所述第二状态信息控制对所述各个分支事务执行目标事务操作,其中,所述目标事务操作包括以下之一:事务提交,事务回滚。The target transaction operation is controlled to be performed on each branch transaction according to the second state information corresponding to each target branch transaction, wherein the target transaction operation includes one of the following: transaction commit and transaction rollback.
  6. 根据权利要求5所述的方法,其中,按照与所述各个目标分支事务对应的所述第二状态信息控制对所述各个分支事务执行所述目标事务操作包括:The method according to claim 5, wherein controlling the execution of the target transaction operation on the respective branch transactions according to the second state information corresponding to the respective target branch transactions comprises:
    在根据与所述各个目标分支事务对应的所述第二状态信息确定出所述各个目标分支事务均已预提交成功的情况下,控制对所述各个目标分支事务进行事务提交;Under the condition that it is determined according to the second state information corresponding to each target branch transaction that all the target branch transactions have been pre-committed successfully, controlling the transaction submission of each target branch transaction;
    在根据与所述各个目标分支事务对应的所述第二状态信息确定出存在预提交失败的分支事务的情况下,控制对所述各个目标分支事务进行事务回滚。When it is determined according to the second state information corresponding to each target branch transaction that there is a branch transaction that fails to pre-commit, the control is to perform transaction rollback on each target branch transaction.
  7. 根据权利要求1至6中任一项所述的方法,其中,在按照所述目标存储对象中记录的拓扑信息,通过所述目标数据库对所述各个全局事务分别进行悬挂事务巡检之后,所述方法还包括:The method according to any one of claims 1 to 6, wherein, after performing suspending transaction inspection on each global transaction through the target database according to the topology information recorded in the target storage object, the The method also includes:
    在所述目标全局事务提交成功的情况下,将所述目标拓扑信息从所述目标存储对象中删除。In the case that the target global transaction is successfully submitted, the target topology information is deleted from the target storage object.
  8. 一种悬挂事务巡检装置,包括:A suspension affairs inspection device, comprising:
    接收单元,设置为通过目标数据库接收目标拓扑信息,其中,所述目标拓扑信息是目标全局事务和与所述目标全局事务对应的多个目标分支事务之间的拓扑信息;a receiving unit, configured to receive target topology information through a target database, wherein the target topology information is the topology information between a target global transaction and a plurality of target branch transactions corresponding to the target global transaction;
    保存单元,设置为将所述目标拓扑信息保存到目标存储对象中,其中,所述目标存储对象用于记录多个全局事务中的每个全局事务和与所述每个全局事务对应的多个分支事务之间的拓扑信息,所述目标数据库用于处理与所述每个全局事务对应的所述多个分支事务中的一个分支事务;A saving unit, configured to save the target topology information into a target storage object, wherein the target storage object is used to record each global transaction in a plurality of global transactions and multiple global transactions corresponding to the each global transaction topology information between branch transactions, the target database is used to process one branch transaction in the plurality of branch transactions corresponding to each global transaction;
    巡检单元,设置为按照所述目标存储对象中记录的拓扑信息,通过所述目标数据库对所述各个全局事务分别进行悬挂事务巡检。The inspection unit is configured to inspect each global transaction through the target database to perform suspension transaction inspection respectively according to the topology information recorded in the target storage object.
  9. 一种电子设备,包括处理器、通信接口、存储器和通信总线,其中,所述处理器、所述通信接口和所述存储器通过所述通信总线完成相互间的通信,An electronic device comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus,
    所述存储器,设置为存储计算机程序;The memory is configured to store computer programs;
    所述处理器,设置为通过运行所述存储器上所存储的所述计算机程序来执行权利要求1至7中任一项所述的方法步骤。The processor is arranged to perform the method steps of any one of claims 1 to 7 by running the computer program stored on the memory.
  10. 一种计算机可读的存储介质,所述存储介质中存储有计算机程序,其中,所述计算机程序被设置为运行时执行权利要求1至7中任一项中所述的方法步骤。A computer-readable storage medium in which a computer program is stored, wherein the computer program is arranged to perform the method steps of any one of claims 1 to 7 when run.
PCT/CN2022/072050 2021-03-25 2022-01-14 Suspended transaction inspection method and apparatus, electronic device and storage medium WO2022199229A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110317349.8 2021-03-25
CN202110317349.8A CN112711466B (en) 2021-03-25 2021-03-25 Hanging affair inspection method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
WO2022199229A1 true WO2022199229A1 (en) 2022-09-29

Family

ID=75550231

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/072050 WO2022199229A1 (en) 2021-03-25 2022-01-14 Suspended transaction inspection method and apparatus, electronic device and storage medium

Country Status (2)

Country Link
CN (1) CN112711466B (en)
WO (1) WO2022199229A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112711466B (en) * 2021-03-25 2021-08-10 北京金山云网络技术有限公司 Hanging affair inspection method and device, electronic equipment and storage medium

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080243865A1 (en) * 2007-03-28 2008-10-02 Oracle International Corporation Maintaining global state of distributed transaction managed by an external transaction manager for clustered database systems
CN106503132A (en) * 2016-10-19 2017-03-15 广州快塑电子商务有限公司 A kind of distributed transaction management method and system
CN107168775A (en) * 2016-03-07 2017-09-15 阿里巴巴集团控股有限公司 It is a kind of to hang the method and apparatus that affairs are automatically processed
CN107908494A (en) * 2017-11-10 2018-04-13 泰康保险集团股份有限公司 Processing method, device, electronic equipment and the storage medium of anomalous event
CN110417586A (en) * 2019-07-18 2019-11-05 新华三大数据技术有限公司 Service monitoring method, service node, server and computer readable storage medium
CN110716793A (en) * 2019-10-10 2020-01-21 腾讯科技(深圳)有限公司 Execution method, device, equipment and storage medium of distributed transaction
CN112115012A (en) * 2019-06-19 2020-12-22 中兴通讯股份有限公司 Transaction monitoring method, device and system for distributed database and storage medium
CN112711466A (en) * 2021-03-25 2021-04-27 北京金山云网络技术有限公司 Hanging affair inspection method and device, electronic equipment and storage medium

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106033562B (en) * 2015-03-16 2019-12-06 阿里巴巴集团控股有限公司 Transaction processing method, transaction participating node and transaction coordinating node
US9979734B2 (en) * 2015-04-20 2018-05-22 Oath Inc. Management of transactions in a distributed transaction system
CN106844014B (en) * 2015-12-07 2020-04-28 阿里巴巴集团控股有限公司 Method and device for realizing suspension prevention of distributed transactions

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080243865A1 (en) * 2007-03-28 2008-10-02 Oracle International Corporation Maintaining global state of distributed transaction managed by an external transaction manager for clustered database systems
CN107168775A (en) * 2016-03-07 2017-09-15 阿里巴巴集团控股有限公司 It is a kind of to hang the method and apparatus that affairs are automatically processed
CN106503132A (en) * 2016-10-19 2017-03-15 广州快塑电子商务有限公司 A kind of distributed transaction management method and system
CN107908494A (en) * 2017-11-10 2018-04-13 泰康保险集团股份有限公司 Processing method, device, electronic equipment and the storage medium of anomalous event
CN112115012A (en) * 2019-06-19 2020-12-22 中兴通讯股份有限公司 Transaction monitoring method, device and system for distributed database and storage medium
CN110417586A (en) * 2019-07-18 2019-11-05 新华三大数据技术有限公司 Service monitoring method, service node, server and computer readable storage medium
CN110716793A (en) * 2019-10-10 2020-01-21 腾讯科技(深圳)有限公司 Execution method, device, equipment and storage medium of distributed transaction
CN112711466A (en) * 2021-03-25 2021-04-27 北京金山云网络技术有限公司 Hanging affair inspection method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN112711466A (en) 2021-04-27
CN112711466B (en) 2021-08-10

Similar Documents

Publication Publication Date Title
US10261853B1 (en) Dynamic replication error retry and recovery
JP5580831B2 (en) Constant-based transactional and consistent membership management in distributed storage systems
US20170163479A1 (en) Method, Device and System of Renewing Terminal Configuration In a Memcached System
CN110365748B (en) Service data processing method and device, storage medium and electronic device
WO2017063520A1 (en) Method and apparatus for operating database
WO2019001017A1 (en) Inter-cluster data migration method and system, server, and computer storage medium
US9201919B2 (en) Bandwidth optimized two-phase commit protocol for distributed transactions
US11106541B2 (en) System and method for replicating data in distributed database systems
US10826812B2 (en) Multiple quorum witness
US20050193037A1 (en) Peer-to-peer replication member initialization and deactivation
WO2018058941A1 (en) Method for detecting communication status of cluster system, and gateway cluster
US11223522B1 (en) Context-based intelligent re-initiation of microservices
WO2016107443A1 (en) Snapshot processing method and related device
US20200264916A1 (en) Method and system for processing transactions
WO2022199229A1 (en) Suspended transaction inspection method and apparatus, electronic device and storage medium
WO2020001060A1 (en) Member change method for distributed system, and distributed system
WO2017181430A1 (en) Method and device for duplicating database in distributed system
US11099827B2 (en) Networking-device-based hyper-coverged infrastructure edge controller system
TW201727517A (en) Data storage and service processing method and device
CN109995585B (en) Exception handling method, device and storage medium
CN110830582A (en) Cluster owner selection method and device based on server
CN112052104A (en) Message queue management method based on multi-computer-room realization and electronic equipment
CN115794769B (en) Method for managing high-availability database, electronic equipment and storage medium
CN113596195B (en) Public IP address management method, device, main node and storage medium
CN112527561B (en) Data backup method and device based on Internet of things cloud storage

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22773892

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 22773892

Country of ref document: EP

Kind code of ref document: A1