Resource transfer method, device, equipment and system

By performing resource reservation and account status verification locally in the transaction manager, the distributed resource transfer process is optimized, solving the performance bottleneck problem of distributed transactions under high network latency and load, improving transfer efficiency and success rate, and reducing costs. Probability of failure.

CN118656178APending Publication Date: 2024-09-17ALIPAY COM CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410668778.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-27
Publication Date
2024-09-17

AI Technical Summary

Technical Problem

Existing distributed transaction solutions take a long time under high network latency and high system load conditions, which may lead to business failure and affect user experience.

Method used

By performing resource reservation and account status verification locally in the transaction manager, the database locking requirements for resource transfer accounts are reduced, the distributed resource transfer transaction processing process is optimized, and the risk of network dependence and lock conflicts is reduced.

Benefits of technology

It improves the efficiency and success rate of resource transfer operations, reduces the probability of transaction failure due to remote network communication, and improves user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118656178A
    Figure CN118656178A
Patent Text Reader

Abstract

The invention provides a resource transfer method, device, equipment and system. According to the scheme, for a distributed transaction for resource transfer from a first account to a second account, in the first stage of two-stage submission, on one hand, a transaction manager calls a local first resource manager to execute resource reservation operation on the first account in a first database, and resource reservation state information is obtained; on the other hand, the transaction manager calls the first resource manager to execute verification operation on the account state information of the second account in the account state data set, and an account state verification result is obtained; and then, resource transfer can be carried out according to the resource reservation state information and the account state verification result.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of distributed technology, and in particular to a resource transfer method, a resource transfer device, a computing device, and a resource transfer system. Background Art

[0002] With the development of Internet technology, scenarios based on distributed network processing and data storage are becoming more and more common. This method greatly improves the processing capability of the business processing process and the scalability of the business upgrade process. In the prior art, in order to ensure the ACID characteristics of data in each node in the distributed network, that is, atomicity, consistency, isolation and durability, the concept of distributed transactions is proposed. Distributed transactions are used to ensure that the data of each node in the distributed network maintains strong consistency. A common distributed transaction is implemented based on a two-phase commit solution.

[0003] Existing distributed transaction solutions, such as Seata (simple extensiable autonomous transaction architecture), usually rely on global locking and two-phase commit mechanisms, which have performance bottlenecks, are relatively time-consuming, and have poor user experience. Especially in the case of network delays and high system loads, it may directly lead to business failure. Summary of the invention

[0004] In view of this, the embodiments of the present application provide a resource transfer method, apparatus, device and system to solve the problems of relatively high time consumption, high network delay and even possible business failure in the distributed transaction solution of the existing method.

[0005] According to a first aspect of an embodiment of the present application, a resource transfer method is provided for transferring resources from a first account to a second account, the method comprising:

[0006] The transaction manager calls the local first resource manager to perform a resource reservation operation on the first account in the first database, and obtains resource reservation status information;

[0007] The transaction manager calls the first resource manager to perform a verification operation on the account status information of the second account in the account status data set to obtain an account status verification result;

[0008] The resources are transferred according to the resource reservation status information and the account status verification result.

[0009] According to a second aspect of an embodiment of the present application, there is provided a resource transfer device for transferring resources from a first account to a second account, the device comprising:

[0010] A resource reservation module, configured to call a local first resource manager to perform a resource reservation operation on the first account in the first database, and obtain resource reservation status information;

[0011] an account status verification module, configured to call the first resource manager to perform a verification operation on the account status information of the second account in the account status data set, and obtain an account status verification result;

[0012] The transaction submission module is used to transfer resources according to the resource reservation status information and the account status verification result.

[0013] According to a third aspect of an embodiment of the present application, a resource transfer device is provided for transferring resources from a first account to a second account, the device comprising:

[0014] at least one processor; and,

[0015] a memory communicatively connected to the at least one processor; wherein,

[0016] The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to:

[0017] Calling a local first resource manager to perform a resource reservation operation on the first account in the first database, and obtaining resource reservation status information;

[0018] calling the first resource manager to perform a verification operation on the account status information of the second account in the account status data set to obtain an account status verification result;

[0019] The resources are transferred according to the resource reservation status information and the account status verification result.

[0020] According to a fourth aspect of an embodiment of the present application, a resource transfer system is provided for transferring resources from a first account to a second account, the system comprising a transaction manager and a first resource manager; wherein:

[0021] The transaction manager is used to call the local first resource manager to execute the first phase transaction of resource transfer;

[0022] The first resource manager is used to, in response to the call of the transaction manager, perform a resource reservation operation on the first account in the first database to obtain resource reservation status information and perform a verification operation on the account status information of the second account in the account status data set to obtain an account status verification result;

[0023] The transaction manager is further configured to initiate a second phase transaction of resource transfer according to the resource reservation status information and the account status verification result.

[0024] An embodiment of the present specification can at least achieve the following beneficial effects: during the cross-region resource transfer process, in the first stage of the two-stage commit, the transaction manager calls the local first resource manager, on the one hand, performs an account reservation operation on the first account of the resource to be transferred out to obtain resource reservation status information, and on the other hand, performs an account status verification operation on the second account of the resource to be transferred in to obtain an account status verification result, and then performs the second stage of the two-stage commit based on the resource reservation status information and the account status verification result. Thus, the account status data set added locally in the transaction manager is used to optimize the distributed resource transfer transaction processing flow, reducing the need for database locking of the resource transfer account. Through this optimization, while ensuring transaction consistency, the efficiency and success rate of the resource transfer operation can be greatly improved, and the probability of transaction processing failure due to remote network communication problems is reduced to a certain extent. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0026] Figure 1 A schematic diagram of a scenario of a distributed transfer transaction processing method using a two-phase commit protocol in the prior art is shown;

[0027] Figure 2 A schematic diagram of a scenario of a distributed transfer transaction processing method relying on an improved two-phase commit protocol in an embodiment of this specification is shown;

[0028] Figure 3 A schematic diagram of a scenario in which a distributed system is used to transfer resources in an actual application scenario according to an embodiment of this specification is shown;

[0029] Figure 4 A schematic diagram of a resource transfer method provided in an embodiment of this specification is shown;

[0030] Figure 5 A successful transfer flow chart based on an embodiment of this specification is shown in a cross-region transfer scenario;

[0031] Figure 6 The embodiment of this specification provides a corresponding Figure 4 A schematic diagram of the structure of a resource transfer device;

[0032] Figure 7 The embodiment of this specification provides a corresponding Figure 4 A structural schematic diagram of a resource transfer device. DETAILED DESCRIPTION

[0033] Many specific details are described in the following description to facilitate a full understanding of the present application. However, the present application can be implemented in many other ways than those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present application, so the present application is not limited by the specific implementation disclosed below.

[0034] The terms used in one or more embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit one or more embodiments of the present application. The singular forms of "a", "said" and "the" used in one or more embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in one or more embodiments of the present application refers to and includes any or all possible combinations of one or more associated listed items.

