[go: up one dir, main page]

CN121146906A - A transaction request processing method, a transaction coordinator, a distributed lock manager, and a medium. - Google Patents

A transaction request processing method, a transaction coordinator, a distributed lock manager, and a medium.

Info

Publication number
CN121146906A
CN121146906A CN202511687308.2A CN202511687308A CN121146906A CN 121146906 A CN121146906 A CN 121146906A CN 202511687308 A CN202511687308 A CN 202511687308A CN 121146906 A CN121146906 A CN 121146906A
Authority
CN
China
Prior art keywords
execution
transaction
service
resource lock
condition
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202511687308.2A
Other languages
Chinese (zh)
Inventor
陈怿辉
童志祥
寻双贵
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Ping Pong Intelligent Technology Co ltd
Original Assignee
Hangzhou Ping Pong Intelligent Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Ping Pong Intelligent Technology Co ltd filed Critical Hangzhou Ping Pong Intelligent Technology Co ltd
Priority to CN202511687308.2A priority Critical patent/CN121146906A/en
Publication of CN121146906A publication Critical patent/CN121146906A/en
Pending legal-status Critical Current

Links

Landscapes

  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

本发明公开了一种交易请求处理方法,用于交易协调器,其中,包括:接收用户的交易请求;解析交易请求携带的用户行为信息和交易请求关联的多种业务服务;其中,所述用户行为信息为交易请求的唯一标识;向分布式锁管理器发送获取资源锁请求;在接收到分布式锁管理器发送的资源锁标识的情况下,在所述超期时间段对关联的多种业务服务执行补偿编排操作,以使得多种业务服务的执行状态保持一致;在多种业务服务的执行状态保持一致的情况下,向分布式锁管理器发送释放资源锁请求;在接收到分布式锁管理器发送的资源锁释放成功的情况下,将交易结果发送至用户。本发明提供的交易请求处理方法具有快速保证交易事务一致性和提升交易系统可靠性等优点。

This invention discloses a transaction request processing method for a transaction coordinator, comprising: receiving a user's transaction request; parsing user behavior information and various business services associated with the transaction request carried in the transaction request; wherein the user behavior information is a unique identifier for the transaction request; sending a resource lock acquisition request to a distributed lock manager; upon receiving a resource lock identifier from the distributed lock manager, performing compensation orchestration operations on the associated various business services during the overdue period to ensure that the execution status of the various business services remains consistent; while ensuring that the execution status of the various business services remains consistent, sending a resource lock release request to the distributed lock manager; and upon receiving a successful resource lock release notification from the distributed lock manager, sending the transaction result to the user. The transaction request processing method provided by this invention has advantages such as rapidly ensuring transaction consistency and improving the reliability of the transaction system.

Description

