Business processing method and device based on distributed lock

By using bitmaps in distributed locks to manage the locking state of multiple resources, the lock waiting problem during interlocking is solved and the efficiency of business processing is improved.

CN113806388BActive Publication Date: 2025-04-15INDUSTRIAL AND COMMERCIAL BANK OF CHINA
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111106703.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-22
Publication Date
2025-04-15
Estimated Expiration
2041-09-22

AI Technical Summary

Technical Problem

In a distributed environment, lock waiting is prone to occur during interlocking, resulting in low service processing efficiency.

Method used

By using a bitmap to represent the locking status of multiple resources, the bit bit value in the bitmap is judged when acquiring a distributed lock. If the value of any resource is the second value, the lock will be released directly; if the value of all resources is the first value, the lock will be updated to the second value and the lock will be released.

Benefits of technology

This reduces the lock waiting situation during interlocking, improves the efficiency of business processing, and makes it shorter for each thread to acquire distributed locks, and other threads can also acquire locks faster for business processing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113806388B_ABST
    Figure CN113806388B_ABST
Patent Text Reader

Abstract

The present invention discloses a business processing method and device based on distributed locks, the method comprising: obtaining a distributed lock when processing a business, wherein the data corresponding to the distributed lock includes a bitmap, the bitmap includes multiple bits, and each bit corresponds to a resource; judging whether the values ​​of the bits corresponding to each resource required by the business on the bitmap are all first values, if so, updating the values ​​to a second value and then releasing the distributed lock, if not, directly releasing the distributed lock. The present invention helps to reduce the situation of lock waiting during interlocking and improve the processing efficiency of the business.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of distributed lock technology, and in particular to a business processing method and device based on distributed locks. Background Art

[0002] With the development of Internet technology, distributed technology has brought many benefits, but it also brings more technical challenges. Distributed locks are one of the solutions to solve distributed consistency, ensuring the sequential modification of the same resource in a distributed environment. But it also brings performance loss, especially when the concurrency is very large. In some business scenarios, you will encounter situations where you need to access multiple resources simultaneously, which requires the use of interlocking. The interlocking solution is to set multiple distributed locks at the same time, and the performance problem will be very bad. For example, the underlying principle of Redis interlocking is to establish a distributed lock for multiple keys in sequence, and it will succeed only when all locks are set successfully.

[0003] Multiple locks are prone to waiting for each other, which makes interlocking more difficult. When multiple processes compete for locks at the same time, it is easy to cause lock waiting. For example, interlocking requires acquiring locks 1 to 5. Thread 1 acquires locks 1, 2, and 5, and thread 2 acquires locks 3 and 4. This will cause lock waiting, and the subsequent process is that both threads fail at the same time and wait for a random event to be initiated again.

[0004] It can be seen that how to reduce the lock waiting situation during interlocking to improve business processing efficiency is an issue that needs to be solved urgently. Summary of the invention

[0005] In order to reduce the lock waiting situation during interlocking and improve the processing efficiency of business, the present invention proposes a business processing method and device based on distributed locks.

[0006] In order to achieve the above object, according to one aspect of the present invention, a business processing method based on a distributed lock is provided, the method comprising:

[0007] Acquire a distributed lock when processing a business, wherein the data corresponding to the distributed lock includes a bitmap, the bitmap includes a plurality of bits, and each bit corresponds to a resource;

[0008] It is determined whether the values ​​of the bits corresponding to each resource required by the business on the bitmap are all first values. If so, the values ​​are updated to the second value and then the distributed lock is released. If not, the distributed lock is directly released.

[0009] Optionally, the business processing method based on distributed locks further includes:

[0010] Acquiring the distributed lock after the business processing is completed;

[0011] The value of each resource required by the service on the bit corresponding to the bitmap is updated to a first value, and then the distributed lock is released.

[0012] Optionally, after directly releasing the distributed lock, the method further includes:

[0013] The distributed lock is continuously acquired until the values ​​of the bits corresponding to each resource required by the business on the bitmap are all the first values, at which time the values ​​of the bits corresponding to each resource required by the business on the bitmap are updated to the second value and then the distributed lock is released.

[0014] Optionally, the business processing method based on distributed locks further includes:

[0015] When the Java virtual machine is shut down, the value of the bit corresponding to the resource locked by each thread of the Java virtual machine on the bitmap is set to the first value through the shutdown hook of the Java virtual machine.

[0016] Optionally, the data corresponding to the distributed lock is a key in the cache.

[0017] Optionally, the first value is 0 and the second value is 1.

