Transaction processing method and device, electronic equipment and storage medium

By dividing the assets of the transaction account into multiple asset fragments in a distributed storage system, and locking only some fragments for transaction processing, the problem of frequent conflicts during multiple transaction processing is solved, and the efficiency of transaction processing is improved.

CN119515542APending Publication Date: 2025-02-25TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311088700.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-25
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

In distributed storage systems, multiple transactions are prone to conflicts when processing, resulting in low transaction processing efficiency.

Method used

By dividing the assets of the target transaction sending account into multiple target asset fragments, and locking only some valid asset fragments when executing the target transaction, efficient execution of transaction processing is achieved.

Benefits of technology

This method greatly reduces the probability of conflict when multiple transactions are conducted in the same account, reduces the probability of locking, rolling back and retry of transaction transactions, thereby improving the concurrency efficiency and execution efficiency of transaction transactions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119515542A_ABST
    Figure CN119515542A_ABST
Patent Text Reader

Abstract

The invention discloses a transaction processing method and device, electronic equipment and a storage medium. The embodiment of the invention relates to the field of cloud technology and the like. The method comprises the following steps: in response to a received target transaction request, according to a target transaction sending account corresponding to a target transaction in the target transaction request, determining a plurality of target asset fragments associated with the target transaction sending account; locking at least one effective asset fragment based on the target transaction asset quantity; and processing the target transaction according to the at least one effective asset fragment in the locked state. According to the transaction processing method and device, different transactions can be carried out on the same account at the same time, transaction conflicts generated when different transaction processing is carried out on the same account at the same time are greatly reduced, the probability of locking blocking, rollback and retry of transaction transactions is reduced, the concurrent efficiency of the transaction transactions is improved, and then the execution efficiency of the transaction transactions is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and more specifically, to a transaction processing method, device, electronic device and storage medium. Background Art

[0002] With the development of network technology, the Internet can provide more and more services. Accordingly, in order to improve the accuracy and efficiency of transaction execution, transactions are processed through distributed storage systems.

[0003] However, when using a distributed storage system to process multiple transactions, conflicts are prone to occur between multiple transactions, resulting in low transaction processing efficiency. Summary of the invention

[0004] In view of this, the embodiments of the present application propose a transaction processing method, device, electronic device and storage medium.

[0005] In a first aspect, an embodiment of the present application provides a transaction processing method, the method comprising: in response to receiving a target transaction request, determining multiple target asset fragments associated with the target transaction sending account according to the target transaction sending account corresponding to the target transaction in the target transaction request; the target transaction request also includes the target transaction asset quantity corresponding to the target transaction; the multiple target asset fragments are obtained by dividing the assets of the target transaction sending account; based on the target transaction asset quantity, determining at least one valid asset fragment in the target asset fragments in an unlocked state among the multiple target asset fragments; wherein the sum of the asset quantities of all valid asset fragments in the at least one valid asset fragment is not less than the target transaction asset quantity; locking at least one valid asset fragment; and processing the target transaction according to the at least one valid asset fragment in a locked state.

[0006] In a second aspect, an embodiment of the present application provides a transaction processing device, the device comprising: a response module, for responding to receiving a target transaction request, and determining multiple target asset fragments associated with a target transaction sending account according to a target transaction sending account corresponding to the target transaction in the target transaction request; the target transaction request also includes the number of target transaction assets corresponding to the target transaction; the multiple target asset fragments are obtained by dividing the assets of the target transaction sending account; a determination module, for determining at least one valid asset fragment in a target asset fragment in an unlocked state among the multiple target asset fragments based on the number of target transaction assets; wherein the sum of the asset quantities of all valid asset fragments in the at least one valid asset fragment is not less than the target transaction asset quantity; a locking module, for locking at least one valid asset fragment; and a transaction module, for processing the target transaction according to at least one valid asset fragment in a locked state.

[0007] Optionally, the method is applied to a target node in a distributed storage system; each node in the distributed storage system stores at least one data shard, and one data shard is used to store multiple asset fragments of an account; one data shard corresponds to a master node and a backup node in the distributed storage system; the response module is also used to determine, in response to receiving a target transaction request, a target data shard for storing multiple target asset fragments based on a target transaction sending account; determine the master node corresponding to the target data shard according to the shard metadata; the shard metadata indicates the master node and the corresponding backup node corresponding to each data shard in the distributed storage system; if the target node is the master node corresponding to the target data shard, according to the target transaction sending account, obtain multiple target asset fragments associated with the target transaction sending account in the target data shard stored on the target node.

[0008] Optionally, the transaction module is also used to execute the target transaction based on at least one valid asset fragment in a locked state to obtain first data and second data; the first data includes the remaining asset quantity of each valid asset fragment after the execution of the target transaction, and the second data includes the asset fragment that needs to be added to the target transaction receiving account of the target transaction after the execution of the target transaction; based on the first data and the second data, write processing is performed on the target data shard and the reference data shard respectively; the reference data shard refers to the data shard where the asset fragment of the target transaction receiving account is located.

[0009] Optionally, the transaction module is also used to perform pre-write processing in the target data shard based on the first data; request the auxiliary node to perform pre-write processing in the reference data shard based on the second data; the auxiliary node refers to the master node corresponding to the reference data shard; if the first data and the second data are both pre-written successfully, the target data shard is written and submitted based on the successfully pre-written first data, and the auxiliary node is requested to write and submit to the reference data shard based on the successfully pre-written second data.

[0010] Optionally, the second data also includes target reference information indicating that the second data references the first data; the transaction module is also used to re-request the auxiliary node to perform a write submission based on the successfully pre-written second data if the status of the second data is a pending submission status and it is determined based on the target reference information that the status of the first data referenced by the second data is a submitted status until the status of the second data is a submitted status.

[0011] Optionally, the transaction module is further used to determine the remaining asset quantity of each valid asset fragment after executing the target transaction based on the asset quantity of each valid asset fragment in at least one valid asset fragment in a locked state and the target transaction asset quantity corresponding to the target transaction; generate first data based on the fragment identifier of at least one valid asset fragment in a locked state and the remaining asset quantity of each valid asset fragment after executing the target transaction; determine the asset fragment that needs to be added to the target transaction receiving account after executing the target transaction based on the target transaction asset quantity corresponding to the target transaction; and generate second data according to the asset fragment that needs to be added to the target transaction receiving account after executing the target transaction.

[0012] Optionally, the transaction module is further configured to return transaction completion information to the initiator of the target transaction request if it is determined that the status of the first data is a submitted status.

[0013] Optionally, the transaction module is also used to read the first shard version information corresponding to the target node in response to receiving a target transaction request; read the second shard version information corresponding to the target node in response to obtaining the first data and the second data; if the first shard version information is consistent with the second shard version information, write processing is performed on the target data shard and the reference data shard based on the first data and the second data, respectively.

[0014] Optionally, the response module is also used to forward the target transaction request to the master node corresponding to the target data shard if the target node is not the master node corresponding to the target data shard.

[0015] Optionally, the transaction module is further configured to unlock a valid asset segment having a non-zero asset quantity in at least one valid asset segment in response to completion of the target transaction.

[0016] Optionally, the device also includes an asset management module, which is used to obtain at least two target asset fragments whose asset quantities are less than a threshold and are in an unlocked state from multiple target asset fragments of the target transaction sending account; and merge the at least two target asset fragments whose asset quantities are less than a threshold and are in an unlocked state.

[0017] In a third aspect, an embodiment of the present application provides an electronic device, including a processor and a memory; one or more programs are stored in the memory and configured to be executed by the processor to implement the above method.

[0018] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a program code is stored, wherein the above method is executed when the program code is executed by a processor.

[0019] In a fifth aspect, an embodiment of the present application provides a computer program product or a computer program, the computer program product or the computer program including computer instructions, the computer instructions being stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device performs the above method.