[0035] It should be understood that, although the terms first, second, etc. may be used to describe various information in one or more embodiments of the present application, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of one or more embodiments of the present application, the first may also be referred to as the second, and similarly, the second may also be referred to as the first. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0036] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards in the relevant regions, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0037] A transaction can be considered as a large activity, which is composed of different small activities, which are either all successful or all failed. In computer systems, transactions are more often controlled by relational databases, which are implemented by using the transaction characteristics of the database itself, so they are called database transactions. Since applications mainly rely on relational databases to control transactions, and databases are usually on the same server as applications, transactions based on relational databases are also called local transactions. Database transactions have four major characteristics, ACID, namely, atomicity, consistency, isolation, and durability.

[0038] With the rapid development of the Internet, software systems have transformed from monolithic applications to distributed applications. Distributed systems split an application system into multiple services that can be deployed independently, so remote collaboration between services is required to complete transaction operations. In this distributed system environment, transactions completed by different services through remote collaboration over the network are called distributed transactions. For example, user registration and bonus point transactions, order creation and inventory reduction transactions, and bank transfer transactions are all distributed transactions. Distributed transactions refer to transactions across multiple databases, systems, or network nodes, which require coordination and management to ensure data consistency and integrity. Based on the distributed architecture, traditional database transactions cannot be used, and transfer transactions need to be implemented through remote calls. Due to network problems, distributed transaction problems will occur. The scenarios in which distributed transactions are generated can include scenarios of microservice architecture (i.e., distributed transactions are generated across processes, and transaction operations are completed through remote calls between microservices), scenarios in which a monolithic system accesses multiple databases (i.e., distributed transactions are generated across data instances, and distributed transactions are generated when a monolithic system needs to access multiple databases (instances)), and scenarios in which multiple services access the same database instance.

[0039] In the embodiments of this specification, in the face of the challenge of big data, in order to overcome the high concurrency of the payment system and improve disaster recovery performance, the payment service provider usually adopts a horizontal split database architecture, that is, a database is divided into multiple database instances, each instance contains a part of the global data set, to improve performance and scalability. As a result, the distributed transaction problem will be introduced.

[0040] The two-phase commit protocol is a distributed transaction protocol that ensures that transactions are fully committed or fully rolled back in all participating systems, ensuring the atomicity of transactions. Many common relational databases (for example, MySQL, etc.) support the two-phase commit protocol. Two-phase commit (also known as two-phase commit, abbreviated as 2PC) divides the entire transaction into two phases, the prepare phase and the commit phase. The 2 in 2PC refers to the two phases, P refers to the prepare phase, and C refers to the commit phase. In the prepare phase, the transaction manager sends a Prepare message to each participant, and each database participant executes the transaction locally and writes a local Undo / Redo log. At this time, the transaction is not committed. The Undo log records the data before modification, which is used for database rollback, and the Redo log records the modified data, which is used to write to the data file after the transaction is committed. In the commit phase, if the transaction manager receives an execution failure or timeout message from a participant, it sends a rollback message to each participant; otherwise, it sends a commit message; the participant executes the commit or rollback operation according to the instructions of the transaction manager and releases the lock resources used in the transaction processing process.

[0041] In order to reduce unnecessary docking costs, the International Open Group defines the distributed transaction processing model DTP (Distributed Transaction Processing). The DTP model defines the following roles: AP (Application Program), that is, the application using 2PC distributed transactions; RM (Resource Manager), that is, the resource manager, is a participant in the transaction, generally refers to a database instance, which controls the database through the resource manager and controls the branch transaction; TM (Transaction Manager), that is, the transaction manager, is responsible for coordinating and managing transactions and controlling the entire global transaction. The DTP model defines the interface specification for communication between the global transaction manager TM and the local resource manager RM as the XA specification. Implementing 2PC based on the database's XA protocol is also called the XA solution. The purpose of the XA specification is to allow multiple resources (such as databases, message queues, etc.) to be accessed in the same transaction, so that ACID properties can remain valid across applications. The XA specification uses two-phase commit (2PC, Two-Phase Commit) to ensure that all resources commit or roll back any specific transaction at the same time. At present, almost all mainstream databases provide support for the XA specification.

[0042] Seata (simple extensiable autonomous transaction architecture) is a distributed transaction solution evolved from two-phase commit. Seata defines global transactions as the overall coordination of several branch transactions. Seata defines three components: Transaction Manager (TM), Transaction Coordinator (TC) and Resource Manager (RM). Among them, TC is an independent middleware that needs to be deployed and run independently. It maintains the running status of global transactions, receives TM instructions to initiate the commit and rollback of global transactions, and is responsible for communicating with RM to coordinate the commit or rollback of each branch transaction. TM needs to be embedded in the application to work. It is responsible for starting a global transaction and ultimately initiating global commit or global rollback instructions to TC. RM controls branch transactions, is responsible for branch registration and status reporting, and receives instructions from the transaction coordinator TC to drive the commit and rollback of branch (local) transactions. Seata's global transaction processing process is divided into two stages: the execution stage, executing branch transactions and ensuring that the execution results are rollbackable and durable when satisfied; the completion stage, based on the resolution formed by the results of the execution stage, the application sends a global commit or rollback request through TM to TC, and TC commands RM to drive the branch transaction to commit or rollback.

[0043] Seata provides flexible transaction (AT, TCC, SAGA) transaction mode and rigid transaction XA transaction mode. Among them, AT, TCC, and Saga are all compensatory. The compensatory transaction processing mechanism is built on transaction resources (either at the middleware level or at the application level). The transaction resources themselves are unaware of distributed transactions, so data consistency from a global perspective outside the transaction framework cannot be guaranteed. Seata's XA mode refers to a transaction mode that uses the support of transaction resources (databases, message services, etc.) for the XA protocol to manage branch transactions using the mechanism of the XA protocol within the distributed transaction framework defined by Seata. In Seata's XA mode, because transaction resources perceive and participate in the distributed transaction processing process, transaction resources (such as databases) can ensure effective isolation of data access from any perspective and meet global data consistency. In application scenarios such as transfers, Seata's XA mode is usually used.

[0044] The two-phase commit of distributed transactions implemented based on the XA protocol has little intrusion on the business. Users can use distributed transactions based on the XA protocol like local transactions, and can strictly guarantee the ACID characteristics of transactions. At the same time, distributed transactions implemented based on the XA protocol need to lock all required resources during execution. For example, in Seata's XA mode, the resources involved in each branch transaction need to be locked during both the execution phase and the submission phase. Therefore, locking resources may cause blocking problems. In the embodiments of this specification, a distributed transaction processing solution improved on Seata's XA mode is provided.

[0045] Figure 1 A scenario diagram of a distributed transfer transaction processing method using a two-phase commit protocol in the prior art is shown.