Transaction request processing method, transaction coordinator, distributed lock manager and medium
Technical Field
The present invention relates to the field of multi-service heterogeneous distributed technologies, and in particular, to a transaction request processing method, an electronic device, and a medium.
Background
Transaction involves a plurality of business services, each of which is processed by a corresponding business actuator, with a distributed architecture being common to transaction systems. When a customer initiates a transaction request, due to the characteristics of the distributed system, the business service related to the transaction request can only be independently completed by the corresponding executing mechanism.
When a business service is abnormal, the rollback (restoration) of all related businesses in the whole distributed transaction link to an initial state cannot be ensured, so that an intermediate state of partial success and partial failure is generated, and the consistency of transaction transactions is seriously affected.
Disclosure of Invention
The present invention aims to solve one of the technical problems in the related art to a certain extent. Therefore, the invention provides a transaction request processing method, a transaction coordinator for executing the transaction request processing method, a distributed lock manager for executing the transaction request processing method and a computer readable medium, which have the advantages of fast ensuring the consistency of transaction transactions, improving the reliability of a transaction system and the like.
In order to achieve the above object, as a first aspect of the present invention, there is provided a transaction request processing method for a transaction coordinator, wherein the transaction request processing method includes:
receiving a transaction request of a user;
Analyzing user behavior information carried by a transaction request and a plurality of business services associated with the transaction request, wherein the user behavior information is a unique identifier of the transaction request;
Sending a resource lock acquisition request to a distributed lock manager, wherein the resource lock request carries user behavior information and an out-of-date time period of a resource lock;
Under the condition that the resource lock identification sent by the distributed lock manager is received, performing compensation arrangement operation on the associated multiple service services in the out-of-date time period so as to keep the execution states of the multiple service services consistent;
And sending a request for releasing the resource lock to the distributed lock manager under the condition that the execution states of the plurality of business services are consistent, and sending a transaction result to the user under the condition that the resource lock release sent by the distributed lock manager is received to be successful, wherein the transaction result comprises a transaction success result or a transaction failure result.
Optionally, the business service includes a wind control compliance level, the business service is in a non-executing state, and the compensation arrangement operation is executed on the associated multiple business services under the condition that the resource lock identifier sent by the distributed lock manager is received, so that the executing states of the multiple business services are kept consistent, including:
Determining the execution sequence of the multiple business services according to the wind control compliance level of the multiple business services;
the method comprises the steps of executing business services according to an execution sequence, updating the non-executed state of the business services to an execution success state when the execution result of the business services indicates that the execution is successful, and updating the non-executed state of the business services to an execution failure state when the execution result of the business services indicates that the execution is failed;
and under the condition that the execution failure state is detected, performing compensation operation on the business services meeting the compensation conditions according to the compensation priority so as to update various business services associated with the business services in the execution failure state to the non-execution state.
Optionally, in the case that the execution failure state is detected, performing compensation operation on the service meeting the compensation condition according to the compensation priority, so as to update the multiple service services associated with the service in the execution failure state to the non-execution state, including:
Judging the service which is in the execution failure state before the execution sequence and is in the execution success state as the service which accords with the compensation condition;
executing operation of canceling service according to reverse order of execution order for service meeting compensation condition;
And under the condition that the execution result is detected to be the cancel success, updating the execution success state of the business service into the non-execution state.
Optionally, the operation of performing the operation of canceling the service on the service meeting the compensation condition in the reverse order of the execution order further includes:
Executing operation of canceling service of service in detected failure state;
And under the condition that the execution result is detected to be that the revocation is successful, updating the execution failure state of the business service into an unexecuted state.
Optionally, the sending the request for releasing the resource lock to the distributed lock manager under the condition that the execution states of the plurality of business services are consistent, and the sending the transaction result to the user under the condition that the resource lock release sent by the distributed lock manager is received successfully, comprises:
Under the condition that the execution states of the multiple business services are all successful execution states, a request for releasing the resource lock is sent to the distributed lock manager, and under the condition that the resource lock release sent by the distributed lock manager is successful, a transaction success result is sent to a client;
And under the condition that the execution states of the multiple business services are not executed, sending a request for releasing the resource lock to the distributed lock manager, and under the condition that the resource lock release sent by the distributed lock manager is successful, sending a transaction failure result to the client.
As a second aspect of the present invention, there is provided a transaction request processing method for a distributed lock manager, wherein the transaction request processing method includes:
Under the condition that a resource lock acquisition request sent by a transaction coordinator is received, analyzing user behavior information and an out-of-date time period carried by the resource lock acquisition request, and generating a resource lock identifier matched with the user behavior information;
transmitting the resource lock identification to a transactor coordinator;
Under the condition that a resource lock releasing request sent by a transaction coordinator is received, analyzing user behavior information carried by the resource lock releasing request, and deleting a resource lock identifier matched with the user behavior information;
And under the condition that the deletion of the resource lock identification is detected to be completed, successfully transmitting the release of the resource lock to the transaction coordinator.
Optionally, the transaction request processing method further includes:
Periodically detecting a resource lock identification, wherein the period is one third of the over-period time period;
And increasing the out-of-date time period under the condition that the existence of the resource lock identification is detected.
As a third aspect of the present invention, there is provided a transaction coordinator, comprising:
One or more processors;
A memory having one or more computer programs stored thereon, which when executed by the one or more processors cause the one or more processors to implement the transaction request processing method provided in accordance with the first aspect of the present invention.
As a fourth aspect of the present invention, there is provided a distributed lock manager, comprising:
One or more processors;
A memory having one or more computer programs stored thereon, which when executed by the one or more processors cause the one or more processors to implement a transaction request processing method provided in accordance with the second aspect of the present invention.
Further, as a fifth aspect of the present invention, there is also provided a computer-readable medium having stored thereon a computer program, wherein the computer program, when executed by a processor, implements the transaction request processing methods provided in the first and second aspects of the present invention.
The transaction request processing method provided by the invention firstly receives the transaction request through the transaction coordinator and analyzes and obtains the unique identification of the transaction request and the associated multiple business services, and applies for the resource lock to the distributed lock manager before execution so as to ensure the exclusive access of the shared resource and effectively prevent the resource conflict caused by repeated transaction requests. After the resource lock is applied successfully, the compensation arrangement operation is carried out on the associated multiple business services in an out-of-date time period, the operation is orderly carried out according to the association relation among the business services, when any business service fails to be carried out, the business service which fails to be carried out and the business service which is carried out successfully are rolled back accurately, the state of all business services is ensured to be consistent (restored to the initial unexecuted state), the intermediate states of partial success and partial failure are thoroughly eliminated, when the business services are carried out successfully or the state of the business services is consistent, the resource lock is applied to be released from a distributed lock manager, the shared resource is released in time, and the execution result of the transaction request is sent to a client. In order to ensure that the compensation arrangement operation is completed in the out-of-date period and the consistency of the transaction is ensured, the distributed lock manager can perform monitoring and renewing operation (if the compensation arrangement operation is not completed in the out-of-date period and the distributed lock manager does not perform any monitoring treatment, an intermediate state exists in the execution states of a plurality of business services, if the business services are in a successful execution state and some business services are in a failed execution state, once the out-of-date period is exceeded, the compensation arrangement is not completed and the resource lock is released, a user can initiate repeated requests by utilizing the intermediate state, and the conditions of funds loss or other business errors can be caused). Specifically, the distributed lock manager periodically detects the lock identifier of the resource lock in an out-of-date time, automatically renews according to the change condition of the lock identifier, and aims to complete compensation arrangement operation during the exclusive access of the resource, and release the resource lock when all service states are consistent. The method for realizing compensation arrangement through mutual coordination and cooperation of the transaction coordinator and the distributed lock manager ensures the consistency of transaction transactions, obviously improves the reliability of a transaction system and improves the utilization rate of system resources, and is particularly suitable for transaction scenes with high concurrency and high reliability requirements.
These features and advantages of the present invention will be disclosed in more detail in the following detailed description and the accompanying drawings. The best mode or means of the present invention will be described in detail with reference to the accompanying drawings, but is not limited to the technical scheme of the present invention. In addition, these features, elements, and components are shown in plural in each of the following and drawings, and are labeled with different symbols or numerals for convenience of description, but each denote a component of the same or similar construction or function.
Drawings
The invention is further described below with reference to the accompanying drawings:
FIG. 1 is a flow chart of a transaction request processing method for a transaction coordinator provided by the invention;
FIG. 2 is a flowchart illustrating an embodiment of a transaction request processing method step S140 according to the present invention;
FIG. 3 is a flowchart illustrating an embodiment of a transaction request processing method step S143 according to the present invention;
FIG. 4 is a flowchart illustrating an embodiment of the transaction request processing method step S143b according to the present invention;
FIG. 5 is a flowchart illustrating an embodiment of a transaction request processing method step S150 according to the present invention;
FIG. 6 is a flow chart of a transaction request processing method for a distributed lock manager provided by the present invention;
FIG. 7 is a flow chart of a process for acquiring, automatically renewing and releasing a resource lock between a transaction coordinator and a distributed manager according to the present invention;
FIG. 8 is a schematic diagram of a transaction coordinator provided by the present invention;
FIG. 9 is a schematic diagram of a distributed lock manager provided by the present invention;
FIG. 10 is a schematic diagram of a computer readable medium provided by the present invention.
Detailed Description
Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to like or similar elements or elements having like or similar functions throughout. The examples in the embodiments are intended to illustrate the present invention and are not to be construed as limiting the present invention.
Reference in the specification to "one embodiment" or "an example" means that a particular feature, structure, or characteristic described in connection with the embodiment itself can be included in at least one embodiment of the disclosure. The appearances of the phrase "in one embodiment" in various places in the specification are not necessarily all referring to the same embodiment.
In a distributed transaction system, a transaction often involves multiple independent business services (e.g., payment, clearing, pneumatic control, etc.), which are handled by different business executives. Because of the characteristics of the distributed architecture, each service is independently executed, and a unified compensation method is lacking, when one service is abnormal, the system cannot ensure that all the associated business services are either completely successful or completely rolled back, so that the problem of inconsistent transaction (partial success and partial failure occurs), the inconsistent transaction also brings the risk of unreliable transaction system, and if the log is manually checked, the state of the forced associated business service is manually compensated, so that the system has the limitations of long time consumption, high operation risk and poor business adaptability.
In view of this, as a first aspect of the present invention, there is provided a transaction request processing method for a transaction coordinator, as shown in fig. 1, the transaction request processing method comprising:
in step S110, a transaction request of a user is received;
In step S120, analyzing user behavior information carried by a transaction request and a plurality of business services associated with the transaction request, wherein the user behavior information is a unique identifier of the transaction request;
In step S130, a request for acquiring the resource lock is sent to a distributed lock manager, wherein the request for acquiring the resource lock carries user behavior information and an out-of-date time period of the resource lock;
In step S140, under the condition that the resource lock identifier sent by the distributed lock manager is received, performing compensation arrangement operation on the associated multiple service in the out-of-date period, so that the execution states of the multiple service remain consistent;
In step S150, a request for releasing the resource lock is sent to the distributed lock manager if the execution states of the multiple service services are consistent, and a transaction result is sent to the user if the resource lock release sent by the distributed lock manager is received successfully, wherein the transaction result comprises a transaction success result or a transaction failure result.
The transaction request processing method provided by the invention firstly receives the transaction request through the transaction coordinator and analyzes and obtains the unique identification of the transaction request and the associated multiple business services, and applies for the resource lock to the distributed lock manager before execution so as to ensure the exclusive access of the shared resource and effectively prevent the resource conflict caused by repeated transaction requests. After the resource lock is applied successfully, the compensation arrangement operation is carried out on the associated multiple business services within the over-time period, according to the orderly execution of the association relation between the business services, when any business service fails to be executed, the business service which fails to be executed and the business service which is executed successfully are rolled back accurately, the states of all the business services are ensured to be consistent (restored to the initial unexecuted state), the intermediate states of partial success and partial failure are thoroughly eliminated, when the business services are executed successfully or the states of the business services are consistent, the resource lock is applied to be released from the distributed lock manager, the shared resource is released in time, and the execution result of the transaction request is sent to the client. In order to ensure that the compensation arrangement operation is completed in the out-of-date time period and the consistency of the transaction is ensured, the distributed lock manager can perform monitoring and renewing operation (if the compensation arrangement operation is not completed in the out-of-date time period and the distributed lock manager does not perform any monitoring treatment, an intermediate state exists in the execution states of a plurality of business services, if the business services are in a successful execution state and some business services are in a failed execution state, and the time resource lock exceeding the out-of-date time period is released, a user can initiate repeated requests by utilizing the intermediate state, and the condition of funds loss or other business errors can be caused). Specifically, the distributed lock manager periodically detects the lock identifier of the resource lock in an out-of-date time, automatically renews according to the change condition of the lock identifier, and aims to complete compensation arrangement operation during the exclusive access of the resource, and release the resource lock when all service states are consistent. The method for realizing compensation arrangement through mutual coordination and cooperation of the transaction coordinator and the distributed lock manager ensures the consistency of transaction transactions, obviously improves the reliability of a transaction system and improves the utilization rate of system resources, and is particularly suitable for transaction scenes with high concurrency and high reliability requirements.
Taking a transaction request as an example of applying for loans by a three-way transaction system, the user behavior information is the three-way application for loans, and the multiple business services associated with the transaction request comprise four types of mortgage registration, loan issuing, insurance purchase and loan pre-examination. And sending a resource lock acquisition request to the distributed lock manager by taking the system time of the transaction coordinator after executing the analysis operation as the starting time, and carrying out compensation arrangement operation on four types of services such as the quality deposit registration, the loan issuing, the insurance purchasing and the loan pre-examination under the condition that the resource lock identification sent by the distributed lock manager is received (needing to be noted, a preset timeout period can be set for the receiving process, and if the resource lock is not received in the timeout period, the transaction request is canceled, and the preset timeout period can not be designated in a scene or a task with low time requirement). Taking the three-application loan as an example, the risk compliance assessment grades of four independent businesses are loan pre-examination, mortgage registration, insurance purchase and loan release in sequence from high to low, and the initial states of the four business services are all unexecuted states. As an embodiment of step S140, as shown in fig. 2, in the case of receiving the resource lock identifier sent by the distributed lock manager, performing a compensation orchestration operation on the associated multiple service services, so that the execution states of the multiple service services remain consistent, including:
in step S141, determining an execution sequence of the plurality of service services according to the wind control compliance level of the plurality of service services;
In step S142, the business service is executed according to the execution sequence, and the non-execution state of the business service is updated to be the successful execution state when the execution result of the business service indicates that the execution is successful;
In step S143, in the case where the execution failure state is detected, the compensation operation is performed on the business services conforming to the compensation condition in accordance with the compensation priority to update the plurality of business services associated with the business services in the execution failure state to the non-execution state.
In the case of applying for loan, the execution sequence of four business services is loan pre-examination, mortgage registration, insurance purchase and loan release, the initial state is the unexecuted state, and the state information of the business is updated only when the corresponding business execution result is obtained. If the loan pre-examination business state is updated from the non-execution state to the execution success state, or the loan pre-examination business state is updated from the non-execution state to the execution failure state.
In order to implement the fast rollback of the service, the compensation operation is triggered immediately when the service fails, and the transaction consistency, the data consistency and the resource release efficiency are ensured, as an implementation manner of step S143, as shown in fig. 3, in the case that the execution failure state is detected, the compensation operation is performed on the service meeting the compensation condition according to the compensation priority, so as to update the multiple service associated with the service in the execution failure state to the non-execution state, including:
in step S143a, the service that is in the successful execution state before the execution order of the service in the execution failure state is determined as the service that meets the compensation condition;
in step S143b, the operation of canceling the service is performed in reverse order of the execution order for the service that meets the compensation condition;
in step S143c, if the result of the execution is detected as the revocation success, the execution success state of the service is updated to the non-execution state.
The processing results of steps S143a to S143c are also described in detail with the example of applying for loan for three, and when four types of business of pre-review, mortgage registration, insurance purchase, and loan issuing are sequentially executed, the execution states of the four types of business services are sequentially an execution success state, an execution failure state, and an unexecuted state in the case that the insurance purchase state is an execution failure state. The loan pre-examination and the mortgage registration in the execution success state are used as business services meeting compensation conditions, the executed business service withdrawal instruction is sent to the corresponding business service execution mechanism (a banking system and a registration center) according to the sequence of the mortgage registration and the loan pre-examination, after the execution mechanism deletes the data information related to the appointed business service, the execution result instruction of the withdrawal success is sent to the transaction coordinator, and the transaction coordinator updates the execution success state of the mortgage registration business service into the non-execution state when the transaction coordinator detects that the execution result is the withdrawal success, and updates the execution success state of the loan pre-examination into the non-execution state after the operation is executed in the same way as the loan pre-examination. At this time, the states of the four types of business services are sequentially compensated as an unexecuted state, an execution failure state, and an unexecuted state. It is further required to update the execution status of the insurance purchase service with execution failure, as an alternative embodiment of step S143b, as shown in fig. 4, the operation of canceling the service is performed on the service that meets the compensation condition in the reverse order of the execution order, and further includes:
In step S143b1, a cancel service operation is performed on the detected service in the execution failure state;
In step S143b2, if the execution result is detected as the revocation success, the execution failure state of the service is updated to the non-execution state.
After the completion of steps S143b 1-S143 b2, after deleting the information related to the insurance purchase through the execution mechanism (insurance center) of the insurance purchase service, the state of the insurance purchase is updated to the unexecuted state, considering that the revocation of the insurance purchase service is successful. The execution states of the four types of business services are an unexecuted state, an unexecuted state and an unexecuted state in sequence. It should be noted that, in the case that each type of service is successfully executed according to the execution order, the states of the four types of service are sequentially an execution success state, and an execution success state. After the compensation arrangement processing, the states of the multiple business services of the transaction request can only be in the unexecuted state and the successful execution state, so that the consistency of the execution states of the multiple business services in the distributed transaction is ensured. As an implementation manner of step S150, as shown in fig. 5, in the case that the execution states of the multiple service services are consistent, a request for releasing the resource lock is sent to the distributed lock manager, and in the case that the resource lock release sent by the distributed lock manager is received successfully, a transaction result is sent to the user, where the method includes:
In step S151, when the execution states of the multiple service are all successful execution states, a request for releasing the resource lock is sent to the distributed lock manager, and when the successful release of the resource lock sent by the distributed lock manager is received, a successful transaction result is sent to the client;
In step S152, when the execution states of the multiple service are all unexecuted states, a request for releasing the resource lock is sent to the distributed lock manager, and when the successful release of the resource lock sent by the distributed lock manager is received, a transaction failure result is sent to the client.
The transaction request processing method provided by the invention further comprises the step of saving the process data of the transaction request processing into a corresponding transaction log, wherein the transaction log comprises the processing step of a time node, the execution result of the processing step and the process data of the processing step, so as to facilitate the subsequent optimization of the time efficiency and the resource utilization rate of the transaction request processing method or the rapid acquisition of the related data information of the designated transaction request in the processing process. The transaction log may be stored in a centralized manner or may be stored in an external storage medium. Thus, the traceability of transaction can be ensured, and the storage pressure of the transaction coordinator can be reduced.
As a second aspect of the present invention, there is provided a transaction request processing method for a distributed lock manager, as shown in fig. 6, comprising:
in step S210, under the condition that a request for acquiring a resource lock sent by a transaction coordinator is received, analyzing user behavior information and an out-of-date time period carried by the request for acquiring the resource lock, and generating a resource lock identifier matched with the user behavior information;
in step S220, the resource lock identifier is sent to a transactor coordinator;
in step S230, under the condition that a request for releasing the resource lock sent by the transaction coordinator is received, analyzing user behavior information carried by the request for releasing the resource lock, and deleting a resource lock identifier matched with the user behavior information;
In step S240, if it is detected that the deletion of the resource lock identifier is completed, the resource lock release is successfully transmitted to the transaction coordinator.
It is to be noted that distributed lock managers include, but are not limited to, redis distributed locks and Zookeeper distributed locks. In the case of the Zhang Sanapplication loan, the expiration period is 30s. And under the condition that the resource lock identifier matched with the user behavior information is generated, the target resource is locked in the expiration time period, and the thread with the resource lock identifier has exclusive processing authority.
As described above, in order to ensure that the target resource is always monopolized during execution of the transaction processing method, considering the problem of lock failure caused by that the completion time of the transaction processing method may exceed the expiration time period of the resource lock, the resource lock is released in advance (once the user initiates the repeat transaction request under the condition of lock failure, since the compensation arrangement corresponding to the previous transaction request is not completely completed, a plurality of service states corresponding to the repeat transaction request are mixed with the service state of the previous transaction request, so that the proceeding state of the transaction request cannot be accurately judged, and there is a fund loss and a service risk). To avoid the above, the distributed lock manager may automatically update the expiration period until the transaction coordinator keeps the execution states of all business services consistent and then releases the resource lock. As an embodiment of step S210, the transaction request processing method further includes:
In step S210a, periodically detecting a resource lock identification, wherein the period is one third of the out-of-date time period;
In step S210b, in the case where the existence of the resource lock flag is detected, the expiration period is increased.
The above steps S210a-S210b aim to illustrate that the resource lock can automatically renew the out-of-date period, so as to achieve that the single transaction request can be independently completed under the protected environment without being interfered by other requests, thereby avoiding the possibility of collision with other requests and further ensuring the consistency of the transaction. It should be noted that, the out-of-date time period of the loan application for Zhang Sanapplication is 30s, and the interval period of the interval check resource lock identifier is 10s. The method of acquiring, releasing and automatically renewing the resource lock by the transaction coordinator and the distributed lock manager is described in detail below with reference to the example of the loan application and fig. 7.
The following further explains why the transaction request processing method provided by the present invention needs to be completed by the cooperative work of the transaction coordinator and the distributed lock manager. The transaction coordinator firstly allocates a timeout period (called initial timeout period) to the distributed lock manager according to the transaction request, the distributed lock manager generates a resource lock corresponding to the transaction request (preventing the same transaction request, such as any request based on the same user, from being refused) and preventing other requests from being occupied, and judges whether the compensation arrangement operation of the transaction request is completely completed or not through monitoring/acquiring the processing information/release request of the transaction coordinator, if the release request of the transaction coordinator is not received in the initial timeout period (namely, the release request is not processed yet), the timeout period (the automatic renewal function of the distributed lock manager) is prolonged. And the automatic renewal is strongly bound with the actual processing time of the transaction request, so that a plurality of service states of a single transaction request are ensured to be consistent. The automatic renewal of the distributed lock needs to be described, the distributed lock manager takes one third of the initial timeout period as a scanning interval, scans whether the resource lock identifier exists in the distributed lock at intervals, if so, the timeout period is increased in advance in order to ensure that the compensation arrangement work of the transaction request can be completed in a protected environment, and the increment of the timeout period can be one third of the initial timeout period or can be configured in the lock manager in advance according to actual conditions.
It should be noted that, the foregoing embodiments are only for aiding in understanding the present invention, and the application scenario not representing the present solution is limited to a simple application scenario of the loan application. Generally, the transaction request is completed by a transaction system, and the method provided by the invention is particularly suitable for the transaction system, especially a cross-border payment system providing the technical scheme of the invention. In the field of cross-border payment wind control, when a user creates a transaction request, such as a vietnam coin payment request for remittance to vietnam, through a cross-border payment system, business services related to the request in the cross-border payment system include not only advanced risk screening, but also post-credit management, such as fund monitoring (monitoring fund sources and directions), checking whether the account of a fund payee is compliant, judging whether the fund transaction amount exceeds a supervision threshold, identifying whether the collection device IP is frequently changed, and the like. By monitoring the execution results of each associated service and performing compensation arrangement operation (namely rollback) according to the execution results, the transaction consistency of the transaction request can be ensured, the wind control early warning can be triggered in time, the completed service can be automatically withdrawn, and therefore the overall wind control risk of cross-border payment is reduced.
The proposal of the invention is not adopted in a cross-border payment system, a transaction coordinator and a distributed lock manager are not adopted to monitor the Vietnam coin payment request, when the funds transaction amount of the Vietnam coin payment request exceeds the supervision threshold value, the last service does not receive a withdrawal instruction (the account of a funds receiver is not compliant but the payment amount can be successfully received) due to lack of detection and compensation arrangement operation of a plurality of service execution states, and likewise the funds monitoring service also does not start the monitoring and tracking of the associated account according to the account of the funds receiver, meanwhile, under the condition that the distributed lock manager is not utilized, because the plurality of service states are inconsistent, if a user initiates a second Vietnam coin payment request through the transaction system again, the system can not accurately distinguish the service states of the two requests, misjudgment easily occurs, the risk payment request is misjudged or the normal payment request is intercepted, and the security and reliability of the cross-border payment system are seriously threatened.
The transaction request processing method provided by the invention firstly receives the transaction request through the transaction coordinator and analyzes and obtains the unique identification of the transaction request and the associated multiple business services, and applies for the resource lock to the distributed lock manager before execution so as to ensure the exclusive access of the shared resource and effectively prevent the resource conflict caused by repeated transaction requests. After the resource lock is applied successfully, compensation arrangement operation is carried out on a plurality of related business services, according to the orderly execution of the association relation among the business services, when any business service fails to execute, the business service which fails to execute and the executed business service are rolled back accurately, the state of all business services is ensured to be consistent (the business service is restored to the initial unexecuted state), the intermediate states of partial success and partial failure are thoroughly eliminated, when the business service is executed successfully or the state of the business service is consistent, the distributed lock manager is applied to release the resource lock, the shared resource is released in time, and the execution result of the transaction request is sent to the client. In order to ensure transaction consistency, the distributed lock manager periodically detects the lock identification of the resource lock in an out-of-date time, automatically renews according to the change condition of the lock identification, and aims to complete compensation arrangement operation during the exclusive access of the resource, and release the resource lock when all service states are kept consistent. The method for realizing compensation arrangement through coordination and cooperation of the transaction coordinator and the distributed lock manager ensures the consistency of transaction transactions, obviously improves the reliability of a transaction system and improves the utilization rate of system resources, and is particularly suitable for transaction scenes with high concurrency and high reliability requirements.
As a third aspect of the present invention, there is provided a transaction coordinator, as shown in fig. 8, comprising:
One or more processors 101;
A memory 102 having one or more computer programs stored thereon, which when executed by the one or more processors 101, cause the one or more processors 101 to implement a transaction request processing method provided in accordance with the first aspect of the present invention.
The tool may also include one or more I/O interfaces 103 coupled between the processor 101 and the memory 102 configured to enable information interaction of the processor 101 with the memory 102.
The processor 101 is a device with data processing capability, including but not limited to a Central Processing Unit (CPU) and the like, the first memory 102 is a device with data storage capability, including but not limited to a random access memory 102 (RAM, more specifically SDRAM, DDR and the like), a read only memory 102 (ROM), an electrically erasable programmable read only memory 102 (EEPROM), and a FLASH memory (FLASH), and an I/O interface 103 (read/write interface) is connected between the processor 101 and the memory 102, so as to enable information interaction between the processor 101 and the memory 102, including but not limited to a data Bus 104 (Bus) and the like.
In some embodiments, processor 101, memory 102, and I/O interface 103 are connected to each other via bus 104, and thus to other components of the computing device.
As a fourth aspect of the present invention, there is provided a distributed lock manager, as shown in fig. 9, comprising:
One or more processors 201;
a memory 202 having one or more computer programs stored thereon, which when executed by the one or more processors 201, cause the one or more processors 201 to implement a transaction request processing method provided in accordance with the second aspect of the present invention.
The tool may also include one or more I/O interfaces 203 coupled between the processor 201 and the memory 202 configured to enable information interaction of the processor 201 with the memory 202.
The processor 201 is a device with data processing capability, including but not limited to a Central Processing Unit (CPU) 201, the first memory 202 is a device with data storage capability, including but not limited to a random access memory 202 (RAM, more specifically SDRAM, DDR, etc.), a read only memory 202 (ROM), an electrically erasable programmable read only memory 202 (EEPROM), a FLASH memory (FLASH), and an I/O interface 203 (read/write interface) is connected between the processor 201 and the memory 202, so as to enable information interaction between the processor 201 and the memory 202, including but not limited to a data Bus 204 (Bus), etc.
In some embodiments, processor 201, memory 202, and I/O interface 203 are connected to each other and, in turn, to other components of the computing device via bus 204.
Further, as a fifth aspect of the present invention, there is also provided a computer-readable medium having stored thereon a computer program which, when executed by a processor, implements the transaction request processing methods provided in the first and second aspects of the present invention, as shown in fig. 10.
Those skilled in the art will appreciate that implementing all or part of the processes in the methods of the embodiments described above may be accomplished by computer programs to instruct related hardware. Accordingly, the computer program may be stored in a non-volatile computer readable storage medium, which when executed, performs the method of any of the above embodiments. Any reference to memory, storage, database, or other medium used in embodiments provided herein may include non-volatile and/or volatile memory. The nonvolatile memory can include Read Only Memory (ROM), programmable ROM (PROM), electrically Programmable ROM (EPROM), electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double Data Rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (SYNCHLINK) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), among others.
The above is only a specific embodiment of the present invention, but the scope of the present invention is not limited thereto, and it should be understood by those skilled in the art that the present invention includes but is not limited to the accompanying drawings and the description of the above specific embodiment. Any modifications which do not depart from the functional and structural principles of the present invention are intended to be included within the scope of the appended claims.

