Transaction processing method and device, equipment, medium and program product

By generating target object locks for transaction requests and associating them with reference counters, the data consistency and concurrency issues in traditional transaction processing are resolved, enabling efficient data migration and processing.

CN121560463APending Publication Date: 2026-02-24CHINA TELECOM CLOUD TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511764319.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-27
Publication Date
2026-02-24

AI Technical Summary

Technical Problem

Traditional transaction processing methods compromise the integrity of native transactions when implementing concurrent writes, leading to increased latency in hot tables and an inability to effectively maintain data consistency.

Method used

By generating a target object lock that matches the transaction request and associating it with a reference counter, the execution order and concurrency of the transaction requests are controlled based on the counter value. The reference counter value is used to represent the order in which transaction requests hold the target object lock, thereby achieving ordered scheduling and maximizing resource utilization.

Benefits of technology

Without compromising transaction integrity, it improves data consistency and processing efficiency, avoids blocking and latency, and achieves high-performance data migration capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121560463A_ABST
    Figure CN121560463A_ABST
Patent Text Reader

Abstract

The invention relates to a transaction processing method and device, equipment, a medium and a program product. The method comprises the following steps: acquiring a target transaction request, and generating a target object lock matched with the target transaction request; associating a reference counter for the target object lock, wherein a count value of the reference counter is used for representing a request sequence of the target transaction request in different transaction requests holding the target object lock; under the condition that the execution of the transaction request holding the target object lock is completed, updating the count value; and under the condition that the count value meets a preset execution condition, executing the target transaction request. By the adoption of the method, the associated transactions are executed in sequence, native transactions are prevented from being damaged, and data consistency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a transaction processing method, apparatus, device, medium, and program product. Background Technology

[0002] With the development of computer technology and database applications, higher demands are placed on the timeliness and consistency of data synchronization in scenarios such as data migration and real-time data analysis. During the write process on the target end, transactions need to be reasonably scheduled and processed to maintain the order of data changes within the same row while also achieving concurrency between different rows of data.

[0003] However, in the traditional approach, the strategy of transaction decomposition and routing is usually used to achieve concurrent writes, which destroys the integrity of the original transaction and causes hot tables due to blocking, resulting in increased latency. Summary of the Invention

[0004] Therefore, it is necessary to provide a transaction processing method, apparatus, device, medium, and program product to address the aforementioned technical problems, so as to avoid disrupting native transactions and improve data consistency.

[0005] Firstly, this application provides a transaction processing method, including:

[0006] Obtain the target transaction request and generate a target object lock that matches the target transaction request;

[0007] Associate a reference counter with the target object lock. The count value of the reference counter is used to represent the request order of the target transaction request among different transaction requests that hold the target object lock.

[0008] The counter value is updated once the transaction request holding the lock on the target object has been completed.

[0009] If the count value meets the preset execution conditions, execute the target transaction request.

[0010] In one embodiment, generating a target object lock that matches the target transaction request includes: obtaining a data operation object corresponding to the target transaction request; generating a target object lock that matches the target transaction request based on the data operation object; wherein the object lock type of the target object lock includes at least one of row lock, table lock, and global lock.

[0011] In one embodiment, the count value is used to characterize the number of target object locks held at the current moment; correspondingly, when a transaction request holding a target object lock is completed, the count value is updated, including: for each transaction request holding a target object lock, when the transaction request is completed, the count value is decreased according to a preset counting step size.

[0012] In one embodiment, the count value is used to characterize the number of target object locks held at the current moment; accordingly, if the count value meets the preset execution conditions, the target transaction request is executed, including: if the count value is less than the preset count threshold, the target transaction request is executed; and the association with the reference counter is canceled.

[0013] In one embodiment, executing a target transaction request includes: obtaining the busyness of different candidate threads; selecting a target thread from the different candidate threads based on the busyness of the different candidate threads; and executing the target transaction request based on the target thread.