[0020] The embodiments of the present application provide a transaction processing method, device, electronic device and storage medium. In the present application, the assets of the target transaction sending account of the target transaction are divided into multiple target asset fragments. When executing the target transaction, only part of the valid asset fragments are locked. When the same account participates in multiple transactions, different valid asset fragments can be locked. All assets of the account are no longer locked for each transaction. Multiple transactions can be performed on the same account at the same time, which greatly reduces the probability of conflict when multiple transactions are performed on the same account at the same time, and reduces the probability of locking, blocking, rolling back and retrying of transaction transactions, thereby improving the concurrency efficiency of transaction transactions, and further improving the execution efficiency of transaction transactions. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0022] Figure 1 A schematic diagram showing an application scenario to which the embodiments of the present application are applicable;

[0023] Figure 2 A flow chart of a transaction processing method proposed in one embodiment of the present application is shown;

[0024] Figure 3 A flowchart of a transaction processing method proposed in another embodiment of the present application is shown;

[0025] Figure 4 A flow chart of a transaction processing method proposed in another embodiment of the present application is shown;

[0026] Figure 5 A schematic diagram of the structure of a node in a distributed storage system according to an embodiment of the present application is shown;

[0027] Figure 6 A schematic diagram of the structure of an asset fragment in an embodiment of the present application is shown;

[0028] Figure 7 A schematic diagram showing a transaction processing process in an embodiment of the present application is shown;

[0029] Figure 8 A schematic diagram of the structure of another asset fragment in an embodiment of the present application is shown;

[0030] Fig. 9 A block diagram of a transaction processing device proposed in one embodiment of the present application is shown;

[0031] Fig.10 A structural block diagram of an electronic device for executing a transaction processing method according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0032] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. According to the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0033] In the following description, the terms "first\second" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0034] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0035] It should be noted that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.

[0036] It should also be noted that in the embodiments of the present application, if the transaction data is the transaction data of a user, the acquisition of the transaction data requires the user's permission or consent, and the collection, use, processing and storage of the transaction data must comply with the regulations of the region where the transaction data is located.

[0037] A transaction is a way for an application to combine multiple read and write operations into a logical unit. Conceptually, all read and write operations in a transaction are treated as a single operation: the entire transaction is either successfully committed (commit) or failed to abort (abort) or rollback (rollback).

[0038] Isolation refers to the property that transactions executed simultaneously are isolated from each other. There are four different isolation levels, from low to high: read uncommitted, read committed, repeatable read, and serializable.

[0039] The serializable isolation level means that the database ensures that transactions behave as if they were run serially (one after another), even though they may actually be run concurrently.

[0040] A distributed transaction refers to a transaction in which the participants, the servers supporting the transaction, the resource servers, and the transaction managers are located on different nodes of different distributed storage systems.

[0041] Currently, there are many technical solutions for distributed transactions, and basically all of them adopt the two-phase commit method. The common ones are as follows:

[0042] The first one: TCC (Try-Confirm-Cancel) is another common distributed transaction mechanism. It is the abbreviation of the three words "Try-Confirm-Cancel". TCC can be divided into three stages: Try: Try to execute the stage, complete all business executable checks (to ensure consistency), and reserve all required business resources (to ensure isolation). Confirm: Confirm the execution stage, without any business checks, and directly use the resources prepared in the Try stage to complete business processing. The Confirm stage may be executed repeatedly, so the operations performed in this stage need to have idempotency. Cancel: Cancel the execution stage and release the business resources reserved in the Try stage. The Cancel stage may be executed repeatedly and also needs to meet idempotency.

[0043] The second type: Two-Phase Locking 2PL (Two-Phase Locking). The core idea of ​​2PL is that reading and writing block each other. The blocking of reading and writing is achieved by adding locks to each object in the database. Locks can be in shared mode or exclusive mode. The use of locks is as follows: If a transaction wants to read an object, it must first acquire a lock in shared mode. Multiple transactions are allowed to hold shared locks at the same time. But if another transaction already holds an exclusive lock on the object, these transactions must wait. If a transaction wants to write to an object, it must first acquire the lock in exclusive mode. No other transaction can hold a lock at the same time (whether in shared or exclusive mode), so if there are any locks on the object, the transaction must wait. If a transaction reads and then writes an object, it may upgrade its shared lock to an exclusive lock. The work of upgrading a lock is the same as directly acquiring an exclusive lock. After a transaction acquires a lock, it must continue to hold the lock until the transaction ends (committed or aborted). This is the origin of the name "two-phase": the first phase (when the transaction is executing) acquires the lock, and the second phase (at the end of the transaction) releases all the locks.

[0044] The third type: Optimistic Concurrency Control (OCC) is a database transaction management strategy used to ensure data consistency and integrity. Compared with pessimistic concurrency control, OCC assumes that conflicts between transactions are rare, so data is not locked immediately during transaction execution. Instead, OCC checks for conflicts during the transaction commit phase and rolls back the transaction if a conflict is found. The main process of OCC is divided into the following three phases: Read Phase: In this phase, the transaction reads data and performs calculations. The transaction records the read data items and their version information so that conflicts can be detected in the commit phase. Validation Phase: In this phase, the transaction checks whether conflicts have occurred in the data items read in the read phase. Conflicts are usually caused by other transactions modifying the same data items during the execution of the current transaction. If a conflict is found, the transaction will be rolled back. Write Phase: If no conflict is found in the validation phase, the transaction will enter the write phase. In this phase, the transaction writes the modified data back to the database and marks the transaction as committed.

[0045] In the above-mentioned types of distributed transaction solutions, a distributed storage system is used to process multiple transactions, and conflicts are prone to occur between multiple transactions, resulting in low transaction processing efficiency.

[0046] Based on this, the inventor proposed a transaction processing method, device, electronic device and storage medium of the present application. In the present application, the assets of the target transaction sending account of the target transaction are divided into multiple target asset fragments. When executing the target transaction, only part of the valid asset fragments are locked. When the same account participates in multiple transactions, different valid asset fragments can be locked. All assets of the account are no longer locked for each transaction. Multiple transactions can be performed on the same account at the same time, which greatly reduces the probability of conflict when multiple transactions are performed on the same account at the same time, and reduces the probability of locking, blocking, rolling back and retrying of transaction transactions, thereby improving the concurrency efficiency of transaction transactions, and then improving the execution efficiency of transaction transactions.

[0047] like Figure 1 As shown, the application scenario applicable to the embodiment of the present application includes a terminal 20 and a distributed storage system 10, the distributed storage system 10 includes multiple nodes 11, and the terminal 20 and each node 11 in the distributed storage system 10 are connected through a wired network or a wireless network.

[0048] Terminal 20 can be a smart phone, tablet computer, laptop computer, desktop computer, smart home appliance, vehicle-mounted terminal, aircraft, wearable device terminal, virtual reality device and other terminal devices that can display pages, or run other applications that can call page display applications (such as instant messaging applications, shopping applications, search applications, game applications, forum applications, map and transportation applications, etc.).

[0049] Node 11 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), as well as big data and artificial intelligence platforms.

[0050] Among them, the terminal 20 can send a target transaction request to the node 11. The node 11 locks at least one valid asset fragment associated with the target transaction sending account corresponding to the target transaction in the target transaction request according to the target transaction request. Then, the node 11 processes the target transaction with at least one valid asset fragment in a locked state. When the node 11 completes the target transaction, the transaction completion information is returned to the terminal.

[0051] See also Figure 2 , Figure 2A flowchart of a transaction processing method proposed in an embodiment of the present application is shown. The method can be applied to a transaction server, which can be an independent physical server, a cloud server, or a distributed system composed of multiple servers. For example, it can be applied to a target node in a distributed storage system, and the target node can be Figure 1 The node 11 receiving the target transaction request, the method includes:

[0052] S110 . In response to receiving a target transaction request, according to a target transaction sending account corresponding to the target transaction in the target transaction request, determine a plurality of target asset fragments associated with the target transaction sending account.

[0053] The target transaction request also includes the target transaction asset quantity corresponding to the target transaction; and the multiple target asset segments are obtained by dividing the assets of the target transaction sending account.

[0054] The target transaction request refers to the transaction request currently to be processed. The transaction requested to be processed by the target transaction request is called the target transaction.

[0055] The target transaction may refer to a transaction, such as a transfer transaction, a payment transaction, a red envelope transaction, etc. The target transaction may be a transaction for virtual assets or real assets. For example, the target transaction may be a transfer of 100 yuan from account A1 to account A2, or another example is a payment of 100 virtual coins from account A3 to account A4 for game props.