[0046] like Figure 1 As shown in , assuming that a distributed transaction of transferring X yuan from account A to account B is executed, then in the first stage of the distributed transaction processing, after the server in the first area receives the accounting request sent by the upstream (step 1), it is necessary not only to perform a transfer-out preparation operation for account A in the local A database to obtain the first branch operation result, but also to perform a transfer-in preparation operation for account B in the B database in the second area through a remote procedure call to obtain the second branch operation result (steps 2 and 3), and then, based on the first branch operation result and the second branch operation result, the first stage operation result is fed back to the upstream (step 4). Among them, steps 1 to 4 reflect the steps involving remote network communication in the entire distributed transaction execution process. In actual application, during the process of performing a transfer-out preparation operation on account A in the first stage, account A needs to be locked; and during the process of performing a transfer-in preparation operation on account B in the first stage, account B needs to be locked.

[0047] although Figure 1 Not shown, in the second stage of the distributed transaction processing, it is necessary to commit the transfer transaction or roll back the transfer transaction. Specifically, the server in the first area needs to perform a transfer-out commit operation for account A in the local A database, and on the other hand, it needs to perform a transfer-in commit operation for account B in the B database in the second area through a remote procedure call. At this point, the transfer is successful and the entire transfer transaction is completed. Or, specifically, the server in the first area needs to perform a transfer-out rollback operation for account A in the local A database, and on the other hand, it needs to perform a transfer-in rollback operation for account B in the B database in the second area through a remote procedure call. At this point, the transfer fails and the entire transfer transaction is ended.

[0048] based on Figure 1The solution uses the traditional two-phase commit mechanism. When database A where account A is located is in a different location from database B where account B is located, a remote procedure call needs to be made to the remote database in both the first and second stages. Cross-city calls will increase the time consumption by about 30ms, affecting the user experience; and cross-city calls will increase the dependence on cross-city networks. If network anomalies or jitters occur, the system stability will be affected. Therefore, in the prior art, when the two-phase commit protocol is applied to implement distributed transactions such as transfer services, it is not only time-consuming, but may also lead to performance bottlenecks, and the overall number of transactions per second (TPS) cannot be supported to be too high; especially in the case of network delays and high system loads, it may directly lead to business failures.

[0049] In the embodiments of this specification, the inventors consider that for the transfer business, as long as the account status is confirmed to be normal, the payment can usually be successfully received, and other operations (such as pre-increase resource operations) may not be performed on the payment account. Figure 2 The schematic diagram of the scenario of the distributed transfer transaction processing method relying on the improved two-phase commit protocol in the embodiment of this specification is shown.

[0050] like Figure 2 As shown in , assuming that a distributed transaction of transferring X yuan from account A to account B is executed, then in the first stage of the distributed transaction processing, after the server in the first region receives the transfer request sent by the upstream (step 1), on the one hand, a resource reservation operation is performed for account A in the local A database to obtain resource reservation status information, and on the other hand, the account status information of account B is queried and verified from the account status information set of the full amount of accounts stored locally to obtain the account status verification result, and then, based on the account reservation status information and the account status verification result, the first stage operation result is fed back to the upstream (step 2). Among them, steps 1 and 2 reflect the steps involving remote network communication in the entire distributed transaction execution process. In actual application, in the process of performing the transfer preparation operation on account A in the first stage, account A needs to be locked; in the first stage, since no operation is performed on the source data of account B, there is no need to lock account B.

[0051] based on Figure 2 The solution, on the one hand, eliminates the cross-city network dependence in the first stage and reduces the impact of cross-city network anomalies; on the other hand, it reduces the network time consumption caused by cross-city calls and improves the user experience; on the other hand, there is no need to lock the collection account in the first stage, reducing the probability of lock conflict problems.

[0052] In an embodiment of the present specification, a distributed system using a two-phase commit protocol is provided, in which components such as those provided in Seata may be provided, including a transaction manager (TM), a transaction coordinator (TC), and a resource manager (RM). More specifically, the distributed system may include a transaction coordinator, a transaction manager, and one or more resource managers. Among them, the transaction coordinator may be deployed on a transaction coordination server, the transaction manager may be deployed on an APP server (i.e., an application server), and the resource manager may be deployed on a database server (e.g., a database server).

[0053] Figure 3 A schematic diagram of a scenario in which a distributed system is used to transfer resources in an actual application scenario of an embodiment of this specification is shown.

[0054] In the embodiments of this specification, in the scenario of cross-region resource transfer, the first account from which the resources are transferred out and the second account to which the resources are transferred in are located in different regions. For example, the first account may be located in city A, and the second account may be located in city B; for another example, the first account may be located in computer room A, and the second account may be located in computer room B. In actual application, communication between services deployed in the same region can be achieved through local procedure calls, and communication between services deployed in different regions needs to be achieved through remote procedure calls.

[0055] like Figure 3 As shown, a transaction coordination server deployed with a transaction coordinator (TC), an APP server deployed with a transaction manager (TM), and a first database server deployed with a first resource manager (first RM) can be located in a first region, and a first database and an account status data set can be run on the first database server. A second database server deployed with a second resource manager (second RM) can be located in a second region different from the first region, and a second database can be run on the second database server.

[0056] The first database may contain the account data of the first account, or the first database contains the source data of the first account; the second database may contain the account data of the second account, or the second database contains the source data of the second account; the account data may at least include account identification, account resource value information, account status information, etc. The account status data set may include account identification and account status information of all accounts; the all accounts may include the first account and the second account.

[0057] In actual application, similar to the first database server, the second database server may also run an account status dataset. Since the process of transferring resources from the first account to the second account does not involve the account status dataset deployed on the second database server, for the sake of simplicity, Figure 3 The account status data set running on the second database server is not shown.

[0058] like Figure 3 As shown in, 1) the user terminal sends an accounting request to the APP server; 2) the transaction manager in the APP server requests the transaction coordinator to start a distributed transaction and obtains response information; 3) in the first stage of the distributed transaction execution two-stage commit, the transaction manager calls the first resource manager through a local procedure, on the one hand, performs a resource reservation operation for the first account on the first database to obtain resource reservation status information, and on the other hand, performs an account status verification operation for the second account on the read-only account status data set to obtain an account status verification result, and the first resource manager sends the resource reservation status information and the account status verification result to the transaction manager; 4) the transaction manager feeds back the resource reservation status information and the account status verification result to the transaction coordinator, and the first stage ends.

[0059] For simplicity, Figure 3 The execution process of the second phase of the two-phase commit is not shown. In actual application, in the second phase, the transaction coordinator can respond to the request of the transaction manager to call the first resource manager to perform the actual resource transfer-out operation on the first account and call the second resource manager to perform the actual resource transfer-in operation on the second account.

[0060] In the embodiments of this specification, a resource transfer method is provided, which also involves a resource transfer apparatus, a computing device and a resource transfer system, which are described in detail one by one in the following embodiments.

[0061] Figure 4 A flowchart of a resource transfer method provided in an embodiment of this specification.

[0062] From the program perspective, the execution subject of the process can be a program installed on the APP server. It can be understood that the method can be executed by any device, equipment, platform, or device cluster with computing and processing capabilities.

[0063] In an embodiment of the present specification, the resource transfer method is applied to a distributed system using a two-phase commit protocol. The resource transfer method is used to transfer resources from a first account to a second account. Specifically, the first account and the second account may be located in different regions, for example, in different computer rooms or different cities. Typically, communication between services in different regions requires remote procedure calls.

