[go: up one dir, main page]

CN114138800B - Lock request processing method, device, computer equipment and medium - Google Patents

Lock request processing method, device, computer equipment and medium Download PDF

Info

Publication number
CN114138800B
CN114138800B CN202111422224.8A CN202111422224A CN114138800B CN 114138800 B CN114138800 B CN 114138800B CN 202111422224 A CN202111422224 A CN 202111422224A CN 114138800 B CN114138800 B CN 114138800B
Authority
CN
China
Prior art keywords
locking
target
request
lock
preset
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202111422224.8A
Other languages
Chinese (zh)
Other versions
CN114138800A (en
Inventor
程强
杨尚
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
China Electronics Technology Group Jincang Beijing Technology Co ltd
Original Assignee
China Electronics Technology Group Jincang Beijing Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by China Electronics Technology Group Jincang Beijing Technology Co ltd filed Critical China Electronics Technology Group Jincang Beijing Technology Co ltd
Priority to CN202111422224.8A priority Critical patent/CN114138800B/en
Publication of CN114138800A publication Critical patent/CN114138800A/en
Application granted granted Critical
Publication of CN114138800B publication Critical patent/CN114138800B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2308Concurrency control
    • G06F16/2336Pessimistic concurrency control approaches, e.g. locking or multiple versions without time stamps
    • G06F16/2343Locking methods, e.g. distributed locking or locking implementation details

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本公开涉及一种锁请求处理方法、装置、计算机设备和介质;其中,该方法包括:接收多个客户端发送的与目标资源对应的多个加锁请求,其中,每个加锁请求中包括对应的锁模式;根据所有的锁模式确定目标加锁请求能够进行加速时,查询预设快速加锁表,其中,目标加锁请求为多个加锁请求中的至少一个加锁请求;根据预设快速加锁表中与目标资源对应的目标加锁次数,确定是否通过目标加锁请求。本公开实施例能够对锁请求进行快速处理,有利于提高处理效率,避免后续对资源进行访问时出现较大的延迟。

The present disclosure relates to a lock request processing method, device, computer equipment and medium; wherein the method comprises: receiving multiple lock requests corresponding to a target resource sent by multiple clients, wherein each lock request includes a corresponding lock mode; when determining that the target lock request can be accelerated according to all lock modes, querying a preset fast lock table, wherein the target lock request is at least one lock request among the multiple lock requests; and determining whether the target lock request is passed according to the target lock count corresponding to the target resource in the preset fast lock table. The embodiments of the present disclosure can quickly process lock requests, which is conducive to improving processing efficiency and avoiding large delays in subsequent access to resources.

Description

Lock request processing method, device, computer equipment and medium
Technical Field
The disclosure relates to the technical field of databases, and in particular relates to a lock request processing method, a lock request processing device, computer equipment and a lock request processing medium.
Background
Locks are an important concept in databases, which are mainly used to ensure database integrity and consistency in multi-user environments. When multiple users access resources in the same database at the same time, problems may occur if the resources in the database are not locked.
When a thread in a stand-alone database management system or a node in a cluster database management system accesses a resource in a database, a request for locking the resource needs to be sent to a lock manager, and the resource can be accessed when the locking request is authorized.
In the existing locking application process, all lock information related to the resource to be accessed is generally required to be traversed, the mutual exclusion lock is required to be added in the traversing process, and the mutual exclusion lock is released after the traversing process is finished, so that a great amount of time is consumed in the process of locking application and the locking application process is slow, and further obvious delay occurs to the subsequent client side when the resource to be accessed is accessed.
Disclosure of Invention
In order to solve the technical problems, the disclosure provides a lock request processing method, a device, computer equipment and a medium.
In a first aspect, the present disclosure provides a lock request processing method, including:
receiving a plurality of locking requests corresponding to target resources sent by a plurality of clients, wherein each locking request comprises a corresponding locking mode;
inquiring a preset quick locking table when determining that target locking requests can accelerate according to all locking modes, wherein the target locking requests are at least one locking request in the plurality of locking requests;
and determining whether the target locking request is passed or not according to the target locking times corresponding to the target resources in the preset quick locking table.
Optionally, when the target locking request is determined to be capable of accelerating according to all the locking modes, before querying the preset quick locking table, the method further includes:
acquiring lock mode categories corresponding to the lock modes respectively;
judging whether the locking requests are mutually exclusive according to the locking mode type;
And if the target locking request is not mutually exclusive with other locking requests and the locking mode category corresponding to the target locking request belongs to the sharing category, determining that the target locking request can accelerate.
Optionally, the determining whether to pass the target locking request according to the target locking times corresponding to the target resource in the preset quick locking table includes:
Determining target locking times corresponding to the target resources in the preset quick locking table;
And determining whether the target locking request is passed or not according to the size relation between the target locking times and a preset threshold value.
Optionally, the method further comprises:
If it is determined that the target locking request cannot be accelerated or the target locking times exceed a preset threshold, the target locking request is sent to a lock controller, so that the lock controller queries lock information corresponding to the target resource, and determines whether the target locking request is passed or not according to the lock information.
Optionally, the method further comprises:
And if the target locking request is determined not to pass according to the locking information, adding the target locking request into an access waiting queue corresponding to the target resource.
Optionally, the lock mode category includes at least one of table sharing, row sharing, update sharing, table exclusivity, row exclusivity, and update exclusivity.
Optionally, the preset quick locking table is established by the following method:
dividing all resources in a shared memory into groups with preset numbers;
For each group in the preset number of groups, acquiring the locking times of each resource contained in the current group, and obtaining the total locking times corresponding to the current group according to the locking times;
and establishing the preset quick locking table based on all the total locking times and the group identification numbers corresponding to the preset number of groups.
In a second aspect, the present disclosure provides a lock request processing apparatus, including:
The receiving module is used for receiving a plurality of locking requests corresponding to the target resources, which are sent by a plurality of clients, wherein each locking request comprises a corresponding locking mode;
the query module is used for querying a preset quick locking table when determining that the target locking request can accelerate according to all the locking modes, wherein the target locking request is at least one locking request in the plurality of locking requests;
And the determining module is used for determining whether the target locking request is passed or not according to the target locking times corresponding to the target resource in the preset quick locking table.
Optionally, the apparatus further includes:
the acceleration determining module is specifically configured to obtain a lock mode category corresponding to each lock mode respectively before querying a preset quick locking table when it is determined that the target locking request can accelerate according to all the lock modes;
judging whether the locking requests are mutually exclusive according to the locking mode type;
And if the target locking request is not mutually exclusive with other locking requests and the locking mode category corresponding to the target locking request belongs to the sharing category, determining that the target locking request can accelerate.
Optionally, the determining module is specifically configured to:
Determining target locking times corresponding to the target resources in the preset quick locking table;
And determining whether the target locking request is passed or not according to the size relation between the target locking times and a preset threshold value.
Optionally, the apparatus further includes:
The sending module is specifically configured to send the target locking request to a lock controller if it is determined that the target locking request cannot be accelerated or the target locking frequency exceeds a preset threshold, so that the lock controller queries lock information corresponding to the target resource, and determines whether to pass the target locking request according to the lock information.
Optionally, the apparatus further includes:
the adding module is specifically configured to add the target locking request to an access waiting queue corresponding to the target resource if it is determined that the target locking request is not passed according to the locking information
Optionally, the lock mode category includes at least one of table sharing, row sharing, update sharing, table exclusivity, row exclusivity, and update exclusivity.
Optionally, the preset quick locking table is established by the following method:
dividing all resources in a shared memory into groups with preset numbers;
For each group in the preset number of groups, acquiring the locking times of each resource contained in the current group, and obtaining the total locking times corresponding to the current group according to the locking times;
and establishing the preset quick locking table based on all the total locking times and the group identification numbers corresponding to the preset number of groups.
In a third aspect, the present disclosure also provides a computer device comprising:
one or more processors;
Storage means for storing one or more programs,
The one or more programs, when executed by the one or more processors, cause the one or more processors to implement the lock request processing method of any of the embodiments of the present disclosure.
In a fourth aspect, the present disclosure also provides a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the lock request processing method according to any of the embodiments of the present disclosure.
Compared with the prior art, the technical scheme provided by the embodiment of the disclosure has the advantages that a plurality of locking requests corresponding to target resources, which are sent by a plurality of clients, are received, wherein each locking request comprises a corresponding locking mode, then when the target locking request is determined to be capable of accelerating according to all locking modes, a preset quick locking table is queried, wherein the target locking request is at least one locking request in the plurality of locking requests, finally, whether the locking request is passed or not is determined according to the target locking times corresponding to the target resources in the preset quick locking table, and the locking requests can be quickly processed by the scheme, so that the processing efficiency is improved, and larger delay in subsequent access to the resources is avoided.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure.
In order to more clearly illustrate the embodiments of the present disclosure or the solutions in the prior art, the drawings that are required for the description of the embodiments or the prior art will be briefly described below, and it will be obvious to those skilled in the art that other drawings can be obtained from these drawings without inventive effort.
FIG. 1 is a flow chart of a lock request processing method according to an embodiment of the disclosure;
FIG. 2A is a flow chart of another lock request processing method provided by an embodiment of the present disclosure;
FIG. 2B is a schematic diagram of a system for processing a lock request in an embodiment of the present disclosure;
FIG. 3 is a schematic diagram of a lock request processing apparatus according to an embodiment of the present disclosure;
fig. 4 is a schematic structural diagram of a computer device according to an embodiment of the present disclosure.
Detailed Description
In order that the above objects, features and advantages of the present disclosure may be more clearly understood, a further description of aspects of the present disclosure will be provided below. It should be noted that, without conflict, the embodiments of the present disclosure and features in the embodiments may be combined with each other.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present disclosure, but the present disclosure may be practiced otherwise than as described herein, and it is apparent that the embodiments in the specification are only some, rather than all, of the embodiments of the present disclosure.
Fig. 1 is a flow chart of a lock request processing method according to an embodiment of the disclosure. The embodiment can be applied to the case of processing a plurality of locking requests for a certain resource sent by a client. The method of the present embodiment may be performed by a lock request processing device, which may be implemented in hardware and/or software, and may be configured in a computer device. As shown in fig. 1, the method specifically includes the following steps:
S110, receiving a plurality of locking requests corresponding to the target resource, which are sent by a plurality of clients, wherein each locking request comprises a corresponding locking mode.
The target resource may be understood as the same resource in the shared memory of the database to be accessed by a plurality of clients. The method in this embodiment may be implemented in a Database management system (Database MANAGEMENT SYSTEM, abbreviated DBMS). A DBMS is understood as a software for manipulating and managing a database, for creating, using and maintaining a database, which is capable of unified management and control of the database to ensure the security and integrity of the database, through which a user accesses data in the database, and through which a database administrator also performs maintenance work of the database. The database management system may include a stand-alone database management system or a cluster database management system, and the embodiment is not particularly limited. A stand-alone database may be understood as a database that runs on a stand-alone and does not provide network functionality, such as ACCESS or FOXPRO, etc. A clustered database is understood to be a database that utilizes at least two or more database servers to form a virtual single database logical image that provides data services to clients. The locking request is a request for locking a resource in a database, which is sent to a lock transit acceleration processor when a thread or a process in a stand-alone database management system or a thread, a process or a node in a cluster database management system needs to access the resource, and the resource can be accessed when the locking request passes (i.e. is authorized). A lock relay acceleration processor may be understood as a processor in the DBMS that processes locking requests quickly, and the method of the present embodiment is performed by the lock relay acceleration processor. A lock mode may be understood as a different mode of locking a target resource.
When a plurality of clients want to access a target resource, each client sends a locking request for the target resource to a lock transit acceleration processor, at this time, the lock transit acceleration processor receives a plurality of locking requests corresponding to the target resource sent by the plurality of clients, and each locking request includes a corresponding locking mode.
S120, inquiring a preset quick locking table when the target locking request is determined to be capable of accelerating according to all the locking modes, wherein the target locking request is at least one locking request in a plurality of locking requests.
The preset quick locking table can be understood as a pre-established quick locking table, and the number of locking times corresponding to the resources in the database is recorded in the table.
According to the relation between the locking modes corresponding to each locking request, it can be judged which locking requests can accelerate and which locking requests cannot accelerate in the plurality of locking requests, and when at least one locking request in the plurality of locking requests, namely, a target locking request can accelerate, a preset quick locking table needs to be queried to determine the target locking times corresponding to the target resource.
S130, determining whether to pass the target locking request according to the target locking times corresponding to the target resources in the preset quick locking table.
The target locking times can be understood as times of target resources, in which quick locking cannot be performed (i.e. the locking mode corresponding to the locking request is an exclusive type). The target locking times can be updated according to the following modes that when a locking mode corresponding to a certain locking request for the target resource is an exclusive type, the target locking times are increased by 1 to obtain new target locking times, and when the locking mode corresponding to the certain locking request for the target resource is the exclusive type and the locking mode is released, the target locking times are decreased by 1 to obtain new target locking times.
After a preset quick locking table is queried, the target locking times corresponding to the target resources can be determined, whether the target locking request passes or not can be determined according to the specific value of the target locking times, and under the passing condition, the target locking request is authorized, and a client corresponding to the target locking request can access the target resources, so that the processing efficiency of the locking request is improved.
In this embodiment, a plurality of locking requests corresponding to a target resource sent by a plurality of clients are received first, wherein each locking request includes a corresponding locking mode, then when it is determined that the target locking request can accelerate according to all the locking modes, a preset fast locking table is queried, wherein the target locking request is at least one locking request in the plurality of locking requests, and finally, according to the target locking times corresponding to the target resource in the preset fast locking table, whether the locking request is passed or not is determined, and by the above scheme, the locking request can be processed fast, which is beneficial to improving the processing efficiency and avoiding a larger delay when accessing the resource later.
In this embodiment, optionally, when it is determined that the target locking request can accelerate according to all the locking modes, before querying the preset fast locking table, the method may further specifically include:
acquiring lock mode categories corresponding to the lock modes respectively;
judging whether the locking requests are mutually exclusive according to the locking mode type;
And if the target locking request is not mutually exclusive with other locking requests and the locking mode category corresponding to the target locking request belongs to the sharing category, determining that the target locking request can accelerate.
The lock mode may be a lock mode name or a lock mode identification number defined by the client, or may be a different mode for locking the target resource defined according to other modes, which is not limited in this embodiment. The lock mode class is a specific class corresponding to the lock mode, and the lock mode class may include at least one of table sharing, row sharing, update sharing, table exclusivity, row exclusivity, and update exclusivity. The table sharing, the line sharing, and the update sharing belong to sharing categories, which are not mutually exclusive, and the table exclusivity, the line exclusivity, and the update exclusivity belong to exclusive categories, which are mutually exclusive. Table sharing is understood to mean that the content corresponding to a table is shared, i.e. multiple clients can access the table at the same time. Line sharing may be understood as where the content corresponding to a line is shared, i.e. multiple clients may access the line at the same time. Update sharing may understand that the content corresponding to an updateable resource is shared, i.e., multiple clients may access the updateable resource at the same time. A table exclusion is understood to mean that the content corresponding to a table is exclusive, i.e. that multiple clients cannot access the table at the same time. A line exclusive is understood to mean that the content corresponding to a line is exclusive, i.e. that multiple clients cannot access the line at the same time. An update exclusive is understood to mean that the content corresponding to an updatable resource is exclusive, i.e. that multiple clients cannot access the updatable resource at the same time.
Specifically, the mutual exclusion relationship between the 6 lock pattern classes can be shown in the following table 1:
TABLE 1
Table sharing Line sharing Update sharing Updating exclusivity Line exclusivity Table exclusivity
Table sharing /
Line sharing / /
Update sharing / / /
Updating exclusivity / / / /
Line exclusivity / / / / /
Table exclusivity / / / / / /
The lock pattern table is searched according to the lock pattern, so that the lock pattern types corresponding to the lock patterns can be determined, for example, if 6 lock patterns are provided, and the corresponding names are lock pattern 1, lock pattern 2, lock pattern 3, lock pattern 4, lock pattern 5 and lock pattern 6, then different lock pattern types corresponding to the 6 lock patterns can be determined after the lock pattern table is searched. After obtaining the lock mode types corresponding to the lock modes respectively, since the locking request corresponds to the lock mode, the lock mode corresponds to the lock mode type, that is, the locking request corresponds to the lock mode type, it can be determined whether the locking requests are mutually exclusive or not according to the lock mode type corresponding to the lock mode (the determination can be made with reference to table 1 above). And on the contrary, if the target locking request is mutually exclusive with other locking requests and the locking mode category corresponding to the target locking request does not belong to the sharing category (namely, belongs to the exclusive category), determining that the target locking request cannot accelerate.
In the embodiment, the target locking request can be accelerated by the method, so that the method is simple and quick, is beneficial to improving the accuracy of the judging process and prevents errors.
In this embodiment, optionally, the preset quick locking table is established by the following manner:
dividing all resources in a shared memory into groups with preset numbers;
For each group in the preset number of groups, acquiring the locking times of each resource contained in the current group, and obtaining the total locking times corresponding to the current group according to the locking times;
and establishing the preset quick locking table based on all the total locking times and the group identification numbers corresponding to the preset number of groups.
The preset number may be preset, or may be determined according to the specific situation, which is not specifically limited in this embodiment. The group identification number may be understood as a code for distinguishing between the groups.
Specifically, as the shared memory of the database has more resources, all the resources in the shared memory are divided into groups with preset numbers, and each group comprises a plurality of resources. The method of resource division in this embodiment is not particularly limited. And for each group in the preset number of groups, acquiring the locking times of each resource contained in the current group, wherein the locking times are determined in an accumulated way according to the fact that the locking mode corresponding to the locking request is an exclusive type, when the locking mode corresponding to the locking request of a certain resource in the current group is the exclusive type, adding 1 to the locking times of the current group, and when the corresponding locking mode corresponding to the certain resource in the current group is released, subtracting 1 from the locking times of the current group, so that the updating of the locking times is realized. After the locking times of each resource contained in the current group are obtained, the locking times of each resource are accumulated to obtain the total locking times corresponding to the current group, and a preset quick locking table can be established based on all the total locking times and group identification numbers corresponding to the preset number of groups.
In this embodiment, the preset quick locking table is established in the above manner, so that the preset quick locking table is convenient to query in the following process, and the processing efficiency of the lock request is improved.
Fig. 2A is a flow chart of another lock request processing method according to an embodiment of the disclosure. This embodiment is optimized based on the above embodiment. Optionally, the present embodiment explains in detail whether the target locking request process is passed or not. As shown in fig. 2A, the method specifically includes the following steps:
S210, receiving a plurality of locking requests corresponding to target resources sent by a plurality of clients, wherein each locking request comprises a corresponding locking mode.
S220, inquiring a preset quick locking table when the target locking request is determined to be capable of accelerating according to all the locking modes, wherein the target locking request is at least one locking request in a plurality of locking requests.
S230, determining target locking times corresponding to the target resources in the preset quick locking table.
Because the preset quick locking table comprises the group identification number and the corresponding total locking times, the target locking times corresponding to the target resources can be determined by inquiring the preset quick locking table according to the group identification number of the target resources.
S240, determining whether to pass the target locking request according to the size relation between the target locking times and the preset threshold value.
The preset threshold may be preset, for example, the preset threshold may be set to 0, or may be set according to circumstances, which is not particularly limited in this embodiment. The preset threshold typically needs to be set to a positive integer.
After the target locking times are obtained, comparing the target locking times with a preset threshold value, so that the size relation between the target locking times and the preset threshold value can be obtained, and whether the target locking request is passed or not can be determined according to the size relation between the target locking times and the preset threshold value.
In this embodiment, a plurality of locking requests corresponding to a target resource sent by a plurality of clients are received first, where each locking request includes a corresponding locking mode, then, when it is determined that the target locking request can accelerate according to all the locking modes, a preset fast locking table is queried, where the target locking request is at least one locking request in the plurality of locking requests, then, the target locking times corresponding to the target resource in the preset fast locking table is determined, finally, according to the size relation between the target locking times and a preset threshold, whether the target locking request is passed or not is determined, and by the method, whether the target locking request is passed or not is simple and fast is determined, so that time can be saved, the lock request is processed fast, processing efficiency is improved, and a larger delay in accessing the resource is avoided.
In this embodiment, optionally, the determining whether to pass the target locking request according to the magnitude relation between the target locking number and the preset threshold includes:
Determining whether the target locking times exceeds a preset threshold value, if so, sending a target locking request to a lock controller so that the lock controller inquires lock information corresponding to target resources, determining whether the target locking request is passed or not according to the lock information, and if not, passing the target locking request.
The lock information corresponding to the target resource comprises a lock mode corresponding to the lock added by the target resource. A lock controller may be understood as a controller in the DBMS that handles locking requests that cannot be accelerated. The lock controller and the lock transit acceleration processor may or may not belong to the same thread or process, and the embodiment is not particularly limited.
After determining the target locking times, determining whether the target locking times exceed a preset threshold value, if the target locking times exceed the preset threshold value, indicating that the target locking request cannot be directly accelerated, and then, sending the target locking request to a lock controller, wherein the lock controller can determine whether the target locking request is passed through by inquiring lock information corresponding to target resources, and particularly can determine whether the target locking request is passed through a mutual exclusion relation between a lock mode corresponding to a lock which is already locked by the target resources and a lock mode corresponding to the target locking request, and if the target locking times do not exceed the preset threshold value, indicating that the target locking request can be directly accelerated, and enabling a client corresponding to the target locking request to access the target resources through the target locking request.
In this embodiment, by the method, whether the target locking request is passed or not can be more accurately determined, so that erroneous judgment is prevented.
In this embodiment, optionally, if it is determined that the target locking request cannot be accelerated, the target locking request is sent to a lock controller, so that the lock controller queries lock information corresponding to the target resource, and determines whether to pass the target locking request according to the lock information.
In this embodiment, a lock controller is added, when it is determined that the target locking request cannot be accelerated, the target locking request is sent to the lock controller, and whether the target locking request is passed or not is determined by the lock controller, so that when the target locking request cannot be accelerated, the target locking request can be continuously processed by the lock controller, and the working efficiency is improved.
Fig. 2B is a schematic structural diagram of a system for processing a lock request in an embodiment of the disclosure, and an implementation is shown in fig. 2B, where an example is shown:
the system comprises a client 1, a client 2, a lock transit acceleration processor and a lock controller. Data interaction can be conducted between the client 1 and the lock transit acceleration processor, data interaction can be conducted between the client 2 and the lock transit acceleration processor, and data interaction can be conducted between the lock transit acceleration processor and the lock controller. The client 1 and the client 2 are used for sending locking requests aiming at the resources in the shared memory to the lock transit acceleration processor, and the lock transit acceleration processor and the lock controller are used for correspondingly processing the locking requests.
It should be noted that, the client 1 and the client 2 in this embodiment are only used to illustrate the system, and the number of clients is not limited. A plurality of lock transit acceleration processors and lock controllers may be disposed, and the embodiment is not particularly limited.
In this embodiment, optionally, the method further includes adding the target locking request to an access waiting queue corresponding to the target resource if it is determined that the target locking request is not passed according to the lock information.
In this embodiment, if it is determined according to the lock information that the target locking request is not passed, the target locking request is added to the access waiting queue corresponding to the target resource, and the access waiting queue is used for ordering and waiting, so that the locking request can be further processed, and the processing procedure of other locking requests is not affected.
Fig. 3 is a schematic structural diagram of a lock request processing apparatus according to an embodiment of the present disclosure, where the apparatus is configured in a computer device, so as to implement a lock request processing method according to any embodiment of the present disclosure. The device specifically comprises the following steps:
a receiving module 310, configured to receive a plurality of locking requests corresponding to a target resource sent by a plurality of clients, where each locking request includes a corresponding locking mode;
The query module 320 is configured to query a preset fast locking table when it is determined that the target locking request can accelerate according to all the locking modes, where the target locking request is at least one locking request of the plurality of locking requests;
And the determining module 330 is configured to determine whether to pass the target locking request according to the target locking times corresponding to the target resource in the preset quick locking table.
In this embodiment, optionally, the apparatus further includes:
the acceleration determining module is specifically configured to obtain a lock mode category corresponding to each lock mode respectively before querying a preset quick locking table when it is determined that the target locking request can accelerate according to all the lock modes;
judging whether the locking requests are mutually exclusive according to the locking mode type;
And if the target locking request is not mutually exclusive with other locking requests and the locking mode category corresponding to the target locking request belongs to the sharing category, determining that the target locking request can accelerate.
In this embodiment, the optional determining module 330 is specifically configured to:
Determining target locking times corresponding to the target resources in the preset quick locking table;
And determining whether the target locking request is passed or not according to the size relation between the target locking times and a preset threshold value.
In this embodiment, optionally, the apparatus further includes:
The sending module is specifically configured to send the target locking request to a lock controller if it is determined that the target locking request cannot be accelerated or the target locking frequency exceeds a preset threshold, so that the lock controller queries lock information corresponding to the target resource, and determines whether to pass the target locking request according to the lock information.
In this embodiment, optionally, the apparatus further includes:
the adding module is specifically configured to add the target locking request to an access waiting queue corresponding to the target resource if it is determined that the target locking request is not passed according to the locking information
In this embodiment, optionally, the lock mode category includes at least one of table sharing, row sharing, update sharing, table exclusivity, row exclusivity, and update exclusivity.
In this embodiment, optionally, the preset quick locking table is established by the following manner:
dividing all resources in a shared memory into groups with preset numbers;
For each group in the preset number of groups, acquiring the locking times of each resource contained in the current group, and obtaining the total locking times corresponding to the current group according to the locking times;
and establishing the preset quick locking table based on all the total locking times and the group identification numbers corresponding to the preset number of groups.
According to the lock request processing device provided by the embodiment of the disclosure, by receiving a plurality of lock requests corresponding to a target resource and sent by a plurality of clients, wherein each lock request comprises a corresponding lock mode, when the target lock request is determined to be capable of accelerating according to all the lock modes, a preset quick lock table is queried, wherein the target lock request is at least one lock request in the plurality of lock requests, and according to the target lock times corresponding to the target resource in the preset quick lock table, whether the lock request is passed or not is determined, so that the lock request can be rapidly processed, the processing efficiency is improved, and the subsequent large delay in accessing the resource is avoided.
The lock request processing device provided by the embodiment of the disclosure can execute the lock request processing method provided by any embodiment of the disclosure, and has the corresponding functional modules and beneficial effects of the execution method.
Fig. 4 is a schematic structural diagram of a computer device according to an embodiment of the present disclosure. As shown in FIG. 4, the computer device includes a processor 410 and a storage 420, the number of processors 410 in the computer device may be one or more, one processor 410 being shown in FIG. 4 as an example, and the processors 410 and the storage 420 in the computer device may be connected by a bus or other means, the connection being shown in FIG. 4 as an example.
The storage device 420 is a computer readable storage medium, and may be used to store a software program, a computer executable program, and a module, such as program instructions/modules corresponding to the lock request processing method in the embodiment of the disclosure. The processor 410 executes various functional applications of the computer device and data processing by running software programs, instructions and modules stored in the storage 420, i.e., implements the lock request processing method provided by the embodiments of the present disclosure.
The storage device 420 may mainly include a storage program area which may store an operating system, an application program required for at least one function, and a storage data area which may store data created according to the use of the terminal, etc. In addition, the storage 420 may include high-speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid-state storage device. In some examples, storage 420 may further include memory remotely located relative to processor 410, which may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The computer equipment provided by the embodiment can be used for executing the lock request processing method provided by any embodiment, and has corresponding functions and beneficial effects.
The disclosed embodiments also provide a storage medium containing computer executable instructions that when executed by a computer processor are used to implement the lock request processing method provided by the disclosed embodiments.
Of course, the storage medium containing the computer executable instructions provided in the embodiments of the present disclosure is not limited to the method operations described above, and may also perform the related operations in the lock request processing method provided in any embodiment of the present disclosure.
From the above description of embodiments, it will be apparent to those skilled in the art that the present disclosure may be implemented by means of software and necessary general purpose hardware, but may of course also be implemented by means of hardware, although in many cases the former is a preferred embodiment. Based on such understanding, the technical solutions of the present disclosure may be embodied essentially or in a part contributing to the prior art in the form of a software product, which may be stored in a computer readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), a FLASH Memory (FLASH), a hard disk, or an optical disk of a computer, etc., including several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the method described in the embodiments of the present disclosure.
It should be noted that, in the embodiment of the lock request processing apparatus, each unit and module included are only divided according to the functional logic, but not limited to the above division, as long as the corresponding functions can be implemented, and the specific names of the functional units are only for convenience of distinguishing from each other, and are not used for limiting the protection scope of the disclosure.
It should be noted that in this document, relational terms such as "first" and "second" and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises an element.
The foregoing is merely a specific embodiment of the disclosure to enable one skilled in the art to understand or practice the disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the disclosure. Thus, the present disclosure is not intended to be limited to the embodiments shown and described herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (9)