[0014] In one embodiment, the method further includes adding the target transaction request to a blocking queue if the count value does not meet the preset execution conditions.

[0015] Secondly, this application also provides a transaction processing apparatus, comprising:

[0016] The generation module is used to obtain the target transaction request and generate a target object lock that matches the target transaction request;

[0017] The association module is used to associate a reference counter with the target object lock. The count value of the reference counter is used to represent the request order of the target transaction request among different transaction requests that hold the target object lock.

[0018] The update module is used to update the count value after the transaction request holding the lock of the target object has been completed;

[0019] The execution module is used to execute the target transaction request when the count value meets the preset execution conditions.

[0020] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0021] Obtain the target transaction request and generate a target object lock that matches the target transaction request;

[0022] Associate a reference counter with the target object lock. The count value of the reference counter is used to represent the request order of the target transaction request among different transaction requests that hold the target object lock.

[0023] The counter value is updated once the transaction request holding the lock on the target object has been completed.

[0024] If the count value meets the preset execution conditions, execute the target transaction request.

[0025] Fourthly, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the following steps:

[0026] Obtain the target transaction request and generate a target object lock that matches the target transaction request;

[0027] Associate a reference counter with the target object lock. The count value of the reference counter is used to represent the request order of the target transaction request among different transaction requests that hold the target object lock.

[0028] The counter value is updated once the transaction request holding the lock on the target object has been completed.

[0029] If the count value meets the preset execution conditions, execute the target transaction request.

[0030] Fifthly, this application also provides a computer program product, including a computer program that, when executed by a processor, performs the following steps:

[0031] Obtain the target transaction request and generate a target object lock that matches the target transaction request;

[0032] Associate a reference counter with the target object lock. The count value of the reference counter is used to represent the request order of the target transaction request among different transaction requests that hold the target object lock.

[0033] The counter value is updated once the transaction request holding the lock on the target object has been completed.

[0034] If the count value meets the preset execution conditions, execute the target transaction request.

[0035] The aforementioned transaction processing methods, apparatus, devices, media, and program products establish an access control mechanism for shared resources or data objects requiring sequential control by acquiring target transaction requests and generating target object locks that match them, thus providing a foundation for subsequent request scheduling strategies. By associating a reference counter with the target object lock, the counter's count value characterizes the request order of the target transaction request among different transaction requests holding the target object lock. This allows for the anchoring of the execution timing of target physical requests based on a simple and lightweight count value, achieving ordered scheduling of transaction requests holding the same target lock object. Furthermore, since the target transaction requests corresponding to different target object locks are parallel and do not block each other, it is beneficial for maximizing the utilization of system resources. By updating the count value after the transaction request holding the target object lock completes, and executing the target transaction request when the count value meets preset execution conditions, associated transactions are executed sequentially without disrupting the original transaction, thus improving data consistency. Attached Figure Description

[0036] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0037] Figure 1 This is a flowchart illustrating a transaction processing method in one embodiment;

[0038] Figure 2 This is a flowchart illustrating the transaction processing method in another embodiment;

[0039] Figure 3 This is a flowchart illustrating the transaction processing method in yet another embodiment;

[0040] Figure 4 This is a structural block diagram of a transaction processing device in one embodiment;

[0041] Figure 5 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation

[0042] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0043] The transaction processing method provided in this application can be applied to data transmission service scenarios. The Data Transmission Service (DTS) can be understood as a data transmission service integrating data migration and real-time data synchronization. As the foundation for data flow, DTS integrates data migration and real-time data synchronization, making it suitable for helping users build real-time data synchronization channels to achieve database disaster recovery / active-active architecture.

[0044] In data transmission service scenarios, requests for different transactions are typically involved, such as adding, deleting, updating, and querying records in the database. The database can include at least one of relational databases and other types of databases. A relational database is used to store interconnected data points and provide access to those data points. It uses a relational model (such as a Relational Database Management System, RDBMS) to directly and intuitively display data in tables.