[0018] In order to achieve the above object, according to another aspect of the present invention, a business processing device based on a distributed lock is provided, the device comprising:

[0019] A first distributed lock acquisition module, used to acquire a distributed lock when processing a business, wherein the data corresponding to the distributed lock includes a bitmap, the bitmap includes a plurality of bits, and each bit corresponds to a resource;

[0020] The first processing module is used to determine whether the values ​​of the bits corresponding to each resource required by the business on the bitmap are all first values. If so, the values ​​are updated to the second value and then the distributed lock is released. If not, the distributed lock is directly released.

[0021] Optionally, the business processing device based on distributed lock further includes:

[0022] A second distributed lock acquisition module, used to acquire the distributed lock after the business processing is completed;

[0023] The second processing module is used to update the value of each resource required by the business on the bit corresponding to the bitmap to a first value, and then release the distributed lock.

[0024] Optionally, the business processing device based on distributed lock further includes:

[0025] The third processing module is used to continuously acquire the distributed lock until the values ​​of the bits corresponding to each resource required by the business on the bitmap are all first values. At this time, the values ​​of the bits corresponding to each resource required by the business on the bitmap are updated to the second value and then the distributed lock is released.

[0026] In order to achieve the above-mentioned purpose, according to another aspect of the present invention, a computer device is also provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps in the above-mentioned business processing method based on distributed locks when executing the computer program.

[0027] In order to achieve the above-mentioned purpose, according to another aspect of the present invention, a computer-readable storage medium is further provided, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed in a computer processor, the steps in the above-mentioned business processing method based on distributed locks are implemented.

[0028] The beneficial effects of the present invention are:

[0029] The present invention obtains a distributed lock when processing a business. If the value of the bit corresponding to any one of the resources required by the business on the bitmap is the second value, the distributed lock is directly released. If the value of the bit corresponding to each resource required by the business on the bitmap is the first value, the value is updated to the second value and then the distributed lock is released. The present invention records the locking status of each resource through a bitmap, so that the time for each thread to obtain the distributed lock is shorter, which is convenient for other threads to obtain the distributed lock for business processing, thereby reducing the lock waiting situation during interlocking and improving the processing efficiency of the business. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the prior art descriptions. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. In the drawings:

[0031] Figure 1 This is a first flow chart of a business processing method based on a distributed lock according to an embodiment of the present invention;

[0032] Figure 2 is a second flow chart of the business processing method based on distributed locks according to an embodiment of the present invention;

[0033] Figure 3 is a first processing schematic diagram of an embodiment of the present invention;

[0034] Figure 4 is a second processing schematic diagram of an embodiment of the present invention;

[0035] Figure 5 is a third processing schematic diagram of an embodiment of the present invention;

[0036] Figure 6 is a fourth processing schematic diagram of an embodiment of the present invention;

[0037] Figure 7 This is a first structural block diagram of a business processing device based on a distributed lock according to an embodiment of the present invention;

[0038] Figure 8 This is a second structural block diagram of a business processing device based on a distributed lock according to an embodiment of the present invention;

[0039] Fig. 9 It is a schematic diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION

[0040] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0041] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0042] It should be noted that the terms "including" and "having" and any variations thereof in the specification and claims of the present invention and the above-mentioned drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or apparatus comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or apparatus.

[0043] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments can be combined with each other. The present invention will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0044] It should be noted that the business processing method based on distributed locks of the present invention is applied to threads, that is, the implementation subject of the method of the present invention is threads.

[0045] Figure 1 is a first flow chart of a business processing method based on a distributed lock according to an embodiment of the present invention. Figure 1 As shown, in one embodiment of the present invention, the business processing method based on distributed locks of the present invention includes step S101 and step S102.

[0046] Step S101, obtaining a distributed lock when processing a business, wherein the data corresponding to the distributed lock includes a bitmap, the bitmap includes a plurality of bits, and each bit corresponds to a resource.

[0047] In the present invention, the bitmap is a unique data structure that stores data bit by bit and is usually used to determine whether certain values ​​exist. For example, to determine whether a user exists, the subscript of the bitmap is mapped to the user ID. If the value corresponding to the subscript position is 0, it means that the user does not exist, and if it is 1, it means that the user exists.

[0048] The present invention presets a bitmap, and stores the bitmap as a key of the cache Redis. Each bit on the bitmap corresponds to a resource, and the value on the bit is used to indicate the occupancy of the corresponding resource. For example, 1 indicates that the corresponding resource is occupied, and 0 indicates that the corresponding resource is not occupied.

