Task processing method and device of database and electronic equipment

By combining state management information and task queues, the lock conflict problem in table lock management under a multi-NUMA architecture is solved, enabling efficient concurrent processing and low-latency task execution in the database system.

CN121560904BActive Publication Date: 2026-04-28JIANGSU HUAKU DATA TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
JIANGSU HUAKU DATA TECH CO LTD
Filing Date
2026-01-22
Publication Date
2026-04-28

AI Technical Summary

Technical Problem

In a multi-service concurrent and non-uniform memory access NUMA architecture, table lock management leads to frequent lock conflicts, affecting the database system's concurrent processing capabilities and overall performance.

Method used

By managing the lock state of the target resource through state management information, it can quickly determine whether an operation request is executable. By managing the number of target operations through a task queue, it can achieve lock conflict prediction and task triggering execution, forming an efficient closed loop and reducing thread blocking caused by lock contention.

Benefits of technology

It improves the efficiency of database table lock management, reduces task processing latency, and enhances the performance and stability of the database system in high-concurrency scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121560904B_ABST
    Figure CN121560904B_ABST
Patent Text Reader

Abstract

The application provides a database task processing method and device and electronic equipment, which can be applied to the technical field of computers. The method comprises the following steps: in response to receiving an operation request for a target resource, determining, from state management information of the target resource, a conflict lock type incompatible with a current lock type of the target resource and an operation quantity of a target operation of executing the current lock type; in response to determining that there is a target lock type to be added in the conflict lock type based on an operation type determined by the operation request, adding a to-be-processed task generated based on the target lock type and the operation request to a waiting queue, so as to execute the to-be-processed task when the to-be-processed task is located at the head of the waiting queue and the operation quantity is a preset value.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer technology, and more specifically to a database task processing method, apparatus, and electronic device. Background Technology

[0002] Table lock management is a core technology for ensuring data consistency when multiple services access data concurrently. Its performance can affect the operating efficiency and stability of the database in high-concurrency and non-uniform memory access (NUMA) environments. Efficient and low-conflict table lock mechanisms have become a key requirement for database performance optimization.

[0003] In realizing the concept of this invention, at least the following problems were found in the related technologies: Table lock management in related technologies often adopts a hash bucket architecture, synchronizing the acquisition and release of table locks through bucket latches. However, under multi-service concurrency and multiple non-uniform memory access NUMA architectures, a large number of requests frequently compete for the same bucket latch, and cross-node competition further exacerbates lock conflicts, leading to prolonged table locking time, blocked related tasks, and affecting the concurrent processing capability and overall performance of the database system. Summary of the Invention

[0004] In view of the above problems, the present invention provides a database task processing method, apparatus, device, medium and program product.

[0005] According to one aspect of the present invention, a database task processing method is provided, comprising: in response to receiving an operation request for a target resource, determining from the state management information of the target resource a conflicting lock type incompatible with the current lock type of the target resource and a number of operations for executing the target operation of the current lock type; in response to determining that there is a target lock type to be added among the conflicting lock types based on the operation type of the operation request, adding a pending task generated based on the target lock type and the operation request to a waiting queue, so as to execute the pending task when the pending task is at the head of the waiting queue and the number of operations is a preset value.

[0006] According to an embodiment of the present invention, when the task to be processed is at the head of the waiting queue and the number of operations is a preset value, the method further includes: taking the target lock type as the new current lock type; and updating the conflicting lock type and the number of operations based on the new current lock type.

[0007] According to an embodiment of the present invention, the above-mentioned updating of the conflicting lock type and the number of operations based on the new current lock type includes: determining, based on the new current lock type, candidate lock types that are incompatible with the new current lock type from preset lock compatibility information, and updating the conflicting lock type to the candidate lock types to obtain the updated conflicting lock type; determining the number of candidate operations based on the number of compatible pending tasks in the waiting queue located between the pending task and the target mutually exclusive pending task; updating the number of operations based on the number of candidate operations to obtain the updated number of operations; wherein, the target mutually exclusive pending task is the one whose execution order is closest to the pending task among the mutually exclusive pending tasks included in the waiting queue, and the updated conflicting lock type includes the lock type of the mutually exclusive pending task but does not include the lock type of the compatible pending task.

[0008] According to an embodiment of the present invention, updating the conflict lock type to the candidate lock type to obtain the updated conflict lock type includes: updating the conflict lock type at time t read from the state management information to the candidate lock type; based on the conflict lock type at time t, verifying whether the conflict lock type at time t+T included in the state management information has changed, and obtaining a type verification result, wherein t and T are both greater than 0; if the type verification result indicates that the conflict lock type at time t+T has not changed, replacing the conflict lock type at time t+T with the candidate lock type to obtain the updated conflict lock type.

[0009] According to an embodiment of the present invention, the method further includes: when the type verification result indicates that the conflict lock type at time t+T has changed, comparing the changed conflict lock type with the target lock type to obtain a comparison result; when it is determined that the comparison result indicates that the target lock type does not exist in the changed conflict lock type, executing the task to be processed and updating the number of operations.

[0010] According to an embodiment of the present invention, updating the number of operations based on the candidate number of operations to obtain an updated number of operations includes: obtaining a target number of operations based on the candidate number of operations and the task to be processed; verifying whether the number of operations included in the state management information at time t+T has changed based on the number of operations read from the state management information, and obtaining a number verification result; if it is determined that the number of operations at time t+T has not changed as indicated by the number verification result, replacing the number of operations at time t+T with the target number of operations to obtain an updated number of operations.

[0011] According to an embodiment of the present invention, the aforementioned status management information is obtained through the following operations: based on the table identifier included in the operation request, a primary storage address matching the field values ​​of a first range in the table identifier is determined from the table lock management information of the database, wherein the table identifier is the identifier of the table where the target resource is located; based on the primary storage address, a secondary storage address matching the field values ​​of a second range in the table identifier is determined from the table lock management information, wherein the first range and the second range are both preset field ranges; and based on the secondary storage address, the status management information of the target resource is determined.

[0012] According to an embodiment of the present invention, the method further includes: responding to the absence of the secondary storage address in the table lock management information at time t, obtaining a candidate secondary storage address based on the field value of the second range in the table identifier; verifying whether the secondary storage address exists in the table lock management information at time t+T, and obtaining an address verification result; and if the address verification result indicates that the secondary storage address does not exist at time t+T, writing the candidate secondary storage address into the table lock management information to obtain the secondary storage address.