[0056] Different users can conduct transactions through their respective accounts. The transaction assets in the target transaction come from the target transaction sending account, and the transaction assets in the target transaction flow to the target transaction receiving account. The number of transaction assets involved in the target transaction is the target transaction asset number.

[0057] The terminal can log in to the target transaction sending account of the target transaction sender of the target transaction. The terminal responds to the transaction operation of the target transaction sender through the target transaction sending account, generates and sends a target transaction request, and the transaction service end executes the target transaction according to the method provided in this application based on the received target transaction request to send the transaction assets in the target transaction to the target transaction receiving account of the target transaction receiver.

[0058] The target transaction request may include information such as the target transaction sending account corresponding to the target transaction, the target transaction receiving account corresponding to the target transaction, the target transaction asset quantity, etc. The target transaction request may also include time information of generating the target transaction request and the identifier of the target transaction request, etc. The identifier of the transaction request may be an identifier composed of numbers and letters.

[0059] The transaction service end can respond to the registration request sent by the target transaction sender through the terminal, allocate a target transaction sending account to the target transaction sender, and after configuring the target transaction sending account for the target transaction sender on the transaction service end, respond to the asset transfer request of the target transaction sender, transfer the assets of the target transaction sender to the target transaction sending account, and then the transaction service end divides the assets in the target transaction sending account to obtain multiple asset fragments corresponding to the target transaction sender. At the same time, the transaction service end can also allocate respective asset fragment identifiers to each asset fragment corresponding to the target transaction sender. It is worth mentioning that the asset fragment identifiers of different asset fragments under the same account are different, and the asset fragment identifiers of asset fragments under different accounts are also different.

[0060] The transaction server can store multiple asset fragments corresponding to multiple accounts, and can determine multiple asset fragments under the target transaction sending account according to the target transaction sending account corresponding to the target transaction in the target transaction request. The asset fragment under the target transaction sending account is called the target asset fragment.

[0061] It should be noted that for any node in the distributed storage system, any user can send a request to the node through any terminal, and the node will configure the corresponding account for the user and divide the assets under the user's account into multiple asset fragments. When any node in the distributed storage system receives a target transaction request, if the node has an asset fragment associated with the target transaction sending account corresponding to the target transaction in the target transaction request, the node is determined to be a transaction server, and multiple target asset fragments associated with the target transaction sending account are directly obtained; if the node does not have an asset fragment associated with the target transaction sending account corresponding to the target transaction in the target transaction request, the target transaction request is forwarded to the transaction server: a node with multiple target asset fragments associated with the target transaction sending account.

[0062] The nodes of the distributed storage system may have a storage layer, and the storage layer of the node is used to store multiple asset fragments of different accounts. That is, multiple target asset fragments are stored in the storage layer of the transaction server.

[0063] S120: Based on the number of target transaction assets, determine at least one valid asset segment from among the target asset segments that are in an unlocked state in the plurality of target asset segments.

[0064] The sum of the asset quantities of all valid asset segments in at least one valid asset segment is not less than the target transaction asset quantity;

[0065] The transaction service end determines at least one valid asset segment from the target asset segments that are unlocked in the multiple target asset segments based on the number of target transaction assets. The valid asset segment is an asset segment that is unlocked and used to participate in the target transaction in the multiple target asset segments, and the asset segment that is unlocked and not used for the target transaction in the multiple target asset segments is not considered as a valid asset segment.

[0066] For example, the number of target transaction assets is 20, and the multiple target asset fragments include asset fragment d1 (the number of assets therein is 10), asset fragment b2 (the number of assets therein is 8), asset fragment b3 (the number of assets therein is 12), and asset fragment b4 (the number of assets therein is 10), wherein asset fragment b2 is locked. At this time, b1 and b4 can be determined as valid asset fragments for the target transaction and b3 is not a valid asset fragment, or b1 and b3 can be determined as valid asset fragments for the target transaction and b4 is not a valid asset fragment, or b3 and b4 can be determined as valid asset fragments for the target transaction and b1 is not a valid asset fragment.

[0067] In this embodiment, it can be determined whether the target asset segment is locked. If the target asset segment is locked, it is determined that the target asset segment is locked. Since the target asset segment in the locked state is actually the asset segment used by other transactions other than the target transaction in which the target transaction sending account participates, the target asset segment in the locked state cannot be used and edited by the target transaction. Therefore, for the target transaction, it is necessary to determine the unlocked target asset segment as the valid asset segment.

[0068] S130. Lock at least one valid asset segment.

[0069] After determining at least one valid asset fragment, each valid asset fragment may be locked to prevent the target transaction sending account from participating in other transactions other than the target transaction using the valid asset fragment. Each valid asset fragment may be locked to achieve locking of each valid asset fragment.

[0070] The locked valid asset fragment cannot be used by other transactions except the target transaction, nor can it be modified by other exchanges. The locked valid asset fragment can only be used to participate in the target transaction.

[0071] S140: Process the target transaction according to at least one valid asset fragment in a locked state.

[0072] After locking each valid asset fragment, the target transaction can be processed through each valid asset fragment in the locked state, the asset quantity in at least one valid asset fragment in the locked state is deducted, and the assets of the target transaction asset quantity in the target transaction sending account are transferred to the target transaction receiving account.

[0073] In some embodiments, the remaining asset quantity of each valid asset fragment after executing the target transaction can be determined based on the target transaction asset quantity. At the same time, the asset fragment that needs to be added to the target transaction receiving account after executing the target transaction can be determined based on the target transaction asset quantity corresponding to the target transaction.

[0074] In some embodiments, the valid asset fragment whose remaining asset quantity is 0 after the execution of the target transaction can also be deleted from the target transaction sending account, and the valid asset fragment whose remaining asset quantity is not 0 after the execution of the target transaction, and the assets of the retained valid asset fragment are the remaining assets of the valid asset fragment after the execution of the target transaction; the asset fragment that needs to be added to the target transaction receiving account after the execution of the target transaction is added to the target transaction receiving party account, so as to realize the transfer of the assets of the target transaction asset quantity in the target transaction sending account to the target transaction receiving account.

[0075] In some embodiments, for each valid asset fragment, if the remaining asset quantity of the valid asset fragment after the target transaction is executed is 0, a new asset fragment with the same asset quantity as the valid asset fragment is generated according to the target transaction receiving account (an asset fragment identifier may also be assigned to the new asset fragment), and the new asset fragment is used as an asset fragment that needs to be added to the target transaction receiving account after the target transaction is executed; if the remaining asset quantity of the valid asset fragment after the target transaction is executed is not 0, the valid asset fragment is retained (the asset quantity of the valid asset fragment is the remaining asset quantity), and a new asset fragment with the same asset quantity change value as the valid asset fragment is generated (an asset fragment identifier may also be assigned to the new asset fragment), and the new asset fragment is used as an asset fragment that needs to be added to the target transaction receiving account after the target transaction is executed.

[0076] For example, the number of target transaction assets is 20, and the multiple target asset fragments include asset fragment d1 (including 10 assets), asset fragment b2 (including 8 assets), asset fragment b3 (including 12 assets) and asset fragment b4 (including 10 assets), wherein asset fragment b2 is locked. At this time, b1 and b3 can be determined as valid asset fragments for the target transaction. According to the number of target transaction assets, the remaining asset quantity of b1 after executing the target transaction is determined to be 0, and a newly added asset fragment b11 (the number of assets is 10) is generated according to the target receiving account. It is determined that the remaining asset quantity of b3 after executing the target transaction is 2, and a newly added asset fragment b21 (the number of assets is 10) is generated according to the target receiving account. At this time, b1 under the target sender account is deleted and b3 with a number of assets of 2 is retained. At the same time, asset fragments b11 and b21 are added to the target transaction receiving account.

[0077] In some embodiments, based on the target transaction asset quantity corresponding to the target transaction and the account identifier corresponding to the target transaction receiving account, an asset segment that needs to be added to the target transaction receiving account after executing the target transaction can be generated, wherein the asset quantity in the added asset segment is equal to the target transaction asset quantity. In other words, in this embodiment, in one transaction, a new asset segment is generated for one transaction receiving account.

