Transaction processing method and device
By freezing hot data in the distributed transaction processing system and recording the processing status during the state value change phase, the problem of low system efficiency caused by hot data is solved, and efficient distributed transaction processing is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-01-28
- Publication Date
- 2026-03-27
AI Technical Summary
Existing distributed transaction processing systems suffer from low processing efficiency when handling hot data. The use of queue waiting mechanisms or transaction lock schemes in existing technologies can affect the response speed of consumers and system performance.
In the first transaction phase, the target data is frozen to avoid spin locks and ensure high-concurrency data usage. In the second transaction phase, the transaction processing status is recorded by changing the state value, thus realizing the entire process of distributed transactions.
It improves the processing efficiency of distributed systems and the response speed of consumers, while ensuring the global uniqueness of transactions and system performance.
Smart Images

Figure CN121742979A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of distribution, and in particular to a transaction processing method, device, equipment, medium and program product. BACKGROUND
[0002] With the gradual expansion of banking system and the adjustment of bank technology architecture, the bank system is becoming more and more complex. For new business, the bank business gradually adopts distributed architecture to solve. When implementing transaction processing under the distributed architecture, it is necessary to ensure the transaction consistency of the distributed system. In order to ensure the consistency of the distributed system transaction, the existing technology adopts the queue waiting mechanism or the transaction lock scheme, however, when hot data appears, the existing technology will cause the consumer to respond too slowly, the system performance is reduced and other problems. SUMMARY
[0003] In view of the above problems, the present application provides a transaction processing method, device, equipment, medium and program product for improving the response efficiency of the consumer and the performance of the distributed system.
[0004] According to a first aspect of the present application, a transaction processing method is provided, comprising: the method comprises: in a first transaction phase, executing transaction processing on target data and freezing to obtain a first processing record; generating a second processing record based on the first processing record, the second processing record comprising: a processing state and a number of invalid retries, the processing state being a first state value; in a second transaction phase, obtaining a transaction corresponding to the first state value, and modifying the first state value to a second state value; executing a business service based on the transaction of the second state value; in the case of successful processing of the business service, updating the second state value to a third state value, the third state value being used to represent the completion of the business service processing.
[0005] According to an embodiment of the present application, the second processing record further comprises: a retry number, and after executing the business service based on the transaction of the second state value, further comprising: in the case of failure of the business service processing, re-executing the business service based on the transaction of the second state value and increasing the retry number.
[0006] According to an embodiment of the present application, after re-executing the business service based on the transaction of the second state value and increasing the retry number, further comprising: for the transaction of the second state value, in the case that the retry number reaches a preset number threshold, updating the second state value to a fourth state value, the fourth state value being used to represent transaction invalidation;
[0007] Based on the second processing record, an alarm is issued.
[0008] According to an embodiment of the present application, the method further comprises: scanning the fourth state value at a preset time interval; and modifying the fourth state value into a fifth state value, the fifth state value being used to represent a transaction duration exception.
[0009] According to an embodiment of the present application, the executing transaction processing on the target data and freezing in the first transaction phase to obtain a first processing record comprises: generating a frozen state bit based on the target data, and marking the frozen state bit as a first frozen value.
[0010] executing business processing on the target data and marking the frozen state bit as a second frozen value; and forming the first processing record based on the second frozen value, a global transaction identifier, a branch identifier, and a version number.
[0011] According to an embodiment of the present application, the executing business processing on the target data and marking the frozen state bit as a second frozen value comprises: performing business processing on the target data by means of database updating, insertion, and release of row-level locks.
[0012] A second aspect of the present application provides a transaction processing apparatus, the apparatus comprising: a transaction processing module configured to execute transaction processing on target data and freeze in a first transaction phase to obtain a first processing record; a record generation module configured to generate a second processing record based on the first processing record, the second processing record comprising: a processing state and a number of invalid retries, the processing state being a first state value; a state value changing module configured to, in a second transaction phase, acquire a transaction corresponding to the first state value, and modify the first state value into a second state value; a business service calling module configured to execute a business service based on the transaction of the second state value; and the state value changing module is further configured to, in a case where the business service processing is successful, update the second state value into a third state value, the third state value being used to represent that the business service processing is completed.
[0013] A third aspect of the present application provides an electronic device, comprising: one or more processors; a memory configured to store one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement steps of the above method.
[0014] A fourth aspect of the present application further provides a computer-readable storage medium having a computer program or instructions stored thereon, wherein the computer program or instructions are executed by a processor to implement steps of the above method.
[0015] A fifth aspect of the present application further provides a computer program product comprising a computer program or instructions, wherein the computer program or instructions are executed by a processor to implement steps of the above method.
[0016] In the embodiments of the present application, in order to solve the technical problem that the existing distributed transaction processing system causes low system processing efficiency when processing hot data, the embodiments of the present application directly freeze the target hot data by means of identification in the first transaction phase, avoid the hot data from being locked due to the use of a spin lock, ensure that high concurrency can continue to use the data, and guarantee the global uniqueness of the transaction through the second state value in the second transaction phase. The processing state of the transaction is recorded through the change of the state value in the second phase, so as to realize the whole process of the distributed transaction. BRIEF DESCRIPTION OF DRAWINGS
[0017] The above and other objects, features and advantages of the present application will become more apparent from the following description when taken in conjunction with the accompanying drawings, in which:
[0018] Figure 1 An application scenario diagram of a transaction processing method, apparatus, device, medium and program product according to an embodiment of the present application is schematically shown;
[0019] Figure 2 A flowchart of a transaction processing method according to an embodiment of the present application is schematically shown;
[0020] Figure 3 A flowchart of another transaction processing method according to an embodiment of the present application is schematically shown
[0021] Figure 4 A structural block diagram of a transaction processing apparatus according to an embodiment of the present application is schematically shown; and
[0022] Figure 5 A block diagram of an electronic device suitable for implementing a transaction processing method according to an embodiment of the present application is schematically shown. DETAILED DESCRIPTION
[0023] Hereinafter, embodiments of the present application will be described with reference to the accompanying drawings. It is to be understood, however, that the description is merely exemplary and is intended to provide a thorough understanding of the embodiments of the present application. The following detailed description and specific examples are presented in order to provide a thorough understanding. No limitations are, however, intended to be implied primarily by the description of a specific example, but rather also by the description of a specific embodiment. In some cases, details have been omitted so as not to obscure the general inventive concepts.
[0024] The terminology used herein is for the purpose of describing embodiments only and is not intended to limit the present application. As used herein, the term "including" and "comprising" and the like are meant to be inclusive in nature and do not exclude the presence of additional elements or steps.
[0025] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.
[0026] When using expressions such as "at least one of A, B and C", they should generally be interpreted in accordance with the meaning that is commonly understood by those skilled in the art (e.g., "a system having at least one of A, B and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B and C, etc.).
[0027] Before providing a detailed disclosure of this application, the key technical data involved in the embodiments of this application will be described one by one, as follows:
[0028] TCC Transaction Framework: This refers to a distributed transaction framework. The TCC transaction framework can divide distributed transactions into three phases: Try, Confirm, and Cancel, namely the attempt phase, confirmation phase, and cancellation phase. The transaction manager coordinates the execution of branch transactions to ensure the consistency of global transactions. Its core objective is to handle the transaction consistency problem of cross-service calls in a distributed environment, which is especially suitable for scenarios with high performance and real-time requirements. The core features of this distributed transaction framework are: (1) Fault recovery mechanism: It needs to have a complete fault recovery capability to deal with abnormal situations such as server crashes and network failures. The basis of fault recovery is the transaction log. The framework records the transaction context (such as global transaction ID, branch transaction status, etc.) and can restore the interrupted transaction to the correct state according to the log after a failure, and continue to execute the unfinished commit or rollback operation. (2) Idempotency guarantee: Since the operations in the confirmation phase and cancellation phase may be called multiple times due to retries (such as during fault recovery), the framework needs to ensure the idempotency of these operations (i.e., multiple requests have the same effect as a single request). Usually, the framework rather than the business system provides idempotency support to reduce business complexity. (3) The refined transaction control framework needs to dynamically decide on subsequent operations based on the execution results of the trial phase: if the operation in the trial phase has not been committed or has been rolled back, there is no need to execute the cancellation phase; the confirmation phase or cancellation phase is only triggered when the operation in the trial phase is successfully committed. The three-phase process of the distributed transaction framework: 1. Trial phase: Complete business checks (such as parameter verification, permission verification) and resource reservation (such as freezing account balance, locking inventory) to prepare for subsequent confirmation operations. Operations in this phase must satisfy idempotency and isolation. 2. Confirmation phase: Execute after all branch transaction trial phases are successful to confirm business operations (such as actually deducting balance, confirming order). The framework assumes that the operation in the confirmation phase will succeed. If it fails, it will ensure eventual consistency through a retry mechanism. 3. Cancellation phase: If any branch transaction trial phase fails, execute the cancellation phase operation to roll back resource reservation (such as unfreezing balance, releasing inventory). Similar to the confirmation phase, the operation in the confirmation phase also needs to be retried if it fails.
[0029] Non-transactional systems typically refer to systems that guarantee the completion of the entire process with a single commit through the atomicity, consistency, isolation, and durability of the database.
[0030] Complex transaction system: refers to a system that contains both non-transactional systems and transactional systems under the TCC transaction framework, and there is an overlap of hot data between the two, and they are processed together.
[0031] For distributed systems, the industry mainly uses the TCC transaction framework to solve the eventual consistency problem of accounting, but it does not solve the problem of hot data and transaction consistency between TCC transaction systems and non-transactional systems.
[0032] In existing technologies, two main solutions are used: 1. A queue waiting mechanism is used in the trial phase, but this will affect the concurrency of the trial phase and the response results of the consumer; 2. A full-link lock solution is used, which acquires a transaction lock from the trial phase and releases it only when the second phase ends. This solution will reduce system performance and availability. In the event of a failure, the availability of the system will also be reduced.
[0033] An embodiment of this application provides a transaction processing method, the method comprising: in a first transaction phase, performing transaction processing on target data and freezing it to obtain a first processing record; generating a second processing record based on the first processing record, the second processing record including: processing status and failure retries, the processing status being a first status value; in a second transaction phase, obtaining the transaction corresponding to the first status value and modifying the first status value to the second status value; executing a business service based on the transaction of the second status value; and if the business service processing is successful, updating the second status value to a third status value, the third status value being used to indicate that the business service processing is completed.
[0034] In the embodiments of this application, in order to solve the technical problem that existing distributed transaction processing systems suffer from low system processing efficiency when processing hot data, the embodiments of this application directly freeze the target hot data by identifying the data in the first transaction stage, avoiding the hot data being locked due to the use of spin locks, and ensuring that the data can continue to be used under high concurrency. Subsequently, in the second transaction stage, the global uniqueness of the transaction can be guaranteed by the second state value. In the second stage, the processing status of the transaction is recorded by changing the state value, thereby realizing the entire process of distributed transactions.
[0035] Figure 1 The diagram illustrates an application scenario of the transaction processing method according to an embodiment of this application.
[0036] like Figure 1 As shown, application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, and a server 105. Network 104 serves as a medium for providing a communication link between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. Network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.
[0037] Users can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 via the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).
[0038] The first terminal device 101, the second terminal device 102, and the third terminal device 103 can be various electronic devices with displays and support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.
[0039] Server 105 can be a server that provides various services, such as a backend management server that supports websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103 (this is just an example). The backend management server can analyze and process data such as received user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal devices.
[0040] It should be noted that the transaction processing method provided in this application embodiment can generally be executed by server 105. Correspondingly, the transaction processing device provided in this application embodiment can generally be located in server 105. The transaction processing method provided in this application embodiment can also be executed by a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105. Correspondingly, the transaction processing device provided in this application embodiment can also be located in a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105.
[0041] It should be understood that Figure 1 The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.
[0042] The following will be based on Figure 1 The described scene, through Figures 2-3 The transaction processing method according to the embodiments of this application will be described in detail.
[0043] Figure 2 A flowchart illustrating a transaction processing method according to an embodiment of this application is shown schematically.
[0044] likeFigure 2 As shown, the transaction processing method of this embodiment includes operations S210 to S250, and the transaction processing method can be executed by the server 105.
[0045] In operation S210, during the first transaction phase, the target data is processed and frozen to obtain the first processing record.
[0046] Specifically, the first transaction phase is the trial phase under the TCC distributed system. In the first transaction phase, database operations are used to perform business processing on the target data and execute the corresponding transaction processing. After the data is processed, the target data is marked as frozen data so that the business operation can be confirmed or canceled in the second transaction phase. After all this is done, a first processing record is generated. The first processing record at least records the frozen state of the corresponding target data. This freezing of data and recording of responses can be implemented at the database level instead of the spin lock processing commonly used by the business at the application level. This can prevent hot data from being locked.
[0047] According to an embodiment of this application, the step of performing transaction processing and freezing on the target data in the first transaction phase to obtain a first processing record includes: generating a frozen state bit based on the target data and marking the frozen state bit as a first frozen value; performing business processing on the target data and marking the frozen state bit as a second frozen value; and forming the first processing record based on the second frozen value, the global transaction identifier, the branch identifier, and the version number.
[0048] Specifically, a frozen status field is inserted into the transaction log. This frozen status field is marked with the first frozen value by default, meaning it is not frozen. Then, business processing is performed on the target data. This business processing can be banking operations such as deductions or queries. For example, when deducting money, the account's response balance data is modified and updated. After the database processing is completed, the frozen status field in the transaction log is changed to the second frozen value, meaning it is frozen. Finally, the first processing record is formed using the second frozen value, the global transaction identifier, the branch identifier, and the version number. This first processing record can be used to mark the uniqueness of the transaction and determine the state of the data in the transaction.
[0049] In a typical scenario, the target data can be account data from a hot account. When a deduction operation needs to be performed on a hot account, a frozen status bit is inserted into the transaction log. The value of the frozen status bit is set to the first frozen value by default, that is, not frozen. Subsequently, the processing status of the corresponding data can be indicated by modifying the field of the frozen status bit, thereby achieving the uniqueness of the global transaction, instead of locking the data as in the existing technology.
[0050] According to an embodiment of this application, performing business processing on the target data and marking the frozen state bit as a second frozen value includes: performing business processing on the target data through database updates, insertions, and releasing row-level locks.
[0051] In a typical scenario, the frozen fields are first deducted using a database update statement, and then the frozen status is marked as the second frozen value using an insert statement. The second frozen value is the one that is already frozen. Then, the row-level lock is released immediately. The row-level lock is held for a very short time, and concurrent threads have almost no waiting time, so that the throughput remains at its peak.
[0052] It is understandable that by inserting the corresponding freeze status into the transaction log, global consistency of transactions can be ensured through database-level means.
[0053] In operation S220, a second processing record is generated based on the first processing record. The second processing record includes: processing status and failure retry count, wherein the processing status is a first status value.
[0054] Specifically, in the first transaction phase, after the database completes the data change and the relevant freeze bit is changed, a second processing record is generated. This second processing record is used to record the transaction processing process in the subsequent second transaction phase. In the process of generating the second processing record from the information in the first processing record, the second processing record inherits the information in the first processing record and adds the processing status and failure retry count. The processing status is the first status value by default, that is, not processed. This first status value indicates that the transaction processing has not been completed in the second phase.
[0055] In a typical scenario, the status of the record inserted in operation S210 is changed from the default to "frozen," and the global transaction identifier, branch identifier, and version number are added as a globally unique identifier. Subsequent second-stage operations can use this identifier in the second processing record as the sole source of truth, ensuring that duplicate messages and duplicate scheduling only change the status once. This prevents duplicate deductions and rollbacks in accounting, and even if concurrent scheduling threads simultaneously acquire the same task, only one call will actually succeed.
[0056] In operation S230, during the second transaction phase, the transaction corresponding to the first state value is obtained, and the first state value is modified to the second state value.
[0057] The second transaction phase refers to the confirmation or cancellation phase. During the second transaction phase, job scheduling is required so that the actual business services on the application side can also execute the transaction accordingly.
[0058] Specifically, operation S230 can be executed asynchronously with the above operations S210-S220. That is, in the embodiments of this application, after the above operations S210-S220 are completed, operation S230 is not necessarily executed immediately, but can be executed at a later time. Therefore, in the second transaction stage, the transaction corresponding to the first state value is obtained, that is, the transaction with the processing state of unprocessed is obtained, and it is modified to the second state value. The second state value is used to represent the state to be processed or the state to be processed.
[0059] In a typical scenario, after the request arrives in the second transaction phase, the framework immediately inserts a record with status = 1 (pending) into the "background task table", which includes: communication message, event number, failure retries = 0, and changes status = 1 to status = 2 (processing).
[0060] Understandably, when synchronous processing is switched to asynchronous scheduling, the task persists even if the current thread is interrupted, and can be woken up by operation S230 when necessary.
[0061] In operation S240, business services are executed based on the transaction of the second state value.
[0062] Specifically, operation S240 and the above-mentioned operation S230 can also be executed asynchronously. In the embodiments of this application, the transaction whose current processing state is the second state value is obtained, and the data of the transaction is consumed to realize the execution of business services.
[0063] In operation S250, if the business service is successfully processed, the second status value is updated to a third status value, which indicates that the business service processing is completed.
[0064] Specifically, upon successful processing of the business service (i.e., successful consumption), the status value is changed from 2 to 3 (i.e., success), and the transaction is completed, thus ensuring that the task is not consumed repeatedly. Here, "business service" refers to the application-side business service, not the database-side service; for example, the business service might be the application-side service for deducting payments.
[0065] In the embodiments of this application, in order to solve the technical problem that existing distributed transaction processing systems suffer from low system processing efficiency when processing hot data, the embodiments of this application directly freeze the target hot data by identifying the data in the first transaction stage, avoiding the hot data being locked due to the use of spin locks, and ensuring that the data can continue to be used under high concurrency. Subsequently, in the second transaction stage, the global uniqueness of the transaction can be guaranteed by the second state value. In the second stage, the processing status of the transaction is recorded by changing the state value, thereby realizing the entire process of distributed transactions.
[0066] Operations S210-S250 above describe the steps performed when a transaction is normal. The following section details the execution process when a transaction fails, as shown below:
[0067] Figure 3 A flowchart illustrating another transaction processing method according to an embodiment of this application is shown schematically.
[0068] like Figure 3 As shown, the transaction processing method of this embodiment includes not only operations S210 to S250, but also operations S310 to S330.
[0069] In operation S310, if the business service processing fails, the business service is re-executed based on the transaction of the second state value and the number of retries is increased.
[0070] Specifically, in the event of a business service failure, the processing status will remain as the second status value, that is, the processing status of the transaction will not be changed and will remain as pending. The compensation operation will be performed again for the transaction with the second status value and the retry count will be incremented by 1.
[0071] Understandably, by re-running the process to achieve abnormal background compensation, temporary anomalies such as momentary network jitter and brief database deadlocks can be automatically resolved.
[0072] In operation S320, for a transaction with the second state value, if the number of retries reaches a preset threshold, the second state value is updated to a fourth state value, which is used to characterize the transaction failure.
[0073] Specifically, there is an upper limit to the number of retries. If the upper limit is reached and the transaction still fails, the retries are stopped and the second state is updated to the fourth state value, which indicates that the transaction has failed and no further compensation work needs to be performed on it.
[0074] In operation S330, an alarm is issued based on the second processing record.
[0075] Specifically, when the fourth state value appears, the specific globally unique transaction can be located through the corresponding identifier in the second processing record, so that relevant personnel can manually participate in the alarm of the transaction, thereby preventing the transaction from automatically retrying and avoiding the endless loop of compensation operations.
[0076] Understandably, persistent anomalies indicate that transactions no longer need to be automatically retried to avoid endless loops. Subsequent maintenance personnel can use the precise clues from the second processing record to perform manual operations, making the risks controllable and traceable.
[0077] According to an embodiment of this application, the method further includes: scanning the fourth state value at a preset time interval; modifying the fourth state value to a fifth state value, wherein the fifth state value is used to characterize the continuous abnormality of the transaction.
[0078] Specifically, for transactions that have been in the fourth state value (i.e., the failed state) for a long time, the state is periodically scanned to obtain these transactions in the fourth state value, and these transactions in the fourth state value are modified to become transactions in the fifth state value. The fifth state value is used to indicate that the transaction is continuously abnormal. For such transactions, the relevant technical personnel are notified by email to handle them.
[0079] Understandably, by periodically retrieving the fourth state value, it is possible to ensure that abnormal tasks that have existed for a long time due to program vulnerabilities or network partition defects are detected, without a black box, thus ensuring the overall security of the system.
[0080] In addition, in the embodiments of this application, "operation time, old state, new state, and number of retries" can be written to the transaction log at each step of the operation; the monitoring dashboard can display "number of frozen tasks in the first transaction phase, success rate of the second phase, and number of failed tasks" in real time, so that the operation and maintenance process can locate anomalies in seconds.
[0081] Based on the above transaction processing method, this application also provides a transaction processing apparatus. The following will be combined with... Figure 4 The device is described in detail.
[0082] Figure 4 A schematic block diagram of a transaction processing apparatus according to an embodiment of this application is shown.
[0083] like Figure 4 As shown, the transaction processing device 400 in this embodiment includes a transaction processing module 410, a record generation module 420, a status value change module 430, and a business service call module 440.
[0084] The transaction processing module 410 is used to perform transaction processing on the target data and freeze it during the first transaction phase to obtain the first processing record. In one embodiment, the transaction processing module 410 can be used to perform the operation S210 described above, which will not be repeated here.
[0085] The record generation module 420 is used to generate a second processing record based on the first processing record. The second processing record includes a processing status and a failure retries count, wherein the processing status is a first status value. In one embodiment, the record generation module 420 can be used to perform the operation S220 described above, which will not be repeated here.
[0086] The status value change module 430 is used in the second transaction phase to obtain the transaction corresponding to the first status value and modify the first status value to the second status value. In one embodiment, the status value change module 430 can be used to perform the operation S230 described above, which will not be repeated here.
[0087] The business service invocation module 440 is used to execute business services based on the transaction of the second state value. In one embodiment, the business service invocation module 440 can be used to execute the operation S240 described above, which will not be repeated here.
[0088] The status value change module 430 is further configured to update the second status value to a third status value, wherein the third status value indicates that the business service processing is complete, if the business service processing is successful. In one embodiment, the status value change module 430 may be used to perform the operation S250 described above, which will not be repeated here.
[0089] In the embodiments of this application, in order to solve the technical problem that existing distributed transaction processing systems suffer from low system processing efficiency when processing hot data, the embodiments of this application directly freeze the target hot data by identifying the data in the first transaction stage, avoiding the hot data being locked due to the use of spin locks, and ensuring that the data can continue to be used under high concurrency. Subsequently, in the second transaction stage, the global uniqueness of the transaction can be guaranteed by the second state value. In the second stage, the processing status of the transaction is recorded by changing the state value, thereby realizing the entire process of distributed transactions.
[0090] According to an embodiment of this application, the second processing record further includes: a retry count; and after the transaction based on the second state value is executed for the business service, the record further includes: if the business service processing fails, re-execute the business service based on the second state value and increase the retry count.
[0091] According to an embodiment of this application, after re-executing the business service based on the second state value and increasing the number of retries, the method further includes: for the transaction with the second state value, if the number of retries reaches a preset threshold, updating the second state value to a fourth state value, the fourth state value being used to characterize transaction failure; and issuing an alarm based on the second processing record.
[0092] According to an embodiment of this application, the method further includes: scanning the fourth state value at a preset time interval; modifying the fourth state value to a fifth state value, wherein the fifth state value is used to characterize the continuous abnormality of the transaction.
[0093] According to an embodiment of this application, the step of performing transaction processing and freezing on the target data in the first transaction stage to obtain a first processing record includes: generating a frozen state bit based on the target data and marking the frozen state bit as a first frozen value;
[0094] Perform business processing on the target data and mark the frozen status bit as the second frozen value; and form the first processing record based on the second frozen value, the global transaction identifier, the branch identifier, and the version number.
[0095] According to an embodiment of this application, performing business processing on the target data and marking the frozen state bit as a second frozen value includes: performing business processing on the target data through database updates, insertions, and releasing row-level locks.
[0096] According to embodiments of this application, any multiple modules among the transaction processing module 410, record generation module 420, status value change module 430, and business service call module 440 can be merged into one module, or any one of these modules can be split into multiple modules. Alternatively, at least some of the functions of one or more of these modules can be combined with at least some of the functions of other modules and implemented in one module. According to embodiments of this application, at least one of the transaction processing module 410, record generation module 420, status value change module 430, and business service call module 440 can be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or any other reasonable means of integrating or packaging circuitry, or implemented in hardware or firmware, or in any one of software, hardware, and firmware implementations, or in a suitable combination of any of these. Alternatively, at least one of the transaction processing module 410, record generation module 420, status value change module 430, and business service call module 440 may be implemented at least partially as a computer program module, which can perform corresponding functions when the computer program module is run.
[0097] Figure 5 A block diagram schematically illustrates an electronic device suitable for implementing a transaction processing method according to an embodiment of this application.
[0098] like Figure 5As shown, an electronic device 900 according to an embodiment of this application includes a processor 901, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 902 or a program loaded from a storage portion 908 into a random access memory (RAM) 903. The processor 901 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 901 may also include onboard memory for caching purposes. The processor 901 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of this application.
[0099] RAM 903 stores various programs and data required for the operation of electronic device 900. Processor 901, ROM 902, and RAM 903 are interconnected via bus 904. Processor 901 executes various operations of the method flow according to embodiments of this application by executing programs in ROM 902 and / or RAM 903. It should be noted that the programs may also be stored in one or more memories other than ROM 902 and RAM 903. Processor 901 may also execute various operations of the method flow according to embodiments of this application by executing programs stored in said one or more memories.
[0100] According to embodiments of this application, the electronic device 900 may further include an input / output (I / O) interface 905, which is also connected to a bus 904. The electronic device 900 may also include one or more of the following components connected to the input / output (I / O) interface 905: an input section 906 including a keyboard, mouse, etc.; an output section 907 including a cathode ray tube (CRT), liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 908 including a hard disk, etc.; and a communication section 909 including a network interface card such as a LAN card, modem, etc. The communication section 909 performs communication processing via a network such as the Internet. A drive 910 is also connected to the input / output (I / O) interface 905 as needed. A removable medium 911, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 910 as needed so that computer programs read from it can be installed into the storage section 908 as needed.
[0101] This application also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs, which, when executed, implement the method according to the embodiments of this application.
[0102] According to embodiments of this application, the computer-readable storage medium can be a non-volatile computer-readable storage medium, such as including but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of this application, the computer-readable storage medium may include ROM 902 and / or RAM 903 and / or one or more memories other than ROM 902 and RAM 903 described above.
[0103] Embodiments of this application also include a computer program product comprising a computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code is used to cause the computer system to implement the methods provided in the embodiments of this application.
[0104] When the computer program is executed by the processor 901, it performs the functions defined in the system / apparatus of this application embodiment. According to the embodiments of this application, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0105] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and downloaded and installed via the communication section 909, and / or installed from a removable medium 911. The program code contained in the computer program can be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination thereof.
[0106] In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 909, and / or installed from the removable medium 911. When the computer program is executed by the processor 901, it performs the functions defined in the system of this application embodiment. According to the embodiments of this application, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.
[0107] According to embodiments of this application, program code for executing the computer programs provided in the embodiments of this application can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, languages such as Java, C++, Python, "C", or similar programming languages. The program code can be executed entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0108] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0109] Those skilled in the art will understand that the features described in the various embodiments of this application can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in this application. In particular, the features described in the various embodiments of this application can be combined and / or combined in various ways without departing from the spirit and teachings of this application. All such combinations and / or combinations fall within the scope of this application.
Claims
1. A transaction processing method, characterized in that, The method includes: In the first transaction phase, the target data is processed and frozen, resulting in the first processed record; A second processing record is generated based on the first processing record. The second processing record includes: processing status and failure retry count. The processing status is a first status value. In the second transaction phase, the transaction corresponding to the first state value is obtained, and the first state value is modified to the second state value; Execute business services based on transactions based on the second state value; If the business service is successfully processed, the second status value is updated to a third status value, which indicates that the business service processing is complete.
2. The method according to claim 1, characterized in that, The second processing record also includes: the number of retries. After the transaction service based on the second state value is executed, the following is also included: If the business service processing fails, the business service is re-executed based on the transaction of the second status value and the number of retries is increased.
3. The method according to claim 2, characterized in that, After re-executing the business service based on the second state value and increasing the number of retries, the process further includes: For a transaction with the second state value, if the number of retries reaches a preset threshold, the second state value is updated to a fourth state value, which is used to indicate that the transaction has failed. An alarm is issued based on the second processing record.
4. The method according to claim 3, characterized in that, The method further includes: The fourth state value is scanned at preset time intervals; The fourth state value is modified to a fifth state value, which is used to characterize the continued abnormality of the transaction.
5. The method according to any one of claims 1-4, characterized in that, In the first transaction phase, the target data is processed and frozen to obtain a first processing record, including: A freeze state bit is generated based on the target data, and the freeze state bit is marked as the first freeze value. Perform business processing on the target data and mark the frozen state bit as the second frozen value; and The first processing record is formed based on the second freeze value, the global transaction identifier, the branch identifier, and the version number.
6. The method according to claim 5, characterized in that, The step of performing business processing on the target data and marking the frozen state bit as the second frozen value includes: Business processes are performed on the target data by updating, inserting, and releasing row-level locks in the database.
7. A transaction processing apparatus, characterized in that, The device includes: The transaction processing module is used to perform transaction processing on the target data and freeze it in the first transaction phase to obtain the first processing record; A record generation module is used to generate a second processing record based on the first processing record. The second processing record includes: processing status and failure retry count, wherein the processing status is a first status value. The status value change module is used in the second transaction phase to obtain the transaction corresponding to the first status value and modify the first status value to the second status value. The business service invocation module is used to execute business services based on transactions based on the second status value; The status value change module is also used to update the second status value to a third status value when the business service is successfully processed, wherein the third status value is used to indicate that the business service processing is completed.
8. An electronic device, comprising: One or more processors; Memory, used to store one or more computer programs. The characteristic feature is that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program or instructions stored thereon, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program or instructions, characterized in that, When the computer program or instructions are executed by a processor, they implement the steps of the method according to any one of claims 1 to 6.