[0064] The resource transfer transaction may include, but is not limited to, any transaction involving the transfer of resources between two accounts, such as transfer, repayment, bill payment, and fee payment.

[0065] like Figure 4 As shown, the process may include the following steps:

[0066] Step 402: The transaction manager calls the local first resource manager to perform a resource reservation operation on the first account in the first database, and obtains resource reservation status information.

[0067] In the embodiments of the present specification, the distributed transaction of resource transfer may include two branch transactions, namely, a resource transfer-out transaction and a resource transfer-in transaction. Hereinafter, the resource transfer-out transaction is also referred to as a first branch transaction, and the resource transfer-in transaction is referred to as a second branch transaction. Typically, in the first phase of the two-phase commit, preparation operations for the resource transfer-out transaction and the resource transfer-in transaction need to be performed.

[0068] Step 402 describes the first stage of executing a resource transfer-out transaction (i.e., a first branch transaction), i.e., performing a resource reservation operation on the first account. Specifically, the transaction manager may send a resource reservation message to the first resource manager, and the resource reservation message may carry the account identifier of the first account and the resource value to be transferred; then, the first resource manager may respond to the resource reservation message to determine whether the first account meets the conditions for performing the resource reservation operation and obtain a first determination result; if the first determination result is yes, the resource reservation operation corresponding to the resource value to be transferred may be performed and successful resource reservation status information may be returned; if the first determination result is no, failed resource reservation status information may be returned.

[0069] Optionally, the determining whether the first account satisfies a condition for performing a resource reservation operation may specifically include: determining whether the account status of the first account is normal and whether the current resource value of the first account is not less than the resource value to be transferred.

[0070] Optionally, executing the resource reservation operation corresponding to the resource value to be transferred may specifically include: adding a first log record corresponding to the first account; the first log record is used to indicate that the resources corresponding to the resource value to be transferred will be transferred from the first account.

[0071] Optionally, the execution of the resource reservation operation corresponding to the resource value to be transferred may further include: setting the reserved resource value of the reserved resource field corresponding to the first account according to the resource value to be transferred, wherein the reserved resource value is used to return the difference between the current resource value of the first account and the reserved resource value when the first resource manager receives an account resource value for querying the first account.

[0072] In the embodiments of the present specification, the call of the transaction manager to the local first resource manager may refer to a local procedure call (LPC). LPC generally refers to the mutual communication between processes running on the same machine, that is, in a multi-process operating system, different running processes can perform function calls through LPC.

[0073] In actual application, in order to ensure that during the execution of the transaction, no other concurrent transactions will operate on the data involved in the transaction and cause conflicts or errors, a locking operation can be performed on the data of the account involved in the transaction. In an embodiment of the present specification, in the first stage of the two-stage commit, for the branch transaction of resource transfer out, it is necessary to perform a resource reservation operation on the first database where the account data of the first account is located. Therefore, before performing the resource reservation operation, it is necessary to perform a locking operation on the first account. Specifically, before the transaction manager sends a resource reservation message to the first resource manager, a locking operation can also be performed on the first account; and if the first judgment result is yes, a lock release operation can also be performed on the first account after performing the resource reservation operation corresponding to the resource value to be transferred; similarly, if the first judgment result is no, a lock release operation can also be performed on the first account after returning the failed reservation status information.

[0074] Step 404: the transaction manager calls the first resource manager to perform a verification operation on the account status information of the second account in the account status data set to obtain an account status verification result.

[0075] Step 404 describes the first stage of executing the resource transfer transaction (i.e., the second branch transaction). In the embodiment of the present specification, when executing the preparation operation of the resource transfer, the second account in the second database is not operated by remotely calling the second resource manager as in the prior art, but the full account status data set containing the account status data of the full account is used, and the first resource manager is called through a local procedure to verify whether the account status of the second account is normal based on the account status information in the account status data set.

[0076] In step 404, the account status information of the second account in the account status data set is consistent with the account status information contained in the account data of the second account in the second database; in fact, the account status information of each account in the account status data set can be updated in real time according to the change of data in the database containing the account data of each account. The account status data set and the first database run on a first database server where the first resource manager is deployed, and the second database runs on a second database server where the second resource manager is deployed. The first database server and the second database server are located in different areas (for example, different computer rooms, different cities, etc.), so that the first resource manager and the second resource manager communicate through the remote procedure call protocol.

[0077] In the embodiment of the present specification, the account status may include a normal status, a frozen status, a deregistered status, etc. In the embodiment of the present specification, considering that the change frequency of the status information of the account is usually not high, therefore, the account status information of each account can be stored by adding a read-only account status data set on each database server, so as to query the account status of the resource transfer account when executing the first stage of the two-stage submission, so as to replace the database where the account data of the resource transfer account is located by operating the remote procedure call, reduce the delay by reducing the remote procedure call, and reduce the problems of low transaction processing efficiency and low success rate caused by network communication.

[0078] In an embodiment of the present specification, the account status data set may include a read-only database or cache. The cache may be a distributed cache, such as Redis, which is used to store frequently accessed data to reduce the number of accesses to the original data source (such as the database where the account data of the resource transfer account is located) and improve the transaction processing performance of the distributed system.

[0079] To explain the account status data set, an example is given. For example, the account data of account A can be stored in the first database deployed on the first database server, the account data of account B can be stored in the second database deployed on the second database server, and the account data of account C can be stored in the third database deployed on the third database server. Then, the first database server, the second database server, and the third database server can all be provided with account status data sets containing account status information of all accounts (including account A, account B, account C, etc.), and the account status information of account A in these account status data sets is consistent with that in the first database, the account status information of account B is consistent with that in the second database, and the account status information of account C is consistent with that in the third database. Assuming that the account status information of account A in the first database changes, the account status information of account A in the account status data sets on the first database server, the second database server, and the third database server will be synchronously updated. If the account status information of account B in the second database changes, the account status information of account B in the account status data sets on the first database server, the second database server, and the third database server will be synchronously updated. Similarly, if the account status information of account C in the third database changes, the account status information of account C in the account status data sets on the first database server, the second database server, and the third database server will be synchronously updated.

[0080] In the embodiments of the present specification, in the first phase of the two-phase commit, for the branch transaction of resource transfer, since only the verification operation is performed on the newly added read-only account status data set, and there is no need to perform any operation on the second database where the account data of the second account (that is, the source data of the second account) is located, there is no need to perform a locking operation on the second database (specifically, the second account), which can reduce data occupancy time and reduce lock conflicts.

[0081] Step 406: Perform resource transfer according to the resource reservation status information and the account status verification result.

[0082] Specifically, the transaction manager determines a transaction execution resolution according to the resource reservation status information and the account status verification result, and the transaction execution resolution includes a transaction commit resolution or a transaction rollback resolution; then, the transaction manager sends a second-phase transaction execution request corresponding to the transaction execution resolution to the transaction coordinator, and the second-phase transaction execution request includes a transaction commit request corresponding to the transaction commit resolution or a transaction rollback request corresponding to the transaction rollback resolution; thereafter, according to the second-phase transaction execution request, the transaction coordinator may call a resource manager to execute a second-phase transaction of resource transfer, wherein the resource manager includes a first resource manager corresponding to a first database containing account data of a first account and a second resource manager corresponding to a second database containing account data of a second account.