Claims (10)

1. A transaction request processing method for a transaction coordinator, the transaction request processing method comprising:
receiving a transaction request of a user;
Analyzing user behavior information carried by a transaction request and a plurality of business services associated with the transaction request, wherein the user behavior information is a unique identifier of the transaction request;
Sending a resource lock acquisition request to a distributed lock manager, wherein the resource lock request carries user behavior information and an out-of-date time period of a resource lock;
Under the condition that the resource lock identification sent by the distributed lock manager is received, performing compensation arrangement operation on the associated multiple service services in the out-of-date time period so as to keep the execution states of the multiple service services consistent;
And sending a request for releasing the resource lock to the distributed lock manager under the condition that the execution states of the plurality of business services are consistent, and sending a transaction result to the user under the condition that the resource lock release sent by the distributed lock manager is received to be successful, wherein the transaction result comprises a transaction success result or a transaction failure result.
2. The method according to claim 1, wherein the business service includes a wind control compliance level, the business service is in an unexecuted state, and the performing compensation arrangement operation on the associated plurality of business services to keep the execution states of the plurality of business services consistent when the resource lock identifier sent by the distributed lock manager is received includes:
Determining the execution sequence of the multiple business services according to the wind control compliance level of the multiple business services;
the method comprises the steps of executing business services according to an execution sequence, updating the non-executed state of the business services to an execution success state when the execution result of the business services indicates that the execution is successful, and updating the non-executed state of the business services to an execution failure state when the execution result of the business services indicates that the execution is failed;
and under the condition that the execution failure state is detected, performing compensation operation on the business services meeting the compensation conditions according to the compensation priority so as to update various business services associated with the business services in the execution failure state to the non-execution state.
3. The transaction request processing method according to claim 2, wherein in the case where the execution failure state is detected, performing a compensation operation on the traffic service conforming to the compensation condition in accordance with the compensation priority to update the plurality of traffic services associated with the traffic service in the execution failure state to the non-execution state, comprises:
Judging the service which is in the execution failure state before the execution sequence and is in the execution success state as the service which accords with the compensation condition;
executing operation of canceling service according to reverse order of execution order for service meeting compensation condition;
And under the condition that the execution result is detected to be the cancel success, updating the execution success state of the business service into the non-execution state.
4. The transaction request processing method according to claim 3, wherein the operation of canceling the service is performed in reverse order of the execution order for the service that meets the compensation condition, further comprising:
Executing operation of canceling service of service in detected failure state;
And under the condition that the execution result is detected to be that the revocation is successful, updating the execution failure state of the business service into an unexecuted state.
5. The method according to claim 1, wherein the step of sending a request for releasing the resource lock to the distributed lock manager in the case where the execution states of the plurality of service services are consistent, and the step of sending the transaction result to the user in the case where the resource lock release sent by the distributed lock manager is received successfully, comprises:
Under the condition that the execution states of the multiple business services are all successful execution states, a request for releasing the resource lock is sent to the distributed lock manager, and under the condition that the resource lock release sent by the distributed lock manager is successful, a transaction success result is sent to a client;
And under the condition that the execution states of the multiple business services are not executed, sending a request for releasing the resource lock to the distributed lock manager, and under the condition that the resource lock release sent by the distributed lock manager is successful, sending a transaction failure result to the client.
6. A transaction request processing method for a distributed lock manager, the transaction request processing method comprising:
Under the condition that a resource lock acquisition request sent by a transaction coordinator is received, analyzing user behavior information and an out-of-date time period carried by the resource lock acquisition request, and generating a resource lock identifier matched with the user behavior information;
transmitting the resource lock identification to a transactor coordinator;
Under the condition that a resource lock releasing request sent by a transaction coordinator is received, analyzing user behavior information carried by the resource lock releasing request, and deleting a resource lock identifier matched with the user behavior information;
And under the condition that the deletion of the resource lock identification is detected to be completed, successfully transmitting the release of the resource lock to the transaction coordinator.
7. The transaction request processing method according to claim 6, further comprising:
Periodically detecting a resource lock identification, wherein the period is one third of the over-period time period;
And increasing the out-of-date time period under the condition that the existence of the resource lock identification is detected.
8. A transaction coordinator, comprising:
One or more processors;
a memory having one or more computer programs stored thereon, which when executed by the one or more processors cause the one or more processors to implement the transaction request processing method of any of claims 1 to 5.
9. A distributed lock manager, comprising:
One or more processors;
Memory having one or more computer programs stored thereon, which when executed by the one or more processors cause the one or more processors to implement the transaction request processing method of any of claims 6 or 7.
10. A computer readable medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the transaction request processing method of any of claims 1 to 7.
CN202511687308.2A 2025-11-18 2025-11-18 A transaction request processing method, a transaction coordinator, a distributed lock manager, and a medium. Pending CN121146906A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202511687308.2A CN121146906A (en) 2025-11-18 2025-11-18 A transaction request processing method, a transaction coordinator, a distributed lock manager, and a medium.

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202511687308.2A CN121146906A (en) 2025-11-18 2025-11-18 A transaction request processing method, a transaction coordinator, a distributed lock manager, and a medium.