[0045] In the traditional approach, the strategy of transaction decomposition and routing is usually used to achieve concurrent writes. This compromises the integrity of the original transaction and can lead to increased latency due to hot tables caused by blocking.

[0046] In one embodiment, such as Figure 1 As shown, a transaction processing method is provided. This embodiment illustrates the method applied to a terminal, but it is understood that the method can also be applied to a server, and further to a system including both a terminal and a server, and implemented through interaction between the terminal and the server. In this embodiment, the method includes the following steps:

[0047] S110. Obtain the target transaction request and generate a target object lock that matches the target transaction request.

[0048] Here, a target transaction request can be understood as a request to execute a target transaction. A target transaction may include processing operations on data rows, data tables, or global data. For example, processing operations may include at least one of the following: data addition operations, data deletion operations, data update operations, and database record query operations.

[0049] For example, the transaction type of the target transaction can include at least one of DML (Data Manipulation Language) and DDL (Data Definition Language). DML is used to add, delete, update, and query database records and check data integrity; commonly used statement keywords include at least one of insert, delete, update, and select. DDL defines different database objects such as data segments, databases, tables, columns, and indexes; commonly used statement keywords include create, drop, and alter.

[0050] The target object lock can be understood as a resource lock associated with the target transaction request and matched according to its scope of operation (i.e., the data operation object), used to implement database concurrency control.

[0051] For example, the target object lock may include at least one of row locks, table locks, and global locks. It is understood that row locks are used to lock target data rows in a target database table; table locks are used to lock the target database table; and global locks are used to lock the database instance. The database instance may maintain multiple database tables, and each database table may include multiple data rows.

[0052] For example, row locks and table locks for DML type target transactions can be generated; table locks and global locks for DDL type target transactions can be generated.

[0053] In an optional embodiment, the data operation object corresponding to the target transaction request can be obtained; based on the data operation object, a target object lock matching the target transaction request can be generated; wherein, the object lock type of the target object lock includes at least one of row lock, table lock, and global lock.

[0054] For example, when the data operation object of the target transaction request object is a database instance, a global lock can be generated for the target transaction request; when the data operation object of the target transaction request object is a target database table, a table lock corresponding to the target database table can be generated for the target transaction request; when the data operation object of the target transaction request object is a target data row in the target database table, a row lock corresponding to the target data row in the target database table can be generated for the target transaction request.

[0055] S120. Associate a reference counter with the target object lock. The count value of the reference counter is used to represent the request order of the target transaction request among different transaction requests holding the target object lock.

[0056] Reference counting can be understood as a means of automatically managing computer memory. Its core is to determine when it is safe to reclaim the memory occupied by an object (such as a block of memory) by tracking the number of times it is referenced.

[0057] In one optional implementation, the count value is used to represent the number of times the target object lock is held at the current moment. Optionally, the count value corresponding to the current target transaction request can be the count value corresponding to the previous transaction request holding the target object lock plus 1.

[0058] For example, when transaction request q1 is first received, its target object lock is table lock b1, which is not currently occupied, meaning the count associated with transaction request q1 is 0. Then, when transaction request q2 is received, its target object lock is also table lock b1. In this case, the count is incremented by 1, meaning the count associated with transaction request q2 is 1. This process continues, incrementing the object locks sequentially according to the order of the transaction requests. This allows for a simple and lightweight representation of the request order within different transactions using count values, facilitating the identification of the execution timing of the target physical request.

[0059] It should be noted that the counting rules for the count values ​​can be set by technicians according to their needs or experience, or determined through a large number of experiments, and this application does not impose any restrictions on this.

[0060] S130. Update the counter value after the transaction request holding the target object lock has been completed.

[0061] In an optional embodiment, the count value is used to characterize the number of target object locks held at the current moment; correspondingly, for each transaction request holding a target object lock, the count value can be decreased according to a preset counting step size after the transaction request is completed.