[0083] In an optional embodiment, if the resource reservation status information indicates that the resource reservation is successful and the account status verification result indicates that the second account is in a preset account status, the transaction manager may generate a transaction commit resolution. Generally, the account status may include a normal status, a frozen status, a deregistered status, etc. In an embodiment of this specification, the preset account status may include a normal status. Accordingly, the transaction manager may send a transaction commit request to the transaction coordinator.

[0084] If the second-stage transaction execution request includes a transaction commit request, on the one hand, the transaction coordinator may call the first resource manager to perform an actual resource deduction operation on the first account to obtain a first commit result; on the other hand, the transaction coordinator may perform an actual resource increase operation on the second account through a remote procedure call to the second resource manager corresponding to the second database including the account data of the second account to obtain a second commit result; thereafter, the transaction coordinator may send the first commit result and the second commit result to the transaction manager; wherein the first commit result and the second commit result are used as a basis for the transaction manager to determine a resource transfer result. The resource transfer result may include a successful resource transfer or a failed resource transfer. Specifically, if the first commit result indicates that the actual resource deduction of the first account is successful and the second commit result indicates that the actual resource increase of the second account is successful, then a successful resource transfer result is obtained; otherwise, a failed resource transfer result is obtained.

[0085] In practical application, the actual resource transfer operation of the account needs to be performed on the source database that stores the account data. For example, if you want to perform a resource transfer operation on account A, you need to perform the operation on the first database that stores the account data of account A, and you need to call the first resource manager. For another example, if you want to perform a resource transfer operation on account B, you need to perform the operation on the second database that stores the account data of account B, and you need to call the second resource manager.

[0086] Among them, different from the call of the transaction manager to the first resource manager, the call of the transaction manager to the second resource manager may refer to a remote procedure call (RPC). RPC refers to the mutual communication between processes running in different machines. A process running on a machine can call the service on the remote machine just like accessing a local service without knowing the underlying communication details.

[0087] In an optional embodiment, if the resource reservation status information indicates that resource reservation has failed or the account status verification result indicates that the second account is not in at least one of the preset account states, the transaction manager may generate a transaction rollback resolution. Accordingly, the transaction manager may send a transaction rollback request to the transaction coordinator.

[0088] If the second-stage transaction execution request includes a transaction rollback request, the transaction coordinator may call the first resource manager to perform a resource reservation rollback operation on the first account and obtain a first rollback result. Furthermore, the transaction coordinator may end the distributed transaction according to the first rollback result.

[0089] In addition, when the embodiments of the present specification are actually applied, after the transaction manager determines the resource transfer result based on the first submission result and the second submission result, it can also: on the one hand, feed back the resource transfer result to the client; on the other hand, feed back the resource transfer result to the transaction coordinator so that the transaction coordinator ends the distributed transaction.

[0090] It should be understood that in the methods described in one or more embodiments of this specification, the order of some steps can be adjusted according to actual needs, or some steps can be omitted.

[0091] Figure 4In the method, during the cross-region resource transfer process, in the first phase of the two-phase commit, the transaction manager calls the local first resource manager, on the one hand, performs an account reservation operation on the first account of the resource to be transferred out to obtain resource reservation status information, and on the other hand, performs an account status verification operation on the second account of the resource to be transferred in to obtain an account status verification result, and then performs the second phase of the two-phase commit based on the resource reservation status information and the account status verification result. Thus, the account status data set added locally in the transaction manager is used to optimize the distributed resource transfer transaction processing process, reducing the need for database locking of the resource transfer account. Through this optimization, while ensuring transaction consistency, the efficiency and success rate of the resource transfer operation can be greatly improved, and the probability of transaction processing failure due to remote network communication problems is reduced to a certain extent, providing users with a faster and more reliable resource transfer experience.

[0092] In addition, based on the solution of the embodiments of the present specification, since in the first stage of the two-stage submission, no operation is performed on the second database storing the account data of the resource transfer account, but only a query operation is performed on the newly added account status data set storing the account status information of the resource transfer account, therefore, assuming that the second stage needs to be rolled back, there is no need to perform a rollback operation on the second database, which will objectively reduce the remote procedure call communication and time consumption in the second stage, save the processing time of distributed transactions, and further reduce the probability of remote procedure call errors due to network reasons and thus the failure of distributed transaction processing.

[0093] The various technical features in the above embodiments can be combined arbitrarily as long as there is no conflict or contradiction between the combinations of features. However, due to space limitations, they are not described one by one. Therefore, any combination of the various technical features in the above embodiments also falls within the scope of this specification.

[0094] based on Figure 4 The method, the embodiments of this specification also provide some specific implementation methods of the method, which are described below.

[0095] In one or more embodiments of the present specification, the problems such as network delay, high time consumption, etc. caused by multiple remote network communications during cross-region resource transfer can be mainly solved. Therefore, before the transaction manager initiates a distributed transaction start request, it can first determine whether the resource transfer requested by the client involves cross-region.

[0096] Specifically, before the transaction manager calls the local first resource manager to perform a resource reservation operation on the first account in the first database (step 402), the process may also include: the transaction manager receives a resource transfer request sent by the client; the resource transfer request carries a first account identifier for identifying the first account and a second account identifier for identifying the second account; then, after the transaction manager determines that the resource transfer request involves accounts located in different regions, that is, after determining that a first database server on which a first database containing account data of the first account is deployed and a second database server on which a second database containing account data of the second account is deployed are located in different regions, since communication between services in different regions needs to be through remote procedure calls, the technical solution of an embodiment of the present application can be initiated to initiate a distributed transaction start request to the transaction coordinator to obtain a distributed transaction response message returned by the transaction coordinator.

[0097] In response to the distributed transaction start request, the transaction coordinator may create a global transaction identification (identity, ID), and feedback a message of successful transaction start to the transaction manager, which may include the global transaction ID. The global transaction ID is used to uniquely identify the current distributed transaction. In practical applications, the global transaction ID may establish an association relationship with the first account identification (ID) and the second account identification (ID).

[0098] Furthermore, before the branch transaction is specifically executed (before step 402 and step 404), the transaction manager may initiate a branch transaction registration request to the transaction coordinator to obtain a branch transaction ID returned by the transaction coordinator. In the embodiment of the present specification, a first branch transaction ID corresponding to a resource transfer-out transaction and a second branch transaction ID corresponding to a resource transfer-in transaction may be registered and obtained, and each branch transaction ID may be carried in subsequent branch transaction processing.

[0099] According to the above description, in the scenario of cross-regional transfer, a schematic diagram of a successful distributed transfer transaction processing flow based on the embodiment of this specification is as follows: Figure 5 shown.

[0100] Among them, the transaction coordinator can be embedded in the transaction coordination server, and the transaction manager can be embedded in the APP server; the account service A is embedded in the first database server, and the database A runs on the first database server; the account service B is embedded in the second database server, and the database B runs on the second database server.