1. A method of lock request processing, the method comprising:
receiving a plurality of locking requests corresponding to target resources sent by a plurality of clients, wherein each locking request comprises a corresponding locking mode;
inquiring a preset quick locking table when determining that target locking requests can accelerate according to all locking modes, wherein the target locking requests are at least one locking request in the plurality of locking requests;
Determining whether the target locking request is passed or not according to the target locking times corresponding to the target resources in the preset quick locking table;
The preset quick locking table is established by dividing all resources in a shared memory into preset number of groups, acquiring the locking times of each resource contained in a current group aiming at each group in the preset number of groups, obtaining the total locking times corresponding to the current group according to the locking times, and establishing the preset quick locking table based on all the total locking times and group identification numbers corresponding to the preset number of groups.
2. The method according to claim 1, wherein when it is determined that the target locking request can be accelerated according to all the lock modes, before querying the preset quick locking table, the method further comprises:
acquiring lock mode categories corresponding to the lock modes respectively;
judging whether the locking requests are mutually exclusive according to the locking mode type;
And if the target locking request is not mutually exclusive with other locking requests and the locking mode category corresponding to the target locking request belongs to the sharing category, determining that the target locking request can accelerate.
3. The method according to claim 1, wherein the determining whether to pass the target locking request according to the target locking times corresponding to the target resource in the preset fast locking table includes:
Determining target locking times corresponding to the target resources in the preset quick locking table;
And determining whether the target locking request is passed or not according to the size relation between the target locking times and a preset threshold value.
4. A method according to claim 3, further comprising:
If it is determined that the target locking request cannot be accelerated or the target locking times exceed a preset threshold, the target locking request is sent to a lock controller, so that the lock controller queries lock information corresponding to the target resource, and determines whether the target locking request is passed or not according to the lock information.
5. The method as recited in claim 4, further comprising:
And if the target locking request is determined not to pass according to the locking information, adding the target locking request into an access waiting queue corresponding to the target resource.
6. The method of claim 2, wherein the lock mode categories include at least one of table sharing, row sharing, update sharing, table exclusivity, row exclusivity, and update exclusivity.
7. A lock request processing apparatus, the apparatus comprising:
The receiving module is used for receiving a plurality of locking requests corresponding to the target resources, which are sent by a plurality of clients, wherein each locking request comprises a corresponding locking mode;
the query module is used for querying a preset quick locking table when determining that the target locking request can accelerate according to all the locking modes, wherein the target locking request is at least one locking request in the plurality of locking requests;
the determining module is used for determining whether the target locking request is passed or not according to the target locking times corresponding to the target resource in the preset quick locking table;
The preset quick locking table is established by dividing all resources in a shared memory into preset number of groups, acquiring the locking times of each resource contained in a current group aiming at each group in the preset number of groups, obtaining the total locking times corresponding to the current group according to the locking times, and establishing the preset quick locking table based on all the total locking times and group identification numbers corresponding to the preset number of groups.
8. A computer device, comprising:
one or more processors;
Storage means for storing one or more programs,
When executed by the one or more processors, causes the one or more processors to implement the method of any of claims 1-6.
9. A computer readable storage medium, on which a computer program is stored, characterized in that the program, when being executed by a processor, implements the method according to any of claims 1-6.
CN202111422224.8A 2021-11-26 2021-11-26 Lock request processing method, device, computer equipment and medium Active CN114138800B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111422224.8A CN114138800B (en) 2021-11-26 2021-11-26 Lock request processing method, device, computer equipment and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111422224.8A CN114138800B (en) 2021-11-26 2021-11-26 Lock request processing method, device, computer equipment and medium

