Distributed transaction processing method and system
By employing a timestamp-sorted distributed transaction processing method in the ShuangzhaoDB database, the inefficiency caused by traditional locking mechanisms is resolved, achieving efficient distributed transaction processing and reducing CPU overhead and lock waiting.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-23
- Publication Date
- 2026-04-07
AI Technical Summary
The use of traditional locking mechanisms for transaction processing in existing distributed database systems leads to inefficiency, especially when multiple transactions compete for the same resource, resulting in lock waiting and blocking, wasting system resources and prolonging processing time.
A distributed transaction processing method is adopted, which obtains transaction processing information, determines the target site and waits for a preset time period, processes transactions in timestamp order, avoids lock acquisition and release, and uses timestamps to sort the transaction processing flow. It is suitable for dispatchers and target sites of ShuangzhaoDB database.
It improves transaction processing efficiency, reduces CPU overhead caused by locking mechanisms, and ensures serial execution efficiency in multi-transaction processing.
Smart Images

Figure CN121807453A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of database systems, and particularly relates to a distributed transaction processing method and system. BACKGROUND
[0002] The existing distributed database system usually uses a traditional lock mechanism for transaction processing, that is, a lock needs to be applied before transaction execution and released after transaction execution, and the two operations themselves will generate additional CPU overhead and log records. At this time, if multiple transactions compete for the same resource, lock waiting will occur, resulting in transaction blocking and retry, wasting system resources and prolonging processing time. Therefore, the prior art has the problem of low transaction processing efficiency. SUMMARY
[0003] The present application provides a distributed transaction processing method and system, which can solve the problem of low processing efficiency caused by using a traditional lock mechanism for transaction processing in the prior art.
[0004] An embodiment of the present application provides a distributed transaction processing method, applicable to a dispatcher, comprising: obtaining transaction processing information of a current to-be-processed transaction; wherein the transaction processing information is obtained by a transaction initiator after receiving a transaction request signal of the current to-be-processed transaction, and the transaction processing information is used to determine a dispatcher for dispatching the current to-be-processed transaction, and the transaction processing information is transmitted to the dispatcher; the transaction processing information comprises a timestamp; determining a target site for processing the current to-be-processed transaction according to the transaction processing information, and sending the transaction processing information to the target site, so that the target site waits for a preset time period after receiving the transaction processing information; if the target site does not receive new transaction processing information within the preset time period, transaction processing is performed according to the transaction processing information, a transaction processing result is obtained and fed back; otherwise, the current to-be-processed transaction and new to-be-processed transactions received within the preset time period are taken as target processing transactions, and the target processing transactions are sorted in a transaction processing order according to the timestamps corresponding to the target processing transactions, and then each target processing transaction is processed in turn according to the transaction processing information of the target processing transaction, a transaction processing result of each target processing transaction is obtained and fed back; result feedback is performed according to the transaction processing result.
[0005] Further, the determining of the target site for processing the current to-be-processed transaction according to the transaction processing information and the sending of the transaction processing information to the target site comprise: extracting all table names of all tables of the current to-be-processed transaction from the transaction processing information; According to the table name and the preset table element database, the type corresponding to each table is determined, wherein the type includes a partition table and a replication table; In a case where all the types of the tables are replication tables, a target site for processing a current to-be-processed transaction is determined according to all the replication tables, and the transaction processing information is distributed to the target site; In a case where the tables include partition tables, the current to-be-processed transaction is divided into a plurality of transaction segments according to the partition tables, and a target site for processing each transaction segment is determined according to the partition tables; and the transaction processing information corresponding to each transaction segment is distributed to the corresponding target site.
[0006] Further, the result feedback according to the transaction processing result includes: obtaining transaction processing results fed back by all the target sites corresponding to the current to-be-processed transaction; merging all the transaction processing results to obtain a final transaction processing result of the current to-be-processed transaction, and feeding back the final transaction processing result to the transaction initiator.
[0007] Further, the method further includes: if any target site does not feed back the corresponding transaction processing result within a preset timeout period, feeding back a timeout signal to the transaction initiator.
[0008] Further, the method further includes: if a transaction restart signal is received when the transaction processing information is sent to the target site, determining a new target site for the current to-be-processed transaction.
[0009] Further, after obtaining the transaction processing result, the method further includes: generating, by the target site, a transaction processing log of a transaction corresponding to the transaction processing result, and storing the transaction processing log.
[0010] On the basis of the method embodiment, the application provides a device embodiment; The application provides a distributed transaction processing system, which includes: a distributor, a target site and a transaction initiator; The transaction initiator is configured to, after receiving a transaction request signal of a current to-be-processed transaction, obtain transaction processing information of the current to-be-processed transaction, determine a distributor for distributing the current to-be-processed transaction according to the transaction processing information, and transmit the transaction processing information to the distributor; wherein the transaction processing information includes a timestamp. The dispatcher is further configured to: acquire transaction processing information of a current to-be-processed transaction; determine a target site for processing the current to-be-processed transaction according to the transaction processing information, and send the transaction processing information to the target site; The target site is configured to: after receiving the transaction processing information, wait for a preset time period; if no new transaction processing information is received within the preset time period, perform transaction processing according to the transaction processing information to obtain a transaction processing result; otherwise, take the current to-be-processed transaction and new to-be-processed transactions received within the preset time period as target processing transactions, perform transaction processing order sorting according to time stamps corresponding to the target processing transactions, and then process the target processing transactions according to transaction processing information of the target processing transactions in sequence to obtain a transaction processing result of each target processing transaction; and send the transaction processing result to the dispatcher. The dispatcher is further configured to perform result feedback according to the transaction processing result.
[0011] Further, the dispatcher is further configured to: extract table names of all tables of the current to-be-processed transaction from the transaction processing information; determine a type corresponding to each table according to the table names and a preset table metadata database; the type includes a partition table and a replication table; in a case where all the tables are replication tables, determine a target site of the current to-be-processed transaction according to all the replication tables, and distribute the transaction processing information to the target site; in a case where there is a partition table in the tables, divide the current to-be-processed transaction into a plurality of transaction segments according to the partition tables, and determine a target site for processing each transaction segment according to the partition tables; and distribute transaction processing information corresponding to each transaction segment to the corresponding target site.
[0012] Further, the dispatcher is further configured to: acquire transaction processing results fed back by all target sites corresponding to the current to-be-processed transaction; merge all the transaction processing results to obtain a final transaction processing result of the current to-be-processed transaction, and feed back the final transaction processing result to the transaction initiator.
[0013] Further, the dispatcher is further configured to: if any target site does not feed back a corresponding transaction processing result within a preset timeout period, feed back a timeout signal to the transaction initiator.
[0014] Embodiments of the present application have the following beneficial effects: This invention provides a distributed transaction processing method and system. The method is applicable to a dispatcher and includes: acquiring transaction processing information of a currently pending transaction; wherein the transaction processing information is acquired by the transaction initiator after receiving a transaction request signal for the currently pending transaction, and the initiator determines a dispatcher for dispatching the currently pending transaction based on the transaction processing information, and transmits the transaction processing information to the dispatcher; the transaction processing information includes a timestamp; subsequently, based on the transaction processing information, the initiator determines a target site for processing the currently pending transaction, and sends the transaction processing information to the target site, so that... After receiving the aforementioned transaction processing information, the target station waits for a preset period. If no new transaction processing information is received within this period, the target station processes the transaction based on the information, obtains the result, and provides feedback. Otherwise, the current pending transaction and any new pending transactions received within the preset period are considered as target processing transactions. Based on the timestamps of these target transactions, the processing order is sorted, and each transaction is processed sequentially according to its transaction processing information. The result of each transaction is then obtained and provided feedback. Finally, the result is fed back based on the transaction processing results. Therefore, this invention eliminates the need for lock acquisition and release during transaction processing. When a station has multiple transactions to process, all transactions are sorted chronologically and processed sequentially, thus reducing the additional CPU overhead associated with locking mechanisms and improving transaction processing efficiency. Attached Figure Description
[0015] To more clearly illustrate the technical solution of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0016] Figure 1 This is a flowchart illustrating a distributed transaction processing method provided in an embodiment of the present invention.
[0017] Figure 2 This is an architectural block diagram of the ShuangzhaoDB database provided in one embodiment of the present invention.
[0018] Figure 3 This is a schematic diagram of the structure of a distributed transaction processing system provided in an embodiment of the present invention. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0020] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains; the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the application; the terms “comprising” and “having”, and any variations thereof, in the specification, claims, and foregoing description of the drawings are intended to cover non-exclusive inclusion.
[0021] In the description of the embodiments of this application, technical terms such as "first" and "second" are used only to distinguish different objects and should not be construed as indicating or implying relative importance or implicitly specifying the number, specific order, or primary and secondary relationship of the indicated technical features. In the description of the embodiments of this application, "multiple" means two or more, unless otherwise explicitly defined.
[0022] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0023] In the description of the embodiments in this application, the term "and / or" is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, and B existing alone. Additionally, the character " / " in this document generally indicates that the preceding and following related objects have an "or" relationship.
[0024] In the description of the embodiments of this application, the term "multiple" refers to two or more (including two), similarly, "multiple sets" refers to two or more (including two sets), and "multiple pieces" refers to two or more (including two pieces).
[0025] In the description of the embodiments of this application, unless otherwise expressly specified and limited, technical terms such as "installation," "connection," "joining," and "fixing" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral part; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; they can refer to the internal communication of two components or the interaction between two components. For those skilled in the art, the specific meaning of the above terms in the embodiments of this application can be understood according to the specific circumstances.
[0026] See Figure 1 To address the inefficiency caused by using traditional locking mechanisms in existing transaction processing technologies, one embodiment of the present invention provides a distributed transaction processing method, applicable to a dispatcher, comprising: Step S101: Obtain transaction processing information of the current pending transaction; wherein, the transaction initiator obtains the transaction processing information of the current pending transaction after receiving the transaction request signal of the current pending transaction, determines the dispatcher for dispatching the current pending transaction based on the transaction processing information, and transmits the transaction processing information to the dispatcher; the transaction processing information includes: timestamp. Specifically, the aforementioned pending transactions and transaction request signals are generated by the client. The transaction processing information includes the data needed to process the transaction, as well as the transaction ID. The transaction ID consists of a timestamp, a counter, a partition ID, and a reserved bit. The timestamp has 40 bits, representing the number of milliseconds since the epoch of the database where the dispatcher resides; the counter has 9 bits, used to generate multiple unique IDs within the same millisecond; the partition ID has 14 bits, used to identify the partition from which the ID was generated; and the reserved bit has 1 bit for future expansion. The aforementioned first transaction information is used to process the corresponding transaction. After receiving the transaction request signal, the transaction initiator generates the corresponding transaction ID based on the current timestamp.
[0027] Specifically, the database mentioned above is ShuangzhaoDB, which uses ZooKeeper to manage the server cluster. Each server host is a node in the ShuangzhaoDB database, and the number of sites deployed on each node is determined by the number of CPU cores. All sites do not share any data or database schema. Each site runs a unique ShuangzhaoDB execution engine thread, managing all data on that site. Each site uses independent CPU and memory, and communication between sites is only through the network. A schematic diagram of the ShuangzhaoDB database architecture is shown below. Figure 2 As shown. Figure 2Each Site stores a copy of a specific partition and the transaction execution engine. Message network communication is configured on each node. Among these copies, a dispatcher is selected according to rules. The "single partition scheduler" within a partition contains the aforementioned dispatcher, while the "multi-partition initializer" is the aforementioned transaction initiator, and the "execution site" is the site used to execute each transaction.
[0028] Specifically, before starting the ShuangzhaoDB database, a sufficient understanding of the application domain is required, and all possible database processing should be pre-written. ShuangzhaoDB provides a Java interface for writing stored procedures; users need to use Java programs to write stored procedures. The ShuangzhaoDB database supports the full SQL-99 standard for data operations. When the ShuangzhaoDB database starts, it will retrieve existing stored procedures from the specified directory according to the configuration file. ShuangzhaoDB will then compile and parse all database processing instructions in the stored procedures to generate relevant execution plans and execution plan fragments to improve transaction execution efficiency.
[0029] Step S102: Based on the above transaction processing information, determine the target site for processing the current pending transaction, and send the above transaction processing information to the target site so that the target site waits for a preset period of time after receiving the above transaction processing information; Specifically, the exact duration of the aforementioned preset time period is determined based on the communication duration between the target site and other sites.
[0030] In a preferred embodiment, determining the target site for processing the current pending transaction based on the transaction processing information and sending the transaction processing information to the target site includes: Extract the table names of all tables currently pending processing from the above transaction processing information; Based on the table names and the preset table metadata database, determine the type of each table; among which, the above types include: partitioned tables and replicated tables; If all tables are of type replicated tables, determine the target site for the current pending transaction based on all replicated tables, and allocate the transaction processing information to the target site. Specifically, the dispatcher will determine whether a transaction is for a single partition or involves multiple partitions based on the stored procedure information in the transaction processing information. If the stored procedure only involves copying tables, then the transaction is a single-partition transaction; if it involves partitioned tables, then the transaction is a multi-partition transaction.
[0031] If a partition table exists in the above table, the current pending transaction is divided into several transaction segments according to each partition table, and the target site for processing each transaction segment is determined according to each partition table; the transaction processing information corresponding to each transaction segment is allocated to the corresponding target site.
[0032] Specifically, after dividing the current pending transaction into several transaction segments, the transaction ID in the transaction processing information corresponding to each transaction segment is still the transaction ID of the corresponding pending transaction.
[0033] Specifically, ShuangzhaoDB supports two types of database tables: replicated tables and partitioned tables. Generally, tables in ShuangzhaoDB are replicated tables by default. This means that ShuangzhaoDB stores multiple copies of the table's data across multiple sites. The specific number of copies is determined by the `k-safety` parameter in the ShuangzhaoDB configuration file, and the number of copies is `K-safety+1`. All copies use a master-master backup mode, meaning that all copies can handle client data requests. After a copy has processed a data request, the site will synchronize the data to other sites as needed. Replicated tables are often used for data with relatively little content but requiring frequent queries.
[0034] Specifically, for data tables that require frequent updates, ShuangzhaoDB uses partitioned tables to store data. The DDL syntax for creating partitions is as follows: CREATE TABLE votes (phone_number BIGINT NOT NULL, contestant_nameVARCHAR(50) NOT NULL, vote_timestamp TIMESTAMP DEFAULT NOW() NOT NULL,PRIMARY KEY (phone_number, contestant_name));PARTITION TABLE votes ON COLUMNphone_number; Specifically, the ShuangzhaoDB cluster will partition and store data based on the partition column. The number of partitions for each table is calculated as: number of hosts * number of sites per host / (K - safety + 1). In principle, each node stores only one copy of a specific partition of the partitioned table. During data storage or retrieval, ShuangzhaoDB will use a distributed hash algorithm to determine the partition containing the data to be retrieved.
[0035] In this preferred embodiment, the target site for processing the aforementioned current pending transaction is determined based on the transaction processing information, and the transaction processing information is allocated to the corresponding target site for processing.
[0036] Step S103: If the target site does not receive new transaction processing information within the preset time period, then process the transaction according to the transaction processing information, obtain the transaction processing result and feed it back; otherwise, take the current pending transaction and the new pending transaction received within the preset time period as the target processing transaction, sort the transaction processing order according to the timestamp corresponding to the target processing transaction, process each target processing transaction in sequence according to the transaction processing information of the target processing transaction, obtain the transaction processing result of each target processing transaction and feed it back. Specifically, the target site sends the transaction processing result back to the dispatcher, which then performs subsequent feedback operations.
[0037] Specifically, whether it is a single-partition transaction or a multi-partition transaction, the target site processes the transaction according to the above procedure after receiving the transaction to be processed.
[0038] Specifically, all pending transactions received within a preset time period are sorted chronologically based on timestamps and then processed sequentially. (Illustrative example) Figure 2 Data processing is performed within the "SQL execution layer".
[0039] Preferably, isolation measures that fully serialize transaction execution eliminate the need for lock requests and unlocks during transaction execution, thereby significantly improving transaction execution efficiency.
[0040] Step S104: Provide feedback on the results based on the transaction processing results described above.
[0041] In a preferred embodiment, the above-mentioned result feedback based on the transaction processing result includes: Retrieve the transaction processing results from all target sites corresponding to the currently pending transaction; All transaction processing results are merged to obtain the final transaction processing result of the current pending transaction, and the final transaction processing result is fed back to the transaction initiator mentioned above.
[0042] Specifically, for single-partition transactions, after the target site completes its transaction processing, the result at that point is the final result of the current pending transaction, which it then sends back to the dispatcher. The dispatcher will handle the subsequent feedback process. For multi-partition transactions, after the dispatcher's site completes its own portion of the transaction, it will not commit the result temporarily, and will continue executing its other transactions, assuming these other transactions will not affect the execution of subsequent transactions. When the dispatcher's site receives the execution results from other target sites, it will merge these results with its own and send them back as the final result of the current pending transaction.
[0043] In this preferred embodiment, the dispatcher integrates the transaction processing results from all target sites of the currently pending transaction before feeding back the final transaction processing result.
[0044] In a preferred embodiment, it further includes: If any target site fails to provide the corresponding transaction processing result within the preset timeout period, a timeout signal will be sent to the transaction initiator.
[0045] Specifically, a timeout flag is set for all sites. If the corresponding transaction processing result is not received within the timeout period, a corresponding timeout response is sent back to the transaction initiator.
[0046] Preferably, when a failure occurs, for single-partition transactions, the transaction initiator collects repair logs from all SPI replicas. These logs include the transaction IDs and execution details of all executed transactions on the site. The initiator also tracks the handle of the largest single-replica transaction in each replica. After comparison, the transaction initiator sends the transactions that need to be re-executed based on the missing transaction numbers in each replica, thereby minimizing network traffic. For multi-partition transactions, the transaction initiator collects repair logs from all MPI replicas and then updates the hash partition manager to the latest version to ensure that partition information is up-to-date. The transaction initiator collects the set of all transactions from the repair logs, and then sends a complete transaction message to all replicas to ensure consistency.
[0047] In this preferred embodiment, a timeout is determined based on a preset timeout period to indicate whether the transaction processing has timed out, and a timeout signal is sent back to the transaction initiator.
[0048] In another preferred embodiment, it further includes: If a transaction restart signal is received when the above transaction processing information is sent to the above target site, a new target site will be determined for the current pending transaction.
[0049] Specifically, if an error occurs when routing a transaction to the relevant Site, the dispatcher will receive a message to restart the transaction. Upon receiving this message, it will reprocess the transaction request and reselect the routing target (i.e., reselect the target site).
[0050] Preferably, the ShuangzhaoDB data cluster also utilizes ZooKeeper cluster management to improve the reliability of the database cluster. When a ShuangzhaoDB host fails for some reason and is unable to complete processing, ZooKeeper will detect an abnormal heartbeat on that host, thus triggering a host failure. ZooKeeper will trigger different operations depending on whether the host is the leader. If the host is the leader, a leader election mechanism will be triggered; if the host is not the leader, ShuangzhaoDB will initiate a dynamic balancing mechanism to complete the data migration based on the host's status.
[0051] In this preferred embodiment, if an error occurs when allocating a transaction, a new target site needs to be selected to process the corresponding transaction.
[0052] In another preferred embodiment, after obtaining the transaction processing result, the method further includes: The target site generates and stores the transaction processing logs corresponding to the transaction processing results.
[0053] Specifically, after execution, the target site will generate and store relevant log records. Figure 2 Within the "data storage layer".
[0054] Preferably, by recording logs, in the event of a failure, the transactions that need to be re-executed can be identified from the logs, thereby minimizing network traffic.
[0055] Based on the above method embodiments, the present invention provides corresponding apparatus embodiments; like Figure 3 As shown, one embodiment of the present invention provides a distributed transaction processing system, including: Dispatcher, target site, and transaction initiator; The aforementioned transaction initiator is used to, upon receiving a transaction request signal from a currently pending transaction, obtain the transaction processing information of the currently pending transaction, determine the dispatcher for dispatching the currently pending transaction based on the aforementioned transaction processing information, and transmit the aforementioned transaction processing information to the aforementioned dispatcher; wherein, the aforementioned transaction processing information includes: a timestamp. The dispatcher described above is used to obtain transaction processing information of the current pending transaction; based on the transaction processing information, it determines the target site for processing the current pending transaction and sends the transaction processing information to the target site. The aforementioned target station is used to wait for a preset period of time after receiving the aforementioned transaction processing information; if no new transaction processing information is received within the aforementioned preset period of time, the station performs transaction processing based on the aforementioned transaction processing information to obtain a transaction processing result; otherwise, the station takes the current pending transaction and the new pending transaction received within the aforementioned preset period of time as target processing transactions, sorts the transaction processing order according to the timestamps corresponding to the target processing transactions, processes each target processing transaction in sequence according to the transaction processing information of the target processing transactions, obtains the transaction processing result of each target processing transaction, and sends the transaction processing result to the dispatcher. The dispatcher described above is also used to provide feedback on the results of the transaction processing described above.
[0056] In a preferred embodiment, the dispenser is further configured to: Extract the table names of all tables currently pending processing from the above transaction processing information; Based on the table names and the preset table metadata database, determine the type of each table; among which, the above types include: partitioned tables and replicated tables; If all tables are of type replicated tables, determine the target site for the current pending transaction based on all replicated tables, and allocate the transaction processing information to the target site. If a partition table exists in the above table, the current pending transaction is divided into several transaction segments according to each partition table, and the target site for processing each transaction segment is determined according to each partition table; the transaction processing information corresponding to each transaction segment is allocated to the corresponding target site.
[0057] In another preferred embodiment, the dispenser is further used for: Retrieve the transaction processing results from all target sites corresponding to the currently pending transaction; All transaction processing results are merged to obtain the final transaction processing result of the current pending transaction, and the final transaction processing result is fed back to the transaction initiator mentioned above.
[0058] In another preferred embodiment, the dispenser is further used for: If any target site fails to provide the corresponding transaction processing result within the preset timeout period, a timeout signal will be sent to the transaction initiator.
[0059] It should be noted that the device embodiments described above are merely illustrative. The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Furthermore, in the accompanying drawings of the device embodiments provided by this invention, the connection relationships between modules indicate that they have communication connections, which can be implemented as one or more communication buses or signal lines. Those skilled in the art can understand and implement this without creative effort. The above schematic diagrams are merely examples of a distributed transaction processing system and do not constitute a limitation on a distributed transaction processing system. It may include more or fewer components than illustrated, or combine certain components, or use different components.
[0060] The above are preferred embodiments of the present invention. It should be noted that, for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications are also considered to be within the scope of protection of the present invention.
Claims
1. A distributed transaction processing method, characterized in that, Suitable for dispensers, including: Obtain transaction processing information of the current pending transaction; wherein, the transaction processing information is obtained by the transaction initiator after receiving the transaction request signal of the current pending transaction, and the dispatcher for dispatching the current pending transaction is determined according to the transaction processing information, and the transaction processing information is transmitted to the dispatcher; the transaction processing information includes: timestamp; Based on the transaction processing information, a target site for processing the current pending transaction is determined, and the transaction processing information is sent to the target site so that the target site waits for a preset period of time after receiving the transaction processing information; If the target site does not receive new transaction processing information within the preset time period, it performs transaction processing based on the transaction processing information, obtains the transaction processing result, and feeds it back; otherwise, it takes the current pending transaction and the new pending transaction received within the preset time period as target processing transactions, sorts the transaction processing order according to the timestamp corresponding to the target processing transactions, processes each target processing transaction in sequence according to the transaction processing information of the target processing transactions, obtains the transaction processing result of each target processing transaction, and feeds it back. Feedback will be provided based on the transaction processing results.
2. The distributed transaction processing method according to claim 1, characterized in that, The step of determining the target site for processing the current pending transaction based on the transaction processing information, and sending the transaction processing information to the target site, includes: Extract the table names of all tables in the current pending transaction from the transaction processing information; Based on the table name and the preset table metadata database, determine the type of each table; wherein, the types include: partitioned tables and replicated tables; If all tables are of type replicated tables, determine the target site for the current pending transaction based on all replicated tables, and allocate the transaction processing information to the target site. If a partition table exists in the table, the current transaction to be processed is divided into several transaction segments according to each partition table, and the target site for processing each transaction segment is determined according to each partition table; the transaction processing information corresponding to each transaction segment is allocated to the corresponding target site.
3. The distributed transaction processing method according to claim 2, characterized in that, The step of providing result feedback based on the transaction processing result includes: Retrieve the transaction processing results from all target sites corresponding to the currently pending transaction; All transaction processing results are merged to obtain the final transaction processing result of the current pending transaction, and the final transaction processing result is fed back to the transaction initiator.
4. The distributed transaction processing method according to claim 3, characterized in that, Also includes: If any target site fails to provide the corresponding transaction processing result within the preset timeout period, a timeout signal is sent to the transaction initiator.
5. A distributed transaction processing method according to claim 4, characterized in that, Also includes: If a transaction restart signal is received when the transaction processing information is sent to the target site, a new target site is determined for the current pending transaction.
6. The distributed transaction processing method according to claim 5, characterized in that, After obtaining the transaction result, it also includes: The target site generates and stores the transaction processing log corresponding to the transaction processing result.
7. A distributed transaction processing system, characterized in that, include: Dispatcher, target site, and transaction initiator; The transaction initiator is configured to, upon receiving a transaction request signal for a currently pending transaction, obtain transaction processing information for the currently pending transaction, determine a dispatcher for dispatching the currently pending transaction based on the transaction processing information, and transmit the transaction processing information to the dispatcher; wherein, the transaction processing information includes: a timestamp; The dispatcher is used to obtain transaction processing information of the current pending transaction; determine the target site for processing the current pending transaction based on the transaction processing information, and send the transaction processing information to the target site. The target station is configured to wait for a preset period of time after receiving the transaction processing information; if no new transaction processing information is received within the preset period of time, the station will process the transaction according to the transaction processing information to obtain the transaction processing result; otherwise, the station will take the current pending transaction and the new pending transaction received within the preset period of time as target processing transactions, sort the transaction processing order according to the timestamp corresponding to the target processing transactions, process each target processing transaction in sequence according to the transaction processing information of the target processing transactions, obtain the transaction processing result of each target processing transaction, and send the transaction processing result to the dispatcher. The dispatcher is also used to provide result feedback based on the transaction processing result.
8. A distributed transaction processing system according to claim 7, characterized in that, The dispenser is also used for: Extract the table names of all tables in the current pending transaction from the transaction processing information; Based on the table name and the preset table metadata database, determine the type of each table; wherein, the types include: partitioned tables and replicated tables; If all tables are of type replicated tables, determine the target site for the current pending transaction based on all replicated tables, and allocate the transaction processing information to the target site. If a partition table exists in the table, the current transaction to be processed is divided into several transaction segments according to each partition table, and the target site for processing each transaction segment is determined according to each partition table; the transaction processing information corresponding to each transaction segment is allocated to the corresponding target site.
9. A distributed transaction processing system according to claim 8, characterized in that, The dispenser is also used for: Retrieve the transaction processing results from all target sites corresponding to the currently pending transaction; All transaction processing results are merged to obtain the final transaction processing result of the current pending transaction, and the final transaction processing result is fed back to the transaction initiator.
10. A distributed transaction processing system according to claim 9, characterized in that, The dispenser is also used for: If any target site fails to provide the corresponding transaction processing result within the preset timeout period, a timeout signal is sent to the transaction initiator.