[0062] Referring to the foregoing, the reference counter's count value is used to characterize the request order of the target transaction request among different transaction requests holding the target object lock. Accordingly, each transaction request can be executed according to this request count, and the count value is decreased accordingly each time a target transaction request completes, thus updating the request order. The preset counting step size can be determined by the counter's counting rules. For example, the preset counting step size can be 1. Continuing with the previous example, after transaction request q1 is completed, the count value associated with transaction request q2 decreases from 1 to 0.

[0063] Understandably, by introducing a reference counter and incrementing the reference counter for the locks of the target objects involved in each transaction, the dependencies between transactions are identified, allowing the transaction that executes first to be executed. After execution, the reference counter for subsequent transactions is decremented, thus driving the execution of subsequent transactions. This fully utilizes the capabilities of multi-threaded processing, maintaining strong transaction consistency while avoiding data inconsistencies and improving data processing efficiency.

[0064] S140. If the count value meets the preset execution conditions, execute the target transaction request.

[0065] The preset execution conditions can be set by technicians according to their needs or experience, or determined through a large number of experiments. This application does not impose any restrictions on this.

[0066] In an optional embodiment, the count value is used to characterize the number of locks on the target object held at the current moment; correspondingly, the target transaction request can be executed if the count value is less than a preset count threshold, and the association with the reference counter can be canceled. For example, the preset count threshold can be 1, meaning the target transaction request is executed when the count value is 0.

[0067] In an optional embodiment, if the count value does not meet the preset execution conditions, the target transaction request can be added to the blocking queue. By adding the target transaction request to the blocking queue, the lock allocation and request wake-up process becomes more controllable and orderly.

[0068] In an optional embodiment, the busyness of different candidate threads can be obtained; a target thread can be selected from the different candidate threads based on their busyness; and a target transaction request can be executed based on the target thread.

[0069] In this context, a candidate thread can be understood as a selectable thread among different threads that is capable of executing the target transaction request.

[0070] Busyness can be understood as a technical indicator used to quantify the current load or working state of a thread. The higher the busyness, the greater the thread load and the busier the thread is; conversely, the lower the busyness, the smaller the load and the more idle the thread is.

[0071] Optionally, the busyness of a candidate thread can be determined based on at least one of the following thread data: CPU utilization of the candidate thread and length of the task queue to be processed; the thread with the lowest busyness among the different candidate threads can be selected as the target thread, thereby further balancing thread pressure, reducing transaction waiting time, and improving concurrent execution efficiency.

[0072] Understandably, the execution strategy can be determined based on the count value. If the count value meets the preset execution conditions, it means that there are no incomplete preceding transactions holding the lock on the target object before the target transaction, and the target transaction can be executed. If the count value does not meet the preset execution conditions, it means that there are incomplete preceding transactions holding the lock on the target object before the target transaction, and the target transaction needs to be blocked. This allows unrelated transactions to run concurrently, while related transactions are executed sequentially, achieving high-performance data migration capabilities under strong data consistency.

[0073] The aforementioned transaction processing method establishes an access control mechanism for shared resources or data objects requiring sequential control by acquiring the target transaction request and generating a target object lock that matches it, thus providing a foundation for subsequent request scheduling strategies. By associating a reference counter with the target object lock, the counter's value represents the request order of the target transaction request among different transaction requests holding the target object lock. This allows for the anchoring of the execution timing of the target physical request based on a simple and lightweight counter value, achieving ordered scheduling of transaction requests holding the same target lock object. Furthermore, since the target transaction requests corresponding to different target object locks are parallel and do not block each other, it maximizes the utilization of system resources. By updating the counter value after the transaction request holding the target object lock completes, and executing the target transaction request only when the counter value meets preset execution conditions, associated transactions are executed sequentially without disrupting the original transaction, thus improving data consistency.