[0078] After the target transaction asset quantity in the target transaction sending account is transferred to the target transaction receiving account, it can be determined that the target transaction is completed, and the transaction completion information is returned to the sender of the target transaction request (that is, the terminal above), so that the terminal can output the transaction completion information through the target transaction sending account.

[0079] In the present application, after S140, the method may further include: in response to completion of the target transaction, unlocking a valid asset segment in which the asset quantity in at least one valid asset segment is not zero.

[0080] As mentioned above, the valid asset fragments are locked. After executing the target transaction, there may be valid asset fragments with non-zero remaining assets. At this time, in response to the completion of the target transaction, at least one valid asset fragment with non-zero asset quantity is unlocked to facilitate the participation of the valid asset fragment in subsequent transactions.

[0081] In another embodiment, after S140, the method may further include: obtaining at least two target asset segments whose asset quantity is less than a threshold and are in an unlocked state from multiple target asset segments of the target transaction sending account; merging at least two target asset segments whose asset quantity is less than the threshold and are in an unlocked state. The threshold may be a value set based on demand, which is not limited in this application.

[0082] The merging process may refer to merging at least two target asset fragments whose asset quantity is less than a threshold and are in an unlocked state to obtain a merged target asset fragment, and at most one of the merged target asset fragments has an asset quantity less than the threshold. Among them, it may be a process of performing the asset fragment merging process when a target condition is triggered, and the target condition may include each transaction of the transaction sending account, the time from the last asset fragment merging process reaches a set time, and the asset fragment merging request sent by the terminal is received.

[0083] In addition, after merging at least two target asset segments whose asset quantity is less than a threshold and which are in an unlocked state, an asset segment identifier may be reallocated to the merged target asset segment. For any merged target asset segment, the reallocated asset segment identifier may be the asset segment identifier of any target asset segment among the target asset segments participating in the merger, and the reallocated asset segment identifier may be a newly generated asset segment identifier that is different from the asset segment identifiers of each target asset segment among the target asset segments participating in the merger.

[0084] In this embodiment, the nodes in the distributed storage system may also include a computing layer, and the process of S110-S140, unlocking the locked valid asset fragments, and merging at least two asset fragments whose asset quantity is less than a threshold and are in an unlocked state may be executed in the computing layer of the transaction service end.

[0085] In addition, in order to ensure the smooth progress of the transaction, the generated transaction needs to meet the following constraints:

[0086] Each transaction has only one sending account, and a transaction can involve multiple receiving accounts. For example, e1 transfers money to e2 and e3.

[0087] The transaction sending account of each transaction is statically determined in the transaction, and the transaction receiving account of each transaction can be multiple. For example, e4 sends a red envelope to the group, and only e5 and e6 who grab the red envelope are used as the transaction receiving account, and e7 who does not grab the red envelope is not used as the transaction receiving account;

[0088] Each transaction can modify the assets belonging to the transaction sending account. The modification may include adding assets (adding assets refers to adding asset segments, which may refer to received coupons and red envelopes, etc.), modifying assets (referring to modifying the asset quantity in the asset segment, for example, deducting the asset quantity in the valid asset segment of the transaction sender account), and deleting assets (referring to deleting asset segments, for example, if the remaining assets of a valid asset segment after the transaction are 0, the valid asset segment is deleted);

[0089] Each transaction can add assets belonging to the transaction receiving account, but the assets of the transaction receiving account cannot be modified or deleted; in other words, a transaction can only add asset fragments to the transaction receiving account, but cannot modify or delete the existing asset fragments of the transaction receiving account.

[0090] Transactions can query the assets of the transaction sending account (for example, query multiple asset fragments of the transaction sending account, the number of assets in each asset fragment, and the status of the asset fragment (for example, unlocked status, locked status)), as well as other immutable data (including: transaction-related contracts, shared configuration data, etc.), but cannot query the assets of the transaction receiving account and other users.

[0091] However, when there is a competition relationship between multiple transactions, each transaction needs to be executed serially, otherwise each transaction can be processed in parallel.

[0092] Competition relationship Multiple transactions corresponding to the same transaction sending account may read and write a certain asset fragment at the same time. In this case, it is determined that multiple transactions compete with each other. For example, the asset fragments of the transaction sending account are g1, g2 and g3. The asset fragments that need to be locked for transaction h1 are g1 and g2. The asset quantity of g1 and g2 can satisfy the transaction asset quantity corresponding to h1. Transaction h2 requires asset fragments g3 and g2 to be locked. The asset quantity of g2 and g3 can satisfy the transaction asset quantity corresponding to transaction h2. However, g2 has been locked and can no longer be used. At this time, it is determined that transaction h1 and transaction h2 are in a competition relationship. Transaction h1 with an earlier occurrence time is executed first, and then transaction h2 is executed after transaction h1 is completed. Based on the solution of this application, for the asset fragment used to participate in the transaction of the transaction sender account, the asset fragment is first locked, thereby ensuring that the same asset fragment cannot participate in multiple transactions at the same time, thereby effectively avoiding the conflict caused by the competition relationship between multiple transactions.

[0093] In this embodiment, the assets of the target transaction sending account of the target transaction are divided into multiple target asset fragments. When executing the target transaction, only part of the valid asset fragments are locked. When performing different transactions on the same account, different valid asset fragments can be locked. All assets of the account are no longer locked for each transaction. Different transactions can be performed on the same account at the same time, which greatly reduces transaction conflicts when different transactions are processed on the same account at the same time, and reduces the probability of locking, blocking, rolling back and retrying of transaction transactions, thereby improving the concurrency efficiency of transaction transactions, and further improving the execution efficiency of transaction transactions.

[0094] At the same time, after the target transaction is completed, the valid asset fragments whose remaining asset quantity is not 0 are also unlocked so that other transactions can continue to use the valid asset fragments, avoiding the situation where the valid asset fragments are continuously locked, resulting in the invalidity of the valid asset fragments and the conflict of the valid asset fragments.

[0095] In addition, asset fragments with a smaller number of assets are merged to reduce the number of asset fragments, thereby reducing the storage space occupied by the asset fragments and avoiding waste of storage space.

[0096] See also Figure 3 , Figure 3 A flowchart of a transaction processing method proposed in another embodiment of the present application is shown. The method can be applied to a target node in a distributed storage system. The target node can be Figure 1 Any node 11 in the method comprises:

[0097] S210. In response to receiving a target transaction request, determine a target data shard for storing multiple target asset fragments based on the target transaction sending account; and determine a master node corresponding to the target data shard according to the shard metadata.

[0098] The shard metadata indicates the corresponding primary node and the corresponding backup node of each data shard in the distributed storage system.

[0099] As mentioned above, the nodes in the distributed storage system may include a storage layer, and at least one data shard is stored in the storage layer of each node. One data shard corresponds to one account, and each data shard is used to store multiple asset fragments of the account corresponding to the data shard; one data shard corresponds to a master node and a backup node in the distributed storage system. For any data shard, the data in the data shard can be read and written in the master node corresponding to the data shard; the data in the data shard is backed up in the backup node corresponding to the data shard to obtain a backup data shard.

[0100] For example, for data shard b1 and data shard b2, data shard b1 stores multiple asset fragments of account c1, and data shard b2 stores multiple asset fragments of account c2; the master node corresponding to data shard b1 is node n1, the backup node corresponding to data shard b1 is node n2, the master node corresponding to data shard b2 is node n2, and the backup node corresponding to data shard b3 is node n1. Data of data shard b1 can be read and written in node n1, and data in data shard b2 in node n2 can be backed up to node n1, so that node n1 backs up data shard b2 to obtain backup data shard b21. Data of data shard b2 can be read and written in node n2, and data in data shard b1 in node n1 can be backed up to node n2, so that node n2 backs up data shard b1 to obtain backup data shard b11.

[0101] For each node in the distributed storage system, there may be a corresponding gateway layer. The gateway layer of the node stores data shard identifiers corresponding to different accounts (data shard identifiers may refer to strings used to identify different data shards, including letters and numbers, etc.) and shard metadata. The data shard identifiers corresponding to different accounts determine the data shard corresponding to the target transaction sending account as the target data shard, and determine the master node corresponding to the target data shard in the distributed storage system based on the shard metadata.