[0013] Another aspect of the present invention provides a task processing apparatus, comprising: a determining module, configured to, in response to receiving an operation request for a target resource, determine from the state management information of the target resource a conflicting lock type incompatible with the current lock type of the target resource and a number of operations for performing the target operation of the current lock type; and a processing module, configured to, in response to determining that there is a target lock type to be added among the conflicting lock types determined based on the operation type of the operation request, add a pending task generated based on the target lock type and the operation request to a waiting queue, so as to execute the pending task when the pending task is at the head of the waiting queue and the number of operations is a preset value.

[0014] Another aspect of the present invention provides an electronic device comprising: one or more processors; and a memory for storing one or more computer programs, wherein the one or more processors execute the one or more computer programs to implement the steps of the method described above.

[0015] Another aspect of the present invention provides a computer-readable storage medium having a computer program or instructions stored thereon, which, when executed by a processor, implement the steps of the above-described method.

[0016] Another aspect of the present invention provides a computer program product, including a computer program or instructions that, when executed by a processor, implement the steps of the above-described method.

[0017] According to embodiments of the present invention, the lock state of a target resource is managed through state management information, thereby quickly determining whether an operation request can be executed by identifying conflicting lock types that are mutually exclusive with the current lock type of the target resource. Furthermore, by managing the number of target operations for the current lock type of the target resource in the state management information, and by using the target operation count and task queue to determine when all target operations have been completed, pending tasks are executed quickly, shortening task processing time. Because the management of lock state and operation count, combined with the ordered scheduling mechanism of the task queue, forms an efficient closed loop from lock conflict prediction and operation progress awareness to task triggering and execution, thread blocking caused by lock contention is reduced, and lock waiting time in high-concurrency scenarios is lowered. Therefore, this at least partially solves the technical problem of poor concurrency processing capability and overall performance of database systems due to table lock management methods in related technologies, achieving the technical effects of improving database table lock management efficiency and reducing task processing latency. Attached Figure Description

[0018] The above-mentioned contents, as well as other objects, features and advantages of the present invention, will become clearer from the following description of embodiments of the present invention with reference to the accompanying drawings.

[0019] Figure 1 The diagram illustrates application scenarios of a database task processing method, apparatus, device, medium, and program product according to embodiments of the present invention.

[0020] Figure 2 A flowchart of a database task processing method according to an embodiment of the present invention is shown.

[0021] Figure 3 A schematic diagram illustrating the updating of status management information according to an embodiment of the present invention is shown.

[0022] Figure 4 A schematic diagram of table lock management information according to an embodiment of the present invention is shown.

[0023] Figure 5 A structural block diagram of a database task processing apparatus according to an embodiment of the present invention is shown.

[0024] Figure 6 A block diagram of an electronic device suitable for implementing a database task processing method according to an embodiment of the present invention is shown. Detailed Implementation

[0025] Hereinafter, embodiments of the present invention will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the invention. In the following detailed description, numerous specific details are set forth to provide a thorough understanding of the embodiments of the invention for ease of explanation. However, it will be apparent that one or more embodiments may be practiced without these specific details. Furthermore, descriptions of well-known structures and techniques are omitted in the following description to avoid unnecessarily obscuring the concept of the invention.

[0026] The terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the invention. The terms “comprising,” “including,” etc., as used herein indicate the presence of the stated features, steps, operations, and / or components, but do not exclude the presence or addition of one or more other features, steps, operations, or components.

[0027] All terms used herein (including technical and scientific terms) have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein are to be interpreted in a manner consistent with the context of this specification, and not in an idealized or overly rigid way.

[0028] When using expressions such as "at least one of A, B and C", they should generally be interpreted in accordance with the meaning that is commonly understood by those skilled in the art (e.g., "a system having at least one of A, B and C" should include, but is not limited to, a system having A alone, a system having B alone, a system having C alone, a system having A and B, a system having A and C, a system having B and C, and / or a system having A, B and C, etc.).

[0029] In the technical solution of this invention, the user information (including but not limited to user personal information, user image information, user device information, such as location information) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, storage, use, processing, transmission, provision, disclosure, and application of related data all comply with relevant laws, regulations, and standards, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entry points for users to choose to authorize or refuse.

[0030] In scenarios involving automated decision-making using personal information, the methods, devices, and systems provided in this invention offer users corresponding entry points for choosing to agree to or reject the automated decision-making results. If the user chooses to reject, the process proceeds to the expert decision-making stage. Here, "automated decision-making" refers to the activity of automatically analyzing and evaluating an individual's behavioral habits, interests, or economic, health, and credit status through computer programs, and then making a decision. Here, "expert decision-making" refers to the activity of making decisions by personnel who specialize in a particular field, possess specialized experience, knowledge, and skills, and have reached a certain level of professional expertise.

[0031] In common implementations, transaction locks are typically managed using hash tables. The locking process is as follows: A hash value is calculated based on the resource's ID. The hash bucket is located in the hash table based on the hash value, and a lock is acquired on it. The locked resource is then located within the hash bucket. The resource is locked, and the bucket latch is released, or the lock on the hash bucket is released, and then a waiting state is entered. The lock release process is similar to the locking process described above. It requires first acquiring the hash bucket latch, and then operating on the bucket linked list, the resource object, and the lock object linked list.

[0032] Multiple NUMA is a computer architecture where multiple processors or processor groups access memory through different memory controllers, causing memory access latency to vary depending on node distance. In a multiple NUMA scenario, the increased memory access latency amplifies the latency caused by locking. In databases designed for high transaction concurrency in multiple NUMA environments, the locking mechanism within transaction locks is a significant bottleneck limiting the ability to improve concurrency processing capabilities.

[0033] In view of this, embodiments of the present invention provide a database task processing method, comprising: in response to receiving an operation request for a target resource, determining from the target resource's state management information a conflicting lock type incompatible with the target resource's current lock type and the number of target operations to be performed for the current lock type; in response to determining that there is a target lock type to be added based on the operation type of the operation request among the conflicting lock types, adding a pending task generated based on the target lock type and the operation request to a waiting queue, so as to execute the pending task when it is at the head of the waiting queue and the number of operations is a preset value.

[0034] Figure 1 The diagram illustrates application scenarios of a database task processing method, apparatus, device, medium, and program product according to embodiments of the present invention.