[0101] Among them, the transaction manager is responsible for initiating a distributed transaction start request to start a distributed transaction, and sending a global commit or global rollback instruction to the transaction coordinator; the transaction coordinator is responsible for maintaining the running status of the distributed transaction, receiving the instructions of the transaction manager to initiate the commit and rollback of the distributed transaction, and is responsible for communicating with the resource manager to coordinate the commit or rollback of each branch transaction; the resource manager is responsible for branch registration and status reporting, and receives instructions from the transaction coordinator to operate the database and drive the commit and rollback of branch (local) transactions.

[0102] The transaction coordinator, the transaction manager and the first resource manager may be located in a first area, and the second resource manager may be located in a second area. The first area and the second area may be different areas. Service calls between different areas need to use remote procedure calls.

[0103] exist Figure 5 In the example, 1) the transaction manager initiates a distributed transaction start request to the transaction coordinator. The transaction coordinator creates a global transaction identity (ID) and feeds back a message to the transaction manager indicating that the transaction was successfully started. The message may include the global transaction ID. The global transaction ID is used to uniquely identify a distributed transaction.

[0104] Typically, before initiating a distributed transaction start request, the transaction manager and the resource manager may first send registration information to the transaction coordinator to register the transaction manager and the resource manager.

[0105] 2) The transaction manager calls the local first resource manager to perform a resource reservation operation on account A in database A, and obtains resource reservation status information fed back by the first resource manager (for example, resource reservation of account A is successful). The first resource manager is embedded in account service A deployed in the first database server. During the execution of the resource transfer-out transaction, account A needs to be locked.

[0106] 3) The transaction manager queries the local read-only account status data set (e.g., the read-only account status database), verifies whether the account status information of account B indicates that account B is in a normal state, and obtains the account status verification result. In actual application, the transaction manager may call the first resource manager to query the local read-only account status data set.

[0107] 4) The transaction manager reports the resource reservation status information and the account status verification result to the transaction coordinator; accordingly, the transaction coordinator feeds back to the transaction manager a message indicating that the resource reservation processing status and the account status verification result have been successfully reported. The first stage is completed.

[0108] 5) In the second stage, the transaction manager initiates a resource transfer commit request or a resource transfer rollback request to the transaction coordinator. For example, when the resource reservation status information indicates that the resource reservation of account A is successful, and the account status verification result indicates that the account status of account B is the preset status, a resource transfer commit request is initiated. As an example, Figure 4 The next steps describe the situation of initiating a resource transfer submission request.

[0109] 6) The transaction coordinator calls the local first resource manager to perform an actual resource deduction operation on account A in database A, and obtains resource deduction result information fed back by the first resource manager.

[0110] 7) The transaction coordinator calls the second resource manager through a remote procedure call, performs an actual resource increase operation on account B in database B, and obtains resource increase result information fed back by the second resource manager.

[0111] 8) The transaction coordinator sends the resource deduction result information and the resource increase result information to the transaction manager, completing the second stage. For example, if the resource deduction of account A is successful and the resource increase of account B is successful, the resource transfer is successfully achieved.

[0112] In one or more embodiments of the present specification, a reading library or cache is introduced to save the status information of account B. Since the operation on account B is a resource transfer, the preparation operation for account B in the first stage can be optimized to only need to verify the account status information of account B. It is believed that as long as the account status information is correct, the payment can usually be successfully received.

[0113] Based on one or more embodiments of this specification, on the one hand, the dependence on the cross-city network in the first stage of the two-stage submission is removed, reducing the impact of cross-city network anomalies; on the other hand, the cross-city network time consumption is reduced, the throughput of transactions per second is improved, and the user experience is improved; on the other hand, since there is no need to lock the resource transfer account B in the first stage, the probability of lock conflict problems is reduced. In summary, it can provide users with faster and more reliable resource transfer services.

[0114] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method.

[0115] Figure 6 The embodiments of this specification provide corresponding to Figure 4 A schematic structural diagram of a resource transfer device.

[0116] like Figure 6 As shown, the device can be applied to a transaction manager to transfer resources from a first account to a second account. The device may include:

[0117] The resource reservation module 602 is used to call the local first resource manager to perform a resource reservation operation on the first account in the first database to obtain resource reservation status information;

[0118] An account status verification module 604 is used to call the first resource manager to perform a verification operation on the account status information of the second account in the account status data set to obtain an account status verification result;

[0119] The transaction submission module 606 is used to transfer resources according to the resource reservation status information and the account status verification result.

[0120] based on Figure 6 The present specification also provides some specific implementation plans of the method, which are described below.

[0121] Optionally, the account status information of the second account in the account status data set is consistent with the account status information contained in the account data of the second account in the second database; wherein the account status data set and the first database run on a first database server where the first resource manager is deployed, the second database runs on a second database server where the second resource manager is deployed, and the first resource manager and the second resource manager communicate via a remote procedure call protocol.

[0122] Optionally, the account status data set includes a read-only database or cache.

[0123] Optionally, the transaction submission module 606 may specifically include:

[0124] A decision unit, configured to determine a transaction execution decision according to the resource reservation status information and the account status verification result; the transaction execution decision includes a transaction commit decision or a transaction rollback decision;

[0125] an execution unit, configured to send a second-phase transaction execution request corresponding to the transaction execution resolution to the transaction coordinator, so that the transaction coordinator calls the resource manager to execute the second-phase transaction of resource transfer according to the second-phase transaction execution request; the second-phase transaction execution request includes a transaction commit request corresponding to the transaction commit resolution or a transaction rollback request corresponding to the transaction rollback resolution.

[0126] Optionally, the resolution unit may be specifically configured to: if the resource reservation status information indicates that the resource reservation is successful and the account status verification result indicates that the second account is in a preset account status, the transaction manager generating a transaction commit resolution.

[0127] It is understood that the above modules refer to computer programs or program segments for executing one or more specific functions. In addition, the distinction between the above modules does not mean that the actual program codes must also be separated.

[0128] The above is a schematic scheme of a resource transfer device of this embodiment. It should be noted that the technical scheme of the resource transfer device and the technical scheme of the resource transfer method described above are of the same concept, and the details not described in detail in the technical scheme of the resource transfer device can be found in the description of the technical scheme of the resource transfer method described above.

[0129] Based on the same idea, the embodiments of this specification also provide a device corresponding to the above method.

[0130] Figure 7 The embodiments of this specification provide corresponding to Figure 4 A structural schematic diagram of a resource transfer device.

[0131] like Figure 7 As shown, the device 700 is used to transfer resources from a first account to a second account, and the device 700 may include:

[0132] at least one processor 710; and,

[0133] A memory 730 in communication with the at least one processor; wherein,

[0134] The memory 730 stores instructions 720 that can be executed by the at least one processor 710. The instructions are executed by the at least one processor 710 to enable the at least one processor 710 to:

[0135] Calling a local first resource manager to perform a resource reservation operation on the first account in the first database, and obtaining resource reservation status information;

[0136] calling the first resource manager to perform a verification operation on the account status information of the second account in the account status data set to obtain an account status verification result;

