A transaction processing method and corresponding apparatus
By synchronizing logical clocks in a distributed storage system and constructing a logical clock vector, the problem of inaccurate transaction sorting caused by physical clock errors of storage nodes is solved, thereby improving the accuracy of transaction sorting and the stability of the system.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
- Filing Date
- 2024-12-06
- Publication Date
- 2026-06-09
AI Technical Summary
In distributed storage systems, inaccurate transaction ordering can be caused by physical clock errors of storage nodes, especially when multiple storage nodes are executed in a distributed manner. The NTP clock problem can lead to inaccurate transaction ordering.
By synchronizing the logical clocks of storage nodes in a distributed system, and leveraging the collaborative work of clients, index modules, and transaction management devices, a logical clock vector is constructed, the logical clock of the transaction management device is updated, ensuring the consistency and synchronization of the logical clocks, detecting concurrent transaction conflicts, and reprocessing possible conflicting transactions.
It improves the accuracy and reliability of transaction ordering in distributed storage systems, reduces inaccurate read and write transaction data, and enhances the stability and reliability of the system.
Smart Images

Figure CN122173209A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of database technology, specifically to a transaction processing method and corresponding apparatus. Background Technology
[0002] In distributed storage systems, transactions are typically ordered using clocks to detect conflicts between them. However, the physical clocks on each storage node are prone to errors, leading to inaccurate ordering results.
[0003] In particular, when a transaction involves distributed execution across multiple storage nodes, a network time protocol (NTP) is typically used to synchronize the physical clocks of the multiple storage nodes. However, if the NTP clock obtained by a storage node through the NTP service malfunctions, it will cause the clocks of other related nodes to malfunction as well, resulting in an inaccurate transaction order. Summary of the Invention
[0004] This application provides a transaction processing method for synchronizing clocks in storage nodes involved in a transaction within a distributed storage system. This synchronizes the clocks to determine if conflicts exist between transactions, improving the accuracy of sorting results when sorting different transactions in a distributed storage system. This application also provides corresponding apparatus, computer-readable storage media, computer program products, and distributed systems.
[0005] This application provides a transaction processing method applied to a client that communicates with a distributed system via a network. The distributed system includes multiple storage nodes, each of which has an index module deployed on it. The distributed system also includes at least one transaction management device, each of which is associated with at least one storage node. The method includes: the client receiving transaction processing information, which includes first transaction information used by the client to determine at least one target storage node; the client sending a first transaction processing request to the at least one target storage node; wherein the first transaction processing request is used to instruct the index module on the at least one target storage node to process the first transaction, and the at least one target storage node belongs to the multiple storage nodes; the client receiving at least one first logical clock from the index module on the at least one target storage node; determining a logical clock vector based on the at least one first logical clock; wherein each of the at least one first logical clock indicates the logical clock of the index module on its corresponding target storage node for processing the first transaction; and the client sending the logical clock vector to the transaction management device associated with the at least one target storage node; wherein the logical clock vector is used to update a second logical clock of the associated transaction management device.
[0006] In this application, the distributed system may include multiple storage nodes, each managed by a transaction management device. A single transaction management device can manage the transaction status of multiple storage nodes. Each storage node includes multiple keys, each key value corresponding to a stored data entry; that is, each key uniquely identifies a value. There can be one or more transaction management devices. When there is only one, that transaction management device manages all storage nodes in the distributed storage system.
[0007] In this application, the data content stored in the storage nodes can also be recorded by the index module. That is, each of the multiple storage nodes is equipped with an index module. The index module records the key value corresponding to each piece of data on the storage node through the index, so that the client can quickly retrieve the corresponding value in the storage node.
[0008] In this application, transaction processing information can be directly input by the user to the client, or it can be converted by the program based on user-inputted instructions and then input to the client. The transaction processing information includes the transaction type, such as read transaction requests and write transaction requests. A read transaction request instructs the reading of specified data from the target storage node, while a write transaction request instructs the writing of specified data to the target storage node. The transaction processing information also includes first transaction information, which includes the target storage node involved in this transaction.
[0009] In this application, the number of target storage nodes can be one or more. When there are multiple target storage nodes, the client sends the first transaction processing request to each of the multiple target storage nodes. The first transaction processing request may also include the local logical clocks of the multiple target storage nodes, that is, the first logical clocks recorded by the multiple target storage nodes when they last processed a transaction. The local logical clocks of the multiple target storage nodes are used by each target storage node to determine whether a transaction conflict has occurred.
[0010] In this application, the first logical clock can be a logical clock on the target storage node, used to record the time when the target storage node receives the first transaction processing request. The second logical clock can be a logical clock on the transaction management device, used by the transaction management device to record the transaction commit time. The logical clock values of the first and second logical clocks are monotonically increasing.
[0011] In this application, the number of dimensions in the logical clock vector can be determined by the client based on the number of target storage nodes, or the client can set a preset value in advance.
[0012] In this application, the transaction management device is used to manage the transactions processed in the target storage node under its responsibility, including the transaction status of each transaction, a first logical clock, and a physical clock indicating the start of the transaction and the physical clock indicating the commit of the transaction.
[0013] In the first aspect mentioned above, during the execution of corresponding transactions by the index modules on the storage nodes, the client obtains the logical clock sent by the index modules on each storage node in the transaction completion message and constructs a logical clock vector. This logical clock vector is then used by the transaction management device to update and synchronize the logical clocks of multiple storage nodes. This improves the consistency and synchronization of logical clocks among multiple storage nodes involved in the same transaction during concurrent transaction processing in a distributed system. Furthermore, since the logical clock for each transaction is set separately on both the storage nodes and the transaction management device, conflicts between different transactions can be quickly detected locally, and the client can reissue the transaction processing request, thus improving the reliability and stability of the distributed system.
[0014] In one possible implementation, when the first transaction is a read transaction, after the client receives at least one first logical clock from an index module on at least one target storage node, the method further includes: the client receiving a third logical clock for a second transaction; wherein the second transaction is a write transaction; if the third logical clock is greater than the first logical clock of the first transaction, the client sends a second transaction processing request to the target storage node; wherein the index module corresponding to the third logical clock of the second transaction is the same index module as the index module corresponding to the first logical clock of the first transaction, and the second transaction processing request is used to request the index module on the target storage node to reprocess the first transaction.
[0015] In this application, the third logical clock for the second transaction can be proactively sent to the client by the target storage node processing the first transaction. The client then compares the magnitudes of the third logical clock and the first logical clock. If the third logical clock is greater than the first logical clock of the first transaction, and the index module corresponding to the second transaction is the same as the index module corresponding to the first transaction, then the read transaction involving the same index module is considered to have occurred before the write transaction. This means that data in the storage node may be unreadable or the read data may be inaccurate. In this case, the client needs to resend the second transaction processing request to the target storage node processing the first transaction, making the processing time of the first transaction later than that of the second transaction.
[0016] In this possible implementation, when the first transaction is a read transaction, the client judges the readability of the read transaction based on the third logical clock of the write transactions involved in each target storage node. This reduces the possibility of inaccurate data read when read and write transactions involve the same storage node, thereby improving the reliability and stability of the distributed storage system.
[0017] In one possible implementation, before the client receives at least one first logical clock from an index module on at least one target storage node, the method further includes: the client receiving a first response, the first response indicating a transaction state conflict between a first transaction and a second transaction; the index module corresponding to the second transaction is the same as the index module corresponding to the first transaction; the client sending a third transaction processing request to the target storage node, the third transaction processing request requesting the index module on the target storage node to reprocess the first transaction.
[0018] In this application, the transaction state of a write transaction can include a transaction start state, a transaction commit state, and a transaction rollback state, while the transaction state of a read transaction can include a transaction start state and a transaction end state. Transaction state conflicts can occur when two transactions of the same type have the same transaction state within the same time period, or when two transactions of different types have conflicting transaction states within the same time interval. Specifically, the two transactions must have the same key, meaning that the index modules involved in the two transactions contain the same key.
[0019] In this possible implementation, when the client receives a conflict response from a storage node, it resends the transaction processing request to the index module of the corresponding storage node based on the conflict response, thereby improving the consistency of data in the storage node and thus improving the reliability and stability of the distributed system.
[0020] In one possible implementation, the method further includes: determining the last dimension of the logic clock vector based on at least one first logic clock; if the number of first logic clocks is greater than the dimension of the logic clock vector, then the value of the last dimension in the logic clock vector is the synchronization value of the target logic clock; the target logic clock is a first logic clock with multiple dimensions, and the last dimension of the logic clock vector is used to represent the target logic clock.
[0021] In this application, the synchronization value of the target logical clock is the maximum value among the target logical clocks plus one. The synchronization value of the target logical clock can be queried and synchronized by the transaction management device from the first logical clock of the multiple dimensions, so that the logical clock values of the first logical clock of the multiple dimensions are the same.
[0022] In this application, the logical clock vector is generated by the client based on the first logical clock of the index module on each target storage node. The dimension of the logical clock vector can remain unchanged. When the number of index modules on the target storage node involved in the first transaction, i.e., the number of first logical clocks, is greater than the dimension of the logical clock vector, the client will synchronize the first logical clocks of the index modules on the excess target storage nodes to the same logical clock value and store this logical clock value in the last dimension of the logical clock vector.
[0023] In this possible implementation, the client reduces the storage space occupied by the logical clock vector composed of all the first logical clocks by synchronizing the first logical clocks of the multiple logical clock vector dimensions. This solves the problem of excessive storage space occupied by the logical clock vector due to the large number of index modules on the storage nodes involved in the transaction processing, and improves the transaction processing efficiency of the distributed system.
[0024] In one possible implementation, before the client sends a first transaction processing request to at least one target storage node, the method further includes: the client sending transaction start information to an associated transaction management device; wherein the transaction start information includes a first physical clock and a transaction number of the first transaction, the first physical clock being used to indicate the start time of the first transaction; after the client sends a logical clock vector to the transaction management device associated with at least one target storage node, the client sending transaction commit information to the associated transaction management device; the client receiving a second physical clock from the associated transaction management device; wherein the second physical clock is used to indicate the commit time of the first transaction, and the client determining whether the first transaction has timed out based on the first physical clock and the second physical clock.
[0025] In this application, physical clocks are set in both the client and the transaction management device to record the start and commit times of transactions.
[0026] In this application, the transaction management device can set a preset timeout for each transaction. When the commit time of a transaction exceeds the preset timeout, the transaction management device can roll back the transaction, thereby avoiding data in an inconsistent state and improving the reliability of the distributed storage system.
[0027] In this possible implementation, the physical clock and logical clock in the distributed system are set separately and are two independent parts. The physical clock is used to determine whether a transaction has timed out. Therefore, when the physical clock malfunctions, it will not cause the logical clock to become inaccurate in transactions. This reduces the dependence of the distributed system on the physical clock when sorting different transactions; that is, the physical clock can have a larger margin of error, reducing the need for physical clock precision and improving the performance of transaction processing in the distributed system.
[0028] A second aspect of this application provides a transaction processing method, characterized in that the method is applied to an index module, the index module is deployed on a target storage node, the target storage node is one of multiple storage nodes in a distributed system, the distributed system further includes at least one transaction management device, each of the at least one transaction management device is associated with at least one storage node, and the method includes: the index module receiving a first transaction processing request from a client; the index module processing a first transaction according to the first transaction processing request; and the index module sending a first logical clock to the client; wherein the first logical clock indicates the logical clock for the index module to process the first transaction.
[0029] In this application, after the index module receives a transaction processing request from the client and completes the first transaction, the target storage node sends its local first logical clock back to the client in the transaction processing response.
[0030] In the second aspect mentioned above, after processing the first transaction, the index module sends the first logical clock back to the client to record the time of the first transaction. After receiving the first logical clocks of the index modules on all target storage nodes, the client synchronizes the first logical clocks on each index module, improving the consistency and synchronization of logical clocks among the index modules on multiple storage nodes involved in the same transaction.
[0031] One possible implementation method, when the first transaction is a read transaction, after the index module sends the first logical clock to the client, the method further includes: the index module receiving a clock query request from the client; wherein, the clock query request is used by the client to obtain the third logical clock of the second transaction, the second transaction being a write transaction; the index module sending the third logical clock to the client; the index module receiving a second transaction processing request; wherein, the second transaction processing request is sent by the client when the third logical clock is greater than the first logical clock, and the index module reprocesses the first transaction according to the second transaction processing request.
[0032] In this application, the third logical clock of the second transaction can be obtained from the local cache of the index module on the target storage node, or the index module on the target storage node can initiate a query request to the transaction management device, and the transaction management device can send the third logical clock of the second transaction involving the index module to the index module, and then the index module can send it to the client.
[0033] In this possible implementation, the target storage node can report the logical clocks of different types of transactions in the same storage node to the client. This allows the client to judge the readability of read transactions and reread read transactions that may have errors, thereby improving the reliability and stability of the distributed system.
[0034] One possible implementation method involves an index module processing a first transaction based on a first transaction processing request, including: the index module determining whether there is a transaction state conflict between the first transaction and a second transaction, wherein the index module corresponding to the second transaction is the same as the index module corresponding to the first transaction; if a transaction state conflict exists, the index module sends a first response to the client; wherein the first response is used to indicate that there is a transaction state conflict between the first transaction and the second transaction; the index module receives a third transaction processing request from the client; the index module reprocesses the first transaction based on the third transaction processing request; if there is no transaction state conflict, the index module executes the first transaction.
[0035] In this application, the transaction state of a write transaction can include a transaction start state, a transaction commit state, and a transaction rollback state, while the transaction state of a read transaction can include a transaction start state and a transaction end state. Transaction state conflicts can occur when two transactions of the same type have the same transaction state within the same time period, or when two transactions of different types have conflicting transaction states within the same time interval. A conflict is confirmed when the corresponding index modules of the two transactions are identical.
[0036] In this possible implementation, the index module on the target storage node determines whether there is a conflict between two transactions based on the logical clock of different transactions in different transaction states. When a conflict occurs, the client re-initiates the transaction processing request, which improves the consistency of data in the storage node.
[0037] In one possible implementation, the first transaction processing request further includes a logical clock vector, which includes at least one first logical clock for the first transaction. The method also includes:
[0038] The indexing module uses a logical clock vector to determine the first logical clock, the value of which is the maximum value in the logical clock vector plus one.
[0039] In this application, a first preset clock value is used to set the logical clock value of the first logical clock in the index module on the target storage node to monotonically increasing. When the index module on the target storage node fails, the index module on the target storage node can restore the first logical clock to the first preset clock value by reading the first preset clock value. The magnitude of the first preset clock value is greater than the first logical clock of the transaction previously processed in the index module on the target storage node, thereby making the value of the first logical clock of the subsequent transaction processed in the index module on the target storage node greater than the first logical clock of the previously processed transaction.
[0040] In this possible implementation, by persistently setting the first logical clock in the index module on the target storage node, the first logical clock in the index module on the target storage node in the distributed system is monotonically increasing, which improves the reliability of the order between different transactions processed by the index module on the target storage node.
[0041] A third aspect of this application provides a transaction processing method, characterized in that the method is applied to a transaction management device, which is one of at least one transaction management devices in a distributed system. The distributed system further includes multiple storage nodes, each of which has an index module deployed on it. Each of the at least one transaction management device is associated with at least one storage node. The method includes:
[0042] The transaction management device receives a logical clock vector from a client; wherein the logical clock vector is determined by the client based on at least one first logical clock of an index module on at least one target storage node, the at least one first logical clock being sent by the index module on at least one target storage node after processing a first transaction based on a first transaction processing request, the first transaction processing request being sent by the client to at least one target storage node, and the at least one target storage node belonging to multiple storage nodes; the transaction management device updates a second logical clock based on the logical clock vector; wherein the second logical clock is used to update at least one first logical clock.
[0043] In this application, the updated second logic clock is the maximum value of each first logic clock and the second logic clock before the update in the logic clock vector plus one.
[0044] In this possible implementation, the transaction management device uses the maximum value of the first logical clock in the index module of all target storage nodes used to process the first transaction and its own local second logical clock to update the second logical clock, so that the second logical clock of the first transaction is the maximum value of the logical clock of the index module of all storage nodes and its own local logical clock, thereby improving the reliability of the logical clock value of the first transaction.
[0045] One possible implementation further includes, before the transaction management device receives the logical clock vector from the client:
[0046] The transaction management device receives transaction start information from the client; wherein the transaction start information includes a first physical clock and a transaction number of the first transaction, the first physical clock being used to indicate the start time of the first transaction; after the transaction management device updates the second logical clock based on the logical clock vector, the transaction management device further includes: sending the second physical clock to the client; wherein the second physical clock being used to indicate the commit time of the first transaction.
[0047] In this possible implementation, the physical clock and logical clock in the distributed system are set separately and are two independent parts. The physical clock is used to determine whether a transaction has timed out. Therefore, when the physical clock malfunctions, it will not cause the logical clock to become inaccurate in transactions. This reduces the dependence of the distributed system on the physical clock when sorting different transactions; that is, the physical clock can have a larger margin of error, reducing the need for physical clock precision and improving the performance of transaction processing in the distributed system.
[0048] In one possible implementation, if the second logical clock is greater than the second threshold, the second preset clock value and the second threshold are increased. The second preset clock value is greater than the second threshold and is used to restore the second logical clock on the transaction management device to the second preset clock value when the transaction management device malfunctions.
[0049] In this application, the second preset clock value is used to set the logical clock value of the second logical clock in the transaction management device to monotonically increasing. When the second storage node fails, the second storage node can restore the second logical clock to the second preset clock value by reading the second preset clock value. The magnitude of the second preset clock value is greater than the second logical clock of a transaction previously recorded in the transaction management device, thereby making the value of the second logical clock of subsequent transactions recorded in the transaction management device greater than the second logical clock of previously recorded transactions.
[0050] In this possible implementation, by persistently setting the second logical clock in the transaction management device, the second logical clock in the transaction management device in the distributed system is monotonically increasing, thereby improving the reliability of the order between different transactions recorded by the transaction management device.
[0051] A fourth aspect of this application provides a transaction processing method, characterized in that the method is applied to a distributed system, the distributed system including a client, a transaction management device, storage nodes, and an index module, the index module being deployed in the storage nodes, and the method comprising:
[0052] The client receives transaction processing information, which includes first transaction information. The first transaction information is used by the client to determine at least one target storage node, and the at least one target storage node is included in the storage node.
[0053] The client sends a first transaction processing request to the index module in at least one target storage node; wherein the first transaction processing request is used to instruct the index module to process a first transaction;
[0054] The index module sends at least one first logical clock to the client, the at least one first logical clock indicating the logical clock for the index module to process the first transaction;
[0055] The transaction management device receives a logical clock vector from the client, which is used to update the transaction management device's second logical clock, which is used to update at least one first logical clock.
[0056] A fifth aspect of this application provides a distributed system, characterized in that the distributed system includes a client, storage nodes, an index module, and a transaction management device, wherein the index module is deployed in the storage nodes.
[0057] The client is used to receive transaction processing information, which includes first transaction information. The first transaction information is used by the client to determine at least one target storage node, and the at least one target storage node is included in the storage node.
[0058] The client is used to send the first transaction processing request; wherein, the first transaction processing request is used to request the index module to process the first transaction;
[0059] The index module is used to receive the first transaction processing request;
[0060] The index module is also used to process the first transaction based on the first transaction processing request;
[0061] The index module is also used to send a first logical clock to the client; wherein the first logical clock indicates the logical clock at which the index module processes the first transaction, and the first logical clock is used by the client to determine the logical clock vector;
[0062] The transaction management device is used to update the second logical clock based on the logical clock vector, and the second logical clock is used to update the first logical clock of the index module.
[0063] The sixth aspect of this application provides a transaction processing apparatus, comprising:
[0064] The transceiver unit is used to receive transaction processing information, which includes first transaction information. The first transaction information is used by the client to determine at least one target storage node.
[0065] The transceiver unit is used to send a first transaction processing request to at least one target storage node; wherein the first transaction processing request is used to instruct the index module on at least one target storage node to process the first transaction, and the at least one target storage node belongs to multiple storage nodes;
[0066] The transceiver unit is also used to receive at least one first logic clock from an index module on at least one target storage node;
[0067] A processing unit is configured to determine a logical clock vector based on at least one first logical clock; wherein each of the at least one first logical clock indicates the logical clock for the index module on its corresponding target storage node to process the first transaction;
[0068] The transceiver unit is also configured to send a logical clock vector to at least one transaction management device associated with a target storage node; wherein the logical clock vector is used to update the second logical clock of the associated transaction management device.
[0069] In one possible implementation, when the first transaction is a read transaction,
[0070] The transceiver unit is also used to receive the third logical clock of the second transaction; wherein the second transaction is a write transaction.
[0071] The processing unit is also used to determine the clock magnitude of the third logical clock and the first logical clock of the first transaction.
[0072] The transceiver unit is also used to send a second transaction processing request to the target storage node; wherein the index module corresponding to the third logical clock of the second transaction is the same index module as the index module corresponding to the first logical clock of the first transaction, and the second transaction processing request is used to request the index module on the target storage node to reprocess the first transaction.
[0073] In one possible implementation, the transceiver unit is also used to receive a first response, which indicates that the first transaction and the second transaction have a transaction state conflict and have not been executed, and the index module corresponding to the second transaction is the same as the index module corresponding to the first transaction.
[0074] The transceiver unit is also used to send a third transaction processing request to the target storage node, which is used to request the index module on the target storage node to reprocess the first transaction.
[0075] In one possible implementation, the processing unit is further configured to determine the last dimension of the logic clock vector based on at least one first logic clock. If the number of first logic clocks is greater than the dimension of the logic clock vector, the value of the last dimension in the logic clock vector is the synchronization value of the target logic clock. The target logic clock is a first logic clock with multiple dimensions, and the last dimension of the logic clock vector is used to represent the target logic clock.
[0076] In one possible implementation, the synchronization value of the target logic clock is the maximum value in the target logic clock plus one.
[0077] In one possible implementation, before the transceiver unit sends the first transaction request to at least one target storage node, it is further used for:
[0078] Send transaction start information to the associated transaction management device; wherein, the transaction start information includes a first physical clock and a transaction number of the first transaction, and the first physical clock is used to indicate the time when the first transaction starts;
[0079] After sending a logical clock vector to a transaction management device associated with at least one target storage node, the transceiver unit is further configured to: after sending the logical clock vector to a transaction management device associated with at least one target storage node, the client sends transaction commit information to the associated transaction management device; the client receives a second physical clock from the associated transaction management device; wherein the second physical clock is used to indicate the time of the first transaction commit, and the client determines whether the first transaction has timed out based on the first physical clock and the second physical clock.
[0080] A seventh aspect of this application provides a transaction processing apparatus, comprising:
[0081] The transceiver unit is used to receive the first transaction processing request from the client.
[0082] A processing unit is configured to process a first transaction based on a first transaction processing request;
[0083] The transceiver unit is also used to send the first logical clock of the first transaction to the client; wherein the first logical clock indicates the logical clock of the index module processing the first transaction.
[0084] In one possible implementation, when the first transaction is a read transaction, the transceiver unit is also used to receive a clock query request from the client; wherein, the clock query request is used by the client to obtain the third logical clock of the second transaction, which is a write transaction;
[0085] The transceiver unit is also used to send a third logical clock to the client;
[0086] The transceiver unit is also used to receive a second transaction processing request; wherein the second transaction processing request is sent by the client when the third logical clock is greater than the first logical clock;
[0087] The processing unit is also used to reprocess the first transaction based on the second transaction processing request.
[0088] In one possible implementation, the processing unit is further configured to determine whether there is a transaction state conflict between the first transaction and the second transaction, wherein the index module corresponding to the second transaction is the same as the index module corresponding to the first transaction.
[0089] If a transaction state conflict exists, the transceiver unit is also used to send a first response to the client; wherein the first response is used to indicate that a transaction state conflict exists in the first transaction.
[0090] The transceiver unit is also used to receive third-party transaction processing requests from clients;
[0091] The processing unit is also used to reprocess the first transaction based on the third transaction processing request;
[0092] If there is no transaction state conflict, the processing unit is also used to execute the first transaction.
[0093] The eighth aspect of this application provides a transaction processing apparatus, comprising:
[0094] A transceiver unit is configured to receive a logical clock vector from a client; wherein the logical clock vector is determined by the client based on at least one first logical clock of an index module on at least one target storage node, the at least one first logical clock being sent by the index module on the at least one target storage node after processing the first transaction based on a first transaction processing request, the first transaction processing request being sent by the client to the at least one target storage node, and the at least one target storage node belonging to the plurality of storage nodes;
[0095] A processing unit is configured to update a second logical clock based on a logical clock vector; wherein the second logical clock is used to update at least one first logical clock.
[0096] In one possible implementation, before receiving the logical clock vector from the client,
[0097] The transceiver unit is also used to receive transaction start information from the client; wherein, the transaction start information includes a first physical clock and a transaction number of the first transaction, and the first physical clock is used to indicate the time when the first transaction starts;
[0098] After updating the second logical clock based on the logical clock vector, the transceiver unit is also used to send the second physical clock to the client; wherein the second physical clock is used to indicate the time when the first transaction was committed.
[0099] In one possible implementation, the updated second logical clock is the maximum value of each first logical clock and the second logical clock before the update in the logical clock vector plus one.
[0100] In one possible implementation, if the second logical clock is greater than the second threshold, the processing unit is further used to increase the second preset clock value and the second threshold. The second preset clock value is greater than the second threshold. The second preset clock value is used to restore the second logical clock on the transaction management device to the second preset clock value when the transaction management device malfunctions.
[0101] A ninth aspect of this application provides a transaction processing apparatus. The apparatus may include at least one processor, a memory, and a communication interface. The processor is coupled to the memory and the communication interface. The memory is used to store instructions, the processor is used to execute the instructions, and the communication interface is used to communicate with other devices under the control of the processor. When executed by the processor, the instructions cause the processor to perform a method of the first aspect or any possible implementation thereof.
[0102] According to a tenth aspect of this application, a transaction processing apparatus is provided. The apparatus may include at least one processor, a memory, and a communication interface. The processor is coupled to the memory and the communication interface. The memory is used to store instructions, the processor is used to execute the instructions, and the communication interface is used to communicate with other devices under the control of the processor. When executed by the processor, the instructions cause the processor to perform a method of the second aspect or any possible implementation thereof.
[0103] According to the eleventh aspect of this application, a transaction processing apparatus is provided. The apparatus may include at least one processor, a memory, and a communication interface. The processor is coupled to the memory and the communication interface. The memory is used to store instructions, the processor is used to execute the instructions, and the communication interface is used to communicate with other devices under the control of the processor. When executed by the processor, the instructions cause the processor to perform a method of the third aspect or any possible implementation thereof.
[0104] The twelfth aspect of this application provides a computing device cluster including multiple computing devices, each computing device including multiple processors and multiple memories, the multiple memories storing program instructions, and the multiple processors executing the program instructions, causing the computing device cluster to perform the methods provided in the first, second, and third aspects of this application and any possible implementation thereof.
[0105] The thirteenth aspect of this application provides a computer-readable storage medium storing one or more computer-executable instructions, wherein when the computer-executable instructions are executed by a processor, the processor performs a method as described in the first aspect or any possible implementation thereof.
[0106] The fourteenth aspect of this application provides a computer-readable storage medium storing one or more computer-executable instructions, wherein when the computer-executable instructions are executed by a processor, the processor performs a method as described in the second aspect above or any possible implementation thereof.
[0107] The fifteenth aspect of this application provides a computer-readable storage medium storing one or more computer-executable instructions, wherein when the computer-executable instructions are executed by a processor, the processor performs a method as described in the third aspect above or any possible implementation thereof.
[0108] The sixteenth aspect of this application provides a computer program product storing one or more computer-executable instructions, wherein when the computer-executable instructions are executed by a processor, the processor executes the method described in the first aspect or any possible implementation thereof.
[0109] The seventeenth aspect of this application provides a computer program product storing one or more computer-executable instructions, wherein when the computer-executable instructions are executed by a processor, the processor executes the method described in the second aspect or any possible implementation thereof.
[0110] The eighteenth aspect of this application provides a computer program product storing one or more computer-executable instructions, wherein when the computer-executable instructions are executed by a processor, the processor executes the method described in the third aspect or any possible implementation thereof.
[0111] The nineteenth aspect of this application provides a chip system including a processor for supporting a computer device in implementing the functions involved in the first aspect or any possible implementation thereof. In one possible design, the chip system may further include a memory for storing necessary program instructions and data. This chip system may be composed of chips or may include chips and other discrete devices.
[0112] The twentieth aspect of this application provides a chip system including a processor for supporting a computer device in implementing the functions involved in the second aspect or any possible implementation thereof. In one possible design, the chip system may further include a memory for storing necessary program instructions and data. This chip system may be composed of chips or may include chips and other discrete devices.
[0113] The twenty-first aspect of this application provides a chip system including a processor for supporting a computer device in implementing the functions involved in the third aspect or any possible implementation thereof. In one possible design, the chip system may further include a memory for storing necessary program instructions and data. This chip system may be composed of chips or may include chips and other discrete devices.
[0114] The technical effects of the sixth aspect or any possible implementation of the sixth aspect, the fourth aspect, the fifth aspect, the ninth aspect, the twelfth aspect, the thirteenth aspect, the sixteenth aspect, or the nineteenth aspect can be found in the first aspect or the technical effects of different possible implementations of the first aspect, and will not be repeated here.
[0115] The technical effects of the seventh aspect or any possible implementation of the seventh aspect, the fourth aspect, the fifth aspect, the tenth aspect, the twelfth aspect, the fourteenth aspect, the seventeenth aspect, or the twentieth aspect can be found in the technical effects of the second aspect or different possible implementations of the second aspect, and will not be repeated here.
[0116] The technical effects of the eighth aspect or any possible implementation of the eighth aspect, the fourth aspect, the fifth aspect, the eleventh aspect, the twelfth aspect, the fifteenth aspect, the eighteenth aspect, or the twenty-first aspect can be found in the technical effects of the third aspect or different possible implementations of the third aspect, and will not be repeated here. Attached Figure Description
[0117] Figure 1A This is a schematic diagram of the architecture of a distributed system and its client.
[0118] Figure 1B This is a schematic diagram of the architecture of a distributed system provided in an embodiment of this application;
[0119] Figure 1C This is another schematic diagram of the architecture of the distributed system provided in the embodiments of this application;
[0120] Figure 2 This is a schematic diagram of an embodiment of the transaction processing method provided in this application;
[0121] Figure 3 This is a schematic diagram of another embodiment of the transaction processing method provided in this application;
[0122] Figure 4 This is a schematic diagram of another embodiment of the transaction processing method provided in this application;
[0123] Figure 5 This is a schematic diagram of an embodiment of the transaction processing method provided in this application for processing write transactions;
[0124] Figure 6 This is a schematic diagram of an embodiment of the transaction processing method provided in this application for processing read transactions;
[0125] Figure 7 This is a schematic diagram of the transaction processing apparatus provided in an embodiment of this application;
[0126] Figure 8 This is another schematic diagram of the transaction processing apparatus provided in the embodiments of this application;
[0127] Figure 9 This is another schematic diagram of the transaction processing apparatus provided in the embodiments of this application;
[0128] Figure 10This is a schematic diagram of a computing device cluster provided in an embodiment of this application;
[0129] Figure 11 This is another schematic diagram of the computing device cluster provided in the embodiments of this application. Detailed Implementation
[0130] The embodiments of this application are described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. As those skilled in the art will understand, with the development of technology and the emergence of new scenarios, the technical solutions provided by the embodiments of this application are also applicable to similar technical problems.
[0131] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments described herein can be implemented in a sequence other than that illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0132] This application provides a transaction processing method in a distributed system, which improves the accuracy of sorting results when sorting different transactions in a distributed storage system. This application also provides corresponding apparatus, computer-readable storage media, computer program products, and distributed systems. These will be described in detail below.
[0133] For ease of understanding, the technical terms involved in the embodiments of this application are briefly introduced below:
[0134] (1) Transaction: A transaction is a sequence of database operations, consisting of a batch of operations executed between the start (begin) and the end (commit) of the transaction. These operations either all succeed or all fail; no intermediate states are allowed, and it is an indivisible unit of work. Specifically, transactions need to satisfy the semantics of atomicity, consistency, isolation, and durability, also known as ACID semantics.
[0135] (2) Atomicity: Atomicity means that in the same business process, a transaction guarantees that modifications to multiple data will either succeed at the same time or be rolled back at the same time.
[0136] (3) Consistency: Consistency means that the database must be in the correct state before and after a transaction is executed, satisfying the integrity constraints.
[0137] (4) Isolation: Isolation means that when multiple transactions are executed concurrently, the operations of one transaction are hidden from other transactions until the transaction is committed. This can prevent interference and data conflicts between concurrent transactions.
[0138] (5) Durability: Durability means that a transaction should ensure that all successfully committed data modifications are correctly persisted, and that no data is lost even if the system crashes.
[0139] (6) Transaction Commit: Transaction commit refers to permanently saving all update operations on the database within a transaction to the physical database on disk, making these changes part of the database, and marking the normal end of the transaction. Once committed, transaction operations cannot be rolled back.
[0140] (7) Write transactions: These are transactions that modify data in the database. These operations include inserting new data, updating existing data, and deleting existing data.
[0141] (8) Read transaction: refers to a transaction that reads data from the database without modifying it. Read transactions are typically used for querying, retrieving, and analyzing data.
[0142] (9) Transaction Status: Transaction status refers to the stage or condition a transaction is in during execution. It reflects the current progress and result of the transaction and is an important basis for the database management system to perform transaction control and concurrent processing. Database transaction status mainly includes active status, partially committed status, failed status, aborted status, rollback status, completed status, and committed status.
[0143] (10) Write transaction processing request: refers to writing the structured query language (SQL) corresponding to the transaction, which is used to request the corresponding data to be written to the distributed storage system.
[0144] (11) Read transaction processing request: refers to the SQL corresponding to the read transaction, which is used to request the query of the corresponding data in the distributed storage system.
[0145] (12) In the embodiments of this application, "send" and "receive" indicate the direction of signal transmission. For example, "send information to XX" can be understood as the destination of the information being XX, which may include sending directly through the air interface or sending indirectly through the air interface by other units or modules. "Receive information from YY" can be understood as the source of the information being YY, which may include receiving directly from YY through the air interface or receiving indirectly from YY through the air interface by other units or modules. "Send" can also be understood as the "output" of the chip interface, and "receive" can also be understood as the "input" of the chip interface.
[0146] (13) The terms "system" and "network" in the embodiments of this application can be used interchangeably. "Multiple" refers to two or more. "And / or" describes the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist simultaneously, or B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the related objects before and after are in an "or" relationship. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, "at least one of A, B and C" includes A, B, C, AB, AC, BC or ABC. And, unless otherwise specified, the ordinal numbers such as "first" and "second" mentioned in the embodiments of this application are used to distinguish multiple objects and are not used to limit the order, sequence, priority or importance of multiple objects.
[0147] (14) In the embodiments of this application, "instruction" may include direct instruction and indirect instruction, as well as explicit instruction and implicit instruction. The information indicated by a certain piece of information (as described below, the instruction information) is called the information to be instructed. In the specific implementation process, there are many ways to indicate the information to be instructed, such as, but not limited to, directly indicating the information to be instructed, such as the information to be instructed itself or its index. It can also indirectly indicate the information to be instructed by indicating other information, where there is an association between the other information and the information to be instructed; or it can only indicate a part of the information to be instructed, while the other parts of the information to be instructed are known or pre-agreed upon. For example, the instruction can be implemented by using a pre-agreed (e.g., protocol predefined or pre-configured) arrangement order of various information, thereby reducing the instruction overhead to a certain extent. This application does not limit the specific method of instruction. It is understood that for the sender of the instruction information, the instruction information can be used to indicate the information to be instructed, and for the receiver of the instruction information, the instruction information can be used to determine the information to be instructed.
[0148] In this application, unless otherwise specified, the same or similar parts between the various embodiments can be referred to each other. In the various embodiments of this application, and the various methods / designs / implementations within each embodiment, unless otherwise specified or logically conflicting, the terminology and / or descriptions between different embodiments and between the various methods / designs / implementations within each embodiment are consistent and can be mutually referenced. The technical features in different embodiments and the various methods / designs / implementations within each embodiment can be combined to form new embodiments, methods, or implementations based on their inherent logical relationships. The following descriptions of the embodiments of this application do not constitute a limitation on the scope of protection of this application.
[0149] The transaction processing method provided in this application can be applied to distributed systems. Figure 1A This illustrates a typical logical architecture of a distributed system, based on Figure 1A The distributed system 100 includes a storage node 120 and a transaction management device 130.
[0150] Storage node 120 is a key component of the distributed system. Each storage node provides a pre-allocated memory area for the cluster, and pre-allocated memory areas on multiple nodes can be combined to form a larger memory space. Its main responsibilities include storing data, handling data read / write requests from applications or other nodes, and performing the actual data storage and retrieval operations.
[0151] The storage node 120 also includes several index modules 110. These index modules help users quickly locate the corresponding stored data in the distributed system, reducing the time required for data retrieval. Each index module associates an index value with the stored data in the storage node, thereby dividing the storage node into multiple storage areas.
[0152] The transaction management device 130 is a module used to manage transactions in a distributed system. It can record the transaction status of transactions occurring in multiple storage nodes, including information such as the start time and end time of the transactions.
[0153] After receiving a user's transaction processing request, client 200 communicates with the distributed system via the network, so that the corresponding target storage node can process the read and write transactions.
[0154] Those skilled in the art can understand that a distributed system may include more than Figure 1A The components shown are fewer or more components, or include those with Figure 1A The components shown are different components. Figure 1A Only components more relevant to the implementation disclosed in the embodiments of the present invention are shown.
[0155] The transaction processing method provided in this application can also be applied to distributed transaction storage systems. A distributed transaction storage system is a system that performs transaction processing across multiple computer systems or data storage systems. It ensures that operations across multiple distributed components or services either all succeed or all fail, thus maintaining data consistency and integrity. Distributed storage is a storage method that distributes data across multiple nodes. Compared to traditional centralized storage, distributed storage distributes data across multiple nodes, each of which can independently store and access data. This distributed storage method can provide higher reliability, scalability, and performance.
[0156] The distributed transaction storage system provided in this application can consist of three modules: storage nodes, transaction management devices, and clients.
[0157] The storage nodes are used to store database data, the transaction management device is used to manage transaction status information, and the client is used to receive user read and write requests and process read and write transactions on the corresponding storage nodes.
[0158] Optionally, the storage nodes in a distributed transaction storage system may also include multiple index modules, each index module including multiple indexes, and each index is used to record the correspondence between the actual stored data and the index value.
[0159] A distributed transaction storage system can contain multiple transaction management devices, each managing a specific number of storage nodes. When a client's transaction processing request involves multiple storage nodes, the client needs to send a notification to the corresponding transaction management device to request the transaction.
[0160] like Figure 1B As shown, transaction management device 1 is used to manage transactions processed in storage node 1, storage node 2 and storage node 3, and transaction management device 2 is used to manage transactions processed in storage node 4, storage node 5 and storage node 6.
[0161] When client 1 requests a read / write transaction involving storage nodes 1 and 3, client 1 needs to send a transaction request notification to transaction management device 1 to inform it that the transaction has begun. After the transaction is completed, the client sends a transaction commit notification to transaction management device 1, which then records the transaction status of the transactions in storage nodes 1 and 3.
[0162] When client 2 requests a read / write transaction involving storage nodes 3 and 6, client 1 needs to send a transaction request notification to transaction management device 1 and transaction management device 2 respectively, to notify them that the transaction has begun. After the transaction is completed, the client sends a transaction commit notification to transaction management device 1 and transaction management device 2. Transaction management device 1 records the transaction status of the transaction in storage node 3, and transaction management device 2 records the transaction status of the transaction in storage node 6.
[0163] Alternatively, in a distributed transaction storage system, all storage nodes can be managed by a single transaction management device. The number of transaction management devices and the number of storage nodes are not limited here.
[0164] like Figure 1C As shown, the transaction management device 1 is used to manage the transactions processed in storage nodes 1, 2, 3, 4, 5 and 6.
[0165] When client 1 requests a transaction involving reading and writing data involving storage nodes 1 and 3, and client 2 requests a transaction involving reading and writing data involving storage nodes 3 and 6, both client 1 and client 2 send a request for transaction and a transaction submission notification to transaction management device 1, respectively.
[0166] The distributed system provided in this application can also be a key-value (KV) storage system. A KV storage system is a non-relational database that stores data using key-value pairs. In a KV storage system, each key uniquely identifies a record, and the corresponding value stores the information of that record.
[0167] Based on the aforementioned distributed system, the transaction processing method provided in this application embodiment can be found in [reference needed]. Figure 2 ,like Figure 2 As shown, the method includes:
[0168] S201. The client receives transaction processing information.
[0169] In this application, the transaction processing information may include first transaction information, which is used by the client to determine at least one target storage node.
[0170] In this application, transaction processing information can be directly input by the user to the client, or it can be converted by the program based on user-inputted instructions and then input to the client. The transaction processing information includes the transaction type, such as read transaction requests and write transaction requests. A read transaction request instructs the reading of specified data from the target storage node, while a write transaction request instructs the writing of specified data to the target storage node. The transaction processing information also includes first transaction information, which includes the target storage node involved in this transaction.
[0171] S202. The client sends a first transaction request to the target storage node. Correspondingly, the target storage node receives the first transaction request.
[0172] In this application, the first transaction processing request is used to instruct the index module on at least one target storage node to process the first transaction, and the at least one target storage node belongs to multiple storage nodes.
[0173] In this application, the first transaction processing request can be a read transaction request to read data or a write transaction request to write data. The number of target storage nodes involved in the first transaction processing request can be one or more. When there are multiple target storage nodes, the client sends the first transaction processing request to each target storage node separately.
[0174] In this application, the target storage node may also include multiple index modules. The index modules are associated with the data content in the storage node through the index value, and are used to record the position of each piece of data in the storage node.
[0175] Optionally, the first transaction processing request may further include the first logical clock of other target storage nodes involved in the transaction and the second logical clock of the transaction management device. When a target storage node receives the first logical clock from other target storage nodes and / or the second logical clock from the transaction management device, it sets the logical clock value of its local first logical clock to the maximum value therein.
[0176] By synchronizing the aforementioned logical clock values, the logical clocks of all target storage nodes involved in this transaction are of the same logical clock value, which is the maximum value stored in all storage nodes and the transaction management device. This improves the accuracy of transaction sorting while achieving time synchronization between different storage nodes.
[0177] S203. At least one index module on the target storage node sends a first logical clock to the client. Correspondingly, the client receives at least one first logical clock.
[0178] In this application, after completing the transaction corresponding to the first transaction processing request, the index module on the target storage node can send a first logical clock indicating transaction completion to the client via transaction completion confirmation information. After receiving the first logical clocks sent by the index modules on all target storage nodes corresponding to the first transaction processing request, the client generates a logical clock vector based on at least one first logical clock.
[0179] In this way, the index module on the target storage node sends the logical clock value to the client during transaction processing, reducing the waiting latency of querying the logical clock when the transaction is committed, and improving the transaction processing efficiency in the distributed system.
[0180] In one possible embodiment, the number of dimensions in the logical clock vector can be determined by the client based on the number of first logical clocks, or the client can pre-set a preset value.
[0181] In this application, the client determines the last dimension of the logical clock vector based on at least one first logical clock. If the number of first logical clocks is greater than the dimension of the logical clock vector, the value of the last dimension in the logical clock vector is the synchronization value of the target logical clock. The target logical clock is a first logical clock with multiple dimensions, and the last dimension of the logical clock vector is used to represent the target logical clock.
[0182] In this application, the logical clock vector is generated by the client based on the first logical clock of the index module on each target storage node. The dimension of the logical clock vector can remain unchanged. When the number of index modules on the target storage nodes involved in the first transaction, i.e., the number of first logical clocks, is greater than the dimension of the logical clock vector, the client will synchronize the first logical clocks of the index modules on the excess target storage nodes to the same logical clock value, and store this logical clock value in the last dimension of the logical clock vector as the logical clock value of the first logical clock of the index modules on the excess target storage nodes.
[0183] The synchronization value of the target logical clock is the maximum value among the target logical clocks plus one. The synchronization value of the target logical clock can be requested by the client from the transaction management device, which then queries and synchronizes the first logical clocks of the multiple dimensions, so that the logical clock values of the first logical clocks of the multiple dimensions are the same.
[0184] By using the above method, the client reduces the storage space occupied by the logical clock vector composed of all the first logical clocks by synchronizing the first logical clocks of the multiple logical clock vector dimensions. This solves the problem of excessive storage space occupied by the logical clock vector due to the large number of index modules involved in the transaction processing, and improves the transaction processing efficiency of the distributed system.
[0185] S204. The client sends a logical clock vector to at least one transaction management device associated with the target storage node. Correspondingly, at least one transaction management device associated with the target storage node receives the logical clock vector.
[0186] In this application, the client sends the generated logical clock vector to the transaction management device through a transaction commit request.
[0187] The transaction commit request may also include the index module numbering information of multiple target storage nodes corresponding to the logical clock vector and the transaction number of this transaction, which are sent to the transaction management device for the transaction management device to store relevant information of this transaction.
[0188] In this application, after the transaction management device receives the logical clock vector, the transaction management device compares the logical clock value of each first logical clock in the logical clock vector with the logical clock value of the second logical clock set locally, obtains the maximum value, and updates the logical clock value of the second logical clock set locally to the maximum value plus one.
[0189] S205. The transaction management device sends a second logical clock to the client. Correspondingly, the client receives the second logical clock.
[0190] In this application, the transaction management device can send a second logical clock to the client via a transaction commit confirmation message.
[0191] The client sends the second logical clock to the index module on the target storage node corresponding to the first transaction processing request, and updates the logical clock value of the first logical clock in each target storage node to the logical clock value of the second logical clock.
[0192] In this application, the transaction management device is further configured to send time information determining the transaction status to the target storage node. Upon receiving the time information determining the transaction status, the index module on the target storage node evicts the key-value pairs corresponding to the relevant transactions before the time point in the time information, thereby releasing the corresponding storage space in the index module of the target storage node.
[0193] As described above, in the solution provided by this application embodiment, the client collects the logical clocks in the index modules of the storage nodes involved in the transaction and generates a logical clock vector during the transaction processing. Then, the transaction management device synchronizes the logical clock values of each storage node, which improves the time synchronization in the distributed system. This eliminates the need to wait for the delay caused by the generation of transaction logical clocks between different transactions when multiple transactions need to be processed in the distributed system, thereby improving the read and write performance of transactions in the distributed system and enhancing the reliability and stability of the distributed system.
[0194] In one possible embodiment, if the first logical clock is greater than the first threshold, the index module on the target storage node will increase the first preset clock value and the first threshold. The first preset clock value is greater than the first threshold. The first preset clock value is used to restore the first logical clock of the index module on the target storage node to the first preset clock value when the index module on the target storage node fails.
[0195] In this application, a first preset clock value is used to set the logical clock value of the first logical clock of the index module on the target storage node to monotonically increasing. When the index module on the target storage node fails, the index module on the target storage node can restore the first logical clock to the first preset clock value by reading the first preset clock value. The magnitude of the first preset clock value is greater than the first logical clock of the transactions previously processed in the index module on the target storage node, thereby ensuring that the value of the first logical clock of subsequent transactions processed in the index module on the target storage node is greater than the first logical clock of previously processed transactions.
[0196] For example, during initialization, the first preset clock value of the index module on the target storage node is set to 1000, and the first threshold is 800. The first logical clock of the index module on the target storage node is set starting from 0 and incremented as messages are transmitted. When the first logical clock increments to the first threshold of 800, the first preset clock value is increased to 2000, and the first threshold is increased to 1600, thus achieving the early persistence of the first logical clock.
[0197] When the index module on the target storage node fails, the first logical clock in the index module on the target storage node becomes 0 after restarting. At this time, the first logical clock of the index module on the target storage node can be restored to the first preset clock value, i.e., 1000. This ensures that the restored logical clock value is greater than the previously set logical clock value, thus maintaining the monotonically increasing nature of the first logical clock.
[0198] In this possible embodiment, by persistently setting the first logical clock of the index module on the target storage node, the first logical clock of the index module on the target storage node in the distributed system is monotonically increasing, thereby improving the reliability of the order between different transactions processed by the index module on the target storage node.
[0199] In one possible embodiment, the index module on the target storage node will also determine whether there are conflicts between transactions before executing the first transaction.
[0200] Transaction conflicts refer to conflicts arising between multiple transactions performing read and write operations on the same data under concurrent access conditions. These conflicts can lead to data inconsistencies and operational errors. Types of conflicts can include:
[0201] 1. Write-write conflict: A write-write conflict occurs when two or more transactions attempt to modify the same data item at approximately the same time. Due to network latency, differences in node processing speed, or imperfections in concurrency control mechanisms, these write operations may interfere with each other, leading to data inconsistency.
[0202] 2. Read-write conflict: A read-write conflict occurs when one transaction is reading a data item while another transaction attempts to modify that same data item. In this situation, the read transaction may retrieve data that the write transaction has not yet committed, or it may retrieve data that has already been changed after the write transaction has committed, resulting in inconsistent results from the two reads.
[0203] 3. Write-read conflict: This occurs when a write transaction modifies a data item before a read transaction is aware of these changes. If the system lacks a proper synchronization mechanism, the read transaction may read an older version of the data.
[0204] In this application, the index module on the target storage node can determine whether there is a conflict between transactions by the state of the transaction or the time interval between different transaction states.
[0205] The transaction state of a write transaction can include the transaction start state, transaction commit state, and transaction rollback state, while the transaction state of a read transaction can include the transaction start state and transaction end state. Transaction state conflicts can occur when two transactions of the same type have the same transaction state within the same time period, or when two transactions of different types have conflicting transaction states within the same time interval. Specifically, the two transactions must have the same key, meaning that some of the storage nodes involved in the two transactions are the same.
[0206] If the index module on the target storage node determines that there is a conflict between transactions, the index module on the target storage node will send a first response to the client. The first response is used to indicate that there is a conflict between the first transaction and the second transaction. Based on the first response, the client resends a third transaction processing request to the target storage node. The third transaction processing request is used to request the index module on the target storage node to reprocess the first transaction.
[0207] In this application, the index module on the target storage node can obtain the status of other transactions by initiating a transaction query request to the transaction management device, or by obtaining the status of other transactions from the locally cached transaction status information.
[0208] In this possible embodiment, the index module on the target storage node determines whether there is a conflict between two transactions based on the first logical clock of different transactions in different transaction states, and the client re-initiates the transaction processing request when a conflict occurs, thereby improving the consistency of data in the index module on the storage node.
[0209] In one possible embodiment, when the first transaction is a read transaction, after the client receives at least one first logical clock from the index module on at least one target storage node, the client will also determine the readability of the first transaction. This process can be found in [reference needed]. Figure 3 To understand, such as Figure 3 As shown, it also includes the following steps:
[0210] S301. The client sends a clock query request to the at least one target storage node.
[0211] In this application, the clock query request is used by the client to obtain the third logical clock of the second transaction, which is a write transaction corresponding to the first transaction. The storage nodes corresponding to the second transaction and the first transaction are the same storage node.
[0212] S302. The target storage node sends the third logical clock of the second transaction to the client.
[0213] In this application, the third logical clock of the second transaction can be obtained from the local cache of the target storage node, or the target storage node can initiate a query request to the transaction management device, and the transaction management device can send the third logical clock of the second transaction involving the target storage node to the target storage node.
[0214] S303. The client determines the readability of the first transaction.
[0215] In this application, the client can determine the readability of the first transaction by comparing the first logical clock of the first transaction with the third logical clock of the second transaction.
[0216] The client compares the third logical clock of the second transaction with the first logical clock of the first transaction. If the third logical clock of the second transaction is greater than the first logical clock of the first transaction, the client confirms that the start time of the second transaction is later than the start time of the first transaction, and therefore the first transaction is unreadable. The index module corresponding to the third logical clock of the second transaction is the same as the index module corresponding to the first logical clock of the first transaction.
[0217] If the first transaction is readable, proceed to step S304a; if the first transaction is unreadable, proceed to step S304b.
[0218] S304a. The client sends a logical clock vector to the transaction management device.
[0219] When the client confirms that the first transaction is readable, it sends the first logical clock of the index module on each target storage node to the transaction management device.
[0220] Step S304a is similar to step S203 above, and will not be described in detail here.
[0221] S304b. The client sends a second transaction request to the target storage node.
[0222] In this application, when the client confirms that the first transaction is unreadable, it will also send a second transaction processing request to the target storage node. The second transaction processing request is used to request the index module on the target storage node to reprocess the first transaction after the third logical clock of the second transaction.
[0223] In this way, when the first transaction is a read transaction, the client judges the readability of the first transaction based on the third logical clock of the second transaction reported by the index module on the target storage node, and performs rereading processing for read transactions that may have errors, thereby improving the reliability and stability of the distributed system.
[0224] In one possible embodiment, before the client sends the first transaction processing request to the target storage node, it also sends transaction start information for the first transaction to the transaction management device. This process can be found in [reference needed]. Figure 4 To understand, such as Figure 4 As shown, it also includes the following steps:
[0225] S401. The client sends a transaction start message to the transaction management device.
[0226] The transaction start information is used to notify the transaction management device that the first transaction has begun. The transaction start information may include a first physical clock and the transaction number of the first transaction; the first physical clock indicates the time when the first transaction began.
[0227] S402. The client sends the first transaction request to the target storage node.
[0228] Step S402 is similar to step S201 in the above embodiment, and will not be described in detail here.
[0229] S403. The target storage node processes the first transaction.
[0230] In this application, the target storage node executes the first transaction after determining that there is no transaction conflict in the first transaction.
[0231] S404. The target storage node sends a transaction completion message to the client.
[0232] In this application, the transaction completion information may include a first logical clock of the target storage node, which is used to indicate the logical time when the first transaction was completed.
[0233] S405. The client sends a transaction commit message to the transaction management device.
[0234] In this application, the transaction commit information includes a list of target storage nodes for this transaction, the index module number of the index module on the target storage node, and the first logical clock corresponding to the index module on each storage node.
[0235] Upon receiving the transaction commit information, the transaction management device generates a second physical clock. The second physical clock indicates the time of the first transaction commit, while both the first and second physical clocks are used by the client to determine whether the first transaction has timed out.
[0236] In this application, the client can determine whether the first transaction has timed out based on a set time threshold or a preset time point. For example, the first transaction is considered to have timed out when the second physical clock of the first transaction exceeds the preset time point, or the first transaction is considered to have timed out when the time interval between the second physical clock and the first physical clock is reached.
[0237] When the first transaction times out, the client can automatically roll back the transaction to avoid data being in an inconsistent state, thus improving the reliability and stability of the distributed system.
[0238] In this possible implementation, the physical clock and logical clock in the distributed system are set separately and are two independent parts. The physical clock is used to determine whether a transaction has timed out. Therefore, when the physical clock malfunctions, it will not cause the logical clock to become inaccurate in transactions. This reduces the dependence of the distributed system on the physical clock when sorting different transactions; that is, the physical clock can have a larger margin of error, reducing the need for physical clock precision and improving the performance of transaction processing in the distributed system.
[0239] In one possible embodiment, if the second logical clock is greater than the second threshold, the transaction management device increases the second preset clock value and the second threshold. The second preset clock value is greater than the second threshold. The second preset clock value is used to restore the second logical clock on the transaction management device to the second preset clock value when the transaction management device malfunctions.
[0240] In this application, the second preset clock value is used to set the logical clock value of the second logical clock in the transaction management device to monotonically increasing. When the second storage node fails, the second storage node can restore the second logical clock to the second preset clock value by reading the second preset clock value. The magnitude of the second preset clock value is greater than the second logical clock of a transaction previously recorded in the transaction management device, thereby making the value of the second logical clock of subsequent transactions recorded in the transaction management device greater than the second logical clock of previously recorded transactions.
[0241] For example, during initialization, the second preset clock value of the transaction management device is set to 1000, and the second threshold is set to 800. The second logical clock of the transaction management device is set starting from 0 and incremented as messages are transmitted. When the second logical clock increments to the second threshold of 800, the second preset clock value is increased to 2000, and the second threshold is increased to 1600, thus realizing the advance persistence of the second logical clock.
[0242] When the transaction management device malfunctions, the second logical clock in the transaction management device becomes 0 after restarting. At this time, the second logical clock of the transaction management device can be restored to the second preset clock value, i.e., 1000. This ensures that the restored logical clock value is greater than the previously set logical clock value, thus maintaining the monotonically increasing nature of the second logical clock.
[0243] In this possible embodiment, by persistently setting the second logical clock in the transaction management device, the second logical clock in the transaction management device in the distributed system is monotonically increasing, thereby improving the reliability of the order between different transactions recorded by the transaction management device.
[0244] The following sections use write transactions and read transactions as examples to illustrate the transaction processing methods provided in the above embodiments. This process can be found in [reference needed]. Figure 5 and Figure 6 To understand, such as Figure 5 As shown, writing a transaction includes the following steps:
[0245] S501. Client 1 sends a write transaction start notification to the transaction management device 1 that manages storage node 1 and storage node 2.
[0246] The write transaction start notification may include the client ID, the first physical clock, and the transaction ID.
[0247] S502. Client 1 simultaneously sends write transaction processing requests to the index module on storage node 1 and the index module on storage node 2.
[0248] S503. The index modules on storage node 1 and storage node 2 respectively determine whether there is a transaction conflict in the write transaction.
[0249] If there are no transaction conflicts in the write transaction, then proceed to S504.
[0250] S504. The index modules on storage node 1 and storage node 2 respectively execute write transactions.
[0251] S505. The index modules on storage node 1 and storage node 2 respectively send confirmation information of transaction completion to client 1.
[0252] The confirmation information for the completion of the transaction includes the first logical clock of the index module on storage node 1 and the index module on storage node 2, and the data written in this transaction.
[0253] S506. Client 1 sends a write transaction commit notification to transaction management device 1.
[0254] The write transaction commit notification includes a logical clock vector, a list of storage nodes corresponding to the logical clock vector, and a transaction ID.
[0255] The logical clock vector is generated by client 1 based on the first logical clock of the index module on storage node 1 and the first logical clock of the index module on storage node 2.
[0256] S507. Transaction management device 1 updates the local second logical clock according to the logical clock vector.
[0257] S508. Transaction management device 1 generates transaction commit confirmation information and sends it to client 1.
[0258] The transaction commit confirmation information includes the updated second logical clock and second physical clock.
[0259] S509. Client 1 sends the second logic clock to the index module on storage node 1 and the index module on storage node 2 respectively.
[0260] S510. The index module on storage node 1 and the index module on storage node 2 update the local first logical clock based on the second logical clock.
[0261] like Figure 6 As shown, reading a transaction includes the following steps:
[0262] S601. Client 1 sends a read transaction start notification to the transaction management device 1 that manages storage node 1 and storage node 2.
[0263] The read transaction start notification may include the client ID, the first physical clock, and the transaction ID.
[0264] S602. Client 1 simultaneously sends read transaction processing requests to the index module on storage node 1 and the index module on storage node 2.
[0265] S603. The index modules on storage node 1 and storage node 2 respectively determine whether there is a transaction conflict in the read transaction.
[0266] If there are no transaction conflicts in the read transaction, proceed to S604.
[0267] S604. The index modules on storage node 1 and storage node 2 execute read transactions respectively.
[0268] S605. The index modules on storage node 1 and storage node 2 respectively send confirmation information of transaction completion to client 1.
[0269] The confirmation information for the completion of the transaction includes the first logical clock of the index module on storage node 1 and the index module on storage node 2, and the data read in this transaction.
[0270] S606. Client 1 determines whether a read transaction is readable.
[0271] When determining the readability of a read transaction, client 1 can send a transaction status query request to transaction management device 1 to obtain the transaction status or logical clock of the write transaction involving the index module on storage node 1 and the index module on storage node 2. Alternatively, client 1 can directly send a transaction status query request to the index module on storage node 1 and the index module on storage node 2 to obtain the transaction status or logical clock of the write transaction in the index module on storage node 1 and the index module on storage node 2.
[0272] If the read transaction is readable, proceed to S607.
[0273] S607. Client 1 sends a read transaction commit notification to transaction management device 1.
[0274] The read transaction commit notification includes the logical clock vector, the list of storage nodes corresponding to the logical clock vector, and the transaction ID.
[0275] The logical clock vector is generated by client 1 based on the first logical clock of the index module on storage node 1 and the first logical clock of the index module on storage node 2.
[0276] S608. Transaction management device 1 updates the local second logical clock according to the logical clock vector.
[0277] S609. Transaction management device 1 generates transaction commit confirmation information and sends it to client 1.
[0278] The transaction commit confirmation information includes the updated second logical clock and second physical clock.
[0279] S610. Client 1 sends the second logic clock to the index module on storage node 1 and the index module on storage node 2 respectively.
[0280] S611. The index module on storage node 1 and the index module on storage node 2 update the local first logical clock based on the second logical clock.
[0281] The above embodiments describe transaction processing methods in distributed systems. The transaction processing apparatus provided in this application is described below with reference to the accompanying drawings. Examples of the basic hardware structures involved in the embodiments of this application are given below.
[0282] This application also provides a computing device 900. For example... Figure 7 As shown, the computing device 900 includes a memory 901, a bus 902, a processor 903, and a communication interface 904. The processor 903, memory 901, and communication interface 904 communicate with each other via the bus 902. The computing device 900 can be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in the computing device 900.
[0283] The 902 bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 7 The bus 902 may be represented by a single line, but this does not mean that there is only one bus or one type of bus. The bus 902 may include a path for transmitting information between various components of the computing device 900 (e.g., memory 901, processor 903, communication interface 904).
[0284] The processor 903 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0285] The memory 901 may include volatile memory, such as random access memory (RAM). The processor 903 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0286] The memory 901 stores executable program code, which the processor 903 executes to implement the functions of the client 801, thereby implementing the transaction processing method. In other words, the memory 901 stores instructions for executing the transaction processing method.
[0287] The communication interface 904 uses transceiver modules such as, but not limited to, network interface cards and transceivers to enable communication between the computing device 900 and other devices or communication networks.
[0288] This application also provides a computing device 900. For example... Figure 8 As shown, the computing device 900 includes a memory 901, a bus 902, a processor 903, and a communication interface 904. The processor 903, memory 901, and communication interface 904 communicate with each other via the bus 902. The computing device 900 can be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in the computing device 900.
[0289] The 902 bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 8 The bus 902 may be represented by a single line, but this does not mean that there is only one bus or one type of bus. The bus 902 may include a path for transmitting information between various components of the computing device 900 (e.g., memory 901, processor 903, communication interface 904).
[0290] The processor 903 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0291] The memory 901 may include volatile memory, such as random access memory (RAM). The processor 903 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0292] The memory 901 stores executable program code, which the processor 903 executes to implement the functions of the index module 802, thereby implementing the transaction processing method. In other words, the memory 901 stores instructions for executing the transaction processing method.
[0293] The communication interface 904 uses transceiver modules such as, but not limited to, network interface cards and transceivers to enable communication between the computing device 900 and other devices or communication networks.
[0294] This application also provides a computing device 900. For example... Figure 9 As shown, the computing device 900 includes a memory 901, a bus 902, a processor 903, and a communication interface 904. The processor 903, memory 901, and communication interface 904 communicate with each other via the bus 902. The computing device 900 can be a server or a terminal device. It should be understood that this application does not limit the number of processors and memories in the computing device 900.
[0295] The 902 bus can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of representation, Figure 9The bus 902 may be represented by a single line, but this does not mean that there is only one bus or one type of bus. The bus 902 may include a path for transmitting information between various components of the computing device 900 (e.g., memory 901, processor 903, communication interface 904).
[0296] The processor 903 may include any one or more processors such as a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0297] The memory 901 may include volatile memory, such as random access memory (RAM). The processor 903 may also include non-volatile memory, such as read-only memory (ROM), flash memory, hard disk drive (HDD), or solid state drive (SSD).
[0298] The memory 901 stores executable program code, and the processor 903 executes the executable program code to implement the functions of the transaction management device 803, thereby implementing the transaction processing method. That is, the memory 901 stores instructions for executing the transaction processing method.
[0299] The communication interface 904 uses transceiver modules such as, but not limited to, network interface cards and transceivers to enable communication between the computing device 900 and other devices or communication networks.
[0300] This application also provides a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smartphone.
[0301] like Figure 10 As shown, the computing device cluster includes at least one computing device 900. The memory 901 of one or more computing devices 900 in the computing device cluster may store the same instructions for executing transaction processing methods.
[0302] In some possible implementations, the memory 901 of one or more computing devices 900 in the computing device cluster may also store partial instructions for executing transaction processing methods. In other words, a combination of one or more computing devices 900 can jointly execute instructions for executing transaction processing methods.
[0303] It should be noted that the memory 901 in different computing devices 900 within the computing device cluster can store different instructions, each used to execute a portion of the functions of the transaction processing device. That is, the instructions stored in the memory 901 of different computing devices 900 can implement the functions of one or more modules among the client 801, the index module 802, and the transaction management device 803.
[0304] In some possible implementations, one or more computing devices in a computing device cluster can be connected via a network. This network can be a wide area network (WAN) or a local area network (LAN), etc. Figure 11 One possible implementation is shown. For example... Figure 11 As shown, the three computing devices 900A, 900B, and 900C are connected via a network. Specifically, they are connected to the network through communication interfaces in each computing device. In this possible implementation, the memory 901 in computing device 900A stores instructions for executing the functions of client 801. Meanwhile, the memory 901 in computing device 900B stores instructions for executing index module 802, and the memory 901 in computing device 900C stores instructions for executing the functions of transaction management device 803.
[0305] It should be understood that Figure 11 The functions of the computing device 900A shown can also be performed by multiple computing devices 900. Similarly, the functions of the computing device 900B can also be performed by multiple computing devices 900.
[0306] This application also provides another computing device cluster. The connection relationships between the computing devices in this computing device cluster can be similarly referred to... Figure 10 and Figure 11 The connection method of the computing device cluster. The difference is that the memory 901 of one or more computing devices 900 in the computing device cluster can store the same instructions for executing transaction processing methods.
[0307] In some possible implementations, the memory 901 of one or more computing devices 900 in the computing device cluster may also store partial instructions for executing transaction processing methods. In other words, a combination of one or more computing devices 900 can jointly execute instructions for executing transaction processing methods.
[0308] It should be noted that the memory 901 in different computing devices 900 within the computing device cluster can store different instructions for executing some functions of the transaction processing system. That is, the instructions stored in the memory 901 of different computing devices 900 can implement the functions of one or more of the client, target storage node, and transaction management device.
[0309] In another embodiment of this application, a computer-readable storage medium is also provided, which stores computer-executable instructions. When at least one processor of the device executes the computer-executable instructions, the device performs the aforementioned... Figures 2 to 6 The transaction processing method described in some embodiments.
[0310] In another embodiment of this application, a computer program product is also provided, comprising computer-executable instructions stored in a computer-readable storage medium; at least one processor of the device can read the computer-executable instructions from the computer-readable storage medium, and the at least one processor executes the computer-executable instructions to cause the device to perform the above-described actions. Figures 2 to 6 The transaction processing method described in some embodiments.
[0311] In another embodiment of this application, a chip system is also provided, the chip system including a processor for supporting a transaction processing device to implement the above. Figures 2 to 6 The transaction processing method described in some embodiments. In one possible design, the chip system may further include a memory for storing program instructions and data necessary for the transaction processing apparatus. This chip system may be composed of chips or may include chips and other discrete components.
[0312] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of this application.
[0313] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0314] In the embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.
[0315] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0316] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium.
[0317] Based on this understanding, the technical solutions of the embodiments of this application, or the parts that contribute to the prior art, or parts of the technical solutions, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A transaction processing method, characterized in that, The method is applied to a client that communicates with a distributed system via a network. The distributed system includes multiple storage nodes, each of which has an index module deployed on it. The distributed system also includes at least one transaction management device, each of which is associated with at least one storage node. The method includes: The client receives transaction processing information, which includes first transaction information, and the first transaction information is used by the client to determine at least one target storage node. The client sends a first transaction processing request to the at least one target storage node; wherein the first transaction processing request is used to instruct the index module on the at least one target storage node to process a first transaction, and the at least one target storage node belongs to the plurality of storage nodes; The client receives at least one first logical clock from the index module on the at least one target storage node; The client determines a logical clock vector based on the at least one first logical clock; wherein each of the at least one first logical clocks indicates the logical clock at which the index module on its corresponding target storage node processes the first transaction; The client sends the logical clock vector to the transaction management device associated with the at least one target storage node; wherein the logical clock vector is used to update the second logical clock of the associated transaction management device.
2. The method according to claim 1, characterized in that, When the first transaction is a read transaction, after the client receives at least one first logical clock from the index module on the at least one target storage node, the method further includes: The client sends a clock query request to the at least one target storage node; wherein, the clock query request is used by the client to obtain the third logical clock of the second transaction, the second transaction being a write transaction; The client receives the third logical clock for the second transaction; If the third logical clock is greater than the first logical clock of the first transaction, the client sends a second transaction processing request to the target storage node; wherein the index module corresponding to the third logical clock of the second transaction is the same index module as the index module corresponding to the first logical clock of the first transaction, and the second transaction processing request is used to request the index module on the target storage node to reprocess the first transaction.
3. The method according to claim 1, characterized in that, Before the client receives at least one first logical clock from the index module on the at least one target storage node, the method further includes: The client receives a first response, which indicates that there is a transaction state conflict between the first transaction and the second transaction, and the index module corresponding to the second transaction is the same as the index module corresponding to the first transaction. The client sends a third transaction processing request to the target storage node, the third transaction processing request being used to request the index module on the target storage node to reprocess the first transaction.
4. The method according to any one of claims 1-3, characterized in that, The method further includes: The client determines the last dimension of the logical clock vector based on the at least one first logical clock. If the number of the first logical clocks is greater than the dimension of the logical clock vector, then the value of the last dimension in the logical clock vector is the synchronization value of the target logical clock; the target logical clock is the first logical clock that has more than the dimension, and the last dimension of the logical clock vector is used to represent the target logical clock.
5. The method according to claim 4, characterized in that, The synchronization value of the target logic clock is the maximum value of the target logic clock plus one.
6. The method according to any one of claims 1-5, characterized in that, Before the client sends the first transaction request to at least one target storage node, the method further includes: The client sends transaction start information to the associated transaction management device; wherein, the transaction start information includes a first physical clock and the transaction number of the first transaction, and the first physical clock is used to indicate the time when the first transaction starts; After the client sends the logical clock vector to the transaction management device associated with the at least one target storage node, The client sends transaction commit information to the associated transaction management device; The client receives a second physical clock from the associated transaction management device; wherein the second physical clock is used to indicate the time when the first transaction was committed. The client determines whether the first transaction has timed out based on the first physical clock and the second physical clock.
7. A transaction processing method, characterized in that, The method is applied to an index module, which is deployed on a target storage node. The target storage node is one of multiple storage nodes in a distributed system. The distributed system further includes at least one transaction management device, each of which is associated with at least one storage node. The method includes: The index module receives a first transaction processing request from the client; The index module processes the first transaction according to the first transaction processing request; The index module sends a first logical clock to the client; wherein the first logical clock indicates the logical clock for the index module to process the first transaction.
8. The method according to claim 7, characterized in that, When the first transaction is a read transaction, after the index module sends the first logical clock to the client, the method further includes: The index module receives a clock query request from the client; wherein the clock query request is used by the client to obtain the third logical clock of the second transaction, which is a write transaction; The index module sends the third logical clock to the client; The index module receives a second transaction processing request; wherein the second transaction processing request is sent by the client when the third logical clock is greater than the first logical clock; The indexing module reprocesses the first transaction based on the second transaction processing request.
9. The method according to claim 8, characterized in that, The indexing module processes the first transaction according to the first transaction processing request, including: The index module determines whether there is a transaction state conflict between the first transaction and the second transaction, and the index module corresponding to the second transaction is the same as the index module corresponding to the first transaction. If a transaction state conflict exists, the index module sends a first response to the client; wherein the first response is used to indicate that the first transaction and the second transaction have a transaction state conflict. The index module receives a third transaction processing request from the client; The indexing module reprocesses the first transaction according to the third transaction processing request; If there is no transaction state conflict, the index module executes the first transaction.
10. The method according to any one of claims 7-9, characterized in that, The first transaction processing request further includes a logical clock vector, the logical clock vector including at least one first logical clock of the first transaction, and the method further includes: The indexing module uses the logical clock vector to determine the first logical clock, where the value of the first logical clock is the maximum value in the logical clock vector plus one.
11. A transaction processing method, characterized in that, The method is applied to a transaction management device, which is one of at least one transaction management devices in a distributed system. The distributed system also includes multiple storage nodes, each of which has an index module deployed on it. Each of the at least one transaction management device is associated with at least one storage node. The method includes: The transaction management device receives a logical clock vector from a client; wherein the logical clock vector is determined by the client based on at least one first logical clock of an index module on at least one target storage node, the at least one first logical clock being sent by the index module on the at least one target storage node after processing the first transaction based on a first transaction processing request, the first transaction processing request being sent by the client to the at least one target storage node, and the at least one target storage node belonging to the plurality of storage nodes; The transaction management device updates the second logical clock based on the logical clock vector; wherein the second logical clock is used to update the at least one first logical clock.
12. The method according to claim 11, characterized in that, Before the transaction management device receives the logical clock vector from the client, it also includes: The transaction management device receives transaction start information from the client; wherein, the transaction start information includes a first physical clock and the transaction number of the first transaction, and the first physical clock is used to indicate the time when the first transaction starts; After the transaction management device updates the second logical clock based on the logical clock vector, the method further includes: The transaction management device sends a second physical clock to the client; wherein the second physical clock is used to indicate the time when the first transaction was committed.
13. The method according to claim 11 or 12, characterized in that, The updated second logical clock is the maximum value of each first logical clock and the second logical clock before the update in the logical clock vector plus one.
14. The method according to any one of claims 11-13, characterized in that, If the second logical clock is greater than the second threshold, then the second preset clock value and the second threshold are increased. The second preset clock value is greater than the second threshold. The second preset clock value is used to restore the second logical clock on the transaction management device to the second preset clock value when the transaction management device malfunctions.
15. A transaction processing method, characterized in that, The method is applied to a distributed system, which includes a client, a transaction management device, a storage node, and an index module. The index module is deployed in the storage node. The method includes: The client receives transaction processing information, which includes first transaction information. The first transaction information is used by the client to determine at least one target storage node, and the at least one target storage node is included in the storage node. The client sends a first transaction processing request to the index module in the at least one target storage node; wherein the first transaction processing request is used to instruct the index module to process a first transaction; The index module sends at least one first logical clock to the client, the at least one first logical clock indicating the logical clock for the index module to process the first transaction; The transaction management device receives a logical clock vector from the client, the logical clock vector being used to update a second logical clock of the transaction management device, the second logical clock being used to update the at least one first logical clock.
16. A distributed system, characterized in that, The distributed system includes a client, storage nodes, an index module, and a transaction management device, wherein the index module is deployed in the storage nodes. The client is used to receive transaction processing information, which includes first transaction information. The first transaction information is used by the client to determine at least one target storage node, and the at least one target storage node is included in the storage node. The client is used to send a first transaction processing request; wherein, the first transaction processing request is used to request the index module to process a first transaction; The index module is used to receive the first transaction processing request; The indexing module is also used to process the first transaction according to the first transaction processing request; The index module is further configured to send a first logical clock to the client; wherein the first logical clock indicates the logical clock for the index module to process the first transaction, and the first logical clock is used by the client to determine the logical clock vector; The transaction management device is used to update a second logical clock based on the logical clock vector, and the second logical clock is used to update the first logical clock of the index module.
17. A transaction management device, characterized in that, The device includes a transceiver unit and a processing unit. The transceiver unit is used to receive transaction processing information, which includes first transaction information. The first transaction information is used by the client to determine at least one target storage node. The transceiver unit is further configured to send a first transaction processing request to at least one target storage node; wherein the first transaction processing request is configured to instruct the index module on the at least one target storage node to process a first transaction, and the at least one target storage node belongs to the plurality of storage nodes; The transceiver unit is also configured to receive at least one first logic clock from the index module on the at least one target storage node; The processing unit is used to determine a logical clock vector based on the at least one first logical clock; wherein each of the at least one first logical clock indicates the logical clock of the index module on its corresponding target storage node for processing the first transaction; The transceiver unit is further configured to send the logical clock vector to the transaction management device associated with the at least one target storage node; wherein the logical clock vector is used to update the second logical clock of the associated transaction management device; and the second logical clock is used to update the at least one first logical clock.
18. A transaction management device, characterized in that, The device includes a transceiver unit and a processing unit. The transceiver unit is used to receive a first transaction processing request from the client; wherein, the first transaction processing request is used to request the index module to process a first transaction; The processing unit is used to process the first transaction according to the first transaction processing request; The transceiver unit is further configured to send a first logical clock to the client; wherein the first logical clock indicates the logical clock of the index module in processing the first transaction, the first logical clock is used by the client to determine a logical clock vector, the logical clock vector is used to update the second logical clock of the transaction management device associated with the target storage node, and the second logical clock is used to update the first logical clock of the index module.
19. A computing device cluster, characterized in that, The system includes multiple computing devices, each comprising multiple processors and multiple memories, the multiple memories storing program instructions, and the multiple processors executing the program instructions to cause the cluster of computing devices to perform the method as described in any one of claims 1 to 15.
20. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores program instructions that, when executed, cause the method as described in any one of claims 1 to 6, or the method as described in any one of claims 7 to 10, or the method as described in any one of claims 8 to 14, or the method as described in claim 15 to be performed.
21. A computer program product containing program instructions, characterized in that, When the program instructions are executed on a computer, the computer causes the computer to perform the method as described in any one of claims 1 to 15.