[0035] like Figure 1As shown, application scenario 100 according to this embodiment may include a first terminal device 101, a second terminal device 102, a third terminal device 103, a network 104, and a server 105. The network 104 serves as a medium for providing communication links between the first terminal device 101, the second terminal device 102, the third terminal device 103, and the server 105. The network 104 may include various connection types, such as wired or wireless communication links, or fiber optic cables, etc.

[0036] Users can use the first terminal device 101, the second terminal device 102, and the third terminal device 103 to interact with the server 105 via the network 104 to receive or send messages, etc. Various communication client applications can be installed on the first terminal device 101, the second terminal device 102, and the third terminal device 103, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social media platform software, etc. (for example only).

[0037] The first terminal device 101, the second terminal device 102, and the third terminal device 103 can be various electronic devices with displays and support web browsing, including but not limited to smartphones, tablets, laptops, and desktop computers.

[0038] Server 105 can be a server that provides various services, such as a backend management server that supports websites browsed by users using the first terminal device 101, the second terminal device 102, and the third terminal device 103 (this is just an example). The backend management server can analyze and process data such as received user requests, and feed back the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal devices.

[0039] It should be noted that the database task processing method provided in this embodiment of the invention can generally be executed by server 105. Correspondingly, the database task processing device provided in this embodiment of the invention can generally be located in server 105. The database task processing method provided in this embodiment of the invention can also be executed by a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105. Correspondingly, the database task processing device provided in this embodiment of the invention can also be located in a server or server cluster that is different from server 105 and capable of communicating with the first terminal device 101, the second terminal device 102, the third terminal device 103, and / or server 105.

[0040] It should be understood that Figure 1The number of terminal devices, networks, and servers shown is merely illustrative. Depending on implementation needs, any number of terminal devices, networks, and servers can be included.

[0041] The following will be based on Figure 1 The described scene, through Figures 2-4 The task processing method for the database in the embodiments of the invention will be described in detail.

[0042] Figure 2 A flowchart of a database task processing method according to an embodiment of the present invention is shown.

[0043] like Figure 2 As shown, the method includes operations S210 to S220.

[0044] In operation S210, in response to receiving an operation request for the target resource, the conflicting lock type that is incompatible with the current lock type of the target resource and the number of target operations that perform the current lock type are determined from the state management information of the target resource.

[0045] In operation S220, in response to determining that there is a target lock type to be added based on the operation type of the operation request in the conflict lock type, the pending task generated based on the target lock type and the operation request is added to the waiting queue, so that the pending task is executed when it is at the first position in the waiting queue and the number of operations is a preset value.

[0046] An operation request can be a request to instruct a set of actions to be performed sequentially on the database. This set of actions reflects a complete user intent and is therefore processed by the database as a whole. Operation requests can also refer to transactions.

[0047] Operation requests, or transactions, are isolated from each other; that is, the result of one operation request is not affected by another operation request executed concurrently. Isolation between operation requests can be achieved through operation scheduling, such as by using locking to resolve conflicts between different operation requests.

[0048] During implementation, the target resource is not limited and can be data stored in a database, such as tables. The current lock type is also not limited and can be an exclusive lock, shared lock, intention lock, etc.

[0049] When a user requests an operation on a specific resource, such as a target table in a database, the system can access the status management information corresponding to that resource. This status management information can also be referred to as a table lock map.

[0050] This state management information can be used to manage the locking status of target resources, the number of target operations executing the current lock type, and waiting queues. This state management information can include a set of conflicting lock types that are mutually exclusive and cannot coexist with the current lock type, and this set of conflicting lock types can include at least one conflicting lock type. The state management information can also include the number of target operations currently being executed that hold the current lock type, and waiting queues. The waiting queue can include pending tasks for the target resource, with each pending task corresponding to an operation request.

[0051] Since compatible lock types can be applied to the target resource simultaneously, there can be multiple current lock types. Furthermore, the set of conflicting lock types can include conflicting lock types for each of the current lock types.

[0052] Furthermore, the number of target operations holding the current lock type can be multiple. For example, it can include the number of target operations A holding the current lock type A, and the number of target operations B holding the current lock type B, where the current lock type A and the current lock type B are compatible. Next, the operation type of the received operation request can be analyzed, such as a read operation or a write operation, and the target lock type that needs to be added to execute the operation request can be determined accordingly.

[0053] The target lock type can be matched against at least one conflicting lock type in the set of conflicting lock types. If the target lock type exists in at least one of the conflicting lock types, it is determined that the target lock type conflicts with the current lock type, meaning that the operation request cannot be executed concurrently with the target operation. Therefore, this operation request can be packaged with the corresponding target lock type to generate a task to be processed, and then placed in a waiting queue for queuing.

[0054] During subsequent operations targeting the target resource, once it is determined that the task to be processed has moved to the front of the waiting queue, and the number of previously recorded operations executing the current lock type has decreased to a preset value, the task can be retrieved from the waiting queue, and its operation request can be executed. The preset value is not limited and can be zero, indicating that no other conflicting target operations are currently being executed.

[0055] Alternatively, during subsequent operations on the target resource, the corresponding conflicting lock type can be continuously updated based on the updated current lock type, and the pending task can be executed when it is determined that the target lock type does not exist in the current conflicting lock type.

[0056] According to an embodiment of the present invention, the lock state of the target resource is managed by state management information. During the locking and unlocking process, it is not necessary to lock any lock state information, thereby reducing the conflicts between threads caused by the locking and unlocking process in multi-NUMA high-concurrency scenarios.

[0057] According to embodiments of the present invention, the lock state of a target resource is managed through state management information, thereby quickly determining whether an operation request can be executed by identifying conflicting lock types that are mutually exclusive with the current lock type of the target resource. Furthermore, by managing the number of target operations for the current lock type of the target resource in the state management information, and by using the target operation count and task queue to determine when all target operations have been completed, pending tasks are executed quickly, shortening task processing time. Because the management of lock state and operation count, combined with the ordered scheduling mechanism of the task queue, forms an efficient closed loop from lock conflict prediction and operation progress awareness to task triggering and execution, thread blocking caused by lock contention is reduced, and lock waiting time in high-concurrency scenarios is lowered. Therefore, this at least partially solves the technical problem of poor concurrency processing capability and overall performance of database systems due to table lock management methods in related technologies, achieving the technical effects of improving database table lock management efficiency and reducing task processing latency.

[0058] According to an embodiment of the present invention, when the task to be processed is at the head of the waiting queue and the number of operations is a preset value, the database task processing method may further include the following operations.

[0059] Set the target lock type as the new current lock type; update the conflicting lock type and number of operations based on the new current lock type.