[0102] S220: If the target node is the master node corresponding to the target data shard, according to the target transaction sending account, obtain multiple target asset fragments associated with the target transaction sending account in the target data shard stored on the target node.

[0103] If the target node is the master node corresponding to the target data shard in the distributed storage system, it means that the target node has a target data shard that stores multiple asset fragments of the target transaction sending account, and the data in the target data shard can be read and written, and the multiple asset fragments of the target transaction sending account can be obtained in the target node. At this time, the target node can obtain multiple target asset fragments associated with the target transaction sending account in the target data shard stored on the target node according to the target transaction sending account.

[0104] As an implementation mode, a message queue of an account corresponding to each data shard is provided in the master node where each data shard is located, and different message queues correspond to different data shards, that is, different accounts correspond to different message queues; S220 may include: if the target node is the master node corresponding to the target data shard, the target transaction request may be sent to the target message queue corresponding to the target transaction sending account, and then the target node responds to taking out the target transaction request from the target message queue, and according to the target transaction sending account, obtains multiple target asset fragments associated with the target transaction sending account in the target data shard stored on the target node.

[0105] S230: Based on the number of target transaction assets, determine at least one valid asset segment from among the multiple target asset segments that are in an unlocked state; and lock the at least one valid asset segment.

[0106] S240: Process the target transaction according to at least one valid asset fragment in a locked state.

[0107] Among them, the description of S230-S240 refers to the description of S120-S140 above, and will not be repeated here.

[0108] In some embodiments, S240 may also include: executing a target transaction according to at least one valid asset fragment in a locked state to obtain first data and second data; and writing the target data fragment and the reference data fragment respectively based on the first data and the second data. The first data includes the remaining asset quantity of each valid asset fragment after executing the target transaction, the second data includes the asset fragment that needs to be added to the target transaction receiving account of the target transaction after executing the target transaction, and the reference data fragment refers to the data fragment where the asset fragment of the target transaction receiving account is located.

[0109] Based on the asset quantity of each valid asset fragment in at least one valid asset fragment in a locked state and the target transaction asset quantity corresponding to the target transaction, the remaining asset quantity of each valid asset fragment after the target transaction is executed can be determined; based on the fragment identifier of at least one valid asset fragment in a locked state and the remaining asset quantity of each valid asset fragment after the target transaction is executed, the first data can be generated; based on the target transaction asset quantity corresponding to the target transaction, the asset fragment that needs to be added to the target transaction receiving account after the target transaction is executed is determined; and according to the asset fragment that needs to be added to the target transaction receiving account after the target transaction is executed, the second data can be generated.

[0110] After obtaining the first data and the second data, write processing can be performed in the target data shard according to the first data, and write processing can be performed in the reference data shard according to the second data. After the write processing of the first data and the second data is completed, it can be determined that the target transaction is completed, and the transaction completion information is returned to the sender of the target transaction request (that is, the terminal above), so that the terminal can output the transaction completion information through the target transaction sending account.

[0111] In one embodiment, write processing can be performed in the target data shard based on the first data; the auxiliary node is requested to perform write processing in the reference data shard based on the second data; the auxiliary node refers to the primary node corresponding to the reference data shard; after the write processing of the first data and the second data is completed, it can be determined that the target transaction is completed.

[0112] If the auxiliary node is the target node, that is, the primary node of the reference data shard is the target node, write processing is performed in the reference data shard in the target node based on the second data; if the auxiliary node is not the target node, that is, the primary node of the reference data shard is not the target node, the target node sends a write request (including the second data) to the primary node of the reference data shard, and the primary node of the reference data shard performs write processing in the reference data shard based on the second data according to the write request.

[0113] As an implementation method, S250 may include: performing pre-write processing in the target data shard based on the first data; requesting the auxiliary node to perform pre-write processing in the reference data shard based on the second data; the auxiliary node refers to the master node corresponding to the reference data shard; if the first data and the second data are both pre-written successfully, writing and submitting the target data shard based on the successfully pre-written first data, and requesting the auxiliary node to write and submit the reference data shard based on the successfully pre-written second data.

[0114] If the auxiliary node is the target node, that is, the primary node of the reference data shard is the target node, pre-write processing and write submission processing are performed in the reference data shard of the target node based on the second data, and the target node directly determines whether the first data and the second data are pre-written successfully; if the auxiliary node is not the target node, that is, the primary node of the reference data shard is not the target node, the target node sends a pre-write request (including the second data) and a write submission request to the auxiliary node, and the auxiliary node performs pre-write processing based on the second data in the reference data shard according to the pre-write request and write submission processing based on the second data in the reference data shard according to the write submission request, and the auxiliary node returns whether the second data is pre-written successfully and whether the write submission is completed.

[0115] Performing pre-write processing in the target data shard based on the first data may refer to modifying the valid asset segment under the target transaction sending account in the target data shard based on the first data, and marking the modified valid asset segment (the number of assets in the modified valid asset segment is the number of assets remaining in the valid asset segment after the target transaction is executed) as a pending submission state or writing the modified valid asset segment into a temporary data area in the target data shard. Similarly, requesting the auxiliary node to perform pre-write processing in the reference data shard based on the second data may refer to requesting the auxiliary node to mark the asset segment added to the target transaction receiving account of the target transaction after the target transaction is executed as a pending submission state or writing the asset segment added to the target transaction receiving account of the target transaction after the target transaction is executed into a temporary data area in the reference data shard based on the second data.

[0116] In some embodiments, if the first data is pre-written successfully, the state of the first data is updated to a pending submission state; similarly, if the second data is pre-written successfully, the state of the second data is updated to a pending submission state.

[0117] If both the first data and the second data are pre-written successfully, it is determined that the pre-writing process of the target transaction is completed, and the target data shard is written and submitted based on the successfully pre-written first data, and the auxiliary node is requested to write and submit the reference data shard based on the successfully pre-written second data.

[0118] Among them, performing write submission processing in the target data shard based on the first data may refer to marking the modified valid asset segment marked as to be submitted as submitted, or writing the modified valid asset segment written to a temporary data area in the target data shard into the target data shard and replacing the valid asset segment before modification. Similarly, requesting the auxiliary node to perform write submission processing in the reference data shard based on the second data may refer to requesting the auxiliary node to mark the newly added asset segment marked as to be submitted as submitted, or writing the newly added asset segment written to a temporary data area in the reference data shard into the reference data shard.

[0119] After both the first data and the second data have completed writing and submission, it can be determined that the target transaction is completed. The state of the first data and the state of the second data can be obtained by the target node, wherein the state of the first data can include a submitted state or an unsubmitted state, and the state of the second data can also include a submitted state or an unsubmitted state. If the state of the first data is a submitted state, it is determined that the first data has completed writing and submission, and if the state of the second data is a submitted state, it is determined that the second data has completed writing and submission. The target node can determine whether the first data and the second data have completed writing and submission based on the state of the first data and the state of the second data.

[0120] As an implementation mode, the second data also includes target reference information indicating that the second data references the first data; in this embodiment, pre-write processing is performed in the target data shard based on the first data; after the step of requesting the auxiliary node to perform pre-write processing in the reference data shard based on the second data, the method also includes: if the status of the second data is a pending-commitment status, and it is determined based on the target reference information that the status of the first data referenced by the second data is a committed status, re-requesting the auxiliary node to perform a write submission based on the successfully pre-written second data until the status of the second data is a committed status.

[0121] As mentioned above, after obtaining the first data and the second data, target reference information indicating that the second data references the first data can also be created, and the target reference information can be added to the second data. When the state of the second data is in the pending state, and the state of the first data referenced by the second data is determined to be in the submitted state according to the target reference information, it is determined that the target transaction has been executed and the write submission process of the second data is blocked. At this time, the auxiliary node can be requested to write and submit based on the successfully pre-written second data until the state of the second data is in the submitted state, thereby avoiding the situation where the target transaction is not executed only based on the state of the second data when the state of the first data is in the submitted state and the state of the second data is in the pending state, resulting in target transaction lock blocking, target transaction lock detection, and transaction read-write set conflict detection, etc., thereby improving the execution efficiency of the target transaction.