[0137] The resources are transferred according to the resource reservation status information and the account status verification result.

[0138] Based on the same idea, the embodiments of this specification also provide a resource transfer system corresponding to the above method.

[0139] In an embodiment of the present specification, a resource transfer system is provided for transferring resources from a first account to a second account, the system comprising a transaction manager and a first resource manager; wherein:

[0140] The transaction manager is used to call the local first resource manager to execute the first phase transaction of resource transfer;

[0141] The first resource manager is used to, in response to the call of the transaction manager, perform a resource reservation operation on the first account in the first database to obtain resource reservation status information and perform a verification operation on the account status information of the second account in the account status data set to obtain an account status verification result;

[0142] The transaction manager is further configured to initiate a second phase transaction of resource transfer according to the resource reservation status information and the account status verification result.

[0143] Optionally, the account status information of the second account in the account status data set is consistent with the account status information contained in the account data of the second account in the second database; wherein the account status data set and the first database run on a first database server where the first resource manager is deployed, and the second database runs on a second database server where the second resource manager is deployed, and the first resource manager and the second resource manager communicate via a remote procedure call protocol.

[0144] Optionally, the account status data set includes a read-only database or a cache.

[0145] Optionally, the resource transfer system also includes a transaction coordinator. The transaction manager is further used to determine a transaction execution resolution according to the resource reservation status information and the account status verification result, and send a second-phase transaction execution request corresponding to the transaction execution resolution to the transaction coordinator; wherein the transaction execution resolution includes a transaction commit resolution or a transaction rollback resolution, when the transaction execution resolution includes a transaction commit resolution, the second-phase transaction execution request includes a transaction commit request, and when the transaction execution resolution includes a transaction rollback resolution, the second-phase transaction execution request includes a transaction rollback request; the transaction coordinator is used to call the resource manager to execute the second-phase transaction of the resource transfer according to the second-phase transaction execution request.

[0146] Optionally, if the second-stage transaction execution request includes a transaction commit request, the transaction coordinator can be specifically used to: call the first resource manager to perform an actual resource deduction operation on the first account to obtain a first commit result; perform an actual resource increase operation on the second account through a remote procedure call to a second resource manager corresponding to a second database including account data of the second account to obtain a second commit result; send the first commit result and the second commit result to the transaction manager; wherein the first commit result and the second commit result are used as a basis for the transaction manager to determine a resource transfer result.

[0147] Each embodiment in this specification is described in a progressive manner, and the same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the device, equipment, and system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments. The devices, equipment, systems and methods provided in the embodiments of this specification correspond to each other, so the devices, equipment, and systems also have beneficial technical effects similar to the corresponding methods. Since the beneficial technical effects of the methods have been described in detail above, the beneficial technical effects of the corresponding devices, equipment, and systems will not be repeated here.

[0148] The above describes specific embodiments of the present application. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0149] In the 1990s, improvements to a technology could be clearly distinguished as hardware improvements (for example, improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the method flow). However, with the development of technology, many improvements to the method flow today can be regarded as direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved method flow into the hardware circuit. Therefore, it cannot be said that an improvement in a method flow cannot be implemented using a hardware entity module. For example, a programmable logic device (PLD) (such as a field programmable gate array (FPGA)) is such an integrated circuit whose logical function is determined by the user's programming of the device. Designers can "integrate" a digital system on a PLD by programming it themselves, without having to ask a chip manufacturer to design and produce a dedicated integrated circuit chip. Moreover, nowadays, instead of manually making integrated circuit chips, this kind of programming is mostly implemented by "logic compiler" software, which is similar to the software compiler used when developing and writing programs, and the original code before compilation must also be written in a specific programming language, which is called hardware description language (HDL). There is not only one HDL, but many kinds, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, RHDL (Ruby Hardware Description Language), etc. The most commonly used ones are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should also know that it is only necessary to program the method flow slightly in the above-mentioned hardware description languages ​​and program it into the integrated circuit, and then it is easy to obtain the hardware circuit that implements the logic method flow.

[0150] The controller can be implemented in any appropriate manner, for example, the controller can take the form of a microprocessor or processor and a computer-readable medium storing a computer-readable program code (such as software or firmware) that can be executed by the (micro)processor, a logic gate, a switch, an application-specific integrated circuit (ASIC), a programmable logic controller, and an embedded microcontroller. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicone Labs C8051F320. The memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art also know that in addition to implementing the controller in a purely computer-readable program code manner, the controller can be implemented in the form of a logic gate, a switch, an application-specific integrated circuit, a programmable logic controller, and an embedded microcontroller by logically programming the method steps. Therefore, this controller can be considered as a hardware component, and the devices included therein for implementing various functions can also be regarded as structures within the hardware component. Or even, the devices for implementing various functions can be regarded as both software modules for implementing the method and structures within the hardware component.

[0151] The systems, devices, modules or units described in the above embodiments may be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer may be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.

[0152] For the convenience of description, the above device is described in various units according to their functions. Of course, when implementing the present application, the functions of each unit can be implemented in the same or multiple software and / or hardware.

[0153] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0154] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0155] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0156] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0157] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0158] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0159] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0160] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0161] The present application may be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application may also be practiced in distributed computing environments where tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules may be located in local and remote computer storage media, including storage devices.

[0162] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. A resource transfer method for transferring resources from a first account to a second account, the method comprising: The transaction manager calls the local first resource manager to perform a resource reservation operation on the first account in the first database, and obtains resource reservation status information; The transaction manager calls the first resource manager to perform a verification operation on the account status information of the second account in the account status data set to obtain an account status verification result; The resources are transferred according to the resource reservation status information and the account status verification result.

2. The method of claim 1, wherein: Before the transaction manager calls the local first resource manager to perform a resource reservation operation on the first account in the first database, the process further includes: The transaction manager receives a resource transfer request sent by a client; the resource transfer request carries a first account identifier for identifying the first account and a second account identifier for identifying the second account; After determining that the resource transfer request involves accounts located in different regions, the transaction manager initiates a distributed transaction start request to the transaction coordinator and obtains a distributed transaction response message returned by the transaction coordinator.

3. The method of claim 1, wherein: The transaction manager calls the local first resource manager to perform a resource reservation operation on the first account in the first database, specifically including: The transaction manager sends a resource reservation message to the first resource manager; the resource reservation message carries the account identifier of the first account and the resource value to be transferred; In response to the resource reservation message, the first resource manager determines whether the first account meets a condition for performing a resource reservation operation, and obtains a first determination result; If the first judgment result is yes, a resource reservation operation corresponding to the to-be-transferred resource value is executed, and successful resource reservation status information is returned.

4. The method of claim 3, wherein: The performing of the resource reservation operation corresponding to the resource value to be transferred specifically includes: A first log record corresponding to the first account is added; the first log record is used to indicate that the resources corresponding to the resource value to be transferred will be transferred from the first account.

5. The method of claim 4, wherein: The performing of the resource reservation operation corresponding to the resource value to be transferred specifically includes: The reserved resource value of the reserved resource field corresponding to the first account is set according to the resource value to be transferred; the reserved resource value is used to return the difference between the current resource value of the first account and the reserved resource value when the first resource manager receives a request for querying the account resource value corresponding to the first account.