[0060] Figure 3 A schematic diagram illustrating the updating of status management information according to an embodiment of the present invention is shown.

[0061] like Figure 3 As shown, the original state management information includes lock type A and lock type B. The number of operations (lock count) for the target operation of the current lock type is 0. The waiting queue includes pending task I, pending task J, and pending task K. When pending task I meets the execution condition (lock count is 0 and pending task I is at the top), the conflict lock type can be updated based on the target lock type of pending task I, resulting in the updated conflict lock type including lock type C.

[0062] It is necessary to determine whether tasks I, J, and K in the waiting queue can be processed in parallel. If it is determined that tasks I and J can be processed in parallel, then update the lock count to 2. Also, update the waiting queue to include task K.

[0063] During the update process, atomic operations can be used. For example, a first atomic operation can be used to update the number of operations based on the new current lock type. Then, a second atomic operation can be used to update the conflicting lock type based on the new current lock type.

[0064] Atomic operations are instructions that ensure the atomicity of data operations in concurrent scenarios. An atomic operation can encapsulate multiple actions, and these actions cannot be interrupted during execution. For example, during execution, the atomic operation might check if the original value at the target address has changed; if not, it swaps the target value with the original value. The target value can be the value to be updated.

[0065] According to an embodiment of the present invention, when a task to be processed is at the head of the waiting queue and the number of operations meets a preset condition, the target lock type is updated to the new current lock type, and the update of the number of operations and the conflicting lock type is completed separately using two atomic operations. This improves the security and efficiency of database task processing in concurrent scenarios. Furthermore, the characteristics of atomic operations ensure the uninterrupted nature of conflicting lock type updates and operation quantity adjustments. The multi-step actions encapsulated in each atomic operation are not interfered with by other threads during execution, reducing potential race conditions when multiple threads concurrently modify shared states.

[0066] According to an embodiment of the present invention, updating the conflict lock type and number of operations based on the new current lock type may include the following operations.

[0067] Based on the new current lock type, candidate lock types that are incompatible with the new current lock type are determined from the preset lock compatibility information, and the conflicting lock type is updated to the candidate lock type to obtain the updated conflicting lock type; based on the number of compatible pending tasks in the waiting queue that are located between the pending task and the target mutually exclusive pending task, the number of candidate operations is determined; based on the number of candidate operations, the number of operations is updated to obtain the updated number of operations; wherein, the target mutually exclusive pending task is the mutually exclusive pending task whose execution order is closest to the pending task among the mutually exclusive pending tasks included in the waiting queue, and the updated conflicting lock type includes the lock type of the mutually exclusive pending task but does not include the lock type of the compatible pending task.

[0068] When updating the conflicting lock type and the number of operations, the preset lock compatibility information that stores the compatibility relationships between multiple lock types can be used to determine the candidate lock types that are mutually exclusive with the new current lock type, and the conflicting lock type set can be atomically updated to these candidate lock types to form the updated conflicting lock type set.

[0069] Simultaneously, the waiting queue can be scanned to locate the target mutex task. This task is the one in the queue whose execution order is closest to the current task. The lock type of the mutex task belongs to the updated set of conflicting lock types. After identifying the target mutex task, the number of compatible tasks in the waiting queue located between the current task and the target mutex task can be counted; this number represents the candidate operation count. The lock types of compatible tasks do not exist in the updated set of conflicting lock types, meaning that the corresponding compatible operations can process the target resource simultaneously with the operation request. Therefore, by updating the current operation count to the calculated candidate operation count, the entire state transition and update can be completed.

[0070] In some embodiments, the conflicting lock type can be updated to a candidate lock type using Compare And Swap (CAS) to obtain the updated conflicting lock type. Furthermore, the number of operations can be updated based on the number of candidate operations using atomic increment operations to obtain the updated number of operations.

[0071] The CAS operation is used to atomically check whether the value at a memory address has changed. If it has not changed, it is swapped with the value in a register.

[0072] According to embodiments of the present invention, by matching the new current lock type with preset lock compatibility information, the set of conflicting lock types is dynamically determined and updated, ensuring that lock conflict rules are aligned with the resource consumption requirements of the current task in real time, thus reducing the risk of concurrent conflicts caused by lock type incompatibility. Simultaneously, by locating the nearest mutually exclusive pending task in the waiting queue to the current pending task, the number of compatible pending tasks between them is accurately counted to update the operation count, ensuring that the operation count reflects the scale of tasks that can be safely executed concurrently.

[0073] In some embodiments, the update process relies on atomic operations to improve the synchronization and consistency of conflict lock types and the number of operations, reduce problems such as lock misjudgment and task scheduling disorder caused by asynchronous state updates in multi-threaded concurrent scenarios, improve the efficiency of concurrent task processing, and also improve the stability and reliability of database task processing, thus realizing the orderly allocation and efficient utilization of resources in high-concurrency scenarios.

[0074] According to an embodiment of the present invention, updating the conflict lock type to a candidate lock type to obtain the updated conflict lock type may include the following operations.

[0075] The conflict lock type at time t, read from the state management information, is updated to a candidate lock type. Based on the conflict lock type at time t, the conflict lock type at time t+T, included in the state management information, is checked to see if it has changed, and a type check result is obtained, where t and T are both greater than 0. If the type check result indicates that the conflict lock type at time t+T has not changed, the conflict lock type at time t+T is replaced with the candidate lock type to obtain the updated conflict lock type.

[0076] When updating the conflict lock type, the conflict lock type recorded at time t can be read from the state management information. Then, this read conflict lock type at time t is updated to the candidate lock type, completing the initial state preparation.

[0077] Subsequently, based on the previously read conflict lock type at time t, the conflict lock type recorded in the state management information at time t+T can be verified to determine whether it has changed between time t and time t+T, thus obtaining the type verification result. If the type verification result shows that the conflict lock type at time t+T has not changed compared to time t, the candidate lock type is used to replace the conflict lock type at time t+T in the state management information, thereby obtaining the updated conflict lock type.

[0078] It should be noted that the above verification and replacement operations are bound together and will not be interrupted or interfered with by other threads during execution.

[0079] According to an embodiment of the present invention, secure updates of conflict lock types are achieved by binding verification and replacement as uninterruptible atomic operations. During the update, the conflict lock type at time t is first read as a baseline. Then, it is verified whether the conflict lock type at time t+T is consistent with this baseline, ensuring that the state before the update has not been tampered with by other threads. If the verification passes, the conflict lock type at time t+T is replaced with a candidate lock type. This reduces race conditions in concurrent scenarios, ensures the atomicity and data consistency of conflict lock type updates, provides more reliable lock state management support for high-concurrency task scheduling, and reduces task execution errors or deadlocks caused by abnormal lock states.