Publications (2)

Publication Number Publication Date
CN114138800A CN114138800A (en) 2022-03-04
CN114138800B true CN114138800B (en) 2025-06-03

Family

ID=80388400

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111422224.8A Active CN114138800B (en) 2021-11-26 2021-11-26 Lock request processing method, device, computer equipment and medium

Country Status (1)

Country Link
CN (1) CN114138800B (en)

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110430258A (en) * 2019-08-01 2019-11-08 哈尔滨哈工大大数据通用技术有限公司 A kind of distributed type lock management method and device

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9460144B2 (en) * 2012-01-13 2016-10-04 Oracle International Corporation Lock acceleration
CN107633090A (en) * 2017-09-29 2018-01-26 郑州云海信息技术有限公司 A kind of method split based on distributed type file system client side lock
CN111258976A (en) * 2018-12-03 2020-06-09 北京京东尚科信息技术有限公司 Distributed lock implementation method, system, device and storage medium
US11113262B2 (en) * 2019-04-01 2021-09-07 Sap Se Time-efficient lock release in database systems
US11294737B2 (en) * 2019-06-24 2022-04-05 International Business Machines Corporation Self-managed lock access
CN112148695A (en) * 2019-06-26 2020-12-29 华为技术有限公司 A resource lock management method and device
US11321300B2 (en) * 2019-10-08 2022-05-03 Huawei Technologies Co., Ltd. Method and system for fast processing of locks requested to access a shared resource

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110430258A (en) * 2019-08-01 2019-11-08 哈尔滨哈工大大数据通用技术有限公司 A kind of distributed type lock management method and device