[0122] In addition, in this application, there may be dependencies between transactions. If the transaction sending account of a transaction L1 is the transaction receiving account in transaction L2, then transaction L1 is said to be dependent on transaction L2. Different transaction orders may result in different execution results. For example, if account m1 transfers to account m2, and account m2 transfers to account m3, if the first transaction is successfully executed, the second transaction must be able to read the execution result of the first transaction, otherwise account m2 may not be executed due to insufficient balance).

[0123] The target transaction is determined to be completed when the status of the first data is submitted, thereby avoiding the situation where, when the status of the first data is submitted and the status of the second data is unsubmitted, it is determined that the target transaction has not been completed, resulting in other transactions that depend on the target transaction being blocked, causing other transactions that depend on the target transaction to fail to be smoothly executed, thereby ensuring the smooth execution of transactions that depend on the target transaction and improving the execution efficiency of transactions that depend on the target transaction.

[0124] Optionally, after S240, if it is determined that the state of the first data is in the submitted state, transaction completion information is returned to the initiator of the target transaction request. When the state of the first data is in the submitted state, it is determined that the target transaction has been executed and completed, and the transaction completion information is directly returned to the initiator of the target transaction request, and there is no need to wait for the state of the second data to be in the submitted state to return the transaction completion information, so that the user can be notified in time that the target transaction has been completed, avoiding the slow return of the transaction completion information caused by the blocking of the writing and submission of the second data, and the difficulty for the user to determine whether the target transaction is completed in time, thereby improving the user experience.

[0125] As an implementation mode, before S250, the method may include: in response to receiving a target transaction request, reading the first shard version information corresponding to the target node; in response to obtaining the first data and the second data, reading the second shard version information corresponding to the target node; accordingly, S250 includes: if the first shard version information is consistent with the second shard version information, based on the first data and the second data, respectively write processing is performed on the target data shard and the reference data shard. The shard version information may refer to the version number of the shard metadata (metadata) used to describe each data shard of the target node.

[0126] When the target transaction request is received and the target node is determined to be the master node of the target data shard, the shard version information of the target node is read in real time as the first shard version information. In the subsequent transaction processing process, when the first data and the second data are obtained, the shard version information of the target node is read in real time as the second shard version information. If the first shard version information is consistent with the second shard version information, it is determined that the target data shard has not been modified, and the steps of writing the target data shard and the reference data shard based on the first data and the second data can be executed respectively; if the first shard version information is inconsistent with the second shard version information, it is determined that the target data shard has been modified, and the steps of writing the target data shard and the reference data shard based on the first data and the second data are not executed, and a prompt message can be output to prompt that the target transaction is abnormal, so that the user can handle the abnormal target transaction through the prompt message.

[0127] In this embodiment, the target transaction is executed through the distributed storage system, and write processing is performed in the target data shard based on the first data, and write processing is performed in the reference data shard based on the second data. Write processing is performed on the data of different accounts in their respective data shards, effectively isolating the transaction data of different accounts, avoiding data disorder and data conflict caused by poor data isolation of different accounts during data write processing.

[0128] At the same time, the writing process of the first data and the second data includes two processes: pre-writing processing and writing submission processing, which ensures stable and accurate execution of transactions.

[0129] See also Figure 4 , Figure 4 A flowchart of a transaction processing method proposed in another embodiment of the present application is shown. The method can be applied to the master node corresponding to the target data shard in the distributed storage system. The master node corresponding to the target data shard can be Figure 1 Any node 11 in the method comprises:

[0130] S310: Receive a transaction request forwarded by a target node.

[0131] In response to receiving the target transaction request, the target node determines the target data shard for storing multiple target asset fragments based on the target transaction sending account; determines the master node corresponding to the target data shard according to the shard metadata; the shard metadata indicates the master node and the corresponding backup node corresponding to each data shard in the distributed storage system. If the target node is not the master node corresponding to the target data shard, forward the target transaction request to the master node corresponding to the target data shard.

[0132] If the target node is not the master node corresponding to the target data shard, the target transaction request can be forwarded by the gateway layer of the target node to the master node corresponding to the target data shard, and the master node corresponding to the target data shard executes the target transaction according to the target transaction request, wherein the master node corresponding to the target data shard also includes a gateway layer, and the target transaction request forwarded by the target node is received through the gateway layer of the master node corresponding to the target data shard.

[0133] S320: Based on the number of target transaction assets, determine at least one valid asset segment from among the multiple target asset segments that are in an unlocked state; and lock the at least one valid asset segment.

[0134] As can be seen from the above, a message queue of the account corresponding to the data shard is set in the master node where each data shard is located, and different message queues correspond to different data shards, that is, different accounts correspond to different message queues. Therefore, S230 may include: sending the target transaction request to the target message queue corresponding to the target transaction sending account, and then the master node corresponding to the target data shard responds to taking out the target transaction request from the target message queue, and according to the target transaction sending account, obtains multiple target asset fragments associated with the target transaction sending account in the target data shard stored on the target node, and then continues to determine at least one valid asset fragment from the target asset fragments that are in an unlocked state among the multiple target asset fragments by the master node corresponding to the target data shard; and locks at least one valid asset fragment.

[0135] S330: Execute a target transaction according to at least one valid asset segment in a locked state to obtain first data and second data.

[0136] S340: Based on the first data and the second data, write processing is performed on the target data segment and the reference data segment respectively.

[0137] The description of the master node corresponding to the target data shard executing S340-S350 refers to the description of the target node executing S240 above, and the process is similar, so it is not repeated here. In addition, the master node corresponding to the target data shard also includes a computing layer, and the steps S320-S340 are executed by the computing layer of the master node corresponding to the target data shard.

[0138] As mentioned above, each account corresponds to its own data shard. For multiple different transactions of the same account, the data shard involved is the same. Therefore, the transaction requests of multiple transactions are sent to the master node corresponding to the storage shard corresponding to the account. The master node executes the transaction according to each transaction request, so that transactions of the same account are only performed in the data shard of the account and run in the master node corresponding to the data shard of the account. Transactions that may have competing relationships are aggregated and processed in the same node and data shard, solving the read and write conflicts of concurrent transactions with very low overhead. At the same time, it avoids the additional overhead caused by communication between nodes when different nodes process transactions of the same account, reducing transaction losses and delays.

[0139] In this embodiment, the target transaction is executed through the distributed storage system, and write processing is performed in the target data shard based on the first data, and write processing is performed in the reference data shard based on the second data. Write processing is performed on the data of different accounts in their respective data shards, effectively isolating the transaction data of different accounts, avoiding data disorder and data conflict caused by poor data isolation of different accounts during data write processing.

[0140] In order to explain the technical solution of the present application more clearly, the transaction processing method of the present application is explained below in conjunction with an exemplary scenario. In this scenario, Figure 5As shown, the distributed storage system includes at least 4 nodes, numbered as node 1, node 2, node 3 and node 4, and each node includes a gateway layer, a storage layer and a computing layer. Node 1 is the master node of data shard r1 and the backup node of data shard r2 (data shard r2 corresponds to backup data shard r12 in node 1), node 2 is the master node of data shard r2 and the backup node of data shard r1 (data shard r1 corresponds to backup data shard r21 in node 2), node 3 is the master node of data shard r3 and the backup node of data shard r4 (data shard r4 corresponds to backup data shard r34 in node 3), and node 4 is the master node of data shard r4 and the backup node of data shard r3 (data shard r3 corresponds to backup data shard r43 in node 4).

[0141] The account corresponding to data shard r1 is Alice. Alice has multiple asset fragments in r1, such as Figure 6 As shown in a in , the sum of all Alice's assets is 666. The account corresponding to data shard r2 is Bob, and the multiple asset fragments corresponding to Bob in r2 are as follows Figure 6 As shown in b in , the total amount of Bob's assets is 220.

[0142] like Figure 7 As shown, Alice sends a transaction request to Node 1 through the terminal - Alice transfers 65 assets to Bob. The gateway layer of Node 1 determines that Node 1 is the master node of the data shard r1 corresponding to Alice through the shard metadata, and records the shard version information p1 corresponding to Node 1.

[0143] The computing layer of node 1 will lock the asset fragments A002 (the aforementioned valid asset fragment) and A003 (the aforementioned valid asset fragment) in Alice according to the transaction asset quantity 65 in the transaction request. Node 1 executes the target transaction according to Alice's corresponding A002 and A003, obtains the read-write set, and obtains the shard version information p2 corresponding to node 1 in real time.