[0080] According to embodiments of the present invention, the database task processing method may further include the following operations.

[0081] If the type verification result indicates that the conflict lock type has changed at time t+T, the changed conflict lock type is compared with the target lock type to obtain the comparison result; if it is determined that the target lock type does not exist in the changed conflict lock type indicated by the comparison result, the pending task is executed and the number of operations is updated.

[0082] Due to the parallel operations on lock states by multiple threads and the dynamic scheduling of lock-related tasks in high-concurrency scenarios, the conflicting lock type at time t+T may change. Specifically, within the time window from when the pending task reads the conflicting lock type at time t to when it verifies the lock type at time t+T, other threads may be processing other tasks in the queue. These tasks may trigger the update logic for the current conflicting lock type. For example, requesting a new mutex lock may add the corresponding type to the conflicting lock type set, or releasing lock resources may remove the relevant type from the conflicting lock type set, directly changing the lock state. Another example is when a new target operation request for the current lock type is added between time t and t+T, thus triggering the update logic for the corresponding conflicting lock type.

[0083] Therefore, the type verification results need to be evaluated. When the verification results clearly indicate that the conflict lock type at time t+T has changed, the changed conflict lock type data can be extracted and compared with the target lock type corresponding to the task to be processed. The inclusion relationship between the two is checked, and a comparison result is generated. After the comparison is completed, if it is confirmed that the changed conflict lock type does not contain the target lock type, it means that there is no risk of lock conflict in the current task execution. At this time, the execution flow of the task to be processed can still be started, and various operations can be carried out according to the preset task processing logic. At the same time, the current number of operations is updated in real time according to the task execution status and preset rules to ensure that the number of operations is consistent with the actual task execution.

[0084] If the comparison result indicates that a target lock type still exists among the conflicting lock types after the change, then continue to wait until the number of operations for the target operation of the current lock type is the preset value.

[0085] According to an embodiment of the present invention, when the type check detects that the conflict lock type has changed at time t+T, the changed conflict lock type can be compared with the target lock type to determine whether there is a risk of lock conflict if the pending task is executed. If no conflict risk is determined, the pending task can be executed and the number of operations updated synchronously, which reduces task execution conflicts caused by lock state changes and ensures task progress in conflict-free scenarios.

[0086] According to an embodiment of the present invention, the number of operations is updated based on the number of candidate operations to obtain an updated number of operations, which may include the following operations.

[0087] Based on the number of candidate operations and the tasks to be processed, the target number of operations is obtained; based on the number of operations read from the state management information at time t, it is verified whether the number of operations included in the state management information at time t+T has changed, and the number of operations is obtained; if it is determined that the number of operations at time t+T has not changed as indicated by the number of operations, the number of operations at time t+T is replaced with the target number of operations to obtain the updated number of operations.

[0088] When updating the number of operations, a target number of operations can be calculated based on the calculated number of candidate operations and the number of tasks to be processed. Next, the number of operations recorded at time t can be read from the state management information as a baseline. This baseline value is then used to verify the number of operations at time t+T in the state management information to determine if it has changed during this period, thus generating a quantity verification result. If the quantity verification result shows that the number of operations at time t+T has not changed compared to time t, the target number of operations at time t+T is then used to replace the number of operations at time t+T in the state management information, resulting in the updated number of operations.

[0089] It should be noted that the above verification and replacement operations are bound together and will not be interrupted or interfered with by other threads during execution.

[0090] If the quantity verification result indicates that the number of operations has changed at time t+T, it can be determined whether the current conflicting lock type is compatible with the target lock type, and if compatible, the pending task can be executed. If incompatible, the pending task can be temporarily suspended until the current conflicting lock type is compatible with the target lock type or the pending task is at the head of the waiting queue and the number of operations is the preset value.

[0091] According to embodiments of the present invention, the target number of operations is determined by combining the number of candidate operations with the number of tasks to be processed, and the consistency of the number of operations at time t+T is verified based on the number of operations at time t-t. Replacement updates are performed when it is confirmed that the number has not changed, thus improving the atomicity and accuracy of operation number updates. This reduces race conditions caused by multi-threaded parallel modification of operation numbers in high-concurrency scenarios and task scheduling deviations or resource allocation imbalances caused by asynchronous number updates.

[0092] According to an embodiment of the present invention, the status management information is obtained through the following operations.

[0093] Based on the table identifier included in the operation request, a primary storage address matching the field values ​​of the first range in the table identifier is determined from the table lock management information of the database. The table identifier is the identifier of the table where the target resource is located. Based on the primary storage address, a secondary storage address matching the field values ​​of the second range in the table identifier is determined from the table lock management information. Both the first and second ranges are pre-defined field ranges. Based on the secondary storage address, the status management information of the target resource is determined.

[0094] Figure 4 A schematic diagram of table lock management information according to an embodiment of the present invention is shown.

[0095] like Figure 4As shown, table lock management information can manage the status information of table locks for multiple tables in the database. Due to the structure of this table lock management information, hash collisions will not occur, so there is no need to use linked lists to manage resources, and no locking is required during operation. Table lock management information can also be called table lock (TABLE).

[0096] The management method for the status management information of each resource in the table lock management information is not limited; it can be achieved through a multi-level pointer structure. For example, the table lock management information can include two levels of pointers. A first-level pointer stores a first-level memory address, which points to a set of second-level pointers. The set of second-level pointers includes multiple second-level pointers, each storing a second-level memory address, which in turn points to the resource's status management information.

[0097] First-level and second-level pointers can be determined based on table identifiers. State management information includes conflicting lock types, lock counts, and wait queues. Multiple conflicting lock types are possible, and all lock types incompatible with the current lock type can be stored bit-by-bit. The number of bytes is not limited and can be 8 bits. This conflicting lock type can be read and modified through atomic operations. The lock count represents the number of operations that execute the target operation of the current lock type, used to store the count of locks already applied to the target resource.

[0098] In some embodiments, the first-level pointer has 1024 elements. Each element is a pointer to a second-level pointer. It is initialized to null. Each second-level pointer can also have 1024 elements. Each element is a pointer to state management information.

[0099] The first and second ranges of the table identifier are not limited and can be set according to the actual situation.