Also Published As

Publication number Publication date
CN114138800A (en) 2022-03-04

Similar Documents

Publication Publication Date Title
CN102682052B (en) The data query that filtering data stores
US8954391B2 (en) System and method for supporting transient partition consistency in a distributed data grid
US10599677B2 (en) Methods and systems of splitting database indexes and digests
JP2011505615A (en) Statistical application in OLTP environment
US20080109813A1 (en) Resource assignment method, resource assignment program and management computer
US12164676B2 (en) Enabling an action based on a permission identifier for real-time identity resolution in a distributed system
RU2585973C2 (en) Method and apparatus for controlling locking operation of database system
US20240119053A1 (en) Fingerprints for database queries
US9785697B2 (en) Methods and apparatus for implementing a distributed database
CN108509524A (en) Method, server and the system of data processing of data processing
WO2022252510A1 (en) Resource management method, apparatus and device
WO2021017907A1 (en) Method and device for optimized inter-microservice communication
CN110798492B (en) Data storage method and device and data processing system
EP3507699B1 (en) Method and systems for master establishment using service-based statistics
CN113839940A (en) URL pattern tree-based defense method and device, electronic equipment and readable storage medium
CN114138800B (en) Lock request processing method, device, computer equipment and medium
CN108306976B (en) SDN controller architecture used in cloud computing network virtualization
CN113516476B (en) Account reconciliation processing method and device
CN117135209B (en) Industrial Internet identification data batch registration method, device and medium
CN117076492A (en) Business data query method, device, equipment and storage medium
CN119127875A (en) Business report generation method, device, equipment and storage medium
CN116881288A (en) Data query method, device and equipment
CN112416552B (en) Main task processing method, device, server and storage medium
CN111221847A (en) Monitoring data storage method and device and computer readable storage medium
CN115914387A (en) Resource sharing and data query method, device and server

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
CB02 Change of applicant information
CB02 Change of applicant information

Country or region after: China

Address after: 100102 201, 2 / F, 101, No. 5 building, No. 7 Rongda Road, Chaoyang District, Beijing

Applicant after: China Electronics Technology Group Jincang (Beijing) Technology Co.,Ltd.

Address before: 100102 201, 2 / F, 101, No. 5 building, No. 7 Rongda Road, Chaoyang District, Beijing

Applicant before: BEIJING KINGBASE INFORMATION TECHNOLOGIES Inc.

Country or region before: China

GR01 Patent grant
GR01 Patent grant