[0074] Based on the technical solutions of the above embodiments, this application also provides an optional embodiment, in which another transaction processing method is provided.

[0075] refer to Figure 2 The diagram shows a flowchart of a transaction processing method in another embodiment. Here, DTS Store is the persistent queue or relay station of the data transmission service; Avro is a data serialization system, and Avro deserialization is used to read data streams from the DTS Store and deserialize them into in-memory data structures that the program can understand and process; the transaction reorganization process is used to analyze the parsed transactions, identify the transaction type (transaction types can include DML and DDL) and the data operation objects to be manipulated; Dispatch, or dispatcher, refers to the core scheduler of the system, used to dispatch the parsed transactions to appropriate execution channels based on the corresponding target object locks and reference counters (i.e., Refence Context).

[0076] The process involves reading a data stream from the DTS Store, deserializing it with Avro to obtain a data structure conforming to a preset format, and parsing it to obtain the data operation object (or transaction type) of the target transaction. Based on the dispatcher, a target object lock matching the target transaction's data operation object is generated, and a reference counter is associated with the target object lock. The count value of the associated reference counter is incremented by 1 based on the count value of the previous transaction request holding the target object lock. If the count value meets the preset execution conditions, the transaction request is dispatched to the corresponding write thread Channel for execution via the dispatch thread. If the transaction request holding the target object lock completes, the count value is decremented by 1. If the count value does not meet the preset execution conditions, the transaction is added to a blocking queue. The target object lock includes at least one of row locks, table locks, and global locks.

[0077] Based on the technical solutions of the above embodiments, this application also provides an optional embodiment in which the transaction processing method is described in detail.

[0078] refer to Figure 3 The diagram shown is a flowchart of a transaction processing method in another embodiment, including:

[0079] S310, Obtain the target transaction request.

[0080] S320. In response to the target transaction request, obtain the data operation object corresponding to the target transaction request.

[0081] S330. Generate a target object lock that matches the target transaction request based on the data operation object.

[0082] The target object lock includes at least one of row locks, table locks, and global locks.

[0083] S340. Associate a reference counter with the target object lock. The count value of the reference counter is incremented based on the count value corresponding to the previous transaction request that holds the target object lock.

[0084] S350. For each transaction request that holds the lock of the target object, after the transaction request is completed, the count value of the associated reference counter is decremented.

[0085] S360. When the count value is less than the preset count threshold, obtain the busyness of different candidate threads.

[0086] S370. Select the target thread from different candidate threads based on their busyness levels.

[0087] S380. Based on the target thread, execute the target transaction request and cancel the association with the reference counter.

[0088] It should be understood that although the steps in the flowcharts of the embodiments described above are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the embodiments described above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0089] Based on the same inventive concept, this application also provides a transaction processing apparatus for implementing the transaction processing method described above. The solution provided by this apparatus is similar to the implementation scheme described in the above method; therefore, the specific limitations in one or more transaction processing apparatus embodiments provided below can be found in the limitations of the transaction processing method described above, and will not be repeated here.

[0090] In one exemplary embodiment, such as Figure 4 As shown, a transaction processing apparatus is provided, comprising: a generation module 410, an association module 420, an update module 430, and an execution module 440, wherein:

[0091] The generation module 410 is used to obtain the target transaction request and generate a target object lock that matches the target transaction request;

[0092] The association module 420 is used to associate a reference counter with the target object lock. The count value of the reference counter is used to represent the request order of the target transaction request among different transaction requests holding the target object lock.

[0093] The update module 430 is used to update the count value after the transaction request holding the lock of the target object has been completed;

[0094] The execution module 440 is used to execute the target transaction request when the count value meets the preset execution conditions.

[0095] In one embodiment, the generation module 410 includes: an acquisition unit for acquiring a data operation object corresponding to the target transaction request; and a generation unit for generating a target object lock that matches the target transaction request based on the data operation object; wherein the object lock type of the target object lock includes at least one of row lock, table lock, and global lock.