[0100] The target first-level pointer can be located in a set of multiple first-level pointers by using the field values ​​of the first range in the table identifier as an index, thereby determining the first-level storage address.

[0101] Accessing the corresponding set of secondary pointers via the primary storage address leads to this set, which stores multiple secondary pointers. Since each secondary pointer corresponding to the table containing the target resource corresponds to a value in the second-range field of the table identifier, the corresponding target secondary pointer is located within the set using the second-range field value of the table identifier as an index. Therefore, the status management information of the target resource can be accessed through the secondary storage address of the target secondary pointer.

[0102] According to embodiments of the present invention, by adding new state management information specifically for managing resource locking status information, and simultaneously adding new table lock management information to organize and manage the state management information using a multi-level pointer structure, no additional locking operations need to be performed on the locking status information of any resource during the unlocking process. This management structure cuts off the path to lock conflicts, reducing resource contention between threads during the unlocking process in multi-NUMA architectures and high-concurrency scenarios, and preventing cross-node contention from further exacerbating lock conflicts.

[0103] Compared to related technologies that rely on hash bucket architecture and bucket latch synchronization for table lock acquisition and release, this invention reduces the performance limitations of frequent contention for the same bucket latch by a large number of requests, improves the concurrent processing capability of the database system, reduces lock operation latency, and optimizes the overall system performance.

[0104] According to embodiments of the present invention, the database task processing method may further include the following operations.

[0105] In response to the absence of a secondary storage address in the table lock management information at time t, a candidate secondary storage address is obtained based on the field value of the second range in the table identifier; the presence of a secondary storage address in the table lock management information at time t+T is verified to obtain the address verification result; if the address verification result indicates that no secondary storage address exists at time t+T, the candidate secondary storage address is written into the table lock management information to obtain the secondary storage address.

[0106] When it is detected that there is no secondary storage address in the table lock management information at time t that corresponds to the value of the second range field of the table identifier, or that there is no secondary storage address that matches both the value of the second range field of the table identifier and the resource identifier of the target resource, a secondary pointer corresponding to the target resource is generated based on the value of the second range field through preset address allocation rules such as memory allocation and preset index calculation, and a candidate secondary storage address is obtained.

[0107] Furthermore, atomic operations are employed. At time t+T, the table lock management information is queried again to check if a target secondary pointer corresponding to the primary pointer exists. This involves verifying whether a secondary pointer written by another thread already exists, thus determining whether the secondary storage address has been written and generating an address verification result. If the verification result shows that a secondary storage address still does not exist, it means that no concurrent thread has completed the generation and address writing of the secondary pointer during this period. Therefore, the previously generated candidate secondary storage address is atomically written to the corresponding position in the table lock management information, thereby obtaining the secondary storage address of the target resource's state management information.

[0108] It is important to note that address verification and writing are bound together and will not be interrupted or interfered with by other threads during execution. In some embodiments, CAS atomic operations can be used to implement the creation of the second-level pointer and the writing of the second-level memory address.

[0109] According to an embodiment of the present invention, if the verification fails, it indicates that other concurrent transactions have already created a secondary pointer, and the newly created secondary pointer can be released. The secondary pointer created by another transaction can then be used directly. If the state management information of the target resource cannot be found on the secondary pointer, similar logic can be used to create the state management information. No locking is required during this process.

[0110] Furthermore, upon completion of each pending task for the target resource, the state management information of that resource can still be located, and the lock count updated. This process can utilize atomic decrement operations. Simultaneously, the conflict lock type is updated, which can be implemented using CAS operations. If the above update process fails, it can be retried.

[0111] According to embodiments of the present invention, the lock-free design of delayed verification and atomic writing reduces the conflict problem of multiple threads repeatedly creating secondary storage addresses for the same table identifier second range field value in multi-concurrency scenarios, and can ensure the uniqueness and security of address creation without relying on additional latches or synchronization mechanisms.

[0112] Based on the above-described database task processing method, this invention also provides a database task processing apparatus. The following will be combined with... Figure 5 The device is described in detail.

[0113] Figure 5 A structural block diagram of a database task processing apparatus according to an embodiment of the present invention is shown.

[0114] like Figure 5 As shown, the database task processing device 500 of this embodiment may include: a determination module 510 and a processing module 520.

[0115] The determination module 510 is used to, in response to receiving an operation request for a target resource, determine from the target resource's status management information the conflicting lock type that is incompatible with the target resource's current lock type and the number of target operations that perform the current lock type.

[0116] The processing module 520 is used to add the pending task generated based on the target lock type and the operation request to the waiting queue in response to the determination that there is a target lock type to be added in the conflict lock type. When the pending task is at the first position in the waiting queue and the number of operations is a preset value, the pending task is executed.

[0117] According to an embodiment of the present invention, when the task to be processed is at the head of the waiting queue and the number of operations is a preset value, the database task processing device 500 further includes: a first update module and a second update module.

[0118] The first update module is used to set the target lock type as the new current lock type.

[0119] The second update module updates the conflicting lock type and number of operations based on the new current lock type.

[0120] According to an embodiment of the present invention, the second update module includes: a first update submodule, a quantity determination submodule, and a second update submodule.

[0121] The first update submodule is used to determine, based on the new current lock type, candidate lock types that are incompatible with the new current lock type from the preset lock compatibility information, and update the conflicting lock type to the candidate lock type to obtain the updated conflicting lock type.

[0122] The quantity determination submodule is used to determine the number of candidate operations based on the number of compatible pending tasks in the waiting queue that are located between pending tasks and target mutually exclusive pending tasks.

[0123] The second update submodule is used to update the number of operations based on the number of candidate operations, obtaining the updated number of operations. The target mutex task is the mutex task in the waiting queue whose execution order is closest to the current task. The updated conflict lock type includes the lock type of the mutex task but excludes the lock type of the compatible task.

[0124] According to an embodiment of the present invention, the first update submodule includes: a first update unit, a first verification unit, and a second update unit.

[0125] The first update unit is used to update the conflict lock type read from the state management information at time t to the candidate lock type.

[0126] The first verification unit is used to verify whether the conflict lock type at time t+T, which is included in the state management information, has changed based on the conflict lock type at time t, and obtain the type verification result, where both t and T are greater than 0.

[0127] The second update unit is used to replace the conflict lock type at time t+T with the candidate lock type to obtain the updated conflict lock type, provided that the conflict lock type represented by the type verification result has not changed.

[0128] According to an embodiment of the present invention, the database task processing device 500 further includes a comparison module and an execution module.

[0129] The comparison module is used to compare the changed conflict lock type with the target lock type when the type verification result indicates that the conflict lock type has changed at time t+T, and obtain the comparison result.

[0130] The execution module is used to execute pending tasks and update the number of operations if it is determined that the target lock type does not exist in the conflict lock types after the comparison result is changed.

[0131] According to an embodiment of the present invention, the second update submodule includes: a quantity determination unit, a second verification unit, and a third update unit.

[0132] The quantity determination unit is used to determine the target number of operations based on the number of candidate operations and the tasks to be processed.

[0133] The second verification unit is used to verify whether the number of operations included in the state management information at time t+T has changed based on the number of operations read from the state management information at time t, and to obtain the number verification result.

[0134] The third update unit is used to replace the number of operations at time t+T with the target number of operations to obtain the updated number of operations, provided that the quantity verification result indicates that the number of operations at time t+T has not changed.

[0135] According to an embodiment of the present invention, the database task processing device 500 further includes: a first address determination module, a second address determination module, and an information determination module.

[0136] The first address determination module is used to determine the first-level storage address that matches the field value of the first range in the table identifier from the table lock management information of the database, based on the table identifier included in the operation request. The table identifier is the identifier of the table where the target resource is located.

[0137] The second address determination module is used to determine, based on the first-level storage address, a second-level storage address that matches the field value of the second range in the table identifier from the table lock management information. Both the first and second ranges are pre-defined field ranges.

[0138] The information determination module is used to determine the status management information of the target resource based on the secondary storage address.

[0139] According to an embodiment of the present invention, the database task processing device 500 further includes: a first address generation module, an address verification module, and an address writing module.

[0140] The first address generation module is used to obtain candidate secondary storage addresses based on the field values ​​of the second range in the table identifier in response to the absence of a secondary storage address in the table lock management information at time t.

[0141] The address verification module is used to verify whether there is a secondary storage address in the timetable lock management information at time t+T, and obtain the address verification result.

[0142] The address writing module is used to write the candidate secondary storage address into the table lock management information when the address verification result is that there is no secondary storage address at time t+T, so as to obtain the secondary storage address.

[0143] According to embodiments of the present invention, any plurality of modules in the determining module 510 and the processing module 520 may be combined into one module, or any one of these modules may be split into multiple modules. Alternatively, at least a portion of the functionality of one or more of these modules may be combined with at least a portion of the functionality of other modules and implemented in one module. According to embodiments of the present invention, at least one of the determining module 510 and the processing module 520 may be at least partially implemented as hardware circuitry, such as a field-programmable gate array (FPGA), a programmable logic array (PLA), a system-on-a-chip, a system-on-a-substrate, a system-on-package, an application-specific integrated circuit (ASIC), or any other reasonable means of integrating or packaging circuitry, or implemented in software, hardware, or firmware, or in any suitable combination of any of these three implementation methods. Alternatively, at least one of the determining module 510 and the processing module 520 may be at least partially implemented as a computer program module, which, when run, can perform corresponding functions.

[0144] Figure 6 A block diagram of an electronic device suitable for implementing a database task processing method according to an embodiment of the present invention is shown.

[0145] like Figure 6 As shown, the electronic device 600 according to an embodiment of the present invention may include the following operations: A processor 601, which can perform various appropriate actions and processes according to a program stored in a read-only memory ROM 602 or a program loaded from a storage portion 608 into a random access memory RAM 603. The processor 601 may include, for example, the following operations: a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or an associated chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 601 may also include the following operations: onboard memory for caching purposes. The processor 601 may include the following operations: a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present invention.

[0146] RAM 603 stores various programs and data required for the operation of electronic device 600. Processor 601, ROM 602, and RAM 603 are interconnected via bus 604. Processor 601 executes various operations of the method flow according to embodiments of the present invention by executing programs in ROM 602 and / or RAM 603. It should be noted that the programs may also be stored in one or more memories other than ROM 602 and RAM 603. Processor 601 may also execute various operations of the method flow according to embodiments of the present invention by executing programs stored in said one or more memories.

[0147] According to an embodiment of the present invention, the electronic device 600 may further include the following operations: An input / output (I / O) interface 605, which is also connected to a bus 604. The electronic device 600 may further include one or more of the following components connected to the input / output (I / O) interface 605: An input section 606, such as a keyboard, mouse, etc.; an output section 607, such as a cathode ray tube (CRT), liquid crystal display (LCD), and a speaker; a storage section 608, such as a hard disk; and a communication section 609, such as a network interface card (LAN card, modem, etc.). The communication section 609 performs communication processing via a network such as the Internet. A drive 610 is also connected to the input / output (I / O) interface 605 as needed. A removable medium 611, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., is installed on the drive 610 as needed so that computer programs read from it can be installed into the storage section 608 as needed.

[0148] The present invention also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or it may exist independently and not assembled into the device / apparatus / system. The computer-readable storage medium carries one or more programs, which, when executed, implement the method according to the embodiments of the present invention.

[0149] According to embodiments of the present invention, a computer-readable storage medium may be a non-volatile computer-readable storage medium, and may include, for example, the following operations: but not limited to: portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In the present invention, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. For example, according to embodiments of the present invention, a computer-readable storage medium may include the following operations: ROM 602 and / or RAM 603 and / or one or more memories other than ROM 602 and RAM 603 described above.

[0150] Embodiments of the present invention may further include the following operations. A computer program product may include the following operations: A computer program containing program code for performing the methods shown in the flowchart. When the computer program product is run on a computer system, the program code is used to enable the computer system to implement the database task processing method provided in the embodiments of the present invention.

[0151] When the computer program is executed by the processor 601, it performs the functions defined in the system / apparatus of this invention. According to embodiments of the invention, the systems, apparatuses, modules, units, etc., described above can be implemented by computer program modules.

[0152] In one embodiment, the computer program may rely on a tangible storage medium such as an optical storage device or a magnetic storage device. In another embodiment, the computer program may also be transmitted and distributed in the form of signals over a network medium, and downloaded and installed via communication section 609, and / or installed from removable medium 611. The program code contained in the computer program can be transmitted using any suitable network medium, and may include, but is not limited to, wireless, wired, etc., or any suitable combination thereof.

[0153] In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 609, and / or installed from the removable medium 611. When the computer program is executed by the processor 601, it performs the functions defined in the system of this embodiment of the invention. According to embodiments of the invention, the systems, devices, apparatuses, modules, units, etc., described above can be implemented by computer program modules.

[0154] According to embodiments of the present invention, program code for executing the computer programs provided in the embodiments of the present invention can be written in any combination of one or more programming languages. Specifically, these computational programs can be implemented using high-level procedural and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages ​​can include, but are not limited to, languages ​​such as Java, C++, Python, "C", or similar programming languages. The program code can be executed entirely on the user's computing device, partially on the user's device, partially on a remote computing device, or entirely on a remote computing device or server. In cases involving remote computing devices, the remote computing device can be connected to the user's computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or it can be connected to an external computing device (e.g., via the Internet using an Internet service provider).

[0155] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram or flowchart, and combinations of blocks in a block diagram or flowchart, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0156] Those skilled in the art will understand that the features described in the various embodiments of the present invention can be combined and / or combined in various ways, even if such combinations or combinations are not explicitly described in the present invention. In particular, the features described in the various embodiments of the present invention can be combined and / or combined in various ways without departing from the spirit and teachings of the present invention. All such combinations and / or combinations fall within the scope of the present invention.

[0157] The embodiments of the present invention have been described above. However, these embodiments are merely illustrative and not intended to limit the scope of the invention. Although various embodiments have been described above, this does not mean that the measures in the various embodiments cannot be used advantageously in combination. Various substitutions and modifications can be made by those skilled in the art without departing from the scope of the invention, and all such substitutions and modifications should fall within the scope of the invention.

Claims

1. A database task processing method, characterized in that, The method includes: In response to receiving an operation request for a target resource, the conflicting lock type that is incompatible with the current lock type of the target resource and the number of operations that perform the target operation of the current lock type are determined from the state management information of the target resource; In response to determining that there is a target lock type to be added among the conflict lock types, which is determined based on the operation type of the operation request, the pending task generated based on the target lock type and the operation request is added to the waiting queue, so that the pending task is executed when the pending task is at the first position in the waiting queue and the number of operations is a preset value; The status management information is obtained through the following operations: Based on the table identifier included in the operation request, a first-level storage address matching the field value of the first range in the table identifier is determined from the table lock management information of the database. The table identifier is the identifier of the table where the target resource is located. Based on the primary storage address, a secondary storage address matching the field value of the second range in the table identifier is determined from the table lock management information. Both the first range and the second range are pre-defined field ranges. Based on the secondary storage address, the status management information of the target resource is determined.

2. The method according to claim 1, characterized in that, When the task to be processed is at the head of the waiting queue and the number of operations of the target operation is a preset value, the method further includes: Set the target lock type as the new current lock type; The conflicting lock type and the number of operations are updated based on the new current lock type.

3. The method according to claim 2, characterized in that, The step of updating the conflicting lock type and the number of operations based on the new current lock type includes: Based on the new current lock type, candidate lock types that are incompatible with the new current lock type are determined from the preset lock compatibility information, and the conflicting lock type is updated to the candidate lock type to obtain the updated conflicting lock type; The number of candidate operations is determined based on the number of compatible pending tasks in the waiting queue that are located between the pending tasks and the target mutually exclusive pending tasks. Based on the number of candidate operations, the number of operations is updated to obtain the updated number of operations; Wherein, the target mutually exclusive pending task is the one whose execution order is closest to the pending task among the mutually exclusive pending tasks included in the waiting queue, and the updated conflict lock type includes the lock type of the mutually exclusive pending task, but does not include the lock type of the compatible pending task.

4. The method according to claim 3, characterized in that, The step of updating the conflicting lock type to the candidate lock type to obtain the updated conflicting lock type includes: The conflict lock type read from the state management information at time t is updated to the candidate lock type; Based on the conflict lock type at time t, verify whether the conflict lock type at time t+T included in the state management information has changed, and obtain the type verification result, where t and T are both greater than 0; If the type verification result indicates that the conflict lock type at time t+T has not changed, the candidate lock type is used to replace the conflict lock type at time t+T to obtain the updated conflict lock type.

5. The method according to claim 4, characterized in that, The method further includes: If the type verification result indicates that the conflict lock type at time t+T has changed, the changed conflict lock type is compared with the target lock type to obtain the comparison result; If it is determined that the target lock type does not exist in the conflict lock types represented by the comparison results after the change, the pending task is executed and the number of operations is updated.

6. The method according to claim 3, characterized in that, The step of updating the number of operations based on the number of candidate operations to obtain the updated number of operations includes: Based on the number of candidate operations and the number of tasks to be processed, the target number of operations is obtained; Based on the number of operations read from the state management information at time t, verify whether the number of operations included in the state management information at time t+T has changed, and obtain the number verification result; If the quantity verification result indicates that the number of operations at time t+T has not changed, the target number of operations is used to replace the number of operations at time t+T to obtain the updated number of operations.

7. The method according to claim 1, characterized in that, The method further includes: In response to the absence of the secondary storage address in the table lock management information at time t, a candidate secondary storage address is obtained based on the field value of the second range in the table identifier; Verify whether the secondary storage address exists in the table lock management information at time t+T, and obtain the address verification result; If the address verification result indicates that the secondary storage address does not exist at time t+T, the candidate secondary storage address is written into the table lock management information to obtain the secondary storage address.

8. A task processing device, characterized in that, The device includes: The determination module is used to, in response to receiving an operation request for a target resource, determine from the state management information of the target resource the conflicting lock type that is incompatible with the current lock type of the target resource and the number of operations that perform the target operation of the current lock type; The processing module is configured to, in response to determining that there is a target lock type to be added among the conflict lock types based on the operation type of the operation request, add the pending task generated based on the target lock type and the operation request to the waiting queue, so as to execute the pending task when the pending task is at the first position in the waiting queue and the number of operations is a preset value; The device further includes: a first address determination module, configured to determine, based on the table identifier included in the operation request, a first-level storage address that matches a field value within a first range in the table identifier from the table lock management information of the database, wherein the table identifier is the identifier of the table where the target resource is located; The second address determination module is used to determine, based on the first-level storage address, a second-level storage address that matches the field value of the second range in the table identifier from the table lock management information, wherein the first range and the second range are both preset field ranges; The information determination module is used to determine the status management information of the target resource based on the secondary storage address.

9. An electronic device, comprising: One or more processors; Memory, used to store one or more computer programs. The characteristic feature is that the one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Controlling atomic updates of indexes using hardware transactional memory

    CN107667364A

  • Distributed event processing method and electronic equipment

    CN121349737A