Publications (1)

Publication Number Publication Date
CN121146906A true CN121146906A (en) 2025-12-16

Family

ID=98004884

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202511687308.2A Pending CN121146906A (en) 2025-11-18 2025-11-18 A transaction request processing method, a transaction coordinator, a distributed lock manager, and a medium.

Country Status (1)

Country Link
CN (1) CN121146906A (en)

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB0407773D0 (en) * 2004-04-06 2004-05-12 Ibm Compensation of data item processing
US20160210627A1 (en) * 2015-01-16 2016-07-21 Red Hat, Inc. Distributed transaction with dynamic form
CN111475515A (en) * 2020-03-05 2020-07-31 深圳壹账通智能科技有限公司 Compensation management method, device, computer equipment and storage medium for failed tasks
CN113778631A (en) * 2021-01-29 2021-12-10 北京沃东天骏信息技术有限公司 Distributed transaction compensation method and device, electronic equipment and readable storage medium
CN117170844A (en) * 2023-09-04 2023-12-05 企查查科技股份有限公司 Offline propagation method and device of distributed lock, computer equipment and storage medium
CN118467115A (en) * 2024-05-22 2024-08-09 浙商银行股份有限公司 Transaction compensation method, system and device applied to multi-service heterogeneous distributed system

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
GB0407773D0 (en) * 2004-04-06 2004-05-12 Ibm Compensation of data item processing
US20160210627A1 (en) * 2015-01-16 2016-07-21 Red Hat, Inc. Distributed transaction with dynamic form
CN111475515A (en) * 2020-03-05 2020-07-31 深圳壹账通智能科技有限公司 Compensation management method, device, computer equipment and storage medium for failed tasks
CN113778631A (en) * 2021-01-29 2021-12-10 北京沃东天骏信息技术有限公司 Distributed transaction compensation method and device, electronic equipment and readable storage medium
CN117170844A (en) * 2023-09-04 2023-12-05 企查查科技股份有限公司 Offline propagation method and device of distributed lock, computer equipment and storage medium
CN118467115A (en) * 2024-05-22 2024-08-09 浙商银行股份有限公司 Transaction compensation method, system and device applied to multi-service heterogeneous distributed system

