CN115858668A - Distributed transaction processing method, device, electronic device and storage medium - Google Patents

Distributed transaction processing method, device, electronic device and storage medium Download PDF

Info

Publication number
CN115858668A
CN115858668A CN202211493431.7A CN202211493431A CN115858668A CN 115858668 A CN115858668 A CN 115858668A CN 202211493431 A CN202211493431 A CN 202211493431A CN 115858668 A CN115858668 A CN 115858668A
Authority
CN
China
Prior art keywords
transaction
gtid
local
gtm
issuing
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202211493431.7A
Other languages
Chinese (zh)
Inventor
张晓丽
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jinzhuan Xinke Co Ltd
Original Assignee
Jinzhuan Xinke Co Ltd
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 Jinzhuan Xinke Co Ltd filed Critical Jinzhuan Xinke Co Ltd
Priority to CN202211493431.7A priority Critical patent/CN115858668A/en
Publication of CN115858668A publication Critical patent/CN115858668A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to a distributed transaction processing method, a device, an electronic device and a storage medium, wherein the method comprises the following steps: receiving a transaction issuing request sent by a service end, and generating a local GTID, wherein the transaction issuing request carries a transaction issuing parameter; based on the transaction issuing parameters, transaction fragments are calculated, and each transaction fragment corresponds to a data node DN; under the condition that the transaction fragments are multiple, selecting a target transaction fragment to be issued currently from the multiple transaction fragments, reporting the local GTID to a global transaction management node (GTM), acquiring target transaction data corresponding to the target transaction fragment from the transaction issue parameters, and issuing the local GTID and the target transaction data to a first DN (digital network name) corresponding to the target transaction fragment so as to enable the first DN to submit the transaction. Through the method and the device, the local GTID is synchronized to the GTM, the GTID does not need to be applied from the GTM, interaction between the GTM and the local GTID is reduced, and the pressure of the GTM is reduced.

Description