[0049] In the present invention, each thread competes for the key in the cache Redis corresponding to the bitmap when processing business. If a thread competes for the key, the thread sets a key value for the key. If the key value is set successfully, it means that the thread has acquired the distributed lock.

[0050] In the present invention, the data corresponding to the distributed lock in this step refers to the key key in the cache Redis corresponding to the bitmap bitmap.

[0051] Step S102, determining whether the values ​​of the bits corresponding to each resource required by the business on the bitmap are all first values, if so, updating the values ​​to second values ​​and then releasing the distributed lock, if not, directly releasing the distributed lock.

[0052] In the present invention, the first value is used to indicate that the resource corresponding to the bit is not locked, and the second value is used to indicate that the resource corresponding to the bit is locked. In one embodiment of the present invention, the first value is 0, and the second value is 1. In another embodiment of the present invention, the first value is 1, and the second value is 0.

[0053] In the present invention, the value of each bit in the bitmap indicates the occupation of the corresponding resource. After the thread acquires the distributed lock, it first determines whether the values ​​of the bits corresponding to the resources required by the business processed by the thread are all the first values. If they are all the first values, it means that the resources required by the business are not locked. At this time, the thread updates the value to the second value and locks the resources required by the business, indicating that the resources are occupied. A resource can only be locked by one thread at a time.

[0054] In the present invention, if the value of the bit corresponding to at least one resource required by the business on the bitmap is the second value, it means that at least one resource has been locked. At this time, the thread directly releases the distributed lock and leaves the opportunity to the next thread. It is very likely that the resources to be locked by the next thread will not conflict, thereby improving concurrency.

[0055] The present invention sets a bitmap so that each thread operates the same key but targets different bits, which can reduce the number of locks and the degree of lock conflict. Only when operating the same bit will there be a conflict.

[0056] In one embodiment of the present invention, after directly releasing the distributed lock in the above step S102, the method of the present invention further includes:

[0057] The distributed lock is continuously acquired until the values ​​of the bits corresponding to each resource required by the business on the bitmap are all the first values, at which time the values ​​of the bits corresponding to each resource required by the business on the bitmap are updated to the second value and then the distributed lock is released.

[0058] In the present invention, if the value of the bit corresponding to at least one resource required by the business on the bitmap is the second value, it means that at least one resource has been locked, and at this time, the thread directly releases the distributed lock. Subsequently, the thread continues to try to acquire the distributed lock until it finds that the value of the bit corresponding to each resource required by the business on the bitmap is the first value after acquiring the distributed lock. At this time, the thread updates the value of the bit corresponding to each resource required by the business on the bitmap to the second value and then releases the distributed lock.

[0059] Figure 2is a second flow chart of the business processing method based on distributed locks according to an embodiment of the present invention. Figure 2 As shown, in one embodiment of the present invention, the business processing method based on distributed locks of the present invention also includes step S201 and step S202.

[0060] Step S201, acquiring the distributed lock after the business processing is completed.

[0061] In the present invention, after the thread has processed the business, the value of each resource required by the business on the bitmap corresponding to the bit value needs to be restored to the first value. Specifically, after the thread has processed the business, the thread continuously attempts to acquire the distributed lock until the distributed lock is acquired.

[0062] Step S202: Update the value of the bit corresponding to each resource required by the service on the bitmap to a first value, and then release the distributed lock.

[0063] In the present invention, when a thread obtains a distributed lock after processing a business, the thread updates the value of each bit corresponding to each resource required by the business on the bitmap from the second value to the first value, and then releases the distributed lock.

[0064] The method of the present invention will be explained below with reference to specific embodiments.

[0065] like Figure 3 As shown, when a thread acquires a distributed lock:

[0066] 1. Thread 1 acquires the distributed lock.

[0067] 2. Use the bitmap format to map multiple resources to be locked to the bitmap, and save the bitmap as a Redis key. Each resource corresponds to a bit on the bitmap. If the bit is 0, it means that the record is not locked, and if it is 1, it means that the record is locked.

[0068] 3. Release the lock immediately without waiting for the business processing to end.

[0069] like Figure 4 As shown, when a second thread wants to acquire the lock and there is no conflict:

[0070] 1. Thread 2 acquires the distributed lock. At this time, thread 1 has released the lock, so thread 2 can successfully acquire the lock.

[0071] 2. Determine whether there is a conflict in the bits corresponding to the multiple resources required by the business processed by thread 2 (wherein the value of the bit is 1 indicating a conflict, and 0 indicating no conflict). If there is no conflict, set the corresponding bit value to 1.