Similar Documents

Publication Publication Date Title
CN110457157B (en) Distributed transaction exception handling method and device, computer equipment and storage medium
US8650272B2 (en) Distributed transaction processing system having resource managers that collaborate to decide whether to commit or abort a transaction in response to failure of a transaction manager
US8676635B2 (en) Method and system for managing transactions
US6502122B1 (en) Method and apparatus for executing transaction programs in parallel
CN111667334B (en) Review failed order processing method, device, computer equipment and storage medium
US12198141B2 (en) Consensus key locking with fast local storage for idempotent transactions
CN108845866B (en) Method and apparatus for processing distributed transactions
CN108366132B (en) Method and device for managing service between servers, computer equipment and storage medium
US20070233924A1 (en) Apparatus, system, and method for resolving computing resource deadlocks
CN110674145A (en) Data consistency detection method and device, computer equipment and storage medium
CN116166390A (en) Service processing method and device, electronic equipment and storage medium
CN114168390A (en) Distributed consistent transaction execution method based on retry mechanism
CN112561506A (en) Live broadcast data processing method, system, device and medium based on virtual currency
CN112765126A (en) Database transaction management method and device, computer equipment and storage medium
CN113177052B (en) A method and device for processing business data consistency in a distributed system
CN108880873B (en) Transaction compensation method and device applied to heterogeneous system
CN113703831A (en) Method, device, equipment and medium for realizing service idempotency
US12198142B2 (en) Watchdog microservice to resolve locks when processing fails on a transaction exchange platform
CN121146906A (en) A transaction request processing method, a transaction coordinator, a distributed lock manager, and a medium.
US7552072B2 (en) Compensation of data item processing
CN109245941B (en) Service compensation method and device
CN115239176A (en) Task allocation method and device, storage medium, and computer equipment
CN114356888A (en) Transaction processing method and device, storage medium and electronic device
US20230144396A1 (en) Regenerating transaction objects when processing fails on a transaction exchange platform
CN117240924A (en) Request processing method, device, equipment and system of multiple data centers

Legal Events

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