[0144] The computing layer of node 1 determines that p1 is consistent with p2, and node 1 splits the read-write set to obtain the first data and the second data. The first data includes the remaining assets of Alice's asset fragment A002, which is 0, and the remaining assets of asset fragment A002, which is 1. The second data includes Bob's newly added asset fragments B003 and B004, where the number of assets in B003 is 60 and the number of assets in B004 is 5.

[0145] Node 1 performs pre-write processing on the data shard in r1 using the first data, and sends a pre-write request including the second data to node 2. Node 2 performs pre-write processing in r2 using the second data, and r2 returns the pre-write processing result.

[0146] Node 1 determines that the first data and the second data (determined based on the pre-write processing result returned by node 2) are both pre-written successfully, and node 1 performs write submission processing on the data shard in r1 using the first data. Node 1 sends a write submission request including the second data to node 2, and node 2 performs write submission processing in r2 using the second data, and r2 returns the write submission processing result.

[0147] Node 1 determines that the first data is successfully written and submitted (the status of the first data is submitted), and the computing layer of node 1 determines that the transaction is completed, and returns transaction success information to the terminal. Among them, node 2 can be asynchronously submitted by writing and submitting the second data in r2, that is, whether the transaction is completed and the status of the second data are determined according to the status of the first data.

[0148] If the status of the second data is uncommitted, it is determined that the second data references the first data based on the target reference information in the second data, and then it is determined that the status of the first data is committed. Node 1 repeatedly sends a write commit request to node 2 until the status of the second data is committed.

[0149] After the transaction, Alice's assets are Figure 8 As shown in a, the total amount of Alice's assets is 601, and Bob's assets are Figure 8 As shown in b in , Bob's total assets are 285. Alice deleted asset segment A002, and the number of assets in asset segment A003 is 1. Bob added asset segments B003 and B004.

[0150] In this scenario, a new account storage model is used to divide the assets of the same account into multiple asset fragments, which can greatly reduce the probability of conflicts in distributed transactions, reduce the probability of transaction locking, blocking, rollback and retry, and thus improve the concurrency efficiency of transactions.

[0151] At the same time, the present invention proposes a transaction constraint rule, based on which the process of distributed transactions can be simplified, and transactions of the same account are only performed in the data shard of the account, and are run in the master node corresponding to the data shard of the account, so that transactions that may have competing relationships are aggregated and processed in the same node and data shard, thereby resolving the read and write conflicts of concurrent transactions with very low overhead.

[0152] In addition, by setting the target reference information, a consistent transaction timing is provided for the transaction. It is only necessary to determine whether the transaction is completed based on whether the data write submission of the transaction sending account is successful or not. It is not necessary to wait for the transaction receiving account to successfully submit the write before determining the transaction is completed. This avoids global transaction overheads such as locking blocking, deadlock detection, read-write set conflict detection, and global clock generation, thereby improving transaction efficiency.

[0153] See also Fig. 9 , Fig. 9 A block diagram of a transaction processing device proposed in one embodiment of the present application is shown, and the device 900 includes:

[0154] A response module 910 is used to respond to receiving a target transaction request and determine, according to a target transaction sending account corresponding to the target transaction in the target transaction request, a plurality of target asset segments associated with the target transaction sending account; the target transaction request also includes the number of target transaction assets corresponding to the target transaction; and the plurality of target asset segments are obtained by dividing the assets of the target transaction sending account;

[0155] A determination module 920 is configured to determine at least one valid asset segment from among the target asset segments that are in an unlocked state in the plurality of target asset segments based on the target transaction asset quantity; wherein the sum of the asset quantities of all the valid asset segments in the at least one valid asset segment is not less than the target transaction asset quantity;

[0156] A locking module 930, configured to lock at least one valid asset segment;

[0157] The transaction module 940 is used to process the target transaction according to at least one valid asset segment in a locked state.

[0158] Optionally, the method is applied to a target node in a distributed storage system; each node in the distributed storage system stores at least one data shard, and one data shard is used to store multiple asset fragments of an account; one data shard corresponds to a master node and a backup node in the distributed storage system; the response module 910 is also used to respond to receiving a target transaction request, determine a target data shard for storing multiple target asset fragments based on a target transaction sending account; determine the master node corresponding to the target data shard according to the shard metadata; the shard metadata indicates the master node and the corresponding backup node corresponding to each data shard in the distributed storage system; if the target node is the master node corresponding to the target data shard, according to the target transaction sending account, obtain multiple target asset fragments associated with the target transaction sending account in the target data shard stored on the target node.

[0159] Optionally, the transaction module 940 is also used to execute the target transaction based on at least one valid asset fragment in a locked state to obtain first data and second data; the first data includes the remaining asset quantity of each valid asset fragment after the execution of the target transaction, and the second data includes the asset fragment that needs to be added to the target transaction receiving account of the target transaction after the execution of the target transaction; based on the first data and the second data, write processing is performed on the target data shard and the reference data shard respectively; the reference data shard refers to the data shard where the asset fragment of the target transaction receiving account is located.

[0160] Optionally, the transaction module 940 is also used to perform pre-write processing in the target data shard based on the first data; request the auxiliary node to perform pre-write processing in the reference data shard based on the second data; the auxiliary node refers to the master node corresponding to the reference data shard; if the first data and the second data are both pre-written successfully, the target data shard is written and submitted based on the successfully pre-written first data, and the auxiliary node is requested to write and submit to the reference data shard based on the successfully pre-written second data.

[0161] Optionally, the second data also includes target reference information indicating that the second data references the first data; the transaction module 940 is also used to re-request the auxiliary node to perform a write submission based on the successfully pre-written second data if the status of the second data is a pending state, and it is determined based on the target reference information that the status of the first data referenced by the second data is a submitted state, until the status of the second data is a submitted state.

[0162] Optionally, the transaction module 940 is further used to determine the remaining asset quantity of each valid asset fragment after executing the target transaction based on the asset quantity of each valid asset fragment in at least one valid asset fragment in a locked state and the target transaction asset quantity corresponding to the target transaction; generate first data based on the fragment identifier of at least one valid asset fragment in a locked state and the remaining asset quantity of each valid asset fragment after executing the target transaction; determine the asset fragment that needs to be added to the target transaction receiving account after executing the target transaction based on the target transaction asset quantity corresponding to the target transaction; and generate second data according to the asset fragment that needs to be added to the target transaction receiving account after executing the target transaction.

[0163] Optionally, the transaction module 940 is further configured to return transaction completion information to the initiator of the target transaction request if it is determined that the status of the first data is a submitted status.

[0164] Optionally, the transaction module 940 is also used to read the first shard version information corresponding to the target node in response to receiving a target transaction request; read the second shard version information corresponding to the target node in response to obtaining the first data and the second data; if the first shard version information is consistent with the second shard version information, write processing is performed on the target data shard and the reference data shard based on the first data and the second data, respectively.

[0165] Optionally, the response module 910 is further used to forward the target transaction request to the master node corresponding to the target data shard if the target node is not the master node corresponding to the target data shard.

[0166] Optionally, the transaction module 940 is further configured to unlock a valid asset segment having a non-zero asset quantity in at least one valid asset segment in response to completion of the target transaction.

[0167] Optionally, the device also includes an asset management module, which is used to obtain at least two target asset fragments whose asset quantities are less than a threshold and are in an unlocked state from multiple target asset fragments of the target transaction sending account; and merge the at least two target asset fragments whose asset quantities are less than a threshold and are in an unlocked state.

[0168] It should be noted that the device embodiment in the present application corresponds to the aforementioned method embodiment. The specific principles in the device embodiment can be found in the contents of the aforementioned method embodiment and will not be repeated here.

[0169] Fig.10 The structure block diagram of an electronic device for executing the transaction processing method according to an embodiment of the present application is shown. The electronic device may be a node in a distributed storage system, etc. It should be noted that: Fig.10 The computer system 1200 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application.