[0072] 3. Release the lock.

[0073] like Figure 5 As shown, when a second thread wants to acquire the lock and there is a conflict:

[0074] 1. Thread 2 acquires the distributed lock. At this time, thread 1 has released the lock, so thread 2 can successfully acquire the lock.

[0075] 2. Determine whether there is a conflict in the bitmap corresponding to multiple resources required by the business processed by thread 2, and find that one position is occupied.

[0076] 3. Release the lock. The reason for releasing the lock here is to leave the opportunity to the next thread. It is very likely that the records to be operated by the next thread will not conflict, which can improve concurrency.

[0077] 4. Retry the entire procedure.

[0078] In one embodiment of the present invention, the method of the present invention further comprises:

[0079] When a Java virtual machine (JVM) is shut down, a shutdown hook of the Java virtual machine is used to set the value of a bit corresponding to a resource locked by each thread of the Java virtual machine on the bitmap to a first value.

[0080] In the present invention, the present invention relies on a bitmap to lock multiple resources, but when the JVM process ends, the corresponding records should be released to prevent deadlock.

[0081] In the present invention, one JVM corresponds to multiple threads. Figure 6 As shown, when the Java virtual machine (JVM) corresponding to the thread is shut down, the shutdown hook of the Java virtual machine obtains the resource information locked by each thread of the Java virtual machine from the cache, wherein when the thread sets the bitmap successfully, the locked resource information will be recorded in the redis cache. Then the shutdown hook sets the value of the corresponding bit position of the resource locked by each thread of the Java virtual machine on the bitmap to the first value to prevent deadlock.

[0082] In addition, if it is a forced shutdown such as kill-9, shutdownhook will not work. Therefore, when the project starts, the redis cache will be checked and cleaned up.

[0083] It can be seen from the above embodiments that the business processing method based on distributed locks of the present invention achieves at least the following beneficial effects:

[0084] 1. The present invention reduces the number of interlocks and the probability of interlock conflicts through bitmap technology;

[0085] 2. In scenarios with large concurrency or multiple locks, the present invention can significantly improve the high concurrency capability of the system and solve the single-point bottleneck problem of the system.

[0086] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0087] Based on the same inventive concept, an embodiment of the present invention also provides a business processing device based on a distributed lock, which can be used to implement the business processing method based on a distributed lock described in the above embodiment, as described in the following embodiment. Since the principle of solving the problem by the business processing device based on a distributed lock is similar to that of the business processing method based on a distributed lock, the embodiment of the business processing device based on a distributed lock can refer to the embodiment of the business processing method based on a distributed lock, and the repeated parts will not be repeated. As used below, the term "unit" or "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.

[0088] Figure 7 is a first structural block diagram of a business processing device based on a distributed lock according to an embodiment of the present invention. Figure 7 As shown, in one embodiment of the present invention, the business processing device based on distributed lock of the present invention includes:

[0089] A first distributed lock acquisition module 1, used to acquire a distributed lock when processing a business, wherein the data corresponding to the distributed lock includes a bitmap, the bitmap includes a plurality of bits, and each bit corresponds to a resource;

[0090] The first processing module 2 is used to determine whether the values ​​of the bits corresponding to each resource required by the business on the bitmap are all first values. If so, the values ​​are updated to the second value and then the distributed lock is released. If not, the distributed lock is directly released.

[0091] Figure 8 is a second structural block diagram of a business processing device based on a distributed lock according to an embodiment of the present invention. Figure 8 As shown, in one embodiment of the present invention, the business processing device based on distributed lock of the present invention further includes:

[0092] A second distributed lock acquisition module 3, used to acquire the distributed lock after the business processing is completed;

[0093] The second processing module 4 is used to update the value of each resource required by the service on the bit corresponding to the bitmap to a first value, and then release the distributed lock.

[0094] In one embodiment of the present invention, the distributed lock-based business processing device of the present invention further includes:

[0095] The third processing module is used to continuously acquire the distributed lock until the values ​​of the bits corresponding to each resource required by the business on the bitmap are all first values. At this time, the values ​​of the bits corresponding to each resource required by the business on the bitmap are updated to the second value and then the distributed lock is released.

[0096] In order to achieve the above object, according to another aspect of the present application, a computer device is also provided. Fig. 9 As shown, the computer device includes a memory, a processor, a communication interface and a communication bus. A computer program that can be executed on the processor is stored in the memory. When the processor executes the computer program, the steps in the above-mentioned embodiment method are implemented.