6. The method according to claim 3, wherein after determining whether the first account satisfies the condition for performing the resource reservation operation and obtaining the first determination result, the method further comprises: If the first judgment result is no, the failed resource reservation status information is returned.

7. The method according to claim 3, before the transaction manager sends the resource reservation message to the first resource manager, further comprising: Performing a locking operation on the first account; After executing the resource reservation operation corresponding to the resource value to be transferred, the method further includes: Perform a unlock operation on the first account.

8. The method of claim 1, wherein: The account status information of the second account in the account status data set is consistent with the account status information included in the account data of the second account in the second database; The account status data set and the first database run on a first database server where the first resource manager is deployed, the second database runs on a second database server where a second resource manager is deployed, and the first resource manager and the second resource manager communicate via a remote procedure call protocol.

9. The method of claim 8, wherein: The account status data set includes a read-only database or cache.

10. The method according to claim 1, wherein the resource transfer according to the resource reservation status information and the account status verification result specifically comprises: The transaction manager determines a transaction execution resolution according to the resource reservation status information and the account status verification result; The transaction execution resolution includes a transaction commit resolution or a transaction rollback resolution; The transaction manager sends a second-phase transaction execution request corresponding to the transaction execution resolution to the transaction coordinator; the second-phase transaction execution request includes a transaction commit request corresponding to the transaction commit resolution or a transaction rollback request corresponding to the transaction rollback resolution; According to the second-phase transaction execution request, the transaction coordinator calls the resource manager to execute the second-phase transaction of resource transfer.

11. The method according to claim 10, wherein the transaction manager determines a transaction execution resolution according to the resource reservation status information and the account status verification result, specifically comprising: If the resource reservation status information indicates that the resource reservation is successful and the account status verification result indicates that the second account is in a preset account status, the transaction manager generates a transaction commit resolution.

12. The method according to claim 10, wherein the transaction coordinator calls the resource manager to execute the second phase transaction of resource transfer, specifically comprising: If the second-stage transaction execution request includes a transaction commit request, the transaction coordinator calls the first resource manager to execute an actual resource deduction operation on the first account to obtain a first commit result; The transaction coordinator performs an actual resource addition operation on the second account by remote procedure calling a second resource manager corresponding to a second database including account data of the second account, and obtains a second commit result; The transaction coordinator sends the first submission result and the second submission result to the transaction manager; wherein the first submission result and the second submission result are used as a basis for the transaction manager to determine a resource transfer result.

13. The method according to claim 10, after the transaction manager sends the second-phase transaction execution request corresponding to the transaction execution resolution to the transaction coordinator, further comprising: If the second-phase transaction execution request includes a transaction rollback request, the transaction coordinator calls the first resource manager to perform a resource reservation rollback operation on the first account.

14. A resource transfer device, applied to a transaction manager, for transferring resources from a first account to a second account, the device comprising: A resource reservation module, configured to call a local first resource manager to perform a resource reservation operation on the first account in the first database, and obtain resource reservation status information; an account status verification module, configured to call the first resource manager to perform a verification operation on the account status information of the second account in the account status data set, and obtain an account status verification result; The transaction submission module is used to transfer resources according to the resource reservation status information and the account status verification result.

15. The device of claim 14, wherein: The account status information of the second account in the account status data set is consistent with the account status information included in the account data of the second account in the second database; The account status data set and the first database run on a first database server where the first resource manager is deployed, the second database runs on a second database server where a second resource manager is deployed, and the first resource manager and the second resource manager communicate via a remote procedure call protocol.

16. The device of claim 15, wherein: The account status data set includes a read-only database or cache.

17. The device of claim 14, wherein: The transaction submission module specifically includes: A decision unit, configured to determine a transaction execution decision according to the resource reservation status information and the account status verification result; the transaction execution decision includes a transaction commit decision or a transaction rollback decision; an execution unit, configured to send a second-phase transaction execution request corresponding to the transaction execution resolution to the transaction coordinator, so that the transaction coordinator calls the resource manager to execute the second-phase transaction of resource transfer according to the second-phase transaction execution request; the second-phase transaction execution request includes a transaction commit request corresponding to the transaction commit resolution or a transaction rollback request corresponding to the transaction rollback resolution.

18. The device of claim 17, wherein: The resolution unit is specifically used for: If the resource reservation status information indicates that the resource reservation is successful and the account status verification result indicates that the second account is in a preset account status, the transaction manager generates a transaction commit resolution.

19. A resource transfer device for transferring resources from a first account to a second account, the device comprising: at least one processor; as well as, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to: Calling a local first resource manager to perform a resource reservation operation on the first account in the first database, and obtaining resource reservation status information; calling the first resource manager to perform a verification operation on the account status information of the second account in the account status data set to obtain an account status verification result; The resources are transferred according to the resource reservation status information and the account status verification result.

20. A resource transfer system for transferring resources from a first account to a second account, the system comprising a transaction manager and a first resource manager; wherein: The transaction manager is used to call the local first resource manager to execute the first phase transaction of resource transfer; The first resource manager is used to, in response to the call of the transaction manager, perform a resource reservation operation on the first account in the first database to obtain resource reservation status information and perform a verification operation on the account status information of the second account in the account status data set to obtain an account status verification result; The transaction manager is further configured to initiate a second phase transaction of resource transfer according to the resource reservation status information and the account status verification result.

21. The system of claim 20, wherein: The account status information of the second account in the account status data set is consistent with the account status information included in the account data of the second account in the second database; The account status data set and the first database run on a first database server where the first resource manager is deployed, the second database runs on a second database server where a second resource manager is deployed, and the first resource manager and the second resource manager communicate via a remote procedure call protocol.

22. The system of claim 21, wherein: The account status data set includes a read-only database or cache.

23. The system of claim 20, further comprising a transaction coordinator, The transaction manager is further configured to determine a transaction execution resolution according to the resource reservation status information and the account status verification result, and send a second-phase transaction execution request corresponding to the transaction execution resolution to the transaction coordinator; wherein, The transaction execution resolution includes a transaction commit resolution or a transaction rollback resolution. When the transaction execution resolution includes a transaction commit resolution, the second-stage transaction execution request includes a transaction commit request. When the transaction execution resolution includes a transaction rollback resolution, the second-stage transaction execution request includes a transaction rollback request. The transaction coordinator is used for calling the resource manager to execute the second phase transaction of resource transfer according to the second phase transaction execution request.

24. The system of claim 23, wherein: If the second-phase transaction execution request includes a transaction commit request, the transaction coordinator is specifically configured to: Calling the first resource manager to perform an actual resource deduction operation on the first account to obtain a first submission result; executing, by remote procedure calling, a second resource manager corresponding to a second database including account data of the second account, an actual resource addition operation on the second account, and obtaining a second submission result; The first submission result and the second submission result are sent to the transaction manager; wherein the first submission result and the second submission result are used as a basis for the transaction manager to determine a resource transfer result.