Distributed transaction processing method, system and device and storage medium
By parsing the business semantic features of distributed transaction requests, creating a transaction list, dynamically matching compensation strategies, and automatically generating compensation vouchers, the problem of manually writing compensation logic in existing technologies is solved, realizing automated distributed transaction processing and loosely coupled development.
Patent Information
- Application Number
- CN202511762888.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-27
- Publication Date
- 2026-03-24
AI Technical Summary
Existing distributed transaction solutions lack a deep understanding of business semantics, resulting in the need to manually write compensation logic, which is highly coupled with business code and difficult to adapt to complex business semantics.
By parsing the business semantic features of distributed transaction requests, a list of distributed transactions is created, and the target compensation strategy is dynamically matched based on the compensation strategy library to automatically generate compensation vouchers, reducing the need for manual writing of requirements and lowering development complexity.
It enables automated processing of distributed transaction compensation logic without relying on specific business implementation code, reducing development complexity and labor costs, and supporting adaptive changes in business logic iterations and the addition of new features.
Smart Images

Figure CN121722486A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of computer software, and in particular to a distributed transaction processing method, system, device and storage medium. BACKGROUND
[0002] With the rapid development of Internet technology, distributed systems have become the core architecture to support large business scenarios, such as order payment of e-commerce platforms, cross-account transfer of financial systems, and order fulfillment of logistics networks. These businesses all need to be processed collaboratively across multiple independent service nodes or databases.
[0003] However, some mainstream distributed transaction solutions currently available provide a transaction management framework, but the transaction management framework lacks deep perception and understanding of business semantics. They still require developers to manually write and deploy corresponding compensation rollback operations for each forward business operation based on their understanding of business logic. This not only means that simple data state rollback needs to be implemented, but developers also need to maintain business context, coordinate the interaction state of external systems, and handle complex data version control in the compensation logic. For example, in a scenario involving multi-level financial audit, performing a cancellation operation on a certain voucher may require updating the state of multiple associated subsystems and strictly following specific accounting period rules. Such complex business semantics and compensation logic are difficult to cover completely and reliably through manual coding. SUMMARY
[0004] The present application provides a distributed transaction processing method, system, device and storage medium to solve the technical problems that compensation logic needs to be manually written, has high coupling with business code, and is difficult to adapt to complex business semantics in the prior art.
[0005] The first aspect of the present application provides a distributed transaction processing method, the method comprising: receiving a distributed transaction request and analyzing the business semantic features of the distributed transaction; creating a distributed transaction list and adding the business semantic features to the transaction list, the transaction list including a plurality of execution commands, each execution command containing business semantic features, and each execution command corresponding to a transaction operation; based on the distributed transaction list, sending instructions to each transaction server to execute local transactions and obtaining the local transaction execution results returned by each transaction server; when all local transaction execution results are successful, sending a pre-commit request to all transaction servers and collecting the pre-commit request feedback results of each transaction server; According to the pre-commit request feedback result, a transaction commit operation or a transaction compensation operation is performed, the transaction commit operation comprising issuing a commit instruction to each transaction server; and the transaction compensation operation comprising dynamically matching a target compensation strategy from a compensation strategy library based on the business semantic feature, and automatically generating and performing a compensation voucher according to the target compensation strategy.
[0006] Optionally, the performing of the transaction commit operation or the transaction compensation operation according to the pre-commit request feedback result comprises: performing a transaction operation according to the pre-commit request feedback result; when all the collected pre-commit request feedback results are agree to commit, the transaction commit operation is performed; when there is at least one pre-commit request commit failure or timeout, the transaction compensation operation is performed.
[0007] Optionally, the dynamically matching of the target compensation strategy from the compensation strategy library comprises: acquiring a plurality of candidate compensation strategies from the compensation strategy library based on the business semantic feature; comprehensively scoring each candidate compensation strategy based on a multi-dimensional scoring model, the scoring dimensions comprising a business impact range, an execution cost, a risk assessment result, and a historical success rate; determining the target compensation strategy from the plurality of candidate compensation strategies based on the comprehensive scoring result.
[0008] Optionally, the comprehensive scoring of each candidate compensation strategy based on the multi-dimensional scoring model comprises: configuring a weight for each scoring dimension, and calculating a score of each candidate compensation strategy in each scoring dimension; weighting and summing the scores of each candidate compensation strategy in each scoring dimension based on the weight, to obtain a comprehensive score of the candidate compensation strategy.
[0009] Optionally, the automatically generating and performing of the compensation voucher according to the target compensation strategy comprises: matching a target voucher template from a voucher template library according to the target compensation strategy and the business semantic feature; automatically calculating a compensation amount and generating a voucher abstract describing a compensation reason based on business data recorded in the distributed transaction list; filling the compensation amount and the voucher abstract into the target voucher template to generate compensation voucher data.
[0010] Optionally, the analyzing of the business semantic feature of the distributed transaction comprises: extracting business metadata in the distributed transaction request; The business metadata is standardized, and a mapping relationship between the business semantic features and the distributed transaction processing rules is established.
[0011] Optionally, the pre-commit request is sent to all the transaction servers in a parallel sending manner.
[0012] The second aspect of the present application provides a distributed transaction processing system, and the system comprises: A semantic analysis unit is configured to receive a distributed transaction request and analyze business semantic features of the distributed transaction. A transaction management unit is configured to create a distributed transaction list and add the business semantic features to the transaction list, wherein the transaction list comprises a plurality of execution commands, each of the execution commands comprises business semantic features, and each execution command corresponds to a transaction operation. A transaction preparation unit is configured to send an instruction to each transaction server based on the distributed transaction list to execute a local transaction and obtain a local transaction execution result returned by each transaction server. A pre-commit processing unit is configured to send a pre-commit request to all the transaction servers when all the local transaction execution results are successful, and collect a pre-commit request feedback result of each transaction server. A transaction operation unit is configured to execute a transaction commit operation or a transaction compensation operation according to the pre-commit request feedback result, wherein the transaction commit operation comprises issuing a commit instruction to each transaction server, and the transaction compensation operation comprises dynamically matching a target compensation strategy from a compensation strategy library based on the business semantic features and automatically generating and executing a compensation voucher according to the target compensation strategy.
[0013] The third aspect of the present application provides a distributed transaction processing device, and the device comprises: A processor, a memory, an input / output unit and a bus; The processor is connected with the memory, the input / output unit and the bus; The memory stores a program, and the processor invokes the program to execute the method of the first aspect and any optional distributed transaction processing in the first aspect.
[0014] The fourth aspect of the present application provides a computer readable storage medium, and the computer readable storage medium stores a program, and the program is executed on a computer to execute the method of the first aspect and any optional distributed transaction processing in the first aspect.
[0015] As can be seen from the above technical solutions, the present application has the following advantages: The distributed transaction processing method provided in the application can automatically generate and execute compensation vouchers by analyzing the business semantic features in the distributed transaction request and dynamically matching a target compensation strategy from a compensation strategy library based on the features, thereby reducing the mode of manually writing compensation logic and reducing development complexity and labor costs; by creating a distributed transaction list as a core carrier for transaction processing, the list uniformly carries standardized business semantic features, execution states of each transaction server, operation timing and other key information, so that the transaction coordination and compensation mechanism no longer depends on specific business implementation code, but is based on a unified and standardized understanding of business semantics. When the business logic is iteratively changed or new business functions are added, as long as the semantic features of the new business are clarified and updated to the transaction list, the underlying compensation processing framework can adapt to the new scenario without any modification or rewriting, effectively solving the problem of deep coupling between compensation logic and core business code in the prior art. BRIEF DESCRIPTION OF DRAWINGS
[0016] In order to more clearly illustrate the technical solutions in the application, the drawings needed in the embodiments will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the application, and other drawings can be obtained by those skilled in the art without creative labor.
[0017] Figure 1 A flowchart of an embodiment of the distributed transaction processing provided in the application; Figure 2 A flowchart of an embodiment of the trigger condition for executing a transaction commit operation and a transaction compensation operation in the distributed transaction processing provided in the application; Figure 3 A flowchart of an embodiment of dynamically matching a target compensation strategy in the distributed transaction processing provided in the application; Figure 4 A flowchart of an embodiment of automatically generating a compensation voucher in the distributed transaction processing provided in the application; Figure 5 A structural diagram of an embodiment of the distributed transaction processing system provided in the application; Figure 6 A structural diagram of an embodiment of the distributed transaction processing device provided in the application. DETAILED DESCRIPTION
[0018] It should be noted that the method, device and storage medium provided by the present application can be applied to a terminal, a system and a server. For example, the terminal can be a smart phone or a computer, a tablet computer, a smart television, a smart watch, a portable computer terminal, and a fixed terminal such as a desktop computer. For convenience of description, the terminal is taken as an example in the present application.
[0019] Please refer to Figure 1 , Figure 1 A flowchart of an embodiment of the distributed transaction processing provided by the present application is shown in the figure. The embodiment includes the following steps. S101, receiving a distributed transaction request and analyzing the business semantic features of the distributed transaction; The distributed transaction request from the client needs to carry complete data related to the business operation. For example, in the financial scenario, the key information includes transaction type, transaction amount, involved accounting subject code, business document number, operation time mark, participant identification, and approval status. Then, based on the preset metadata extraction rule, the core business metadata is extracted from the above request, the redundant format data and irrelevant fields are removed, the extracted business metadata is standardized, the data format difference and semantic ambiguity are eliminated, for example, the expressions such as “payment”, “transfer payment”, and “payment” input by different clients are uniformly standardized as “payment transaction”, and the accounting subject code is uniformly coded according to the enterprise accounting standards and internal financial system. The inconsistent expression leads to subsequent processing deviation.
[0020] After analyzing the business semantic features, the association between the standardized business semantic features and the distributed transaction processing rules is established. The processing rules include transaction execution priority, data consistency requirement level, and compensation logic trigger condition, which provide standardized basis for compensation strategy matching and compensation voucher generation.
[0021] S102, creating a distributed transaction list, adding the business semantic features to the transaction list, the transaction list including a plurality of execution commands, each execution command containing the business semantic features, and each execution command corresponding to a transaction operation; A basic framework of the transaction list is constructed according to a preset standardized format, and the framework needs to include fixed fields and extended fields. The fixed fields are used to carry general information of the transaction, such as the creation time of the list, the overall state of the transaction, and the global transaction identifier, and the extended fields are used to reserve bits of personalized information of the business. The parsed standardized business semantic features are added to the transaction list, and the semantic feature information is regularized according to the preset field structure, such as in the transaction list of the financial scenario, the semantic type, the core parameter, the consistency requirement, and the compensation trigger condition are explicitly recorded. According to the overall business goal of the distributed transaction, the transaction is split into a plurality of independent execution commands, and each execution command corresponds to a specific transaction operation. Taking the financial cross-border procurement payment transaction as an example, the execution commands can be split into “deducting the balance of the procurement account”, “increasing the supplier's receivables”, and “generating a temporary financial voucher record”. Meanwhile, the corresponding business semantic sub-features are embedded in each execution command, such as the semantic sub-features associated with the deduction of the procurement account include the expenditure transaction, the procurement account, the corresponding amount, and the cross-border attribute.
[0022] The transaction list with filled information is subjected to multi-dimensional verification, and the verification content includes information integrity, whether the semantic sub-features of each execution command are consistent with the overall business semantic features, and the like, to ensure the correctness of the list.
[0023] S103, based on the distributed transaction list, an instruction is sent to each transaction server to execute a local transaction, and a local transaction execution result returned by each transaction server is obtained; All execution commands and corresponding semantic sub-features are extracted from the distributed transaction list, and a dedicated local transaction execution instruction is generated for each transaction server. The instruction includes a global transaction identifier, an execution command content, a semantic sub-feature, an execution parameter, and a data consistency requirement level. The instruction is sent to all transaction servers simultaneously using a parallel communication mechanism. For high-priority transactions marked in the list, a resource pre-allocation request is sent to the nodes in advance to reserve computing cores, database locks, and other resources. The execution is triggered after receiving the confirmation feedback from all transaction servers.
[0024] After receiving the instruction, each transaction server first verifies the legality of the instruction through the global transaction identifier and the locally cached list copy, and then executes the operation based on the semantic sub-feature by calling the local transaction manager. During the execution process, logs are recorded in real time, including the instruction receiving and execution time, the execution state, the data snapshot, and the failure reason. After the execution is completed, the transaction server feeds back the result to the local transaction through an asynchronous callback mechanism.
[0025] S104, when all local transaction execution results are successful, a pre-commit request is sent to all transaction servers, and pre-commit request feedback results of each transaction server are collected; Only when all execution commands are successful and the node state is normal, the pre-commit process is formally triggered, the terminal generates a standardized pre-commit request based on the distributed transaction list, which contains the global transaction identifier, the pre-commit validity period dynamically set according to the transaction priority and business attribute; the pre-commit request is distributed using batch parallel communication technology, all server requests are integrated into a batch data packet and compressed to reduce transmission overhead, and sent to all transaction servers in parallel through multiple links, if the request transmission of a server fails, it will be immediately retried through the backup link to ensure that all servers can receive the request.
[0026] After each transaction server receives the request, it continues to collect feedback results within the pre-commit validity period and records them in the "pre-commit feedback state" field of the transaction list, if all servers receive "agree to commit" within the validity period, it is marked as pre-commit success, if there is "refuse to commit", it is directly marked as failure, if the feedback is not received within the timeout, the unfeedback server is started for fault detection, and finally the pre-commit result is synchronized and updated to the transaction list, providing a basis for subsequent execution of commit or compensation operation.
[0027] S105, according to the pre-commit request feedback result, execute transaction commit operation or transaction compensation operation, the transaction commit operation includes issuing commit instruction to each transaction server; the transaction compensation operation includes dynamically matching target compensation strategy from compensation strategy library based on business semantic characteristics, and automatically generating and executing compensation voucher according to target compensation strategy.
[0028] Read the "pre-commit feedback state" field in the distributed transaction list to determine the pre-commit result, if all transaction servers feedback "agree to commit" and there is no exception, it is determined as "pre-commit success" and triggers the transaction commit operation, if there is "refuse to commit" or timeout and node exception, it is determined as "pre-commit failure" and triggers the transaction compensation operation, and the determination result is updated to the list "transaction overall state" field.
[0029] When the commit operation is triggered, the terminal generates a standardized commit instruction containing the global transaction identifier, the commit time mark and the data final confirmation mark based on the list, and distributes it to all servers using batch parallel communication mechanism combined with link multiplexing and data compression technology, if the transmission fails, it will be retried through the backup link, each server receives and verifies the legality of the instruction, executes the local transaction final confirmation and releases the pre-commit reserved resources, and then feeds back "commit success" to the terminal, after collecting all feedback, the list state is updated to "committed" and the whole process log is persisted, if the feedback is not received within the timeout, the node state is confirmed and the data is repaired through fault detection.
[0030] When triggering the compensation operation, the business semantic features are extracted from the list, candidate strategies are screened from the compensation strategy library, a target compensation strategy is selected through multi-dimensional weighted scoring of business impact range, execution cost, risk assessment result and historical success rate and written into the list, an adaptive template is matched from the voucher template library, the compensation amount is reversely calculated by the amount calculation engine combined with the list information, the compensation subject is matched by the subject mapping algorithm, the voucher abstract is generated by the natural language generation technology, the structured compensation voucher containing traceability information is assembled according to the template, and then it is distributed to each server in parallel. The server checks the legality of the voucher, executes the compensation operation and records the log after the legality of the voucher is checked, verifies the data consistency through global hash checking, triggers at most three retries if the compensation fails, triggers manual alarm if the retry fails, and finally updates the list state to "compensation completed" and persists the compensation related information when the compensation is successful and the data is consistent, thereby ensuring the consistency of the data.
[0031] In the embodiment, by analyzing the business semantic features in the distributed transaction request and dynamically matching the target compensation strategy from the compensation strategy library based on the features, the terminal can automatically generate and execute the compensation voucher, thereby reducing the mode of manually writing compensation logic, reducing development complexity and labor cost; by creating a distributed transaction list as the core carrier of transaction processing, the list uniformly carries the standardized business semantic features, the execution status of each transaction server, the operation time sequence and other key information, so that the transaction coordination and compensation mechanism no longer depends on specific business implementation code, but is based on the unified and standardized understanding of business semantics. When the business logic is iteratively changed or new business functions are added, as long as the semantic features of the new business are clarified and updated to the transaction list, the underlying compensation processing framework can adapt to the new scenario without any modification or rewriting, thereby effectively solving the problem of deep coupling between compensation logic and core business code in the prior art.
[0032] The triggering conditions for executing the transaction submission operation and the transaction compensation operation will be described in detail below. Please refer to Figure 2 , Figure 2 The flowchart of an embodiment of the triggering conditions for executing the transaction submission operation and the transaction compensation operation in the distributed transaction processing, and the embodiment comprises: S201, executing the transaction operation according to the pre-commit request feedback result; Read the full amount of information in the "pre-commit feedback state" field in the distributed transaction list, and make a comprehensive judgment on the pre-commit request feedback result. The judgment process is the core link of connecting the pre-commit process and the subsequent transaction operation. When judging, the explicit feedback result of each transaction server, the feedback integrity within the pre-commit validity period, and the fault detection result of the server that has not fed back within the timeout period need to be combined. Based on the above information, make a global comprehensive evaluation, determine the unique type of pre-commit result, and trigger the corresponding transaction operation based on it, to ensure that each pre-commit result corresponds to only one transaction operation, reducing operation conflicts or missed execution.
[0033] S202, when all the pre-commit request feedback results collected are agreed to commit, the transaction commit operation is executed; When all transaction servers return "agree to commit" feedback within the pre-commit validity period, and no node is in a fault or abnormal state, the pre-commit result is determined to be "agree to commit", and the transaction commit operation is triggered. The terminal updates the "transaction operation to be executed identifier" in the distributed transaction list to "commit operation", and synchronously updates the "transaction overall state" to "to be finally committed"; based on the distributed transaction list, a standardized commit instruction is generated, which includes the global transaction identifier, the commit time mark, and the data final confirmation identifier.
[0034] The commit instruction is distributed through a batch parallel communication mechanism. If the instruction transmission of a server fails, it is retried through a backup link to ensure that all servers participating in the transaction can receive the instruction; after receiving the instruction, each transaction server executes the local transaction final confirmation operation, releases the database locks, temporary storage areas and other resources reserved in the pre-commit stage, and returns "commit success" confirmation information to the terminal after the execution is completed.
[0035] After the terminal collects all the returned "commit success" feedback, it updates the "transaction overall state" in the distributed transaction list to "committed", and persists the pre-commit feedback result, the commit instruction log, and the execution result of each server to the distributed transaction log storage module. If the terminal does not receive the commit feedback of a server within the timeout period, it confirms the node state through the fault detection mechanism, re-sends the commit instruction if the node is normal, and repairs the data of the node based on the consistent data snapshot of other nodes if the node is abnormal.
[0036] S203, when there is at least one pre-commit request commit failure or timeout, the transaction compensation operation is executed.
[0037] When any transaction server returns "reject commit" feedback, or the server does not feedback within the pre-commit validity period and the fault detection confirms that the node is abnormal, or the timeout does not collect all feedback and still cannot obtain valid feedback after retrying, it is determined that the pre-commit result is "non-full quantity agreed to commit", and the transaction compensation operation is triggered. The terminal updates the "transaction operation to be executed identifier" in the distributed transaction list to "compensation operation", and synchronously updates the "transaction overall state" to "to be compensated".
[0038] The standardized business semantic features of the current transaction are extracted from the distributed transaction list, the adaptive candidate compensation strategies are screened from the compensation strategy library based on the features, the strategy with the highest comprehensive score is selected as the target compensation strategy through multi-dimensional weighted scoring of business impact range, execution cost, risk assessment result and historical success rate, and the target compensation strategy identifier and core parameters are written into the "compensation information" field of the distributed transaction list. The standardized voucher template corresponding to the target compensation strategy and the business semantic features is matched from the voucher template library, the compensation amount is calculated reversely through the original transaction data in the distributed transaction list, the amount calculation engine, the compensation accounting subject is matched through the subject mapping algorithm, and the voucher abstract is generated through the natural language generation technology. The structured compensation voucher containing the global transaction identifier, the compensation strategy identifier and the original transaction associated information is assembled according to the template field format. The compensation voucher is sent to all servers participating in the original transaction through the batch parallel communication mechanism, and the compensation information in the distributed transaction list is synchronously transmitted during the distribution process.
[0039] If all node data checks are consistent, it is determined that "compensation is successful", and the "transaction overall state" in the distributed transaction list is updated to "compensation completion". If the compensation operation of a server fails, the terminal triggers the retry mechanism at most three times, and records the fault information to the distributed transaction list if the retry fails, and triggers the manual intervention alarm.
[0040] In the embodiment, through the pre-commit feedback state analysis system, the feedback results of each node recorded in the distributed transaction list are comprehensively determined in multiple dimensions, including the explicit feedback state of each transaction server, the feedback integrity index within the pre-commit validity period, and the fault detection result of the server that does not feedback within the timeout. When the determination result is full quantity agreed to commit, the terminal starts the standardized transaction commit process; when it is detected that there is a node feedback abnormality or timeout, the transaction compensation mechanism is automatically triggered.
[0041] The dynamic matching of the target compensation strategy will be described in detail below. Please refer to Figure 3 , Figure 3 The flowchart of an embodiment of dynamically matching the target compensation strategy in the distributed transaction processing, which comprises: S301, based on the business semantic features, obtaining a plurality of candidate compensation strategies from the compensation strategy library; The standardized business semantic features of the current transaction are extracted from the distributed transaction list, including but not limited to transaction type, business attribute, consistency requirement level, execution priority, and fault type.
[0042] The compensation strategy library pre-stores standardized compensation strategies adapted to different business scenarios, and each strategy is associated with clear "semantic feature adaptation conditions". Through a feature matching algorithm, the business semantic features of the current transaction are compared with the adaptation conditions of each strategy in the strategy library. If the adaptation conditions of a strategy completely match the core semantic features of the current transaction, or the intersection of the core features meets a preset threshold, the strategy is included in the candidate compensation strategy set. For example, for the business semantic features of "cross-border procurement payment, strong consistency, and inconsistent pre-commit data verification", 3-5 strategies that meet the adaptation conditions, such as "cross-border transaction full offset strategy", "multi-subject step-by-step rollback strategy", and "exchange rate adjustment compensation strategy", are selected from the strategy library to form a candidate set.
[0043] S302, weights are configured for each scoring dimension of the compensation strategy, and the score of each candidate compensation strategy in each scoring dimension is calculated; At least four scoring dimensions are determined based on business needs and risk control objectives, including business impact range, execution cost, risk assessment result, and historical success rate. Each scoring dimension is configured with a weight, for example, the preset base weights are 0.3 for business impact range, 0.2 for execution cost, 0.3 for risk assessment result, and 0.2 for historical success rate, and dynamic adjustment is supported according to business scenarios, such as increasing the risk assessment weight to 0.4 for financial core transactions.
[0044] In the business impact range dimension, a business impact tree model is established to quantitatively evaluate from three aspects of time, range, and degree, including business interruption time, user impact range, and financial impact degree. Each factor is calculated by weighting to obtain the total score of the dimension. In the execution cost dimension, a complete cost accounting model is constructed to evaluate in detail the various resource consumptions required for strategy execution, including resource consumption, estimated execution time, and manual intervention complexity. The dimension evaluation result is obtained through cost-benefit analysis. In the risk assessment dimension, the risk matrix evaluation method is used to comprehensively analyze the potential risks of strategy execution from two dimensions of possibility and impact degree, specifically evaluating the failure probability of strategy execution, data inconsistency risk, and rollback complexity. The risk score is calculated by a risk quantification model. In the historical success rate dimension, a historical execution data warehouse is used to calculate the global historical success rate and the success rate of similar scenarios of the strategy through time series analysis and scene clustering techniques. The reliable dimension score is obtained through confidence interval calculation and trend analysis.
[0045] S303, based on the weights, the scores of each candidate compensation strategy in each scoring dimension are weighted and summed to obtain the comprehensive score of the candidate compensation strategy; The multi-dimensional scores are integrated into a comprehensive score with comparability through dynamic weight configuration and weighted summation algorithm. The terminal first selects the most suitable weight scheme from the preset weight configuration template library according to the business semantic characteristics of the current transaction. The weight configuration template library contains multiple weight schemes optimized for different business scenarios, for example: the "risk priority type" configuration scheme for financial core transactions, giving the risk assessment dimension a weight of 40%, the business impact range 30%, the historical success rate 20%, and the execution cost 10%; the "efficiency priority type" configuration scheme for internal batch processing, giving the execution cost dimension a weight of 40%, the historical success rate 30%, the business impact range 20%, and the risk assessment 10%; the "experience priority type" configuration scheme for customer sensitive business, giving the business impact range a weight of 40%, the risk assessment 30%, the historical success rate 20%, and the execution cost 10%. In special scenarios, dynamic fine-tuning of weight coefficients based on specific parameters of business semantic characteristics is also supported. After the weights are determined, each candidate strategy is accurately calculated according to the weighted summation formula: where W1, W2, W3, W4 represent the weight coefficients of the four dimensions respectively, and satisfy the constraint condition that the sum is 1, and S1, S2, S3, S4 represent the standardized scores of the corresponding dimensions.
[0046] S304, based on the comprehensive score result, determine the target compensation strategy from the several candidate compensation strategies.
[0047] The comprehensive scores of all candidate strategies are arranged in descending order to generate a strategy list with rankings. When there are multiple strategies competing with similar comprehensive scores, the terminal starts a second round of decision-making process, and selects a strategy that better meets the immediate needs among the strategies with similar scores according to the business priority of the current transaction and the terminal running state: when the load is high, it tends to select a strategy with lower execution cost, when the business is in peak period, it tends to select a strategy with smaller business impact, and when stability is concerned, it tends to select a strategy with higher historical success rate.
[0048] After determining the target strategy, the terminal records the unique identifier, core configuration parameters, detailed scores of each dimension, comprehensive score, and decision basis of the strategy into the "compensation decision information" field of the distributed transaction list, completing the compensation strategy dynamic matching process.
[0049] In this embodiment, complete business semantic features are extracted from the transaction list, and according to these features, a preliminary screening of candidate strategies is performed from the pre-set compensation strategy library through a feature matching algorithm, and then the candidate strategies are evaluated according to a multi-dimensional scoring model, at least from four dimensions of business impact range, execution cost, risk assessment and historical success rate, the scores of each scoring dimension are weighted and summed, and finally the comprehensive score of the candidate strategy is obtained through the weighted sum, and the target strategy is determined by combining the business priority and the running state, which provides an intelligent selection mechanism for distributed transaction compensation and effectively improves the efficiency of distributed transaction compensation.
[0050] The following will be described in detail for automatically generating and executing compensation vouchers according to the target compensation strategy. Please refer to Figure 4 , Figure 4 The flowchart of an embodiment of automatically generating compensation vouchers in distributed transaction processing, which includes: S401, according to the target compensation strategy and the business semantic features, matching the target voucher template from the voucher template library; The target compensation strategy determined by intelligent decision and the business semantic feature set are obtained, the voucher template is organized according to the index architecture of business dimension, each template object contains metadata attributes such as strategy adaptation range, business scenario feature constraint, voucher structure definition and field mapping rule. According to the target compensation strategy type, the completely incompatible template options are excluded. Calculate the comprehensive matching degree of each candidate template and the current business semantic features, when the matching degree exceeds the preset threshold, include it in the qualified candidate set, and finally select the template with the highest matching degree from the qualified candidate as the target voucher template.
[0051] S402, based on the business data recorded in the distributed transaction list, automatically calculating the compensation amount and generating the voucher abstract describing the compensation reason; The complete original transaction record is extracted from the business data area of the transaction list, including transaction amount, currency information, historical exchange rate, tax rate parameter and other key financial data. The compensation amount calculation engine executes the corresponding calculation logic according to the type characteristics of the target compensation strategy. For full offset type strategy, the engine directly takes the opposite number of the original transaction amount and keeps the precision consistent; for partial compensation type strategy, the engine calls the built-in multi-parameter rule calculator, combines fault type, responsibility definition clause and business impact degree and other variables to calculate the compensation proportion according to the preset formula; for cross-border transaction scenarios involving multiple currencies, the engine will automatically match the historical exchange rate at the time of transaction to perform accurate conversion and consider the potential impact of exchange rate difference.
[0052] In the calculation process, multiple verification mechanisms such as amount boundary verification, loan balance verification and tax compliance check are synchronously performed, in the voucher abstract generation link, the natural language generation technology based on the semantic template is adopted, the basic sentence template highly adapted to the target compensation strategy and the business type is selected from the abstract template library, the specific business parameters are intelligently filled into the template variable position through the parameter substitution engine, and finally the abstract text meeting the accounting language specification and having complete business traceability ability is generated, such as "2024-01-15 16:30:05 due to communication timeout, automatically offset the amount of purchase order PO-20240115008", and the uniqueness of the abstract is ensured through the text similarity detection algorithm.
[0053] S403, fill the compensation amount and the voucher abstract into the target voucher template to generate compensation voucher data.
[0054] A complete target voucher template object is loaded from the voucher template library, and the template clearly defines the hierarchical structure of the voucher, including the detailed specifications of the management information area of the voucher header and the detailed record area of the voucher body. In the data assembly stage, the terminal performs structured filling according to the pre-defined field mapping rule: the global transaction context information obtained from the transaction list is automatically filled in the voucher header, and a unique voucher number is obtained through a distributed sequence generator; in the voucher body part, according to the subject mapping rule defined by the template and the calculated compensation amount data, the accounting subject, the amount value and the debit direction identifier of each line of journal are filled, the generated standardized voucher abstract text is filled into the corresponding field position, and finally the compensation voucher data is generated.
[0055] In the embodiment, through the pre-set voucher template library, the most suitable voucher template is quickly matched according to the determined target compensation strategy and business characteristics; in the processing process, the original business data recorded in the distributed transaction list is called, the amount calculation engine is used to calculate according to different strategy types, and the intelligent text generation technology is combined to automatically generate the voucher abstract meeting the specification. Finally, the global transaction information, the corresponding accounting subject, the compensation amount and other data are filled in according to the format requirements of the standard template to form a complete compensation voucher; by establishing a standardized voucher processing process, the efficiency and accuracy of the compensation business processing are effectively improved.
[0056] The application also provides a distributed transaction processing system, please refer to Figure 5 , Figure 5 The structural schematic diagram of an embodiment of the distributed transaction processing system provided by the application is shown in the figure, and the system comprises: The semantic analysis unit 501 is used for receiving a distributed transaction request and analyzing the business semantic characteristics of the distributed transaction. The transaction management unit 502 is configured to create a distributed transaction list, add business semantic features to the transaction list, and the transaction list includes a plurality of execution commands, each of the execution commands includes the business semantic features, and each of the execution commands corresponds to a transaction operation; The transaction preparation unit 503 is configured to send an instruction to each of the transaction servers based on the distributed transaction list to execute a local transaction, and obtain a local transaction execution result returned by each of the transaction servers; The pre-commit processing unit 504 is configured to send a pre-commit request to all the transaction servers when all the local transaction execution results are successful, and collect a pre-commit request feedback result of each of the transaction servers; The transaction operation unit 505 is configured to execute a transaction commit operation or a transaction compensation operation according to the pre-commit request feedback result, the transaction commit operation includes sending a commit instruction to each of the transaction servers, and the transaction compensation operation includes dynamically matching a target compensation strategy from a compensation strategy library based on the business semantic features, and automatically generating and executing a compensation voucher according to the target compensation strategy.
[0057] The application further provides a distributed transaction processing device, please refer to Figure 6 , Figure 6 An embodiment of the distributed transaction processing device provided by the application has the structure as shown in the figure, and the device includes: A processor 601, a memory 602, an input and output unit 603, and a bus 604; The processor 601 is connected with the memory 602, the input and output unit 603, and the bus 604; The memory 602 stores a program, and the processor 601 invokes the program to execute any of the above distributed transaction processing methods.
[0058] The application further relates to a computer readable storage medium, and the computer readable storage medium stores a program, and when the program runs on a computer, the computer executes any of the above distributed transaction processing methods. The specific implementation process is described in the embodiment of Figures 1-5 , and details are not described herein.
[0059] Those skilled in the art can clearly understand the specific working process of the system, device and unit described above for the convenience and brevity of description, and the corresponding process in the foregoing method embodiments can be referred to, and details are not described herein.
[0060] In several embodiments provided in the present application, it should be understood that the disclosed system, device and method can be implemented in other manners. For example, the division of the above-described device embodiments is merely a logical function division, and there can be another division manner for actual implementation, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections between different units, or the among different units, can be indirect couplings or communication connections through some interfaces, devices or units, and can be in electrical, mechanical or other forms.
[0061] The units described as separated components can or can not be physically separated, and the components displayed as units can or can not be physical units, i.e., can be located in one place, or can be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purposes of the embodiments.
[0062] In addition, each functional unit in the embodiments of the present application can be integrated in a processing unit, or each unit can exist physically as a separate unit, or two or more units can be integrated in one unit. The integrated unit can be implemented in the form of hardware, or in the form of a software functional unit.
[0063] When the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on such an understanding, the technical solutions of the present application essentially, or the part that makes a contribution to the prior art, or all or a part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in the embodiments of the present application. The foregoing storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), magnetic disk or optical disk, and various other media that can store program codes.
Claims
1. A distributed transaction processing method, characterized in that, The method includes: Receive distributed transaction requests and parse the business semantic features of the distributed transactions; A distributed transaction list is created, and the business semantic features are added to the transaction list. The transaction list includes several execution commands, each of which contains business semantic features, and each execution command corresponds to a transaction operation. Based on the distributed transaction list, instructions are sent to each transaction server to execute local transactions, and the execution results of the local transactions returned by each transaction server are obtained. When all local transactions are executed successfully, a pre-commit request is sent to all the transaction servers, and the feedback results of the pre-commit requests from each transaction server are collected. Based on the feedback result of the pre-commit request, a transaction commit operation or a transaction compensation operation is performed. The transaction commit operation includes issuing a commit instruction to each transaction server. The transaction compensation operation includes dynamically matching a target compensation strategy from the compensation strategy library based on the business semantic features, and automatically generating and executing compensation vouchers according to the target compensation strategy.
2. The distributed transaction processing method according to claim 1, characterized in that, The step of performing a transaction commit operation or a transaction compensation operation based on the feedback result of the pre-commit request includes: Execute the transaction operation based on the feedback result of the pre-commit request; When all the pre-commit requests received indicate agreement to commit, the transaction commit operation is executed. The transaction compensation operation is performed when at least one pre-commit request fails to commit or times out.
3. The distributed transaction processing method according to claim 1, characterized in that, The step of dynamically matching the target compensation strategy from the compensation strategy library includes: Based on the aforementioned business semantic features, several candidate compensation strategies are obtained from the compensation strategy library; Each candidate compensation strategy is comprehensively scored based on a multi-dimensional scoring model. The scoring dimensions include the scope of business impact, execution cost, risk assessment results, and historical success rate. Based on the comprehensive scoring results, the target compensation strategy is determined from the plurality of candidate compensation strategies.
4. The distributed transaction processing method according to claim 3, characterized in that, The comprehensive scoring of each candidate compensation strategy based on the multi-dimensional scoring model includes: Assign weights to each scoring dimension and calculate the score of each candidate compensation strategy in each scoring dimension; Based on the weights, the scores of each candidate compensation strategy in each scoring dimension are weighted and summed to obtain the comprehensive score of the candidate compensation strategy.
5. The distributed transaction processing method according to claim 1, characterized in that, The automatic generation and execution of compensation vouchers according to the target compensation strategy includes: Based on the target compensation strategy and the business semantic features, a target voucher template is matched from the voucher template library; Based on the business data recorded in the distributed transaction list, the compensation amount is automatically calculated and a voucher summary describing the reason for the compensation is generated; The compensation amount and the voucher summary are filled into the target voucher template to generate compensation voucher data.
6. The distributed transaction processing method according to claim 1, characterized in that, The parsing of the business semantic features of the distributed transaction includes: Extract business metadata from the distributed transaction request; The business metadata is standardized to establish a mapping relationship between the business semantic features and distributed transaction processing rules.
7. The distributed transaction processing method according to any one of claims 1 to 6, characterized in that, The pre-commit request is sent to all the transaction servers in a parallel manner.
8. A distributed transaction processing system, characterized in that, The system includes: A semantic parsing unit is used to receive distributed transaction requests and parse the business semantic features of the distributed transaction. A transaction management unit is used to create a distributed transaction list and add the business semantic features to the transaction list. The transaction list includes several execution commands, each of which contains business semantic features, and each execution command corresponds to a transaction operation. The transaction preparation unit is used to send instructions to each transaction server to execute local transactions based on the distributed transaction list, and to obtain the local transaction execution results returned by each transaction server. The pre-commit processing unit is used to send a pre-commit request to all the transaction servers when all local transactions have been executed successfully, and to collect the feedback results of the pre-commit requests from each transaction server. The transaction operation unit is used to perform a transaction commit operation or a transaction compensation operation based on the feedback result of the pre-commit request. The transaction commit operation includes issuing a commit instruction to each transaction server. The transaction compensation operation includes dynamically matching a target compensation strategy from the compensation strategy library based on the business semantic features, and automatically generating and executing compensation vouchers according to the target compensation strategy.
9. A distributed transaction processing device, characterized in that, The device includes: Processor, memory, input / output units, and bus; The processor is connected to the memory, the input / output unit, and the bus; The memory stores a program, which the processor invokes to perform the method as described in any one of claims 1 to 7.
10. A computer-readable storage medium having a program stored thereon, the program performing the method as claimed in any one of claims 1 to 7 when executed on a computer.