[0097] The processor may be a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or a combination of the above chips.

[0098] The memory, as a non-transitory computer-readable storage medium, can be used to store non-transitory software programs, non-transitory computer executable programs and units, such as the corresponding program units in the above method embodiments of the present invention. The processor executes various functional applications of the processor and works data processing by running the non-transitory software programs, instructions and modules stored in the memory, that is, implementing the method in the above method embodiments.

[0099] The memory may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created by the processor, etc. In addition, the memory may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0100] The one or more units are stored in the memory, and when executed by the processor, the method in the above embodiment is performed.

[0101] The specific details of the above-mentioned computer device can be understood by referring to the corresponding related descriptions and effects in the above-mentioned embodiments, and will not be repeated here.

[0102] In order to achieve the above purpose, according to another aspect of the present application, a computer-readable storage medium is also provided, wherein the computer-readable storage medium stores a computer program, and the computer program implements the steps in the above-mentioned business processing method based on distributed locks when executed in a computer processor. Those skilled in the art can understand that the implementation of all or part of the process in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the program can be stored in a computer-readable storage medium, and the program can include the process of the embodiment of each method as described above when executed. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory (Flash Memory), a hard disk (Hard Disk Drive, abbreviated as: HDD) or a solid-state drive (SSD), etc.; the storage medium can also include a combination of the above-mentioned types of memory.

[0103] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.

[0104] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A business processing method based on distributed locks, characterized in that: include: Acquire a distributed lock when processing a business, wherein the data corresponding to the distributed lock includes a bitmap, the bitmap includes a plurality of bits, and each bit corresponds to a resource; Determine whether the values ​​of the bits corresponding to each resource required by the business on the bitmap are all the first values, if so, update the values ​​to the second value and then release the distributed lock, if not, directly release the distributed lock; Wherein, the data corresponding to the distributed lock is the key in the cache; If the value of the bit on the bitmap is the first value, it means that the resource corresponding to the bit is not locked; if the value of the bit on the bitmap is the second value, it means that the resource corresponding to the bit is locked.

2. The business processing method based on distributed lock according to claim 1 is characterized in that: Also includes: Acquiring the distributed lock after the business processing is completed; The value of each resource required by the service on the bit corresponding to the bitmap is updated to a first value, and then the distributed lock is released.

3. The business processing method based on distributed lock according to claim 1 is characterized in that: After directly releasing the distributed lock, the method further includes: The distributed lock is continuously acquired until the values ​​of the bits corresponding to each resource required by the business on the bitmap are all the first values, at which time the values ​​of the bits corresponding to each resource required by the business on the bitmap are updated to the second value and then the distributed lock is released.

4. The business processing method based on distributed lock according to claim 1 is characterized in that: Also includes: When the Java virtual machine is shut down, the value of the bit corresponding to the resource locked by each thread of the Java virtual machine on the bitmap is set to the first value through the shutdown hook of the Java virtual machine.

5. The business processing method based on distributed lock according to claim 1 is characterized in that: The first value is 0, and the second value is 1.

6. A business processing device based on distributed lock, characterized in that: include: A first distributed lock acquisition module, used to acquire a distributed lock when processing a business, wherein the data corresponding to the distributed lock includes a bitmap, the bitmap includes a plurality of bits, and each bit corresponds to a resource; A first processing module, configured to determine whether the values ​​of the bits corresponding to each resource required by the business on the bitmap are all first values, and if so, update the values ​​to second values ​​and then release the distributed lock; if not, directly release the distributed lock; Wherein, the data corresponding to the distributed lock is the key in the cache; If the value of the bit on the bitmap is the first value, it means that the resource corresponding to the bit is not locked; if the value of the bit on the bitmap is the second value, it means that the resource corresponding to the bit is locked.

7. The business processing device based on distributed lock according to claim 6, characterized in that: Also includes: A second distributed lock acquisition module, used to acquire the distributed lock after the business processing is completed; The second processing module is used to update the value of each resource required by the business on the bit corresponding to the bitmap to a first value, and then release the distributed lock.

8. The distributed lock-based business processing device according to claim 6, characterized in that: Also includes: The third processing module is used to continuously acquire the distributed lock until the values ​​of the bits corresponding to each resource required by the business on the bitmap are all first values. At this time, the values ​​of the bits corresponding to each resource required by the business on the bitmap are updated to the second value and then the distributed lock is released.

9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 5 is implemented.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed in a computer processor, the computer program implements the method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Distributed lock implementation method and device

    CN110032424A