Distributed transaction processing method, device, electronic device and storage medium
Technical Field
The present application relates to the field of distributed database technologies, and in particular, to a distributed transaction processing method and apparatus, an electronic apparatus, and a storage medium.
Background
In the field of distributed databases, different solutions are provided for ensuring the consistency of transactions; in the related art, ensuring transaction consistency based on global transaction management is a common technical solution, for example: the golden DB distributed database provides a scheme for ensuring the consistency of transactions by using the mutual cooperation of a computing node, a data node and a global transaction management node.
In the related technology, when a Transaction starts, a golden DB distributed database applies for a Global Transaction unique identifier (Global Transaction ID, GTID for short) from a Global Transaction Manager Node (GTM for short) through a middle component computing Node (Computer Node, CN for short), adds the Global Transaction unique identifier (Global Transaction ID, GTID for short) into an active list, then sends the Global Transaction unique identifier to a Data Node (Data Node, DN for short) and records the Data in each piece of Data, releases the GTID when the Transaction ends, and removes the GTID from the active list, thereby ensuring the consistency of the Transaction.
In the related technology, in order to guarantee distributed transactions, corresponding transaction processing is performed in a multi-fragment transaction mode, but not all transactions need to apply for GTID and determine whether GTID is active, for a transaction (for example, a single-node transaction) involving only one fragment, GTID does not need to be applied from GTM, and when all transactions in the distributed transactions acquire GTID and an active list from GTM, problems of large GTM pressure, data transmission amount and network delay are caused.
Aiming at the problems that in the related technology, all transactions in distributed transactions acquire GTIDs and active lists from GTMs indiscriminately, the GTMs are prone to have large pressure, large data transmission quantity and network delay, and no better technical scheme exists.
Disclosure of Invention
The application provides a distributed transaction processing method, a distributed transaction processing device, an electronic device and a storage medium, which are used for at least solving the problems that in the related technology, all transactions in the distributed transactions acquire GTIDs and active lists indiscriminately from GTMs, so that the GTMs are high in pressure, large in data transmission quantity and network delay.
In a first aspect, the present application provides a distributed transaction processing method, applied to a middle component computing node CN, including: receiving a transaction issuing request sent by a service end, and generating a local global transaction unique identifier (GTID), wherein the transaction issuing request carries a transaction issuing parameter; based on the transaction issuing parameters, transaction fragments are calculated, wherein each transaction fragment corresponds to a data node DN; under the condition that the transaction fragments are multiple, selecting a target transaction fragment to be issued currently from the multiple transaction fragments, reporting the local GTID to a global transaction management node (GTM), acquiring target transaction data corresponding to the target transaction fragment from the transaction issuing parameters, and issuing the local GTID and the target transaction data to a first DN (digital network name) corresponding to the target transaction fragment so as to enable the first DN to perform transaction submission.
In a second aspect, the present application provides a distributed transaction processing apparatus, applied to a middle component computing node CN, including:
the generating module is used for receiving a transaction issuing request sent by a service end and generating a local global transaction unique identifier GTID, wherein the transaction issuing request carries a transaction issuing parameter;
the computing module is used for computing transaction fragments based on the transaction issuing parameters, wherein each transaction fragment corresponds to a data node DN;
and the processing module is used for selecting a target transaction fragment to be currently issued from the plurality of transaction fragments under the condition that the transaction fragments are multiple, acquiring target transaction data corresponding to the target transaction fragment from the transaction issuing parameters after reporting the local GTID to a global transaction management node (GTM), and issuing the local GTID and the target transaction data to a first DN (DN) corresponding to the target transaction fragment so as to submit the transaction by the first DN.
In a third aspect, an electronic device is provided, which includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor, configured to implement the steps of the distributed transaction processing method according to any embodiment of the first aspect when executing the program stored in the memory.
In a fourth aspect, a computer-readable storage medium is provided, on which a computer program is stored, which computer program, when being executed by a processor, carries out the steps of the distributed transaction processing method according to any one of the embodiments of the first aspect.
Compared with the related art, the embodiment provides a distributed transaction processing method, a distributed transaction processing device, an electronic device and a storage medium, and generates a local GTID by receiving a transaction issue request sent by a service end, where the transaction issue request carries a transaction issue parameter; based on the transaction issuing parameters, transaction fragments are calculated, wherein each transaction fragment corresponds to a data node DN; under the condition that the transaction fragments are multiple, selecting a target transaction fragment to be issued currently from the multiple transaction fragments, reporting the local GTID to a global transaction management node (GTM), acquiring target transaction data corresponding to the target transaction fragment from the transaction issue parameters, and issuing the local GTID and the target transaction data to a first DN corresponding to the target transaction fragment, so that the first DN submits transactions, the problems that in the related technology, GTIDs and active lists are acquired from the GTM indiscriminately in distributed transactions, the GTM is high in pressure, data transmission quantity and network delay are easily caused are solved, the local GTID is synchronized to the GTM, the GTID does not need to be applied from the GTM, interaction between the GTM and GTM is reduced, and the pressure of the GTM is reduced.
The details of one or more embodiments of the application are set forth in the accompanying drawings and the description below to provide a more thorough understanding of the application.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the invention and together with the description, serve to explain the principles of the invention.
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, and it is obvious for those skilled in the art that other drawings can be obtained according to the drawings without inventive exercise.
Fig. 1 is a schematic flowchart of a distributed transaction processing method according to an embodiment of the present application;
FIG. 2 is a flow diagram of a distributed transaction processing method in accordance with a preferred embodiment of the present application;
FIG. 3 is a process flow of a single-node local GTID in an embodiment of the present application;
FIG. 4 is a process flow of multi-transaction fragmentation issuing using local GTIDs in an embodiment of the present application;
fig. 5 is a block diagram of a distributed transaction processing apparatus according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.
Fig. 1 is a schematic flowchart of a distributed transaction processing method according to an embodiment of the present application. As shown in fig. 1, an embodiment of the present application provides a distributed transaction processing method, which is applied to a middle component computing node CN, and the method includes the following steps:
step S101, receiving a transaction issuing request sent by a service end, and generating a local global transaction unique identifier GTID, wherein the transaction issuing request carries a transaction issuing parameter.
In this embodiment, an execution subject for executing the distributed transaction processing method in the present application is a middle component computing node CN in a distributed database, and meanwhile, the CN interacts with a service end (for example, an application program APP) and a global transaction management node GTM, thereby completing consistency reading of distributed transactions.
In this embodiment, the transaction issuing parameters carried by the transaction issuing request include corresponding transaction data and node information of a data node to which the transaction number needs to be issued, where the transaction data includes, but is not limited to, a Structured Query Language (SQL) statement, for example: insert writes SQL statement, query select statement.
In this embodiment, the generated local GTID is an unscheduled long 64-bit shaped character, occupies 8 bytes, and is respectively composed of Timestamp information Timestamp, data node information CNid, and a global variable Seq, where Timestamp is periodically pushed by a global transaction management node GTM to prevent clock callback, and ensure that the time for generating the local GTID each time is generated according to the same standard; the CNid is realized by calling an internal interface by a CN, a plurality of CNs exist in a distributed database system (such as a golden DB database), each CN can push a generated local GTID to a GTM, and the CNid is added when the local GTID is generated for distinguishing different CNs; and Seq is a defined global variable and is used for representing the addition of the read-write lock, the Seq is acquired through a worker thread each time, whether the GTM pushes a new Timestamp is judged through the worker thread, if yes, the Seq restarts from 1, and if not, the Seq is increased backwards on the basis of the Timestamp pushed last time.
Step S102, transaction fragments are calculated based on transaction issuing parameters, wherein each transaction fragment corresponds to a data node DN.
In this embodiment, after applying for a local GTID, that is, after generating a local GTID, transaction fragmentation calculation is performed to determine whether a current service is a single-node transaction (single-fragment transaction) or a multi-fragment transaction; in this embodiment, each calculated transaction fragment corresponds to one DN issued to the data node, so that the transaction is submitted after the corresponding transaction data is issued to the DN.
Step S103, under the condition that the transaction fragments are multiple, selecting a target transaction fragment to be issued currently from the multiple transaction fragments, reporting a local GTID to a global transaction management node GTM, acquiring target transaction data corresponding to the target transaction fragment from the transaction issue parameters, and issuing the local GTID and the target transaction data to a first DN corresponding to the target transaction fragment so as to enable the first DN to submit the transaction.
In this embodiment, if the current service is a multi-fragment transaction, before issuing a target transaction fragment, a local GTID generated locally is acquired, when the target transaction fragment needs to be issued, the locally generated local GTID is reported to the GTM, the GTM generates and maintains a corresponding active list according to the received local GTID, so that when the CN subsequently determines whether the GTID is active, the active list maintained by the GTM can be acquired from the GTM, and the determination of whether the transaction is active is realized based on the active list; meanwhile, the CN takes the local GTID to the DN, and the DN maintains the GTID corresponding to the distributed transaction when the transaction is reported so as to ensure that the normal work can be realized after the switching.
In this embodiment, transaction fragments before a target transaction fragment, that is, the first transaction fragment of a corresponding transaction, are not interacted with a GTM, and a local GTID locally generated by a CN and corresponding transaction data (for example, an SQL statement) are issued to a corresponding DN; before the target transaction fragment needs to be issued, a local GTID generated locally is reported to a GTM, when the target transaction fragment needs to be issued, a CN takes the local GTID to a corresponding first DN, and the first DN maintains the GTID corresponding to the distributed transaction when the transaction is reported.
In this embodiment, after the DN completes the transaction submission, the CN sends a message to the GTM, so that the GTM deletes the GTID in the active list maintained by the GTM, and the CN sends a message to the corresponding DN, so that the corresponding DN deletes the GTID in the active list maintained by the CN, and the CN implements, through asynchronous processing, notifying the corresponding DN to delete the GTID in the active list; meanwhile, the corresponding CN needs to acquire all active lists from the GTM for active conflict determination, and then perform active conflict determination.
Through the steps from S101 to S103, receiving a transaction issue request sent by a service end, and generating a local GTID, wherein the transaction issue request carries a transaction issue parameter; calculating transaction fragments based on transaction issuing parameters, wherein each transaction fragment corresponds to a data node DN; under the condition that the transaction fragments are multiple, the target transaction fragment to be issued at present is selected from the multiple transaction fragments, after the local GTID is reported to the global transaction management node GTM, the target transaction data corresponding to the target transaction fragment is obtained from the transaction issuing parameters, and the local GTID and the target transaction data are issued to the first DN corresponding to the target transaction fragment, so that the first DN can submit the transaction, the problems that in the related technology, all transactions in the distributed transaction acquire the GTID and the active list from the GTM indiscriminately are solved, the pressure of the GTM is large, the data transmission quantity and the network delay are easily caused are solved, the local GTID is synchronized to the GTM, the GTID does not need to be applied from the GTM, the interaction between the GTM and the GTM is reduced, and the pressure of the GTM is reduced.
It should be noted that, in a distributed database system (for example, golden db database), the defined indifferent application of GTID from GTM means that when the service is notified in a manner of carrying a hint flag that the transaction is a single-node transaction, the transaction is a multi-slice transaction by default, the GTID is applied from GTM, and an active list is obtained from GTM query, thereby determining an active conflict, and when the service is a single-node transaction, it is not necessary to apply for GTID from GTM and obtain an active list; in this embodiment, by generating a local GTID, when the current service is in a multi-fragment transaction scenario, and when an SQL statement corresponding to transaction data does not yet relate to a target transaction fragment, a local GTID locally generated by the CN is obtained, and when the SQL statement needs to issue the target transaction fragment, the local GTID locally generated is reported to the GTM, the GTM maintains the active list, the CN provides a DN with a distributed transaction identifier, and the DN maintains the GTID corresponding to the distributed transaction when the transaction submits a commit, so as to ensure that the system can normally work after switching.
It should be further noted that, when the current transaction fragment is issued, the CN does not need to interact with the GTM; when the target transaction fragment is sent, the corresponding GTID does not need to be applied from the GTM, and only the locally generated local GTID needs to be reported to the GTM, so that the interaction between the GTM and the local GTID is reduced, and the pressure of the GTM is reduced.
In some embodiments, after reporting the local GTID to the global transaction management node GTM, the following steps are further performed:
and step 21, obtaining an active list maintained by the GTM, where the active list maintained by the GTM is generated by the GTM based on the received local GTID.
And step 22, detecting the reported local GTID in an active list maintained by the GTM, and determining whether the local GTID is active according to a detection result.
And step 23, determining a corresponding transaction submission result based on whether the local GTID is active.
In this embodiment, the obtaining of the active list maintained by the GTM may be that, in the transaction issuing parameters, target transaction data corresponding to the target transaction fragment is obtained, and after the local GTID and the target transaction data are issued to the first DN corresponding to the target transaction fragment, the first DN performs a transaction submission process and/or reports a result to the CN, and the CN obtains the active list maintained by the GTM, detects a local GTID in the corresponding active list, and determines whether the local GTID is active, so as to determine a transaction submission result, for example: when the local GTID is judged to be active, the transaction is submitted in progress; the obtaining of the active list maintained by the GTM may also be that after the issuing of the multiple transaction fragments corresponding to the current transaction is completed and the DNs corresponding to all the transaction fragments complete the transaction reporting, at this time, by performing active judgment, it is determined whether the corresponding transaction reporting is completed after the current transaction is issued to the corresponding DN, for example: if the local GTID is not found in the active list obtained from the GTM, the transaction report success can be sent to the service end, and the result set of the query is returned. Obtaining an active list maintained by the GTM in the steps; detecting a local GTID in an active list maintained by the GTM, and determining whether the local GTID is active or not according to a detection result; and determining a corresponding transaction submission result based on whether the local GTID is active, so that the judgment of whether the local GTID is active is realized, and the transaction submission result is determined.
In some embodiments, after all DNs corresponding to the plurality of transaction fragments complete the corresponding transaction commit, the following steps are also performed: a transaction identification delete instruction is sent to the GTM to cause the GTM to remove the local GTID from the active list maintained by the GTM.
In some embodiments, after all DNs corresponding to the plurality of transaction fragments complete the corresponding transaction commit, the following steps are also performed: and sending a transaction identifier deleting instruction to all DNs corresponding to the plurality of transaction fragments so that the corresponding DNs remove the local GTID from an active list maintained by the corresponding DN.
In some embodiments, the transaction issuing parameter includes first transaction data and first node information, and the transaction fragment is calculated based on the transaction issuing parameter, and the following steps are performed:
and step 31, detecting first node information corresponding to the first transaction data in the transaction issuing parameters, wherein the first node information is used for representing target information of a DN to which the corresponding first transaction data is issued.
In this embodiment, the first is not a limitation on the transaction data, and is only used to represent the transaction data corresponding to different embodiments; in this embodiment, when the service end sends the transaction issue request, the transaction issue request carries the corresponding transaction data, that is, the first transaction data, and also carries the target information of the data node DN to which the corresponding first transaction data needs to be issued, and the address to which the corresponding first transaction data is issued is determined through the corresponding target information.
And 32, calculating to obtain the transaction fragments and the number of the transaction fragments according to the detected first node information.
In this embodiment, the first transaction data associated with the data node corresponding to the first node information is taken as a corresponding transaction fragment, so as to determine the corresponding transaction fragment and the number of the transaction fragments.
Detecting first node information corresponding to the first transaction data through the transaction issuing parameters in the steps, wherein the first node information is used for representing target information of a DN to which the corresponding first transaction data is issued; and calculating the transaction fragments and the number of the transaction fragments according to the detected first node information, so as to realize the calculation of the transaction fragments, further determine whether the current transaction is a single-node transaction or a multi-fragment transaction, and further determine the corresponding transaction processing flow.
In some embodiments, generating the local GTID is performed by:
and step 41, receiving the timestamp information pushed by the GTM, and acquiring target information corresponding to the CN.
And 42, generating a local GTID according to at least the timestamp information and the target information.
Receiving the timestamp information pushed by the GTM in the steps, and acquiring target information corresponding to the CN; and generating the local GTID at least according to the timestamp information and the target information, thereby realizing the local GTID generation at the CN.
Fig. 2 is a flow chart of a distributed transaction processing method according to the preferred embodiment of the present application, and referring to fig. 2, the flow chart includes the following steps:
step S201, receiving a transaction issue request sent by a service end, and generating a local global transaction unique identifier GTID, where the transaction issue request carries a transaction issue parameter.
Step S202, transaction fragments are calculated based on the transaction issuing parameters, wherein each transaction fragment corresponds to a data node DN.
Step S203, under the condition that the transaction fragments are multiple, selecting a target transaction fragment to be issued currently from the multiple transaction fragments, reporting the local GTID to the global transaction management node GTM, acquiring target transaction data corresponding to the target transaction fragment from the transaction issue parameters, and issuing the local GTID and the target transaction data to a first DN corresponding to the target transaction fragment so as to enable the first DN to submit the transaction.
And step S204, under the condition that the transaction fragments are single, issuing the second transaction data in the local GTID and the transaction issuing parameters to a second DN corresponding to the transaction fragments so as to make the second DN submit the transactions.
In this embodiment, corresponding to a single-node scenario, the GTID may be directly obtained locally, and the active conflict may also be directly determined in the DN. Compared with the prior art with the hit mark, the method does not need manual judgment and has no invasion to the service; compared with the method without carrying a hit mark, the GTID does not need to be applied to the GTM, the active list does not need to be inquired to the GTM when the active state is judged, interaction with the GTM is reduced, network delay is reduced, and data transmission is reduced.
In this embodiment, a user sends a transaction issuing request from a service end, where the transaction issuing request carries corresponding transaction data (e.g., insert writes SQL statements), the CN locally generates local GTID, calculates issued transaction fragments, and if the transaction fragments corresponding to the current transaction are only issued single transaction fragments by the transaction data, issues the locally generated local GTID and the transaction data (SQL statements) to the DN; the DN maintains its own active list while reporting transactions, and also puts the local GTID into the active list.
Receiving a transaction issuing request sent by the service end through the steps S201 to S204, and generating a local global transaction unique identifier GTID, where the transaction issuing request carries a transaction issuing parameter;
fig. 3 is a processing flow of a single-node local GTID in this embodiment, fig. 4 is a processing flow of using a local GTID for multi-transaction fragment issue in this embodiment, and reference is made to fig. 1, fig. 2, fig. 3, and fig. 4 to describe processing of a distributed transaction in this embodiment as follows:
when the current transaction is a single-node transaction, as shown in fig. 3, the service flow is directly simplified, and GTM interaction is not required, and the locally generated GTID communication data is directly sent to the DN together.
When the current transaction is a multi-sharded transaction, as shown in fig. 4, the processing flow using the local GTID and the processing flow of the active conflict include the following steps:
step 1, a user issues insert writing statements from a service end, applies for local GTID, and calculates issued transaction fragments.
And 2, if the current insert write statement only issues the transaction fragment 1 (refer to fig. 4), not performing other operations.
And 3, issuing the generated local GTID and the insert writing statement to the DN.
And 4, maintaining an active list of the DN by the DN when the transaction is reported, and putting the local GTID into the active list.
And 5, if the insert statement of the service end is issued to the transaction fragment 1 and starts to issue the transaction fragment 2, pushing the current local GTID to the GTM, maintaining an active list of the GTM, and putting the GTID into the active list.
And 6, if a query select statement appears, firstly, the GTM is removed to obtain an active list, and finally, when a query result returns, whether the GTID corresponding to the query in the deactivation skip list is active or not is judged, and if the GTID is active, waiting is carried out, and then, active retry is carried out.
And 7, after the DNs corresponding to all the transaction fragments successfully complete the transaction report, returning the result of insert ok by the write statement.
Step 8, the CN sends a message to make the GTM remove the corresponding GTID from the active list.
And 9, actively retrying query, and if the GTID is not in the active list after being queried in the active list acquired by the GTM, sending select ok to the business end and returning a query result set.
Step 10, the CN sends a message to the DN to judge whether the GTID is in an active list of each fragment, and if the GTID is in the active list of each fragment, the GTID is removed.
In this embodiment, a distributed transaction processing apparatus is further provided, and the apparatus is used to implement the foregoing embodiments and preferred embodiments, and details of which have been already described are omitted. The terms "module," "unit," "subunit," and the like as used below may implement a combination of software and/or hardware for a predetermined function. Although the means described in the embodiments below are preferably implemented in software, an implementation in hardware or a combination of software and hardware is also possible and contemplated.
Fig. 5 is a block diagram of a distributed transaction processing apparatus according to an embodiment of the present application, and as shown in fig. 5, the embodiment of the present application provides a distributed transaction processing apparatus, including:
the generating module 51 is configured to receive a transaction issuing request sent by a service end, and generate a local GTID, where the transaction issuing request carries a transaction issuing parameter;
the calculating module 52 is coupled to the generating module 51, and is configured to calculate transaction fragments based on the transaction issuing parameters, where each transaction fragment corresponds to one data node DN;
and the processing module 53, coupled to the computing module 52, configured to select a target transaction fragment to be currently issued from the multiple transaction fragments when the transaction fragments are multiple, obtain target transaction data corresponding to the target transaction fragment from the transaction issue parameters after reporting the local GTID to the global transaction management node GTM, and issue the local GTID and the target transaction data to a first DN corresponding to the target transaction fragment, so that the first DN submits the transaction.
By the distributed transaction processing device, a transaction issuing request sent by a service end is received, and a local GTID is generated, wherein the transaction issuing request carries a transaction issuing parameter; calculating transaction fragments based on transaction issuing parameters, wherein each transaction fragment corresponds to a data node DN; under the condition that the transaction fragments are multiple, the target transaction fragment to be issued at present is selected from the multiple transaction fragments, after the local GTID is reported to the global transaction management node GTM, the target transaction data corresponding to the target transaction fragment is obtained from the transaction issuing parameters, and the local GTID and the target transaction data are issued to the first DN corresponding to the target transaction fragment, so that the first DN can submit the transaction.
In some embodiments, after reporting the local GTID to the global transaction management node GTM, the distributed transaction processing apparatus is further configured to obtain an active list maintained by the GTM, where the active list maintained by the GTM is generated by the GTM based on the received local GTID; detecting a local GTID in an active list maintained by the GTM, and determining whether the local GTID is active or not according to a detection result; based on whether the local GTID is active, a corresponding transaction commit result is determined.
In some embodiments, after all DNs corresponding to the plurality of transaction fragments complete the corresponding transaction commit, the distributed transaction processing apparatus is further configured to send a transaction identification deletion instruction to the GTM to cause the GTM to remove the local GTID from the active list maintained by the GTM.
In some embodiments, after all DNs corresponding to the plurality of transaction fragments complete the corresponding transaction commit, the distributed transaction processing apparatus is further configured to send a transaction identifier deletion instruction to all DNs corresponding to the plurality of transaction fragments, so that the corresponding DNs removes the local GTID from an active list maintained by the corresponding DN.
In some embodiments, the transaction issue parameter includes a first transaction data and a first node information, and the calculation module 52 further includes:
and the first detection unit is used for detecting first node information corresponding to the first transaction data in the transaction issuing parameters, wherein the first node information is used for representing target information of a DN to which the corresponding first transaction data is issued.
And the first calculating unit is coupled with the first detecting unit and used for calculating the transaction fragments and the number of the transaction fragments according to the detected first node information.
In some embodiments, the generating module 51 is further configured to receive timestamp information pushed by the GTM, and obtain target information corresponding to the CN; and generating a local GTID according to at least the timestamp information and the target information.
In some embodiments, in the case that the transaction fragment is single, the distributed transaction processing apparatus is further configured to issue second transaction data in the local GTID and the transaction issue parameter to a second DN corresponding to the transaction fragment, so that the second DN submits the transaction.
Fig. 6 is a schematic structural diagram of an electronic device according to an embodiment of the present application, and as shown in fig. 6, an embodiment of the present application provides an electronic device including a processor 61, a communication interface 62, a memory 63, and a communication bus 64, where the processor 61, the communication interface 62, and the memory 63 complete mutual communication through the communication bus 64,
a memory 63 for storing a computer program;
the processor 61 is adapted to implement the method steps of fig. 1 when executing the program stored in the memory 63.
The processing in the electronic device implements the method steps in fig. 1, and the technical effect brought by the method is consistent with the technical effect of the method for executing the distributed transaction in fig. 1 in the foregoing embodiment, and is not described again here.
The communication bus mentioned in the electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown in FIG. 6, but this is not intended to represent only one bus or type of bus.
The communication interface is used for communication between the electronic device and other equipment.
The Memory may include a Random Access Memory (RAM), or may also include a non-volatile Memory (non-volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; the Integrated Circuit may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, or discrete hardware components.
Embodiments of the present application further provide a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the steps of the distributed transaction processing method provided in any of the foregoing method embodiments.
In yet another embodiment provided by the present application, there is also provided a computer program product containing instructions which, when run on a computer, cause the computer to perform the steps of the distributed transaction processing method described in any of the above embodiments.
It is noted that, in this document, relational terms such as "first" and "second," and the like, may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Furthermore, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include all elements but does not include all elements expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising a … …" does not exclude the presence of another identical element in a process, method, article, or apparatus that comprises the element.
The foregoing are merely exemplary embodiments of the present invention, which enable those skilled in the art to understand or practice the present invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the invention. Thus, the present invention is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A distributed transaction processing method is applied to a middle component Computing Node (CN), and is characterized by comprising the following steps:
receiving a transaction issuing request sent by a service end, and generating a local global transaction unique identifier (GTID), wherein the transaction issuing request carries a transaction issuing parameter;
based on the transaction issuing parameters, transaction fragments are calculated, wherein each transaction fragment corresponds to a data node DN;
under the condition that the transaction fragments are multiple, selecting a target transaction fragment to be issued currently from the multiple transaction fragments, reporting the local GTID to a global transaction management node (GTM), acquiring target transaction data corresponding to the target transaction fragment from the transaction issuing parameters, and issuing the local GTID and the target transaction data to a first DN (digital network name) corresponding to the target transaction fragment so as to enable the first DN to perform transaction submission.
2. The method of claim 1, wherein after reporting the local GTID to a global transaction management node, GTM, the method further comprises:
obtaining an active list maintained by the GTM, wherein the active list maintained by the GTM is generated by the GTM based on the received local GTID;
in an active list maintained by the GTM, detecting the reported local GTID, and determining whether the local GTID is active according to a detection result;
determining a corresponding transaction commit result based on whether the local GTID is active.
3. The method of claim 2, wherein after all of the DNs corresponding to a plurality of the transaction fragments complete a corresponding transaction commit, the method further comprises: sending a transaction identification delete instruction to the GTM to cause the GTM to remove the local GTID from an active list maintained by the GTM.
4. The method of claim 2, wherein after all of the DNs corresponding to a plurality of the transaction fragments complete a corresponding transaction commit, the method further comprises: and sending a transaction identifier deleting instruction to all DNs corresponding to the plurality of transaction fragments so that the corresponding DNs remove the local GTIDs from an active list maintained by the corresponding DNs.
5. The method of claim 1, wherein the transaction issuance parameter includes first transaction data and first node information, and wherein computing the transaction fragment based on the transaction issuance parameter comprises:
detecting the first node information corresponding to the first transaction data in the transaction issuing parameters, wherein the first node information is used for representing the target information of the DN to which the corresponding first transaction data is issued;
and calculating to obtain the transaction fragments and the number of the transaction fragments according to the detected first node information.
6. The method of claim 1, wherein generating a local GTID comprises:
receiving timestamp information pushed by the GTM, and acquiring target information corresponding to the CN;
and generating the local GTID at least according to the timestamp information and the target information.
7. The method according to claim 1, wherein in case the transaction fragment is single, the method further comprises: and issuing second transaction data in the local GTID and the transaction issuing parameters to a second DN corresponding to the transaction fragment so as to submit the transaction by the second DN.
8. A distributed transaction processing device applied to a middle component Computing Node (CN) is characterized by comprising the following components:
the generating module is used for receiving a transaction issuing request sent by a service end and generating a local global transaction unique identifier GTID, wherein the transaction issuing request carries a transaction issuing parameter;
the computing module is used for computing transaction fragments based on the transaction issuing parameters, wherein each transaction fragment corresponds to a data node DN;
and the processing module is used for selecting a target transaction fragment to be currently issued from the plurality of transaction fragments under the condition that the transaction fragments are multiple, acquiring target transaction data corresponding to the target transaction fragment from the transaction issuing parameters after reporting the local GTID to a global transaction management node (GTM), and issuing the local GTID and the target transaction data to a first DN (DN) corresponding to the target transaction fragment so as to submit the transaction by the first DN.
9. An electronic device is characterized by comprising a processor, a communication interface, a memory and a communication bus, wherein the processor and the communication interface are used for realizing the communication between the processor and the memory through the communication bus;
a memory for storing a computer program;
a processor for implementing the steps of the distributed transaction processing method of any one of claims 1 to 7 when executing a program stored on a memory.
10. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the distributed transaction processing method according to any one of claims 1 to 7.
CN202211493431.7A 2022-11-25 2022-11-25 Distributed transaction processing method, device, electronic device and storage medium Pending CN115858668A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211493431.7A CN115858668A (en) 2022-11-25 2022-11-25 Distributed transaction processing method, device, electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211493431.7A CN115858668A (en) 2022-11-25 2022-11-25 Distributed transaction processing method, device, electronic device and storage medium

Publications (1)

Publication Number Publication Date
CN115858668A true CN115858668A (en) 2023-03-28

Family

ID=85666653

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211493431.7A Pending CN115858668A (en) 2022-11-25 2022-11-25 Distributed transaction processing method, device, electronic device and storage medium

Country Status (1)

Country Link
CN (1) CN115858668A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116737744A (en) * 2023-08-14 2023-09-12 金篆信科有限责任公司 Database control system, method, computer device and storage medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116737744A (en) * 2023-08-14 2023-09-12 金篆信科有限责任公司 Database control system, method, computer device and storage medium
CN116737744B (en) * 2023-08-14 2023-11-24 金篆信科有限责任公司 Database control system, method, computer device and storage medium

Similar Documents

Publication Publication Date Title
US10439937B2 (en) Service addressing in distributed environment
CN111104392B (en) Database migration method and device, electronic equipment and storage medium
CN109284073B (en) Data storage method, device, system, server, control node and medium
CN109815291B (en) Data synchronization method and device, electronic equipment and storage medium
CN108255620B (en) Service logic processing method, device, service server and system
CN111427859B (en) Message processing method and device, electronic equipment and storage medium
CN110413650B (en) Method, device, equipment and storage medium for processing service data
CN109213604B (en) Data source management method and device
CN110008041B (en) Message processing method and device
CN109684270B (en) Database archiving method, device, system, equipment and readable storage medium
WO2019076102A1 (en) Data rollback method and system, device, and computer readable storage medium
CN104423982A (en) Request processing method and device
CN111159160B (en) Version rollback method and device, electronic equipment and storage medium
CN111382206B (en) Data storage method and device
CN115858668A (en) Distributed transaction processing method, device, electronic device and storage medium
CN112148794A (en) Version management method and device of intelligent contract and storage medium
CN111125240A (en) Distributed transaction implementation method and device, electronic equipment and storage medium
WO2020029588A1 (en) Data reading method, device, system, and distributed system
CN111355765A (en) Network request processing and sending method and device
CN111124751B (en) Data recovery method and system, data storage node and database management node
CN111930528A (en) Message writing method, device and equipment of message middleware and readable storage medium
CN111367694A (en) Event processing method, server and computer storage medium
CN110955460A (en) Service process starting method and device, electronic equipment and storage medium
CN111309693A (en) Data synchronization method, device and system, electronic equipment and storage medium
CN110727895A (en) Sensitive word sending method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination