Data lock management method and device, computer equipment and storage medium

By deducting the thread intervals in the computer storage system and locking step by step, the problem of locking in the prior art is solved, and efficient data access concurrency performance and resource utilization are achieved.

CN120179426APending Publication Date: 2025-06-20天津中科曙光存储科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311739938.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-18
Publication Date
2025-06-20

AI Technical Summary

Technical Problem

The implementation method of locks in the prior art will reduce data access efficiency and will not effectively improve the concurrency performance and resource utilization of data access.

Method used

By determining the access address and accessing and locking status updates to the target granularity interval when receiving the data processing request, the detailed division of thread intervals and locking step by step is realized, ensuring that the data methods of each granularity interval are not affected by each other, allowing data within the same thread interval to be processed in parallel.

Benefits of technology

It improves the efficiency and concurrency performance of data access, and on the basis of ensuring the consistency of data access, maximizes the utilization rate of thread interval resources, reduces the competition for accessing the same resources at the same time, and improves the system throughput and response speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120179426A_ABST
    Figure CN120179426A_ABST
Patent Text Reader

Abstract

The invention relates to a data lock management method and device, computer equipment and a storage medium, and the method comprises the steps: determining an access address according to a data processing request under the condition that the data processing request is received, and then accessing a target granularity interval corresponding to the access address according to the data processing request. And updating the lock state of the target granularity interval, and updating the lock state of the thread interval where the target granularity interval is located. In the method, the thread interval is divided into a plurality of granularity intervals, and when the thread interval is subjected to data access, the granularity interval where the to-be-accessed data is located and the corresponding thread interval are locked step by step, so that the thread interval is refined, and meanwhile, each granularity interval is locked; the data methods of each granularity interval are not mutually influenced, the data in the same thread interval are processed in parallel, and the data access efficiency and concurrency performance are improved to a certain extent.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer storage technology, and in particular, to a method and device for managing data locks, a computer device, and a storage medium. Background Art

[0002] In the storage system of a computer device, the key operation is the read and write access to data. In a large number of frequent read and write accesses, locks are often needed to control concurrency of reading and writing and ensure data consistency. Therefore, in the process of data access, the implementation mechanism of locks becomes a key factor affecting the efficiency of system data access. Currently, the implementation mechanism of locks generally serially executes multiple access requests within a thread, and all access requests within the thread compete for the same thread lock for data read and write operations.

[0003] However, the above-mentioned lock implementation method reduces data access efficiency. Summary of the Invention

[0004] Based on this, it is necessary to provide a method and device for managing data locks, a computer device, and a storage medium that can improve data access for the above technical problems.

[0005] In a first aspect, this application provides a method for managing data locks, the method including:

[0006] When receiving a data processing request, determining an access address according to the data processing request;

[0007] Accessing a target granularity interval corresponding to the access address according to the data processing request, updating the lock status of the target granularity interval, and updating the lock status of the thread interval where the target granularity interval is located.

[0008] The method for managing data locks provided by the embodiments of this application, when receiving a data processing request, first determines an access address according to the data processing request, then accesses a target granularity interval corresponding to the access address according to the data processing request, updates the lock status of the target granularity interval, and updates the lock status of the thread interval where the target granularity interval is located. In the above method, the thread interval is divided into multiple granularity intervals, and when accessing data in the thread interval, the granularity interval where the data to be accessed is located and the corresponding thread interval are locked step by step. While realizing the refinement of the thread interval, by locking each granularity interval, the data access of each granularity interval is not affected by each other, enabling parallel processing of data within the same thread interval, and improving the efficiency and concurrency performance of data access to a certain extent. Moreover, compared with the existing method of only locking the thread interval, the above method maximally improves the utilization rate of thread interval resources while ensuring data access consistency.

[0009] In one embodiment, a thread range includes a plurality of item ranges, and each item range includes a plurality of granularity ranges. Updating the lock state of the thread range where the target granularity range is located includes:

[0010] Updating the lock state of the target item range according to the updated lock state of the target granularity range and the lock states of other granularity ranges; the target item range is the item range where the target granularity range is located;

[0011] Updating the lock state of the thread range where the target granularity range is located according to the updated lock state of the target item range and the lock states of other item ranges.

[0012] In one embodiment, updating the lock state of the target item range according to the updated lock state of the target granularity range and the lock states of other granularity ranges includes:

[0013] If the updated lock state of the target granularity range and the lock states of other granularity ranges both indicate a locked state, then update the lock state of the target item range to the locked state;

[0014] If there is a situation where the updated lock state of the target granularity range and the lock states of other granularity ranges indicate an unlocked state, then update the lock state of the target item range to the unlocked state.

[0015] The method described in the embodiments of the present application divides a thread range into a plurality of item ranges, and then divides each item range into a plurality of granularity ranges. Data within the same item range can be processed in parallel, which can greatly improve the efficiency of data access and concurrent performance, and on the basis of ensuring data consistency, maximize the utilization of resources. In addition, by updating the lock states of the locks of each range, the competition situation caused by simultaneous access to the same resource can be reduced, and the throughput and response speed of the system are improved.

[0016] In one embodiment, a thread range includes a plurality of bucket ranges, and each bucket range includes a plurality of item ranges. Updating the lock state of the thread range where the target granularity range is located according to the updated lock state of the target item range and the lock states of other item ranges includes:

[0017] Updating the lock state of the target bucket range according to the updated lock state of the target item range and the lock states of other item ranges; the target bucket range is the bucket range where the target item range is located;

[0018] Updating the lock state of the thread range where the target granularity range is located according to the updated lock state of the target bucket range and the lock states of other bucket ranges.

[0019] In one embodiment, updating the lock state of the target bucket interval according to the lock state of the updated target item interval and the lock states of other item intervals includes:

[0020] If the lock states of both the updated target item interval and other item intervals indicate a locked state, then update the lock state of the target bucket interval to the locked state;

[0021] If there is a situation where the lock state of the updated target item interval or the lock states of other item intervals indicate an unlocked state, then update the lock state of the target bucket interval to the unlocked state.

[0022] In one embodiment, updating the lock state of the thread interval where the target granularity interval is located according to the lock state of the updated target bucket interval and the lock states of other bucket intervals includes:

[0023] If the lock states of both the updated target bucket interval and other bucket intervals indicate a locked state, then update the lock state of the thread interval to the locked state;

[0024] If there is a situation where the lock state of the updated target bucket interval or the lock states of other bucket intervals indicate an unlocked state, then update the lock state of the thread interval to the unlocked state.

[0025] The method described in the embodiments of the present application divides the thread interval into multiple bucket intervals, then divides each bucket interval into multiple item intervals, and divides each item interval into multiple granularity intervals. Data within the same item interval can be processed in parallel, which can greatly improve the efficiency of data access and concurrency performance, and on the basis of ensuring data consistency, maximize the utilization of resources. In addition, by updating the lock states of the locks of each interval, the competition situation caused by simultaneous access to the same resource can be reduced, and the throughput and response speed of the system are improved.

[0026] In one embodiment, the method further includes:

[0027] Determine the lock state of the target granularity interval corresponding to the access address according to a preset mapping relationship; the preset mapping relationship includes the corresponding relationship between the lock states of each type of interval and the addresses of each type of interval;

[0028] In the case where the lock state indicates that the target granularity interval is in an unlocked state, perform the step of accessing the target granularity interval corresponding to the access address according to the data processing request.

[0029] The method described in the embodiments of the present application can accurately determine the target granularity interval corresponding to the access address by constructing a preset mapping relationship, ensure effective operation on the target granularity interval, contribute to precise control of concurrent access, avoid multiple threads accessing different granularity intervals simultaneously, and improve the concurrency of the system and the efficiency of data processing.

[0030] In one embodiment, the thread interval includes multiple bucket intervals, each bucket interval includes multiple item intervals, and each item interval includes multiple granularity intervals. The method further includes:

[0031] Update the preset mapping relationship according to the lock status of the updated bucket interval, the lock status of the updated item interval, and the lock status of the updated granularity interval.

[0032] The method described in the embodiments of the present application can ensure the consistency between the preset mapping relationship and the actual lock status by updating the preset mapping relationship.

[0033] In one embodiment, the method further includes:

[0034] Store the updated preset mapping relationship in the cache.

[0035] The method described in the embodiments of the present application improves the efficiency of data processing by setting cache lines and saving other interval locks to the cache when acquiring one of the interval locks.

[0036] In a second aspect, the present application further provides a data lock management device, which includes:

[0037] A first determination module, configured to determine an access address according to a data processing request when receiving the data processing request;

[0038] A first update module, configured to access the target granularity interval corresponding to the access address according to the data processing request, update the lock status of the target granularity interval, and update the lock status of the thread interval where the target granularity interval is located.

[0039] In a third aspect, the present application further provides a computer device, which includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0040] When receiving a data processing request, determine an access address according to the data processing request;

[0041] Access the target granularity interval corresponding to the access address according to the data processing request, update the lock status of the target granularity interval, and update the lock status of the thread interval where the target granularity interval is located.

[0042] Fourthly, the present application also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:

[0043] In the case of receiving a data processing request, determine an access address according to the data processing request;

[0044] Access the target granularity interval corresponding to the access address according to the data processing request, update the lock state of the target granularity interval, and update the lock state of the thread interval where the target granularity interval is located.

[0045] Fifthly, the present application also provides a computer program product, which includes a computer program. When the computer program is executed by a processor, the following steps are implemented:

[0046] In the case of receiving a data processing request, determine an access address according to the data processing request;

[0047] Access the target granularity interval corresponding to the access address according to the data processing request, update the lock state of the target granularity interval, and update the lock state of the thread interval where the target granularity interval is located.

[0048] In the above data lock management method, device, computer device and storage medium, the method first determines an access address according to the data processing request when receiving the data processing request, and then accesses the target granularity interval corresponding to the access address according to the data processing request, and updates the lock state of the target granularity interval, and updates the lock state of the thread interval where the target granularity interval is located. In the above method, the thread interval is divided into multiple granularity intervals, and when accessing data in the thread interval, the granularity interval where the data to be accessed is located and the corresponding thread interval are locked step by step, realizing the refinement of the thread interval. At the same time, by locking each granularity interval, the data methods of each granularity interval do not affect each other, enabling parallel processing of data within the same thread interval, and improving the data access efficiency and concurrency performance to a certain extent. Moreover, compared with the existing method of only locking the thread interval, the above method maximally improves the utilization rate of thread interval resources on the basis of ensuring data access consistency. Description of the Drawings

[0049] Figure 1 It is the internal structure diagram of a computer device in an embodiment;

[0050] Figure 2 It is the flowchart of the data lock management method in an embodiment;

[0051] Figure 3Schematic flowchart of the management method of data lock in another embodiment;

[0052] Figure 4 Schematic flowchart of the management method of data lock in another embodiment;

[0053] Figure 5 Schematic flowchart of the management method of data lock in another embodiment;

[0054] Figure 6 Schematic flowchart of the management method of data lock in another embodiment;

[0055] Figure 7 Schematic flowchart of the management method of data lock in another embodiment;

[0056] Figure 8 Schematic flowchart of the management method of data lock in another embodiment;

[0057] Figure 9 Schematic structural diagram of data lock in one embodiment;

[0058] Figure 10 Schematic flowchart of the management method of data lock in another embodiment;

[0059] Figure 11 Schematic flowchart of the management method of data lock in another embodiment;

[0060] Figure 12 Schematic flowchart of the management method of data lock in another embodiment;

[0061] Figure 13 Schematic flowchart of the management method of data lock in another embodiment;

[0062] Figure 14 Schematic flowchart of the management method of data lock in another embodiment;

[0063] Figure 15 Schematic block diagram of the management device of data lock in one embodiment;

[0064] Figure 16 Schematic block diagram of the management device of data lock in another embodiment;

[0065] Figure 17 Schematic block diagram of the management device of data lock in another embodiment;

[0066] Figure 18 Schematic block diagram of the management device of data lock in another embodiment;

[0067] Figure 19Structural block diagram of the management device for data locks in another embodiment;

[0068] Figure 20 Structural block diagram of the management device for data locks in another embodiment;

[0069] Figure 21 Structural block diagram of the management device for data locks in another embodiment. Detailed implementation manners

[0070] In order to make the objectives, technical solutions and advantages of the present application more clear and understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0071] In the storage system of a computer device, the key operations are reading and writing access to data. In a large number of frequent read and write accesses, it is often necessary to use locks to control read and write concurrency and ensure data consistency. Therefore, in the process of data access, the implementation mechanism of locks becomes a key factor affecting the data access efficiency of the system. Currently, the implementation mechanism of locks generally serially executes multiple access requests within a thread, and all access requests within the thread compete for the same thread lock for data read and write operations. However, the above-mentioned lock implementation method will reduce data access efficiency.

[0072] The present application provides a method for managing data locks, aiming to solve the above technical problems. The following embodiments will specifically illustrate the method for managing data locks described in the present application.

[0073] The method for managing data locks provided by the embodiments of the present application can be applied to a computer device as shown in Figure 1 The computer device can be a terminal or a server, and its internal structural diagram can be as shown in Figure 1As shown in the figure. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface, the display unit, and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals in a wired or wireless manner, and the wireless manner can be achieved through WIFI, a mobile cellular network, NFC (Near Field Communication), or other technologies. When the computer program is executed by the processor, it implements a method for managing data locks. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device can be a touch layer covering the display screen, or a button, a trackball, or a touchpad provided on the computer device housing, or an external keyboard, touchpad, or mouse, etc.

[0074] Those skilled in the art can understand that Figure 1 the structure shown in the figure is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.

[0075] In one embodiment, as Figure 2 shown, a method for managing data locks is provided. Taking the computer device in Figure 1 as an example for illustration, the method includes the following steps:

[0076] S101, in the case of receiving a data processing request, determine an access address according to the data processing request.

[0077] Among them, the data processing request includes a data read request or a data write request. The access address includes the positions of the thread interval and the target granularity interval requested by the data processing request, such as the serial number or number of the thread interval and the target granularity interval.

[0078] In the embodiments of the present application, a computer device may pre-divide a thread interval into multiple granularity intervals, and set corresponding locks for the thread interval and each granularity interval to indicate whether the interval is valid. When a client or other data source needs to write data to the storage system or read data from the storage system, a data processing request can be sent to the computer device where the storage system is located. After receiving the data processing request, the computer device can parse the data processing request, extract relevant information of the data sorting request, for example, extract the request type, data processing operation, access address, etc., and then obtain the access address corresponding to the data processing request.

[0079] S102, access the target granularity interval corresponding to the access address according to the data processing request, update the lock state of the target granularity interval, and update the lock state of the thread interval where the target granularity interval is located.

[0080] Among them, the thread interval includes multiple target granularity intervals, and corresponding locks are set for both the thread interval and the target granularity interval. The lock state includes an unlocked state and a locked state; the unlocked state indicates that the current interval is idle or valid, and at this time the interval can be accessed; the locked state indicates that the current interval is not idle or invalid, and at this time the interval cannot be accessed. Further, the locked state can also include the read state or the write state of the current interval.

[0081] In the embodiments of the present application, after the computer device obtains the access address corresponding to the data processing request, it can determine the identifier of the target granularity interval to be accessed according to the access address, then determine the target granularity interval to be accessed according to the identifier of the target granularity interval, and further determine whether the target granularity interval is idle. If the target granularity interval is idle, it can access the target granularity interval according to the operation indicated by the data request. When accessing the target granularity interval, the lock state corresponding to the target granularity interval can be updated. Specifically, the lock state can be updated from the unlocked state to the locked state. Optionally, the lock state can also be updated from the unlocked state to the read state or the write state. After the lock state of the target granularity interval is updated, it can be further confirmed whether the lock state of the thread interval needs to be updated according to the lock states of the target granularity intervals, and if it needs to be updated, the lock state of the thread interval is updated. For example, the lock state of the thread interval is updated from the unlocked state to the locked state.

[0082] The data lock management method provided by the embodiments of the present application, when receiving a data processing request, first determines an access address according to the data processing request, then accesses the target granularity interval corresponding to the access address according to the data processing request, updates the lock status of the target granularity interval, and updates the lock status of the thread interval where the target granularity interval is located. In the above method, the thread interval is divided into multiple granularity intervals, and when accessing data in the thread interval, the granularity interval where the data to be accessed is located and the corresponding thread interval are locked step by step. While realizing the refinement of the thread interval, by locking each granularity interval, the data methods of each granularity interval are not affected by each other, enabling parallel processing of data within the same thread interval, and improving the data access efficiency and concurrency performance to a certain extent. Moreover, compared with the existing method of only locking the thread interval, the above method maximally improves the utilization rate of thread interval resources while ensuring data access consistency.

[0083] In one embodiment, a specific implementation manner for updating the lock status of the thread interval is further provided, as Figure 3 shown, the "updating the lock status of the thread interval where the target granularity interval is located" in the above step S102 includes:

[0084] S201, updating the lock status of the target item interval according to the updated lock status of the target granularity interval and the lock status of other granularity intervals.

[0085] Wherein, the target item interval is the item interval where the target granularity interval is located. The thread interval includes multiple item intervals, and each item interval includes multiple granularity intervals.

[0086] In the embodiments of the present application, after the computer device updates the target granularity interval, it can obtain the updated lock status of the target granularity interval from the database or memory, and obtain the lock status of other granularity intervals except the target granularity interval in the item interval where the target granularity interval is located in the thread interval. Then, according to the updated lock status of the target granularity interval and the lock status of other granularity intervals, the lock status of the item interval where the target granularity interval is located is updated to obtain the lock status of the target item interval. Specifically, a logical operation can be performed on the updated lock status of the target granularity interval and the lock status of other granularity intervals to obtain the updated lock status of the target item interval. Optionally, the updated lock status of the target granularity interval and the lock status of other granularity intervals can also be input into a pre-set function for calculation to obtain the updated lock status of the target item interval.

[0087] Furthermore, as Figure 4 shown, the above step S201 "updating the lock status of the target item interval according to the updated lock status of the target granularity interval and the lock status of other granularity intervals" includes:

[0088] In S2010, if the lock status of the updated target granularity interval and the lock statuses of other granularity intervals both indicate the locked status, then update the lock status of the target item interval to the locked status.

[0089] In the embodiments of the present application, when the computer device determines that the lock status of the updated target granularity interval and the lock statuses of other granularity intervals both indicate the locked status, it can update the lock status of the target item interval from the unlocked status to the locked status. Optionally, it can also update the lock status from the unlocked status to the read status or the write status according to the specific data operation situation.

[0090] In S2011, if there is a situation where the lock status of the updated target granularity interval or the lock statuses of other granularity intervals indicates the unlocked status, then update the lock status of the target item interval to the unlocked status.

[0091] In the embodiments of the present application, when the computer device determines that there is a situation where the lock status of the updated target granularity interval or the lock statuses of other granularity intervals indicates the unlocked status, it can update the lock status of the target item interval to the unlocked status.

[0092] In S202, update the lock status of the thread interval where the target granularity interval is located according to the lock status of the updated target item interval and the lock statuses of other item intervals.

[0093] In the embodiments of the present application, after the computer device obtains the lock status of the updated target item interval, it can obtain the lock statuses of other item intervals within the thread interval except the target item interval from the database or memory, and then update the thread interval where the target item interval is located according to the lock status of the updated target item interval and the lock statuses of other item intervals to obtain the lock status of the updated target thread interval. Specifically, logical operations can be performed on the lock status of the updated target item interval and the lock statuses of other item intervals to obtain the lock status of the target thread interval. Optionally, the lock status of the updated target item interval and the lock statuses of other item intervals can also be input into a pre-set function for calculation to obtain the lock status of the target thread interval.

[0094] The method described in the embodiments of the present application divides the thread interval into multiple item intervals, and then divides each item interval into multiple granularity intervals. The data within the same item interval can be processed in parallel, which can greatly improve the data access efficiency and concurrency performance, and on the basis of ensuring data consistency, make the most of resources to the greatest extent. In addition, by updating the lock statuses of each interval lock, the competition situation caused by simultaneous access to the same resource can be reduced, and the throughput and response speed of the system are improved.

[0095] In one embodiment, a specific implementation manner for updating the lock state of a thread interval according to the lock state of a bucket interval is further provided, as follows Figure 5 As shown, the step S202 of "updating the lock state of the thread interval where the target granularity interval is located according to the lock state of the updated target item interval and the lock states of other item intervals" includes:

[0096] S401. Update the lock state of the target bucket interval according to the lock state of the updated target item interval and the lock states of other item intervals.

[0097] Among them, the target bucket interval is the bucket interval where the target item interval is located. A thread interval includes multiple bucket intervals, and each bucket interval includes multiple item intervals.

[0098] In the embodiment of the present application, after the computer device updates the target item interval, it can obtain the lock state of the updated target item interval from the database or memory, and obtain the lock states of other item intervals in the bucket interval where the target item interval is located in this thread interval except the target item interval. Then, according to the lock state of the updated target item interval and the lock states of other item intervals, update the lock state of the bucket interval where the target item interval is located to obtain the lock state of the updated target bucket interval. Specifically, a logical operation can be performed on the lock state of the updated target item interval and the lock states of other item intervals to obtain the lock state of the updated target bucket interval. Optionally, the lock state of the updated target item interval and the lock states of other item intervals can also be input into a pre-set function for calculation to obtain the lock state of the updated target bucket interval.

[0099] Further, as Figure 6 shown, the above step S401 of "updating the lock state of the target bucket interval according to the lock state of the updated target item interval and the lock states of other item intervals" includes:

[0100] S4010. If the lock states of the updated target item interval and other item intervals both indicate the locked state, update the lock state of the target bucket interval to the locked state.

[0101] In the embodiment of the present application, when the computer device determines that the lock states of the updated target item interval and other item intervals both indicate the locked state, it can update the lock state of the target bucket interval from the unlocked state to the locked state.

[0102] S4011. If there is a situation where the lock state indicates the unlocked state among the lock states of the updated target item interval and other item intervals, update the lock state of the target bucket interval to the unlocked state.

[0103] In an embodiment of the present application, when the computer device determines that there is an unlocked state indication in the lock state of the updated target item range, it may update the lock state of the target bucket range to the unlocked state.

[0104] S402. Update the lock state of the thread range where the target granularity range is located according to the lock state of the updated target bucket range and the lock states of other bucket ranges.

[0105] In an embodiment of the present application, after the computer device obtains the lock state of the updated target bucket range, it may obtain the lock states of other bucket ranges in the thread range except the target bucket range from the database or memory, and then update the thread range where the target bucket range is located according to the lock state of the updated target bucket range and the lock states of other bucket ranges to obtain the lock state of the updated target thread range. Specifically, a logical operation may be performed on the lock state of the updated target bucket range and the lock states of other bucket ranges to obtain the lock state of the target thread range. Optionally, the lock state of the updated target bucket range and the lock states of other bucket ranges may also be input into a pre-set function for calculation to obtain the lock state of the target thread range.

[0106] Further, as Figure 7 shown, the above step S402, "Update the lock state of the thread range where the target granularity range is located according to the lock state of the updated target bucket range and the lock states of other bucket ranges", includes:

[0107] S4020. If the lock states of the updated target bucket range and other bucket ranges both indicate the locked state, update the lock state of the thread range to the locked state.

[0108] In an embodiment of the present application, when the computer device determines that the lock states of the updated target bucket range and other bucket ranges both indicate the locked state, it may update the lock state of the thread range from the unlocked state to the locked state.

[0109] S4021. If the lock states of the updated target bucket range and other bucket ranges both indicate the locked state, update the lock state of the thread range to the locked state.

[0110] In an embodiment of the present application, when the computer device determines that there is an unlocked state indication in the lock state of the updated target bucket range, it may update the lock state of the thread range to the unlocked state.

[0111] In the method described in the embodiments of the present application, by dividing the thread interval into multiple bucket intervals, then dividing each bucket interval into multiple item intervals, and further dividing each item interval into multiple granularity intervals, the data within the same item interval can be processed in parallel, which can greatly improve the efficiency of data access and concurrency performance, and on the basis of ensuring data consistency, maximize the utilization of resources. Additionally, by updating the lock states of each interval lock, the competition situation caused by simultaneous access to the same resource can be reduced, improving the throughput and response speed of the system.

[0112] In one embodiment, a method for managing a data lock is further provided, as Figure 8 shown. Figure 2 The method of the embodiment further includes:

[0113] S103. Determine the lock state of the target granularity interval corresponding to the access address according to a preset mapping relationship.

[0114] Among them, the preset mapping relationship includes the corresponding relationship between the lock states of each type of interval and the addresses of each type of interval. The thread interval includes multiple bucket intervals, each bucket interval includes multiple item intervals, and each item interval includes multiple granularity intervals.

[0115] In the embodiments of the present application, after the computer device divides the thread interval into multiple bucket intervals, divides each bucket interval into multiple item intervals, and divides each item interval into multiple granularity intervals, it can then set corresponding interval locks for each type of interval, and then establish the corresponding relationship between the lock states of each type of interval and the addresses of each type of interval, and store this corresponding relationship as a preset mapping relationship in a database or memory, for example, record each lock state through a bitmap.

[0116] Specifically, the lock state of each granularity interval can be represented by a bit, the lock state of the item interval can be represented by an interval lock item, the lock state of the bucket interval can be represented by a hash bucket or an interval lock hash bucket, and the lock state of the thread interval can be represented by an interval lock. Among them, the relationship between the interval lock hash bucket and the bucket interval can be a one-to-one relationship, that is, one interval lock hash bucket can represent the lock state of one bucket interval; optionally, the relationship between the interval lock hash bucket and the bucket interval can be a one-to-many relationship, that is, one interval lock hash bucket can represent the lock states of multiple bucket intervals. The relationship between the interval lock item and the item interval can be a one-to-one relationship, that is, one interval lock item can represent the lock state of one item interval; optionally, the relationship between one interval lock item and the item interval can be a many-to-one relationship, that is, multiple interval lock items can represent the lock state of one item interval; each interval lock item corresponds to an IO type. For example, one item interval corresponds to 2 interval lock items, interval lock item 1 is a read request, and the interval lock item is a write request.

[0117] Among them, the range lock includes bit positions corresponding to each hash bucket, each hash bucket includes bit positions corresponding to each range lock item, and each range lock item includes multiple bits corresponding to the lock states of each granularity range. For example, Figure 9 As shown, the range lock includes L hash buckets or L range lock hash tables (abbreviated as RGLHT), each hash bucket includes m range lock items (item 0, item 1... item m), and each range lock item includes the absolute sequence number of the item range (corresponding to idx in the figure), n bits corresponding to the granularity ranges (corresponding to item.bitmap n bit in the figure), and the read or write type, that is, the IO type (corresponding to rwType in the figure).

[0118] For example, the mapping relationship between ranges and range locks includes the mapping relationship between bucket ranges and hash buckets, item ranges and item range locks, and granularity ranges (also known as the minimum granularity range). Among them, 1. Range lock hash bucket RGLHT (Range Lock Hash Table), bucket range: Use a cache to represent the lock state of a fixed-size range, and this cache is called the "range lock hash bucket". The range obtained by aligning and dividing the thread range (volume logical space) according to the above size is called the "bucket range". 2. Range lock item RGLITEM (Range Lock Item), item range: An RGLHT contains multiple sub-data items, and each sub-data item represents the lock state of a sub-range. This sub-data item is called the "range lock item", and the corresponding sub-range is called the "item range". Each "bucket range" can be equally divided into multiple "item ranges". 3. Granularity range: An RGLITEM contains multiple sub-data items, and each sub-data item represents whether the lock of a sub-range is valid. This sub-range is the "minimum granularity range" that can be locked independently. Each "item range" can be equally divided into multiple "minimum granularity ranges". Among them, there is a many-to-one fixed mapping between the bucket range and the hash bucket, ensuring that the hash bucket can be confirmed in o(1) time according to the absolute order of the bucket range. The mapping relationship between the item range and the range lock item is, in most cases, a one-to-one fixed mapping for fast indexing; in extreme cases, for the same item range, there are 2 IOs, one for writing and one for reading, at the same time. To improve the success rate of locking, these 2 IOs are allowed to lock successfully at the same time. One IO occupies the range lock item with the fixed mapping relationship, and the other IO needs to occupy other idle items.

[0119] In an embodiment of the present application, when a computer device receives a data processing request, it can parse the data processing request to extract relevant information of the data grooming request. For example, it extracts the request type, data processing operation, access address, etc., and then obtains the access address corresponding to the data processing request. Then, it determines the identifier of the target granularity interval to be accessed according to the access address, and then obtains the lock state of the target granularity interval corresponding to the access address by obtaining a preset mapping relationship from the memory and looking up the identifier of the target granularity interval in the preset mapping relationship.

[0120] S104. When the lock state indicates that the target granularity interval is in an unlocked state, execute the steps of S102.

[0121] In an embodiment of the present application, after the computer device obtains the lock state of the target granularity interval corresponding to the access address, it can further determine the situation of the lock state. When the lock state indicates that the target granularity interval is in an unlocked state, it executes the above-mentioned steps of S102.

[0122] The method described in the embodiment of the present application can accurately determine the target granularity interval corresponding to the access address by constructing a preset mapping relationship, ensure effective operation on the target granularity interval, help to precisely control concurrent access, avoid multiple threads accessing different granularity intervals simultaneously, and improve the concurrency of the system and the efficiency of data processing.

[0123] In one example, a method for managing data locks is also provided, as Figure 10 shown. Figure 8 The method of the embodiment further includes:

[0124] S105. Update the preset mapping relationship according to the lock state of the updated bucket interval, the lock state of the updated item interval, and the lock state of the updated granularity interval.

[0125] Among them, the thread interval includes multiple bucket intervals, each bucket interval includes multiple item intervals, and each item interval includes multiple granularity intervals.

[0126] In an embodiment of the present application, after the computer device obtains the lock state of the updated bucket interval, the lock state of the updated item interval, and the lock state of the updated granularity interval based on the foregoing steps, it can update the lock state of the updated bucket interval, the lock state of the updated item interval, and the lock state of the updated granularity interval to the preset mapping relationship to obtain an updated preset mapping relationship.

[0127] The method described in the embodiment of the present application can ensure the consistency between the preset mapping relationship and the actual lock state by updating the preset mapping relationship.

[0128] In one example, a method for managing data locks is also provided, as Figure 11 shown, Figure 9 The method of the embodiment further includes:

[0129] S106, storing the updated preset mapping relationship into the cache.

[0130] Among them, according to the principle of spatial locality (the adjacent data of the recently accessed data is likely to be accessed), multiple interval locks are aligned according to the cache line. When obtaining one of the interval locks, other interval locks are saved to the cache at the same time, improving the cache hit rate.

[0131] In the embodiment of the present application, when the computer device obtains the lock state of a certain interval, it can directly read all the values of the hash bucket where the interval lock state is located from the memory to the cache layer, that is, store the updated preset mapping relationship into the cache. Then, when the computing device receives a data processing request for the same bucket interval, it can read the lock state of the interval where the data processing request is located from the cache.

[0132] The method described in the embodiment of the present application improves the data processing efficiency by setting the cache line and saving other interval locks to the cache when obtaining one of the interval locks.

[0133] Combining all the above embodiments, a method for managing data locks is also provided, as Figure 12 shown, where the thread interval includes multiple bucket intervals, each bucket interval includes multiple item intervals, and each item interval includes multiple granularity intervals. The method includes:

[0134] S701, in the case of receiving a data processing request, determining the access address according to the data processing request.

[0135] S702, according to the preset mapping relationship, determining the lock state of the target granularity interval corresponding to the access address. The preset mapping relationship includes the corresponding relationship between the lock states of each type of interval and the addresses of each type of interval.

[0136] S703, in the case that the lock state indicates that the target granularity interval is in an unlocked state, accessing the target granularity interval corresponding to the access address according to the data processing request.

[0137] S704, updating the lock state of the target granularity interval.

[0138] S705, if the lock state of the updated target granularity interval and the lock states of other granularity intervals both indicate a locked state, updating the lock state of the target item interval to a locked state.

[0139] S706, if there is an unlocked state among the lock states of the updated target granularity range and the lock states of other granularity ranges, update the lock state of the target item range to the unlocked state.

[0140] S707, update the lock state of the target bucket range according to the lock state of the updated target item range and the lock states of other item ranges.

[0141] S708, if the lock states of the updated target item range and other item ranges both indicate the locked state, update the lock state of the target bucket range to the locked state.

[0142] S709, if there is an unlocked state among the lock states of the updated target item range and the lock states of other item ranges, update the lock state of the target bucket range to the unlocked state.

[0143] S710, update the lock state of the thread range according to the lock state of the updated target bucket range and the lock states of other bucket ranges.

[0144] S711, if the lock states of the updated target bucket range and other bucket ranges both indicate the locked state, update the lock state of the thread range to the locked state.

[0145] S712, if there is an unlocked state among the lock states of the updated target bucket range and the lock states of other bucket ranges, update the lock state of the thread range to the unlocked state.

[0146] S713, update the preset mapping relationship according to the lock state of the updated bucket range, the lock state of the updated item range, and the lock state of the updated granularity range.

[0147] S714, store the updated preset mapping relationship into the cache.

[0148] In the embodiments of the present application, as Figure 13 shown, the basic process of interval locking (corresponding to locking the IO interval in the figure): 1) Divide the IO interval into multiple bucket intervals; 2) Traverse the bucket intervals and lock the bucket intervals; 3) If the bucket interval is successfully locked, continue with step 2); otherwise, unlock the bucket interval that has been successfully locked and return failure; 4) If all bucket intervals are successfully locked, the IO interval is successfully locked; 5) If any bucket interval is locked unsuccessfully, the IO interval is locked unsuccessfully. The process of locking the bucket interval is similar to that of locking the IO interval: 1) Divide the bucket interval into multiple item intervals; 2) Traverse the item intervals and lock the item intervals; 3) If the item interval is successfully locked, continue with step 2); otherwise, unlock the item interval that has been successfully locked and return failure; 4) If all item intervals are successfully locked, the bucket interval is successfully locked; 5) If any item interval is locked unsuccessfully, the bucket interval is locked unsuccessfully.

[0149] As shown in Figure 14 Figure , the item interval locking process is as follows: 1) Index to the interval lock hash bucket according to the absolute order of the bucket interval where the item interval is located; 2) Traverse all interval lock items in the interval lock hash bucket to find whether there is an available interval lock item: if there is no available interval lock item (there are conflicting items or no idle items), the item interval locking fails; if there is an available interval lock item (there are mergeable items or idle items), record the lock status according to the IO type and item interval number; 3) Return the bucket interval locking result.

[0150] In the method described in the embodiments of the present application, inside the thread, mutual exclusion control is only performed between write-write IOs and read-write IOs with overlapping access intervals; while for read-read IOs and any IOs with non-overlapping intervals, parallel execution is allowed. In this way, on the basis of ensuring data consistency, the IO concurrency efficiency of the entire system is maximally improved. The volume space is divided by threads, and the intervals between threads do not overlap, so the IOs of different threads can be parallel; the interval is fixedly mapped to the hash bucket, and the lock status can be quickly judged in the hash bucket; based on the cache layer (cache line) interval lock hash bucket, the cache hit rate of lock information is improved.

[0151] The methods described in the above steps are all described in the foregoing embodiments. For detailed content, please refer to the foregoing description and will not be elaborated here.

[0152] It should be understood that although the steps in the flowcharts involved in the above-described embodiments are shown in sequence according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless there is a clear indication in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed 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 executed alternately or alternately with at least a part of other steps or steps or stages in other steps.

[0153] Based on the same inventive concept, the embodiments of the present application also provide a data lock management device for implementing the data lock management method described above. The implementation solutions provided by this device to solve problems are similar to the implementation solutions described in the above method. Therefore, the specific limitations in one or more embodiments of the data lock management device provided below can refer to the limitations on the data lock management method in the above text and will not be elaborated here.

[0154] In one embodiment, as shown in Figure 15 Figure , a data lock management device is provided, including:

[0155] The first determination module 10 is configured to determine an access address according to a data processing request when receiving the data processing request.

[0156] The first update module 11 is configured to access a target granularity interval corresponding to the access address according to the data processing request, update the lock status of the target granularity interval, and update the lock status of the thread interval where the target granularity interval is located.

[0157] In one embodiment, as Figure 16 shown, the above-mentioned first update module 11 includes:

[0158] The first update unit 110 is configured to update the lock status of the target item interval according to the lock status of the updated target granularity interval and the lock status of other granularity intervals. The target item interval is the item interval where the target granularity interval is located.

[0159] The second update unit 111 is configured to update the lock status of the thread interval where the target granularity interval is located according to the lock status of the updated target item interval and the lock status of other item intervals.

[0160] In one embodiment, as Figure 17 shown, the above-mentioned first update unit 110 includes:

[0161] The first update subunit 1101 is configured to update the lock status of the target item interval to the locked state if the lock status of the updated target granularity interval and the lock status of other granularity intervals both indicate the locked state.

[0162] The second update subunit 1102 is configured to update the lock status of the target item interval to the unlocked state if there is a situation where the lock status of the updated target granularity interval and the lock status of other granularity intervals indicate the unlocked state.

[0163] In one embodiment, as Figure 18 shown, the above-mentioned second update unit 111 includes:

[0164] The third update subunit 1111 is configured to update the lock status of the target bucket interval according to the lock status of the updated target item interval and the lock status of other item intervals. The target bucket interval is the bucket interval where the target item interval is located.

[0165] The fourth update subunit 1112 is configured to update the lock status of the thread interval where the target granularity interval is located according to the lock status of the updated target bucket interval and the lock status of other bucket intervals.

[0166] In one embodiment, the above-mentioned third update subunit 1101 is specifically configured to update the lock status of the target bucket interval to the locked state if the lock status of the updated target item interval and the lock status of other item intervals both indicate the locked state; if there is a case where the lock status of the updated target item interval and the lock status of other item intervals indicate the unlocked state, update the lock status of the target bucket interval to the unlocked state.

[0167] In one embodiment, the above-mentioned fourth update subunit 1102 is specifically configured to update the lock status of the thread interval to the locked state if the lock status of the updated target bucket interval and the lock status of other bucket intervals both indicate the locked state; if there is a case where the lock status of the updated target bucket interval and the lock status of other bucket intervals indicate the unlocked state, update the lock status of the thread interval to the unlocked state.

[0168] In one embodiment, as Figure 19 shown, Figure 15 the data lock management device described above further includes:

[0169] A second determination module 12, configured to determine the lock status of the target granularity interval corresponding to the access address according to a preset mapping relationship. The preset mapping relationship includes the corresponding relationship between the lock status of each type of interval and the address of each type of interval.

[0170] A second update module 13, configured to perform the step of accessing the target granularity interval corresponding to the access address according to the data processing request when the lock status indicates that the target granularity interval is in the unlocked state.

[0171] In one embodiment, as Figure 20 shown, Figure 19 the data lock management device described above further includes:

[0172] A third update module 14, configured to update the preset mapping relationship according to the updated lock status of the bucket interval, the updated lock status of the item interval, and the updated lock status of the granularity interval.

[0173] In one embodiment, as Figure 21 shown, Figure 20 the data lock management device described above further includes:

[0174] A storage module 15, configured to store the updated preset mapping relationship in a cache.

[0175] Each module in the above-mentioned data lock management device can be implemented in whole or in part by software, hardware, and their combination. The above-mentioned modules can be embedded in the processor of the computer device in hardware form or be independent of it, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the operations corresponding to the above-mentioned modules.

[0176] In one embodiment, a computer device is provided, including a memory and a processor. A computer program is stored in the memory. When the processor executes the computer program, the following steps are implemented:

[0177] In the case of receiving a data processing request, determine an access address according to the data processing request;

[0178] Access a target granularity interval corresponding to the access address according to the data processing request, update the lock state of the target granularity interval, and update the lock state of the thread interval where the target granularity interval is located.

[0179] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:

[0180] In the case of receiving a data processing request, determine an access address according to the data processing request;

[0181] Access a target granularity interval corresponding to the access address according to the data processing request, update the lock state of the target granularity interval, and update the lock state of the thread interval where the target granularity interval is located.

[0182] In one embodiment, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the following steps are implemented:

[0183] In the case of receiving a data processing request, determine an access address according to the data processing request;

[0184] Access a target granularity interval corresponding to the access address according to the data processing request, update the lock state of the target granularity interval, and update the lock state of the thread interval where the target granularity interval is located.

[0185] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Among them, any reference to a memory, database, or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memories. 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), magnetoresistive 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 be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processors, graphics processors, digital signal processors, programmable logic devices, data processing logics based on quantum computing, etc., without limitation.

[0186] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, 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, it should be considered as the scope described in this specification.

[0187] The above-described embodiments merely represent several implementation manners of the present application. The description is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.

Claims

1. A method for managing a data lock, characterized in that, The method includes: Upon receiving a data processing request, determining an access address according to the data processing request; Accessing a target granularity range corresponding to the access address according to the data processing request, updating the lock status of the target granularity range, and updating the lock status of the thread range where the target granularity range is located.

2. The method according to claim 1, characterized in that, The thread range includes a plurality of item ranges, and each of the item ranges includes a plurality of granularity ranges. The updating of the lock status of the thread range where the target granularity range is located includes: Updating the lock status of a target item range according to the lock status of the updated target granularity range and the lock status of other granularity ranges; the target item range is the item range where the target granularity range is located; Updating the lock status of the thread range where the target granularity range is located according to the lock status of the updated target item range and the lock status of other item ranges.

3. The method according to claim 2, characterized in that, The updating of the lock status of the target item range according to the lock status of the updated target granularity range and the lock status of other granularity ranges includes: If the lock status of the updated target granularity range and the lock status of other granularity ranges both indicate a locked state, updating the lock status of the target item range to the locked state; If there is a situation where the lock status of the updated target granularity range and the lock status of other granularity ranges indicate an unlocked state, updating the lock status of the target item range to the unlocked state.

4. The method according to claim 2 or 3, characterized in that, The thread range includes a plurality of bucket ranges, and each of the bucket ranges includes a plurality of the item ranges. The updating of the lock status of the thread range where the target granularity range is located according to the lock status of the updated target item range and the lock status of other item ranges includes: Updating the lock status of a target bucket range according to the lock status of the updated target item range and the lock status of other item ranges; the target bucket range is the bucket range where the target item range is located; Updating the lock status of the thread range where the target granularity range is located according to the lock status of the updated target bucket range and the lock status of other bucket ranges.

5. The method according to claim 4, characterized in that, The updating of the lock status of the target bucket range according to the lock status of the updated target item range and the lock status of other item ranges includes: If the lock status of the updated target item range and the lock status of other item ranges both indicate a locked state, updating the lock status of the target bucket range to the locked state; If there is a situation where the lock status of the updated target item range and the lock status of other item ranges indicate an unlocked state, updating the lock status of the target bucket range to the unlocked state.

6. The method according to claim 4, characterized in that, The updating of the lock status of the thread range where the target granularity range is located according to the lock status of the updated target bucket range and the lock status of other bucket ranges includes: If the lock status of the updated target bucket range and the lock status of other bucket ranges both indicate a locked state, updating the lock status of the thread range to the locked state; If there is a situation where the lock status of the updated target bucket range and the lock status of other bucket ranges indicate an unlocked state, updating the lock status of the thread range to the unlocked state.

7. The method according to claim 1, characterized in that, The method further includes: Determining a lock state of a target granularity interval corresponding to the access address according to a preset mapping relationship; the preset mapping relationship includes a correspondence between the lock states of each type of interval and the addresses of each type of interval; When the lock state indicates that the target granularity interval is in an unlocked state, performing the step of accessing the target granularity interval corresponding to the access address according to the data processing request.

8. The method according to claim 7, characterized in that, The thread interval includes a plurality of bucket intervals, each of the bucket intervals includes a plurality of item intervals, and each item interval includes a plurality of granularity intervals. The method further includes: Updating the preset mapping relationship according to the lock state of the updated bucket interval, the lock state of the updated item interval, and the lock state of the updated granularity interval.

9. The method according to claim 8, characterized in that, The method further includes: Storing the updated preset mapping relationship into a cache.

10. A device for managing a data lock, characterized in that, The apparatus includes: A first determination module, configured to determine an access address according to the data processing request when receiving the data processing request; A first update module, configured to access a target granularity interval corresponding to the access address according to the data processing request, update the lock state of the target granularity interval, and update the lock state of the thread interval where the target granularity interval is located.

11. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, the steps of the method according to any one of claims 1 to 9 are implemented.

12. A computer-readable storage medium, on which a computer program is stored, characterized in that, When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.

13. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.