[0096] In one embodiment, the count value is used to characterize the number of target object locks held at the current moment; correspondingly, the update module 430 includes: a processing unit, used to decrease the count value according to a preset counting step size for each transaction request holding a target object lock, after the transaction request is completed.

[0097] In one embodiment, the count value is used to characterize the number of target object locks held at the current moment; correspondingly, the execution module includes: an execution unit for executing the target transaction request when the count value is less than a preset count threshold; and an association unit for canceling the association with the reference counter.

[0098] In one embodiment, the execution unit includes: a first acquisition subunit for acquiring the busyness of different candidate threads; a selection subunit for selecting a target thread from the different candidate threads based on their busyness; and an execution subunit for executing a target transaction request based on the target thread.

[0099] In one embodiment, the above apparatus further includes: an adding module, used to add the target transaction request to the blocking queue if the count value does not meet the preset execution conditions.

[0100] Each module in the aforementioned transaction processing device can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can invoke and execute the operations corresponding to each module.

[0101] In one exemplary embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 5 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and a database. The internal memory provides the environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The database stores data to be accessed. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a transaction processing method.

[0102] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0103] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to perform the following steps:

[0104] Obtain the target transaction request and generate a target object lock that matches the target transaction request;

[0105] Associate a reference counter with the target object lock. The count value of the reference counter is used to represent the request order of the target transaction request among different transaction requests that hold the target object lock.

[0106] The counter value is updated once the transaction request holding the lock on the target object has been completed.

[0107] If the count value meets the preset execution conditions, execute the target transaction request.

[0108] In one embodiment, when the processor executes the computer program, it further performs the following steps: obtaining the data operation object corresponding to the target transaction request; generating a target object lock that matches the target transaction request based on the data operation object; wherein the object lock type of the target object lock includes at least one of row lock, table lock, and global lock.

[0109] In one embodiment, the count value is used to represent the number of target object locks held at the current moment; when the processor executes the computer program, it also performs the following steps: for each transaction request holding a target object lock, after the transaction request is completed, the count value is decreased according to a preset counting step size.

[0110] In one embodiment, the count value is used to characterize the number of locks on the target object held at the current moment; when the processor executes the computer program, it also performs the following steps: if the count value is less than a preset count threshold, execute the target transaction request; and cancel the association with the reference counter.

[0111] In one embodiment, when the processor executes the computer program, it further performs the following steps: obtaining the busyness of different candidate threads; selecting a target thread from the different candidate threads based on the busyness of the different candidate threads; and executing a target transaction request based on the target thread.

[0112] In one embodiment, when the processor executes the computer program, it further performs the following steps: adding the target transaction request to the blocking queue if the count value does not meet the preset execution conditions.

[0113] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, the computer program performing the following steps when executed by a processor:

[0114] Obtain the target transaction request and generate a target object lock that matches the target transaction request;

[0115] Associate a reference counter with the target object lock. The count value of the reference counter is used to represent the request order of the target transaction request among different transaction requests that hold the target object lock.

[0116] The counter value is updated once the transaction request holding the lock on the target object has been completed.

[0117] If the count value meets the preset execution conditions, execute the target transaction request.

[0118] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: obtaining the data operation object corresponding to the target transaction request; generating a target object lock that matches the target transaction request based on the data operation object; wherein the object lock type of the target object lock includes at least one of row lock, table lock, and global lock.

[0119] In one embodiment, the count value is used to represent the number of target object locks held at the current moment; when the computer program is executed by the processor, it also implements the following steps: for each transaction request holding a target object lock, after the transaction request is completed, the count value is decreased according to a preset counting step size.

[0120] In one embodiment, the count value is used to characterize the number of locks on the target object held at the current moment; when the computer program is executed by the processor, it also performs the following steps: if the count value is less than a preset count threshold, execute the target transaction request; and cancel the association with the reference counter.