[0170] like Fig.10As shown, the computer system 1200 includes a central processing unit (CPU) 1201, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1202 or the program loaded from the storage part 1208 to the random access memory (RAM) 1203, such as executing the method in the above embodiment. In RAM 1203, various programs and data required for system operation are also stored. CPU 1201, ROM 1202 and RAM 1203 are connected to each other through bus 1204. Input / output (I / O) interface 1205 is also connected to bus 1204.

[0171] The following components are connected to the I / O interface 1205: an input section 1206 including a keyboard, a mouse, etc.; an output section 1207 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1208 including a hard disk, etc.; and a communication section 1209 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1209 performs communication processing via a network such as the Internet. A drive 1210 is also connected to the I / O interface 1205 as needed. A removable medium 1211, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1210 as needed so that a computer program read therefrom is installed into the storage section 1208 as needed.

[0172] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 1209, and / or installed from a removable medium 1211. When the computer program is executed by a central processing unit (CPU) 1201, various functions defined in the system of the present application are executed.

[0173] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, - but not limited to - an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.

[0174] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0175] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.

[0176] As another aspect, the present application further provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiments; or may exist independently without being assembled into the electronic device. The above computer-readable storage medium carries computer-readable instructions, and when the computer-readable storage instructions are executed by a processor, the method in any of the above embodiments is implemented.

[0177] According to one aspect of the embodiments of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. A processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the method in any of the above embodiments.

[0178] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.

[0179] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation method of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, including several instructions to enable an electronic device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation method of the present application.

[0180] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary techniques in the art that are not disclosed in the present application. It should be understood that the present application is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.

[0181] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A transaction processing method, characterized in that: The method comprises: In response to receiving a target transaction request, according to a target transaction sending account corresponding to the target transaction in the target transaction request, a plurality of target asset fragments associated with the target transaction sending account are determined; the target transaction request also includes the number of target transaction assets corresponding to the target transaction; the plurality of target asset fragments are obtained by dividing the assets of the target transaction sending account; Based on the target transaction asset quantity, at least one valid asset segment is determined from the target asset segments in an unlocked state among the multiple target asset segments; wherein the sum of the asset quantities of all valid asset segments in the at least one valid asset segment is not less than the target transaction asset quantity; Locking the at least one valid asset fragment; The target transaction is processed according to the at least one valid asset fragment in a locked state.

2. The method according to claim 1, characterized in that The method is applied to a target node in a distributed storage system; each node in the distributed storage system stores at least one data shard, and one data shard is used to store multiple asset fragments of an account; A data shard corresponds to a master node and a backup node in the distributed storage system; The step of determining, in response to receiving the target transaction request, a plurality of target asset fragments associated with the target transaction sending account according to the target transaction sending account corresponding to the target transaction in the target transaction request, includes: In response to receiving the target transaction request, determining a target data shard for storing the plurality of target asset fragments based on the target transaction sending account; Determine the master node corresponding to the target data shard according to the shard metadata; the shard metadata indicates the master node and the backup node corresponding to each data shard in the distributed storage system; If the target node is the master node corresponding to the target data shard, according to the target transaction sending account, multiple target asset fragments associated with the target transaction sending account are obtained from the target data shard stored on the target node.

3. The method according to claim 2, characterized in that The processing of the target transaction according to the at least one valid asset fragment in a locked state comprises: Execute the target transaction according to at least one valid asset fragment in a locked state to obtain first data and second data; the first data includes the remaining asset quantity of each valid asset fragment after executing the target transaction, and the second data includes the asset fragment that needs to be added to the target transaction receiving account of the target transaction after executing the target transaction; Based on the first data and the second data, write processing is performed on the target data shard and the reference data shard respectively; the reference data shard refers to the data shard where the asset fragment of the target transaction receiving account is located.

4. The method according to claim 3, characterized in that The writing process is performed on the target data slice and the reference data slice respectively based on the first data and the second data, including: Performing pre-writing processing in the target data slice based on the first data; Requesting an auxiliary node to perform pre-write processing on the reference data shard based on the second data; the auxiliary node refers to a primary node corresponding to the reference data shard; If both the first data and the second data are pre-written successfully, write submission is performed on the target data shard based on the pre-written first data, and the auxiliary node is requested to write submission on the reference data shard based on the pre-written second data.

5. The method according to claim 4, characterized in that The second data further includes target reference information indicating that the second data references the first data; If both the first data and the second data are pre-written successfully, after writing and submitting the target data shard based on the first data that is pre-written successfully, and requesting the auxiliary node to write and submit the reference data shard based on the second data that is pre-written successfully, the method further includes: If the status of the second data is in a pending-commitment status, and it is determined based on the target reference information that the status of the first data referenced by the second data is in a committed status, the auxiliary node is re-requested to perform a write submission based on the successfully pre-written second data until the status of the second data is in a committed status.

6. The method according to claim 4 or 5, characterized in that: The step of executing the target transaction according to at least one valid asset fragment in a locked state to obtain the first data and the second data includes: Determine the remaining asset quantity of each valid asset segment after executing the target transaction based on the asset quantity of each valid asset segment in at least one valid asset segment in a locked state and the target transaction asset quantity corresponding to the target transaction; generating the first data based on a segment identifier of at least one valid asset segment in a locked state and a remaining asset quantity of each valid asset segment after executing the target transaction; Based on the target transaction asset quantity corresponding to the target transaction, determining the asset segment that needs to be added to the target transaction receiving account after executing the target transaction; The second data is generated according to the asset fragment that needs to be added to the target transaction receiving account after executing the target transaction.

7. The method according to claim 4, characterized in that If both the first data and the second data are pre-written successfully, after writing and submitting the target data shard based on the first data that is pre-written successfully, and requesting the auxiliary node to write and submit the reference data shard based on the second data that is pre-written successfully, the method further includes: If it is determined that the state of the first data is a submitted state, transaction completion information is returned to the initiator of the target transaction request.

8. The method according to claim 3, characterized in that Before performing write processing on the target data slice and the reference data slice respectively based on the first data and the second data, the method further includes: In response to receiving the target transaction request, reading the first shard version information corresponding to the target node; In response to obtaining the first data and the second data, reading second shard version information corresponding to the target node; The writing process is performed on the target data slice and the reference data slice respectively based on the first data and the second data, including: If the first shard version information is consistent with the second shard version information, write processing is performed on the target data shard and the reference data shard respectively based on the first data and the second data.

9. The method according to claim 2, characterized in that: The method further comprises: If the target node is not the master node corresponding to the target data shard, forward the target transaction request to the master node corresponding to the target data shard.

10. The method according to claim 1, characterized in that After processing the target transaction according to the at least one valid asset fragment in a locked state, the method further includes: In response to the target transaction being completed, unlocking a valid asset segment having a non-zero asset quantity in the at least one valid asset segment.

11. The method according to claim 1, characterized in that: After processing the target transaction according to the at least one valid asset fragment in a locked state, the method further includes: Acquire at least two target asset fragments whose asset quantity is less than a threshold and are in an unlocked state from the multiple target asset fragments of the target transaction sending account; At least two target asset fragments whose asset quantity is less than a threshold and are in an unlocked state are merged.

12. A transaction processing device, characterized in that: The device comprises: a response module, configured to, in response to receiving a target transaction request, determine, according to a target transaction sending account corresponding to the target transaction in the target transaction request, a plurality of target asset segments associated with the target transaction sending account; the target transaction request also includes the number of target transaction assets corresponding to the target transaction; the plurality of target asset segments are obtained by dividing the assets of the target transaction sending account; A determination module, configured to determine at least one valid asset segment from among the target asset segments that are in an unlocked state in the multiple target asset segments based on the target transaction asset quantity; wherein the sum of the asset quantities of all the valid asset segments in the at least one valid asset segment is not less than the target transaction asset quantity; A locking module, used to lock the at least one valid asset segment; The transaction module is used to process the target transaction according to the at least one valid asset fragment in a locked state.

13. An electronic device, characterized in that: include: one or more processors; Memory; One or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs are configured to execute the method according to any one of claims 1-11.

14. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, which can be called by a processor to execute the method according to any one of claims 1 to 11.

15. A computer program product or a computer program, characterized in that The computer program product or computer program includes computer instructions, which are stored in a computer-readable storage medium; a processor of an electronic device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the electronic device executes the method as described in any one of claims 1-11.