[0121] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: obtaining the busyness of different candidate threads; selecting a target thread from the different candidate threads based on the busyness of the different candidate threads; and executing a target transaction request based on the target thread.

[0122] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: adding the target transaction request to the blocking queue if the count value does not meet the preset execution conditions.

[0123] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, performs the following steps:

[0124] Obtain the target transaction request and generate a target object lock that matches the target transaction request;

[0125] Associate a reference counter with the target object lock. The count value of the reference counter is used to represent the request order of the target transaction request among different transaction requests that hold the target object lock.

[0126] The counter value is updated once the transaction request holding the lock on the target object has been completed.

[0127] If the count value meets the preset execution conditions, execute the target transaction request.

[0128] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: obtaining the data operation object corresponding to the target transaction request; generating a target object lock that matches the target transaction request based on the data operation object; wherein the object lock type of the target object lock includes at least one of row lock, table lock, and global lock.

[0129] In one embodiment, the count value is used to represent the number of target object locks held at the current moment; when the computer program is executed by the processor, it also implements the following steps: for each transaction request holding a target object lock, after the transaction request is completed, the count value is decreased according to a preset counting step size.

[0130] In one embodiment, the count value is used to characterize the number of locks on the target object held at the current moment; when the computer program is executed by the processor, it also performs the following steps: if the count value is less than a preset count threshold, execute the target transaction request; and cancel the association with the reference counter.

[0131] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: obtaining the busyness of different candidate threads; selecting a target thread from the different candidate threads based on the busyness of the different candidate threads; and executing a target transaction request based on the target thread.

[0132] In one embodiment, when the computer program is executed by the processor, it further performs the following steps: adding the target transaction request to the blocking queue if the count value does not meet the preset execution conditions.

[0133] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.

[0134] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0135] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are specific and detailed, they should not be construed as limiting the scope of this patent application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A transaction processing method, characterized in that, The method includes: Obtain the target transaction request and generate a target object lock that matches the target transaction request; A reference counter is associated with the target object lock, and the count value of the reference counter is used to characterize the request order of the target transaction request among different transaction requests holding the target object lock; The counter value is updated once the transaction request holding the lock of the target object has been completed. If the count value meets the preset execution conditions, the target transaction request is executed.

2. The method according to claim 1, characterized in that, The generation of the target object lock that matches the target transaction request includes: Obtain the data operation object corresponding to the target transaction request; Based on the data operation object, generate a target object lock that matches the target transaction request; The target object lock's object lock type includes at least one of row lock, table lock, and global lock.

3. The method according to claim 1, characterized in that, The count value is used to represent the number of locks held by the target object at the current moment; correspondingly, when the transaction request holding the target object lock is completed, the count value is updated, including: For each transaction request holding the lock of the target object, after the transaction request is completed, the count value is decreased according to a preset counting step size.

4. The method according to claim 1, characterized in that, The count value is used to represent the number of locks held by the target object at the current moment; correspondingly, executing the target transaction request when the count value meets preset execution conditions includes: If the count value is less than a preset count threshold, the target transaction request is executed; and, Cancel the association with the reference counter.

5. The method according to claim 4, characterized in that, The execution of the target transaction request includes: Get the busy level of different candidate threads; The target thread is selected from the different candidate threads based on their busyness. Based on the target thread, execute the target transaction request.

6. The method according to any one of claims 1-5, characterized in that, The method further includes: If the count value does not meet the preset execution conditions, the target transaction request will be added to the blocking queue.

7. A transaction processing apparatus, characterized in that, The device includes: The generation module is used to obtain the target transaction request and generate a target object lock that matches the target transaction request; The association module is used to associate a reference counter with the target object lock, and the count value of the reference counter is used to characterize the request order of the target transaction request among different transaction requests holding the target object lock; An update module is used to update the count value after the transaction request holding the lock of the target object has been completed; An execution module is used to execute the target transaction request if the count value meets preset execution conditions.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.