Database request processing method and apparatus, electronic device, readable medium, and program product

By performing semantic analysis and rate limiting strategy retrieval on database access statements, fine-grained rate limiting for specific statement structures is achieved, solving the problem of imprecise rate limiting control in existing technologies and improving the database's response speed and execution efficiency.

WO2026040661A1PCT designated stage Publication Date: 2026-02-26TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
PCT/CN2025/106813
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2024-08-23
Filing Date
2025-07-03
Publication Date
2026-02-26

AI Technical Summary

Technical Problem

In existing database concurrency control schemes, rate limiting conditions are set for the entire database, resulting in insufficient control granularity. When a large amount of traffic generated by some functions reaches the connection limit, the database processing delay increases, affecting the overall response speed and execution efficiency.

Method used

By performing semantic analysis on database access statements, we can obtain statement structure identifiers and retrieve corresponding policy entries from the rate limiting policy set. Based on statement execution information and rate limiting policies, we can control database access requests, achieve fine-grained rate limiting for specific statement structures, and avoid affecting other access statements.

Benefits of technology

It improves the granularity of database rate limiting control, enhances the overall response speed and execution efficiency of the database, and reduces the impact on other access statements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2025106813_26022026_PF_FP_ABST
    Figure CN2025106813_26022026_PF_FP_ABST
Patent Text Reader

Abstract

Provided in the present application are a database request processing method and apparatus, an electronic device, and a readable medium. The method comprises: acquiring a database access request, the database access request comprising a database access statement; performing semantic analysis on a target statement structure of the database access statement to obtain a target statement structure identifier corresponding to the target statement structure; on the basis of the statement structure identifier, retrieving from a rate-limiting policy set a target policy entry corresponding to the target statement structure identifier, the target policy entry comprising statement execution information of the target statement structure and a target statement rate-limiting policy for the target statement structure; and if the statement execution information does not reach a rate-limiting condition in the target statement rate-limiting policy, executing the database access request.
Need to check novelty before this filing date? Find Prior Art

Description

Database request processing method and device, electronic equipment, readable medium and program product TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a database request processing method and device, electronic equipment, readable medium and computer program product.

[0002] BACKGROUND

[0003] With the rapid development of the Internet industry, the access frequency faced by various Internet applications is increasing, which also leads to an increase in database traffic. A large number of requests will cause a large load on the database. Therefore, the control of database concurrency has become a key factor to maintain stable operation of the database.

[0004] In related technologies, the number of connections can be added to the database to control or limit the number of concurrent accesses to the database. SUMMARY

[0005] To solve the above technical problems, the present application provides a database request processing method and device, electronic equipment and readable medium to improve the precision of database flow control and improve the overall response speed and execution efficiency of the database.

[0006] Other features and advantages of the present application will become apparent from the following detailed description, or will be learned by practice of the present application.

[0007] According to an aspect of an embodiment of the present application, a database request processing method is provided, comprising:

[0008] Obtaining a database access request, wherein the database access request contains a database access statement;

[0009] Performing semantic analysis on a target statement structure of the database access statement to obtain a target statement structure identifier corresponding to the target statement structure;

[0010] Retrieving a target policy item corresponding to the target statement structure identifier from a flow control policy set according to the target statement structure identifier, wherein the target policy item contains statement execution information of the target statement structure and a target statement flow control policy for the target statement structure;

[0011] If the statement execution information does not meet a flow control condition in the target statement flow control policy, executing the database access request.

[0012] According to an aspect of an embodiment of the present application, a database request processing device is provided, comprising:

[0013] The request obtaining module is configured to obtain a database access request, wherein the database access request comprises a database access statement;

[0014] The semantic analysis module is configured to perform semantic analysis on a target statement structure of the database access statement to obtain a target statement structure identifier corresponding to the target statement structure.

[0015] The policy retrieving module is configured to retrieve, according to the target statement structure identifier, a target policy entry corresponding to the target statement structure identifier from a flow control policy set, wherein the target policy entry comprises statement execution information of the target statement structure and a target statement flow control policy for the target statement structure.

[0016] The request executing module is configured to execute the database access request if the statement execution information does not reach a flow control condition in the target statement flow control policy.

[0017] In some embodiments of the present application, based on the above technical solutions, the request executing module is specifically configured to: obtain a statement concurrency quantity in the statement execution information and a maximum concurrency quantity in the target statement flow control policy; if the statement concurrency quantity is lower than the maximum concurrency quantity, increment the statement concurrency quantity in the statement execution information; execute the database access request and decrement the statement concurrency quantity in the statement execution information after the database access statement is executed.

[0018] In some embodiments of the present application, based on the above technical solutions, the request executing module is specifically configured to: if the statement concurrency quantity is lower than the maximum concurrency quantity, obtain a policy access lock for the target policy entry; increment the statement concurrency quantity and save it into the statement execution information of the target policy entry; release the policy access lock and a shared access lock for the flow control policy set, wherein the shared access lock is an access control lock obtained for the flow control policy set before the target policy entry is queried.

[0019] In some embodiments of the present application, based on the above technical solutions, the database access statement comprises calling information of a specified access statement; the request executing module is further configured to: obtain a specified policy entry corresponding to the specified access statement according to the calling information; and if a statement concurrency quantity of statement execution information in the specified policy entry is higher than a maximum concurrency quantity of a specified statement flow control policy in the specified policy entry, stop processing the database access request.

[0020] In some embodiments of the present application, based on the above technical solutions, the policy retrieval module is further configured to: acquire a flow limiting policy addition request, the flow limiting policy addition request containing an addition statement structure identifier or an access statement of an addition statement structure and an addition statement flow limiting policy corresponding to the addition statement structure; acquire an exclusive access lock for the flow limiting policy set; add an addition policy entry corresponding to the addition statement structure to the flow limiting policy set according to the flow limiting policy addition request, the addition policy entry containing the addition statement flow limiting policy; modify policy quantity information in the flow limiting policy set and release the exclusive access lock.

[0021] In some embodiments of the present application, based on the above technical solutions, the policy retrieval module is further configured to: if the flow limiting policy addition request contains an addition statement structure identifier, query an addition statement structure according to the addition statement structure identifier; if the flow limiting policy addition request contains an access statement, perform semantic analysis on a statement structure of the access statement to obtain an addition statement structure, and calculate the addition statement structure identifier according to the addition statement structure.

[0022] In some embodiments of the present application, based on the above technical solutions, the policy retrieval module is further configured to: if the flow limiting policy addition request contains a policy persistence identifier, acquire a policy entry corresponding to the addition statement structure identifier in the flow limiting policy set, the policy entry containing the addition statement flow limiting policy; insert the policy entry into a policy data table corresponding to the flow limiting policy set.

[0023] In some embodiments of the present application, based on the above technical solutions, the policy retrieval module is further configured to: acquire a policy loading instruction; according to the policy loading instruction, traverse each policy entry in the policy data table; in the process of traversing the policy data table, load each policy entry into the flow limiting policy set.

[0024] In some embodiments of the present application, based on the above technical solutions, the policy retrieval module is further configured to: acquire a policy unloading instruction, the policy unloading instruction containing a statement structure identifier to be unloaded; according to the policy unloading instruction, delete a policy entry corresponding to the statement structure identifier to be unloaded from the flow limiting policy set; if the policy unloading instruction contains a policy deletion identifier, according to the policy unloading instruction, delete a policy entry corresponding to the policy deletion identifier from the policy data table.

[0025] In some embodiments of the present application, based on the above technical solutions, the policy retrieval module is specifically configured to: generate a policy query instruction according to the target statement structure identifier; according to the policy query instruction, query a target policy entry corresponding to the target statement structure identifier from a policy data table corresponding to the flow limiting policy set.

[0026] In some embodiments of this application, based on the above technical solutions, the semantic analysis module is further configured to: obtain the requester account information of the database access request; and execute the database access request if the requester is a specified account in the target statement rate limiting policy according to the requester account information.

[0027] According to one aspect of the embodiments of this application, an electronic device is provided, the electronic device comprising: a processor; and a memory for storing executable instructions of the processor; wherein the processor is configured to perform the database request processing method as described above by executing the executable instructions.

[0028] According to one aspect of the embodiments of this application, a computer-readable storage medium is provided, on which a computer program is stored, which, when executed by a processor, implements the database request processing method as described in the above technical solutions.

[0029] According to one aspect of the embodiments of this application, a computer program product or computer program is provided, which includes computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the database request processing method provided in the various optional implementations described above.

[0030] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and do not limit this application.

[0031] Brief description of the attached figures

[0032] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application. It is obvious that the drawings described below are merely some embodiments of this application, and those skilled in the art can obtain other drawings based on these drawings without any inventive effort.

[0033] Figure 1 shows the system architecture of the database request processing method of this application applied to a cloud host platform.

[0034] Figure 2 is a flowchart of a database request processing method according to an embodiment of this application.

[0035] Figure 3 is a flowchart of a database request processing method according to an embodiment of this application.

[0036] Figure 4 is a flowchart of a database request processing method according to an embodiment of this application.

[0037] Figure 5 is a diagram of the overall structure of the current-limiting scheme in the embodiment of the present application.

[0038] Figure 6 is a diagram of the concurrent control process in the embodiment of the present application.

[0039] Figure 7 is a diagram of the overall flow of the addition of a policy in the embodiment of the present application.

[0040] Figure 8 is a diagram of the executor phase in the embodiment of the present application.

[0041] Figure 9 is a diagram of the constituent blocks of the database request processing apparatus in the embodiment of the present application.

[0042] Figure 10 is a diagram of the structure of a computer system of an electronic device suitable for implementing the embodiment of the present application.

[0043] Manner of implementing the present application

[0044] Example implementations will now be described more fully with reference to the accompanying drawings. Example implementations may, however, be implemented in many different forms and should not be construed as limited to the implementations set forth herein; rather, these implementations are provided so that this disclosure will be thorough and complete, and will fully convey the inventive aspects to those skilled in the art. Like reference numerals may refer to like elements throughout the description.

[0045] Moreover, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the application. One skilled in the relevant art will recognize, however, that the

[0046] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program having a predetermined function, and works together with other relevant parts to achieve the predetermined function, and can be implemented wholly or partially using software, hardware (such as a processing circuit or a memory), or a combination thereof. Similarly, one processor (or multiple processors or memories) can be used to implement one or more modules or units. Furthermore, each module or unit can be a part of an overall module or unit that includes the function of the module or unit.

[0047] The block diagrams shown in the drawings are merely functional entities, and do not necessarily have to correspond to physically independent entities. That is, the functional entities can be implemented in the form of software, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.

[0048] The flowcharts shown in the drawings are only illustrative, and do not necessarily include all contents and operations / steps, nor are they necessarily executed in the order described. For example, some operations / steps can be further decomposed, and some operations / steps can be combined or partially combined, so the actual execution order can be changed according to actual conditions.

[0049] It should be understood that the scheme of the present application can be applied in a database system, and specifically in the scenario of the database system limiting the structured query language of the database. Network applications often face situations of large traffic, which usually brings large access to the database. For example, a shopping website will generate more database access for product information queries when holding an event, or more user login or user registration access when launching a new game. Such situations usually increase the load pressure of the database, causing the overall response speed of the database to decrease.

[0050] However, the present inventors have found that in the current database concurrency control scheme, the throttling condition is set for the entire database, and the control precision of the database throttling is insufficient. When the large amount of traffic generated by part of the functions reaches the connection limit, the processing delay of the database for each request will become longer, thereby affecting the overall response speed and execution efficiency of the database.

[0051] Based on this, the technical scheme of the embodiments of the present application proposes a database request processing scheme. Specifically, referring to FIG. 1, according to the database request processing method of the present application, the system structure of the application in the database system can mainly include two parts, a business server 110 and a database server 120. The business server 110 and the database server 120 can be centralized servers or distributed servers, and the devices in each part of the system structure can include smartphones, tablets, laptops, smart voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, etc. The devices of the block chain can also be servers providing various services, which can be independent physical servers, or server clusters or distributed systems composed of multiple physical servers, or cloud servers providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and basic cloud computing services such as big data and artificial intelligence platforms. There can be various connection types of communication media between devices, such as wired communication links or wireless communication links.

[0052] According to implementation requirements, the system architecture in the embodiments of the present application can have any number of terminal devices and servers. For example, the devices of the parts such as the service server 110 and the database server 120 can be server groups composed of multiple server devices. In addition, the technical solutions provided by the embodiments of the present application can be applied to a computing platform, or can be jointly implemented by various parts in the system, and the present application does not specially limit this.

[0053] As shown in FIG. 1, the user terminal can initiate a request for browsing a specific page or performing a specific function to the service server 110, and the service server 110 initiates a database access request for required data to the database server 120 according to the request of the user terminal. The database server 120 determines the current load of the same type of statement in the database and the flow limiting policy for the same type of statement according to the statement structure of the database access statement contained in the received request. If the current load has exceeded the provision of the flow limiting policy, the database will limit the database access request with the same type of statement structure, for example, directly report an error or process the request through queuing.

[0054] The implementation details of the technical solutions of the embodiments of the present application are described in detail as follows: FIG. 2 shows a flowchart of a database request processing method according to one embodiment of the present application, which can be executed by a device with computing processing function, such as a server or a terminal device of a database system. Referring to FIG. 2, the database request processing at least includes steps S210 to S240, which are described in detail as follows:

[0055] Step S210, obtaining a database access request, wherein the database access request contains a database access statement.

[0056] The database system usually obtains a database access request from a service server or a user terminal. The database access request contains a database access statement. The database access statement is obtained by using a structured query language of a database, and is usually used to query and update data in the database.

[0057] Step S220, performing semantic analysis on a target statement structure of the database access statement to obtain a target statement structure identifier corresponding to the target statement structure.

[0058] The database system performs semantic analysis on the target statement structure of the received database access statement, and obtains a target statement structure identifier corresponding to the target statement structure. The database access statement can be considered to be obtained by combining a statement structure and business parameters. The statement structure is related to the function to be implemented by the database access statement, and the business parameters are determined according to specific business data. The statement structure is different for different purposes of the database access statement, but does not change with the change of specific business data. For example, statements for querying prices of different commodities can have the same statement structure, and the business parameters therein depend on different commodities browsed by customers. For example, the statement structure for querying information of a certain commodity is "select id, data from table_a where id = 600", and the semantic analysis obtains a structure of "select id, data from table_a where id = @1", where @1 represents the position of a business parameter. In the database system, different statement structures have different statement structure identifiers, which can be obtained by, for example, performing hash coding on the statement structure. In some embodiments, there is a table, view or data structure in the database for storing statement structures and statement structure identifiers. Therefore, the database system can obtain the corresponding statement structure through the statement structure identifier, or calculate the corresponding statement structure identifier through the statement structure.

[0059] In step S230, the target statement structure identifier is used to retrieve a target policy entry corresponding to the target statement structure identifier from a set of throttling policies. The target policy entry contains statement execution information of the target statement structure and a target statement throttling policy for the target statement structure.

[0060] The database system can retrieve a target policy entry corresponding to the target statement structure identifier from a set of throttling policies according to the statement structure identifier. The set of throttling policies is a set of policies for throttling according to statement structures, which is pre-set in the database system. The set of throttling policies can be saved in the memory of the database system in the form of a hash table. The set of throttling policies contains the correspondence between target statement structure identifiers and policy entries. A policy entry contains throttling-related data of a statement structure, including statement execution information and a statement throttling policy. The statement execution information mainly contains how many database access statements with the same statement structure are currently being executed in parallel in the current database, and can also contain how many such statistics are triggered by the policy. The statement throttling policy mainly contains throttling conditions for the statement, such as the maximum number of concurrent statements, and information about the effective range and effective mode of the throttling policy.

[0061] If the statement execution information does not reach the throttling condition in the target statement throttling policy, the database access request is executed.

[0062] If the statement execution information does not reach the throttling condition required in the target statement throttling policy, for example, the current database load is lower than the required load in the policy, it indicates that the concurrent data of the current statement structure does not need to be throttled, and thus the database access request can be executed. Correspondingly, if the statement execution information reaches the throttling condition required in the target statement throttling policy, for example, the load of the current system is higher than the required load in the policy, the database access request can not be executed, but an error message indicating execution failure is sent to the requester or the database access request is put into a request queue for queued execution.

[0063] In an embodiment of the present application, the database system obtains a database access request containing a database access statement, and performs semantic analysis on a target statement structure of the database access statement to obtain a target statement structure identifier corresponding to the target statement structure. According to the statement structure identifier, the database system can retrieve a target policy entry corresponding to the target statement structure identifier from a throttling policy set, wherein the target policy entry contains statement execution information of the target statement structure and a target statement throttling policy for the target statement structure. If the statement execution information does not reach the throttling condition in the target statement throttling policy, the database system executes the database access request. In this way, the database system can throttle the database access statement containing a specific statement structure according to the throttling policy, implement flow control for specific access statements, limit the large flow of part of the access statements while avoiding affecting the requests of other access statements, improve the precision of database throttling control, and thus improve the overall response speed and execution efficiency of the database.

[0064] In the embodiments of the present application, based on the technical solutions of the present application, in the process of retrieving the target policy item corresponding to the target statement structure identifier from the throttling policy set according to the target statement structure identifier, the database system generates a policy query instruction according to the target statement structure identifier, and then queries the target policy item corresponding to the target statement structure identifier from the policy data table corresponding to the throttling policy set according to the policy query instruction. In the present embodiment, the throttling policy set is saved in a data table in the database. When the database system needs to query the policy item, it needs to generate a policy query instruction according to the statement structure identifier. The policy query instruction is usually generated by the structured query language of the database, such as a database access statement for table query. The database system accesses the policy data table corresponding to the throttling policy set by executing the generated policy query instruction, so as to obtain the target policy item corresponding to the statement structure identifier in the policy data table. By querying the policy item from the policy data table corresponding to the throttling policy set, compared with querying the throttling policy set from the hash table in the memory, the inconsistency of the throttling policy for processing the request caused by the update of the item in the memory can be avoided, and the consistency of the information in the policy item is ensured.

[0065] In the embodiments of the present application, based on the technical solutions of the present application, before performing semantic analysis on the target statement structure of the database access statement, the database system further acquires the requestor account information of the database access request, and then according to the requestor account information, if the requestor is a specified account in the target statement throttling policy, the database access request is executed. In the present embodiment, before the database system acquires the policy item to perform the throttling action check, it will first check whether the requestor of the database access request belongs to a specified account, such as whether it is an administrator account or whether it belongs to a special account with a specific identifier or a specific prefix. If it is a specified account, the database system will not perform throttling check, but directly execute the database access request of the requestor. In this way, the specified account is allowed to bypass the control of the throttling, so that the specific user can bypass the concurrency control to access the database, which is beneficial to testing in the case where concurrency control has occurred, and improves the security of the scheme.

[0066] In the embodiments of the present application, other embodiments are further proposed to refine the technical solutions of the embodiment shown in FIG. 2, as shown in FIG. 3, in the database request processing method of an embodiment of the present application, the scheme of the present application can include the following steps:

[0067] Step S310, acquiring a database access request, wherein the database access request contains a database access statement.

[0068] Optionally, the implementation details of step S310 are consistent with step S210 shown in FIG. 2, and will not be described again.

[0069] Step S320, performing semantic analysis on the target statement structure of the database access statement to obtain a target statement structure identifier corresponding to the target statement structure.

[0070] Optionally, the implementation details of step S320 are consistent with step S220 shown in FIG. 2, and will not be described herein again.

[0071] Step S330, retrieving a target policy entry corresponding to the target statement structure identifier from a throttling policy set according to the target statement structure identifier, wherein the target policy entry contains statement execution information of the target statement structure and a target statement throttling policy for the target statement structure.

[0072] Optionally, the implementation details of step S330 are consistent with step S230 shown in FIG. 2, and will not be described herein again.

[0073] Step S340, obtaining a statement concurrency quantity in the statement execution information and a maximum concurrency quantity in the target statement throttling policy.

[0074] Step S350, if the statement concurrency quantity is lower than the maximum concurrency quantity, then incrementing the statement concurrency quantity in the statement execution information.

[0075] Step S360, executing the database access request, and decrementing the statement concurrency quantity in the statement execution information after the database access statement is executed.

[0076] In this embodiment, the database system throttles statements according to the concurrency quantity of statements with the same statement structure. Specifically, the statement concurrency data is contained in the statement execution information, which is used to indicate how many database access statements with the same statement structure are currently being executed in the database. The maximum concurrency quantity is contained in the target statement throttling policy, which is used to indicate the maximum concurrency quantity of database access statements with the same statement structure allowed. If the statement concurrency quantity is lower than the maximum concurrency quantity, it indicates that the database access statements with the same statement structure can be concurrently executed in the database system. At this time, the database system will increment the statement concurrency quantity in the statement execution information, and then execute the database access request. After the database access statement is executed, the database system will also decrement the statement concurrency quantity in the statement execution information. In this way, the database system updates the concurrency quantity in time when throttling control is performed, and does not need to detect the concurrency quantity when the target statement throttling policy is checked, thereby facilitating the improvement of the execution efficiency of the throttling process.

[0077] In the embodiments of the present application, the database system obtains a database access request containing a database access statement, then performs semantic analysis on the target statement structure of the database access statement to obtain a target statement structure identifier corresponding to the target statement structure. According to the statement structure identifier, the database system can retrieve a target policy entry corresponding to the target statement structure identifier from the flow limiting policy set, wherein the target policy entry contains the statement execution information of the target statement structure and the target statement flow limiting policy for the target statement structure. If the statement execution information does not meet the flow limiting condition in the target statement flow limiting policy, the database system executes the database access request. In this way, the database system can limit the flow of database access statements containing specific statement structures according to the flow limiting policy, implement flow control for specific access statements, limit the large flow of part of the access statements while avoiding affecting the requests of other access statements, improve the fineness of database flow limiting control, and thus improve the overall response speed and execution efficiency of the database.

[0078] In the embodiments of the present application, based on the technical solutions of the present application, in the process of retrieving the target policy entry corresponding to the target statement structure identifier from the flow limiting policy set according to the target statement structure identifier, the database system generates a policy query instruction according to the target statement structure identifier, and then queries the target policy entry corresponding to the target statement structure identifier from the policy data table corresponding to the flow limiting policy set according to the policy query instruction. In this embodiment, the flow limiting policy set is saved in the data table in the database. When the database system needs to query the policy entry, it needs to generate a policy query instruction according to the statement structure identifier. The policy query instruction is usually generated by the structured query language of the database, for example, a database access statement used for table query. The database system accesses the policy data table corresponding to the flow limiting policy set by executing the generated policy query instruction, so as to obtain the target policy entry corresponding to the statement structure identifier in the policy data table. By querying the policy entry from the policy data table corresponding to the flow limiting policy set, compared with querying the flow limiting policy set from the hash table in the memory, the inconsistency of the flow limiting policy for processing requests caused by the update of the entry in the memory can be avoided, and the consistency of the information in the policy entry can be ensured.

[0079] In the embodiments of the present application, based on the technical solutions of the present application, before performing semantic analysis on the target statement structure of the database access statement, the database system further acquires the requestor account information of the database access request, and then according to the requestor account information indicating that the requestor is a specified account in the flow limiting policy of the target statement, the database access request is executed. In this embodiment, before the database system checks the policy entry to perform the flow limiting action, it first checks whether the requestor of the database access request belongs to the specified account, for example, whether it is an administrator account or whether it belongs to a special account with a specific identifier or a specific prefix. If it is a specified account, the database system will not perform flow limiting check, but directly execute the database access request of the requestor. In this way, the specified account is allowed to bypass the flow control, so that the specific user can access the database by bypassing the concurrency control, which is beneficial to testing in the case where concurrency control has occurred, and improves the security of the scheme.

[0080] In the embodiments of the present application, based on the technical solutions of the present application, if the number of concurrent statements is less than the maximum number of concurrent statements, the database system will first acquire a policy access lock for the target policy entry in the process of incrementing the number of concurrent statements in the target statement throttling policy, then increment the number of concurrent statements and save it to the statement execution information of the target policy entry, and finally release the policy access lock and the shared access lock for the throttling policy set, wherein the shared access lock is an access control lock acquired for the throttling policy set before querying the target policy entry. In this embodiment, the database system will lock the target policy entry and the throttling policy set respectively during throttling. Specifically, before querying the throttling policy set, the database system will acquire a shared access lock for the throttling policy set. This shared access lock will allow other requests to also read the throttling policy set, but will not allow modification of the throttling policy set. Subsequently, after determining that the statement in the database access request can be executed, the database system will acquire a policy access lock for the target policy entry. This policy access lock is mainly used to lock the corresponding policy entry, and does not allow other requests to read and modify the target policy entry. At this time, the current request processing process has acquired two locks, allowing the current processing process to modify the data in the target policy entry, but cannot modify other unlocked entries, while other requests can read other entries in the throttling policy set except the locked target policy entry, and in the case of need, other requests can also acquire a policy access lock for other entries except the locked target policy entry. After acquiring the required locks, the database system will increment the number of concurrent statements and save it to the statement execution information of the target policy entry, thereby updating the target policy entry. After updating is completed, the data system releases the two acquired locks at one time, thereby completing the locking and updating process. By locking the policy entries of the throttling policy set respectively, the sharing access degree of the data in the throttling policy set can be ensured while ensuring data consistency, avoiding the extension of request processing delay caused by resource contention during throttling execution, and improving the processing efficiency of access requests.

[0081] In the embodiments of the present application, based on the technical solutions of the present application, the calling information of the specified access statement is included in the database access statement, and the database system further acquires the specified policy entry corresponding to the specified access statement according to the calling information; if the number of concurrent statements of the statement execution information in the specified policy entry is higher than the maximum number of concurrent statements of the specified statement flow control policy in the specified policy entry, the database access request is stopped from being processed. In the embodiments, when there is a nested call in the database request, the database system further performs flow control according to the statement of the nested call. Specifically, another database access statement can be called in the database access statement. In the embodiments, for such a call, the database system further performs flow control policy checking on the called access statement according to the calling information, and if the called statement is in a state that needs to be flow controlled, the caller in the current access request is also flow controlled. In some embodiments, the calling information includes multiple levels of nested calls, and the database system can check whether the database access statements in all calling levels are in a flow controlled state, and if any database access statement in any calling level is flow controlled, the current database access request is stopped from being processed. In other embodiments, the database system can no longer perform flow control checking on the calls after a certain nesting level. For example, the checking level of the nested call is specified as 3 in the target policy entry, and the database access statement includes 4 levels of nested calls, and whether the statement of the fourth level of nested call is in a flow controlled state does not affect the processing of the current database access request. It can be understood that the detection level can be set to 0 or 1, so that only the database access statement of the database access request itself is flow controlled and checked, and the statements of the called levels do not need to be checked. In this way, the database system allows specific flow control checking settings for different nested calls of the database access statement, which is beneficial to improving the controllability and flexibility of the flow control checking process in the scheme.

[0082] In the embodiments of the present application, other embodiments are further proposed for the technical solutions of the embodiment shown in FIG. 2, as shown in FIG. 4. In the database request processing method of an embodiment of the present application, the scheme of the present application can include the following steps:

[0083] Step S410, acquiring a database access request, wherein the database access request includes a database access statement.

[0084] Optionally, the implementation details of step S410 are consistent with step S210 shown in FIG. 2, and will not be described again.

[0085] Step S420, performing semantic analysis on a target statement structure of the database access statement to obtain a target statement structure identifier corresponding to the target statement structure.

[0086] Optionally, the implementation details of step S420 are consistent with step S220 shown in FIG. 2, and will not be repeated here.

[0087] Step S430, retrieving a target policy entry corresponding to the target statement structure identifier from the throttling policy set according to the target statement structure identifier, wherein the target policy entry contains statement execution information of the target statement structure and a target statement throttling policy for the target statement structure.

[0088] Optionally, the implementation details of step S430 are consistent with step S230 shown in FIG. 2, and will not be repeated here.

[0089] Step S440, if the statement execution information does not reach the throttling condition in the target statement throttling policy, executing the database access request.

[0090] Optionally, the implementation details of step S440 are consistent with step S240 shown in FIG. 2, and will not be repeated here.

[0091] Step S450, obtaining a throttling policy addition request, wherein the throttling policy addition request contains an addition statement structure identifier or an access statement of an addition statement structure and an addition statement throttling policy corresponding to the addition statement structure.

[0092] Step S460, obtaining an exclusive access lock for the throttling policy set.

[0093] Step S470, according to the throttling policy addition request, adding an addition policy entry corresponding to the addition statement structure to the throttling policy set, wherein the addition policy entry contains the addition statement throttling policy.

[0094] Step S480, modifying the policy quantity information in the throttling policy set and releasing the exclusive access lock.

[0095] In the present embodiment, the database system can add a corresponding policy entry in the throttling policy set according to a throttling policy addition request proposed by the user. Specifically, the throttling policy addition request contains an addition statement structure identifier of an addition statement structure or an access statement and an addition statement throttling policy corresponding to the addition statement structure. It can be understood that if the throttling policy addition request contains an access statement of an addition statement structure, the database system can perform semantic analysis on the access statement to obtain the addition statement structure identifier. If the throttling policy addition request directly contains the addition statement structure identifier, it means that the database system has already performed semantic analysis on the addition statement structure, and thus the addition statement structure identifier can be directly used to create a new policy entry. Before adding the new policy entry, the database system acquires an exclusive access lock of the throttling policy set. The exclusive access lock and the shared access lock described above can be different locking modes of the same lock. That is, the throttling policy set locked by the shared access lock cannot be locked by the exclusive access lock, and vice versa. The exclusive access lock prevents other requests from reading and modifying the throttling policy set. During the period of being locked by the exclusive access lock, only the process that has acquired the lock can modify the content in the throttling policy set. After being locked, the database system adds an addition policy entry corresponding to the addition statement structure to the throttling policy set according to the throttling policy addition request, and the addition policy entry contains the addition statement throttling policy. In some embodiments, the addition policy entry also contains initialized statement execution information, for example, the concurrency number can be initialized to 0. It can be understood that if the throttling policy set already contains a policy entry corresponding to the addition statement structure identifier, the database system can report an error to the addition request, or directly update the corresponding policy entry, depending on the specific instructions. After the addition of the entry is completed, the database system modifies the policy quantity information in the throttling policy set and releases the exclusive access lock. The policy quantity information is statistical information of the throttling policy in the throttling policy set. The throttling policy set can also contain other statistical information, for example, how many times each throttling policy is triggered, the time period of triggering, the triggering frequency, and the number of rejected requests during throttling, etc. The user can query these information from the throttling policy set through a query instruction and display these information in the form of a graphical interface, thereby allowing the user or the database administrator to more intuitively understand the execution status of the database throttling. Through the above-mentioned manner, the database system allows to update and maintain the throttling policy set without additional resources to manage the information of the throttling policy set, which is conducive to reducing the resource consumption of the throttling scheme.

[0096] In the embodiments of the present application, the database system obtains a database access request containing a database access statement, then performs semantic analysis on the target statement structure of the database access statement to obtain a target statement structure identifier corresponding to the target statement structure. According to the statement structure identifier, the database system can retrieve a target policy entry corresponding to the target statement structure identifier from the flow limiting policy set, wherein the target policy entry contains the statement execution information of the target statement structure and the target statement flow limiting policy for the target statement structure. If the statement execution information does not meet the flow limiting condition in the target statement flow limiting policy, the database system executes the database access request. In this way, the database system can limit the flow of database access statements containing specific statement structures according to the flow limiting policy, implement flow control for specific access statements, limit the large flow of part of the access statements while avoiding affecting the requests of other access statements, improve the fineness of database flow limiting control, and thus improve the overall response speed and execution efficiency of the database.

[0097] In the embodiments of the present application, based on the technical solutions of the present application, in the process of retrieving the target policy entry corresponding to the target statement structure identifier from the flow limiting policy set according to the target statement structure identifier, the database system generates a policy query instruction according to the target statement structure identifier, and then queries the target policy entry corresponding to the target statement structure identifier from the policy data table corresponding to the flow limiting policy set according to the policy query instruction. In this embodiment, the flow limiting policy set is saved in the data table in the database. When the database system needs to query the policy entry, it needs to generate a policy query instruction according to the statement structure identifier. The policy query instruction is usually generated by the structured query language of the database, for example, a database access statement used for table query. The database system accesses the policy data table corresponding to the flow limiting policy set by executing the generated policy query instruction, so as to obtain the target policy entry corresponding to the statement structure identifier in the policy data table. By querying the policy entry from the policy data table corresponding to the flow limiting policy set, compared with querying the flow limiting policy set from the hash table in the memory, the inconsistency of the flow limiting policy for processing requests caused by the update of the entry in the memory can be avoided, and the consistency of the information in the policy entry can be ensured.

[0098] In the embodiments of the present application, based on the technical solutions of the present application, before performing semantic analysis on the target statement structure of the database access statement, the database system further acquires the requestor account information of the database access request, and then according to the requestor account information, if the requestor is indicated as a specified account in the flow limiting policy of the target statement, the database access request is executed. In the embodiments, before the database system performs the flow limiting action according to the policy entry, the database system first checks whether the requestor of the database access request is a specified account, for example, whether it is an administrator account or a special account with a specific identifier or a specific prefix. If it is a specified account, the database system does not perform flow limiting check, but directly executes the database access request of the requestor. In this way, the specified account is allowed to bypass the flow limiting control, so that the specific user can bypass the concurrent control to access the database, which is beneficial to testing in the case where concurrent control has occurred, and improves the security of the scheme.

[0099] In the embodiments of the present application, based on the technical solutions of the present application, after acquiring the flow limiting policy addition request, if the flow limiting policy addition request contains an added statement structure identifier, the database system queries the added statement structure according to the added statement structure identifier. If the flow limiting policy addition request contains an access statement, the database system performs semantic analysis on the statement structure of the access statement to obtain an added statement structure, and calculates the added statement structure identifier according to the added statement structure. Specifically, if the flow limiting policy addition request provides an added statement structure identifier, the database system queries the corresponding added statement structure in the database, so as to ensure that the corresponding statement structure actually exists. It can be understood that the database access statement can be provided to the database system for semantic analysis in advance, and the database saves the analyzed statement structure, the statement identifier and the access statement provided at that time in a specific table of the database, so that other processing procedures can verify the statement structure according to the statement identifier when needed. In some embodiments, if the added statement structure exists, it is added to the corresponding entry in the flow limiting policy set. If the flow limiting policy addition request provides an access statement, the database system obtains the corresponding added statement structure through semantic analysis, and calculates the added statement structure identifier. Through the above-mentioned manner, the database system allows the flow limiting policy to be added to the flow limiting policy set in two ways of access statement and statement structure identifier, which is beneficial to improving the flexibility of the scheme.

[0100] In the embodiments of the present application, based on the technical solutions of the present application, after releasing the exclusive access lock, if the throttling policy addition request contains a policy persistence identifier, the database system further acquires a policy entry corresponding to the added statement structure identifier in the throttling policy set, the policy entry contains the added statement throttling policy, and then inserts the policy entry into the policy data table corresponding to the throttling policy set. Specifically, the throttling policy set is usually saved in the memory of the database system in the form of a hash table. If the throttling policy addition request contains a policy persistence identifier, the database system saves the policy entry in the data policy table of the database. In some embodiments, the database system can also persist all policy entries in the throttling policy set in the policy data table according to the received policy persistence instruction. The specific operation can be to insert each entry in the throttling policy set as new data into the policy data table in turn, and if a duplicate statement structure identifier is encountered, an error is reported or the update is executed again. In this way, the query of the throttling policy set is still performed through the hash table in the memory, and the saving of the policy data is performed through the database, so as to ensure the persistence of the throttling policy while ensuring the performance of the policy query, and improve the convenience of throttling policy management.

[0101] In the embodiments of the present application, based on the technical solutions of the present application, the database system further acquires a policy loading instruction, and then traverses each policy entry in the policy data table according to the policy loading instruction. During the traversal of the policy data table, the database system loads each policy entry into the throttling policy set. Specifically, the policy entries persisted in the policy data table can be loaded by the database system, for example, the loading of the throttling policy set during the startup of the database system, or the loading when the memory is invalid. In some embodiments, the statement structure identifier can be contained in the policy loading instruction, and the database system can query the corresponding policy entry from the policy data table according to the statement structure identifier and load the entry to load the specified throttling policy. Through the above-mentioned manner, the database system is allowed to load each policy at a time, avoiding the operation process of reconstructing the throttling policy set in the memory, thereby improving the loading efficiency of the throttling policy.

[0102] In the embodiments of the present application, based on the technical solutions of the present application, the database system further acquires a policy uninstall instruction, which contains a to-be-uninstalled statement structure identifier. Subsequently, the database system deletes, according to the policy uninstall instruction, a policy entry corresponding to the to-be-uninstalled statement structure identifier from the flow limiting policy set. If the policy uninstall instruction contains a policy deletion identifier, the database system further deletes, according to the policy uninstall instruction, a policy entry corresponding to the policy deletion identifier from the policy data table. Specifically, the policy uninstall instruction is mainly used to delete a policy entry from the flow limiting policy set. In the case where the policy uninstall instruction does not contain a policy deletion identifier, the policy entry is only deleted from the hash table in the memory, and thus the specified flow limiting policy is unloaded from the database system. If the policy uninstall instruction contains a policy deletion identifier, the database system deletes the corresponding policy entry from the policy data table, which means that the flow limiting policy is completely deleted. In some embodiments, the statement structure identifier can not be specified in the policy uninstall instruction, and the database system unloads all the policies in the flow limiting policy set. If the policy uninstall instruction contains a policy deletion identifier, the database system further deletes all the policy entries. It can be understood that deleting a policy entry from the policy data table requires a database operation, and the database system automatically generates a statement of the corresponding database operation according to the policy deletion identifier and the uninstall statement structure identifier. In some embodiments, the database system can include a master instance and a read-only instance, wherein the master instance is an instance of the database running, and can be deleted and modified, and the read-only instance is synchronized with the master instance, and is mainly used for reading, so as to avoid too many read requests of the master instance from affecting the running. For such a case, the deletion operation is usually performed only on the instance of the current running instruction, for example, deleting a policy in the hash table of the read-only instance does not affect the policy in the hash table of the master instance, and vice versa, deleting an instance in the hash table of the master instance does not affect the read-only instance. Through the above-mentioned manner, the database system allows the flow limiting policy in the flow limiting policy set and the policy data table to be deleted, and in the case of an abnormal flow limiting policy, the policy is deleted to avoid affecting the running of the database system, thereby improving the stability of the database.

[0103] The implementation details of the technical solutions of the embodiments of the present application are described below with specific examples. Specifically, the scheme of the present application can be implemented by a plug-in of a database, for example, the function interface of the functions described in the technical solutions of the present application can be implemented by the tencentdb_sql_throttling plug-in to facilitate users to use the functions. At the same time, the overall scalability of PG is ensured. The plug-in mainly includes six operations of adding, deleting, loading, persisting, viewing and modifying the throttling strategy. Specifically, the adding of the throttling strategy can support two ways: adding the strategy by a statement structure identifier queryid and adding the strategy by an access statement query. In some applications, the strategy is also represented by rule. For example, in an example, the way of adding the strategy by queryid is as follows: SELECT tencentdb_sql_throttling.add_rule_with_queryid(queryid bigint, work_node int, max_concurrency int, is_enabled boolean, memory_only boolean, query_string text). Wherein, queryid: the 64-bit integer obtained by hashing the normalized query statement. In some applications, it can be obtained by querying the functions provided by the database, such as pg_stat_statements or pg_stat_activity view. work_node: the node where the throttling strategy takes effect, which can be divided into three kinds of indicating the master instance, read-only instance and both. For example, in an example, 0 is used to indicate that the master instance and the read-only instance both take effect, 1 is used to indicate that only the master instance takes effect, and 2 is used to indicate that only the read-only instance takes effect. max_concurrency: the maximum number of allowed concurrency of the throttling strategy; is_enabled: whether the current strategy takes effect; memory_only: optional, whether the strategy needs to be persisted to the table, and the strategy recovery command can be used to load the strategy into the memory after restart / failure; query_string: optional, the query statement can be added to the strategy. If this parameter is not provided, the database system can automatically find the access statement corresponding to the queryid in the statement structure view (for example, in the pg_stat_statements view) and record the result in the strategy.For example, in one example, the query addition strategy can be as follows: SELECT tencentdb_sql_throttling.add_rule_with_query(query_string text, work_node int, max_concurrency int, is_enabled boolean, memory_only boolean). Wherein, query is the access statement that needs to be throttled, such as a SQL statement. Work_node: the node where the throttling strategy takes effect, which is divided into three types, indicating that the master instance takes effect, the read-only instance takes effect, and both take effect. Max_concurrency: the maximum number of concurrent allowed by the throttling strategy; is_enabled: whether the current strategy takes effect; memory_only: whether the strategy needs to be persisted to the table, and the strategy recovery command can be used to load the strategy into the memory after restart / failure. This method returns the queryid of the query. Two ways are supported for deleting the throttling strategy: deleting a specified strategy through queryid and deleting all strategies. The way of deleting a specified strategy through queryid is as follows: SELECT tencentdb_sql_throttling.drop_rule(queryid bigint, memory_only). Wherein, memory_only is whether to delete only the strategy in the memory, and memory_only is true, only the strategy in the memory is deleted, the strategy in the persistent table is not affected, which can be regarded as uninstalling the throttling strategy from the memory; memory_only is false, the strategy in the memory and the table will be deleted at the same time, if it cannot be deleted, an alarm log will be printed. The read-only instance can only delete the strategy in the memory. The deletion action only takes effect on the current instance and does not synchronize to the read-only, the read-only instance needs to run the method separately to uninstall the strategy. The way of deleting all strategies is as follows: SELECT tencentdb_sql_throttling.drop_all_rules(memory_only boolean). The use of memory_only is the same as in the deletion of a specified strategy. Two ways are supported for loading the throttling strategy: loading the strategy through queryid and loading all strategies. The way of loading the strategy through queryid is as follows: SELECT tencentdb_sql_throttling.load_rule(queryid bigint). When loading all strategies, no parameters need to be provided. Loading all strategies will load all strategies in the table for saving the throttling strategy into the memory, if a strategy fails to load, it will skip to the next strategy. The loading method can reload the data in the throttling strategy table into the hash table in the memory.The loading method can be to traverse the throttling strategy table, and call the method of adding a strategy through queryid one by one to insert the strategy into the hash table. Similarly, the persistent throttling strategy supports two ways: persisting the strategy through queryid and persisting all strategies. The way of persisting the strategy through queryid is as follows: SELECT tencentdb_sql_throttling.dump_rule(queryid bigint). The persistent storage of all strategies does not need to provide queryid. The method can export all current strategies to the throttling strategy table for persistent storage. Exporting can be regarded as inserting all strategies in the current hash table into the throttling strategy table one by one, and no change will be made to the data in the table. If there is a conflict, an error will be reported and the program will exit. Before exporting, an exclusive access lock will be obtained in an exclusive mode, and the lock will be released after the exporting is completed. The throttling strategy set will contain statistical information about the throttling strategy. The way of viewing the throttling strategy is as follows: SELECT*FROM tencentdb_sql_throttling.rules. Among them, the returned view contains the following contents: queryid: the queryid of the throttled SQL, work_node: the node where the strategy takes effect, max_concurrency: the maximum allowed concurrency, is_enabled: whether the throttling strategy takes effect, query_string: the SQL statement corresponding to the throttling strategy, current_concurrency: the current concurrency of the SQL statement, total_hit_count: the number of times the throttling strategy is hit, and reject_count: the total number of times the strategy is throttled. The way of modifying the throttling strategy is as follows: SELECT tencentdb_sql_throttling.change_rule_status(queryid bigint, is_enabled boolean, max_concurrency int). The method can modify whether the existing strategy takes effect / maximum concurrency quantity through queryid, and modify the effective state of the existing strategy through queryid. The current concurrency quantity of a certain strategy can also be modified through queryid. When an exception occurs, the current concurrency of the strategy can be manually modified to ensure the continuous operation of the strategy. SELECT tencentdb_sql_throttling.change_rule_current_concurrency(queryid bigint, new_currenct_concurrency int).

[0104] Referring to FIG. 5, FIG. 5 is a whole structure diagram of the flow limiting scheme in the embodiment of the present application. As shown in FIG. 1, when a user executes a database SQL statement, the database performs syntax analysis on the SQL statement, thereby obtaining a corresponding queryid. Subsequently, after scheduling and execution by a planner, the database system performs policy retrieval on a hash table of a policy set according to the queryid. If a policy is hit, the database system checks whether the number of currently concurrent SQL statements corresponding to the queryid exceeds the maximum concurrency number specified by the policy. If yes, an error is reported and the execution is exited. If no, the SQL statement is executed by an executor, thereby completing the query process of the query. For the policies in the hash table, the management party can add a new policy, and the database system calculates the queryid of the query to which the new policy is directed, and adds the new policy to the hash table. The management party can further require saving the policy, and the database system saves the policy in the hash table to a flow limiting policy table for saving. In the process of concurrency control, the database system guarantees data consistency through a locking mechanism. Specifically, referring to FIG. 6, FIG. 6 is a schematic diagram of the process of concurrency control in the embodiment of the present application. As shown in FIG. 6, for adding and deleting a policy, a lightweight lock (LWLock) is acquired in an exclusive mode. After exclusive locking, a data definition language for changing table structure and the like can be executed to update the hash table. After the update is completed, the LWLock is released, thereby completing the deleting and adding process. When executing the SQL, the LWLock is acquired in a shared mode. After determining the involved policy, a spin lock (SpinLock) is acquired for the policy, and then the information of the policy can be modified. After the modification is completed, the SpinLock and the LWLock are released. FIG. 7 is a whole flow chart of adding a new policy in the embodiment of the present application. As shown in FIG. 7, the database system first checks whether the SQL statement corresponding to the queryid is included in the input request. If not, the corresponding SQL statement is queried from a statement structure table. If the corresponding SQL statement cannot be queried, an alarm is given. If the new policy provides the SQL statement or the corresponding SQL statement is queried according to the queryid, the database system acquires the LWLock of the hash table of the flow limiting policy set in an exclusive mode. If the hash table is full, an error is reported and the execution is exited. If not, the database system inserts the new policy into the hash table and modifies the current policy total number (Current_rule_num) data. Subsequently, the database system releases the LWLock of the hash table, and checks whether the entry needs to be persisted. If yes, the entry in the hash table is persisted to a table of the database through a database access interface SPI, thereby completing the execution process. If only the query is provided without the queryid when adding the rule, the database system first performs syntax analysis on the query, and then performs semantic analysis on the obtained statement structure tree to obtain a statement structure, and then calculates the queryid.The subsequent process is similar to the process in FIG. 7, but the process of retrieving the query according to the queryid is omitted. In the executor execution stage, the data is modified through the hook program hook. Please refer to FIG. 8, which is a schematic diagram of the executor stage in the embodiment of the present application. As shown in FIG. 8, the executor contains three hook programs. Among them, the executor run hook (ExecutorRun_hook) is used to calculate the current nested level nested_level and the current user to determine whether the flow limiting is needed; if the flow limiting is needed, the current concurrency current_concurrency+1 is given, and other data (such as the hit count hit_count, etc.) is modified. The executor end hook (ExecutorEnd_hook) is used to give the current_concurrency-1 of the corresponding strategy in the hash table. The executor finish hook (ExecutorFinish_hook) is used to maintain the variable for calculating the nested level nested_level, that is, the nested_level-1 is given after the nested execution is completed.

[0105] In the embodiment of the present application, in terms of technical implementation, the plug-in form of implementation mode can reduce the invasiveness to the system kernel. The linkage storage mechanism of the hash table in the memory and the external storage table can guarantee the high performance and also guarantee the persistence of the flow limiting strategy (some applications use rule representation). In the embodiment of the present application, by separately setting the flow limiting strategy of a certain instance (such as a host, a backup machine), the flow limiting strategy can not be affected by other instances.

[0106] It should be noted that although the steps of the method in the present application are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in this specific order, or that all the steps shown must be performed to achieve the desired results. In addition or alternatively, some steps can be omitted, a plurality of steps can be combined into one step, and / or one step can be divided into a plurality of steps, etc.

[0107] The device implementation of the present application is introduced below, which can be used to execute the database request processing method in the above-mentioned embodiments of the present application. FIG. 9 schematically shows the component block diagram of the database request processing device in the embodiment of the present application. As shown in FIG. 9, the database request processing device 900 can mainly include:

[0108] The request acquisition module 910 is configured to acquire a database access request, wherein the database access request contains a database access statement.

[0109] The semantic analysis module 920 is configured to perform semantic analysis on the target statement structure of the database access statement, and obtain the target statement structure identifier corresponding to the target statement structure.

[0110] The policy retrieving module 930 is configured to retrieve a target policy entry corresponding to the target statement structure identifier from a throttling policy set according to the target statement structure identifier, wherein the target policy entry contains statement execution information of the target statement structure and a target statement throttling policy for the target statement structure;

[0111] The request executing module 940 is configured to execute the database access request if the statement execution information does not reach a throttling condition in the target statement throttling policy.

[0112] In some embodiments of the present application, based on the above technical solutions, the request executing module 940 is specifically configured to: obtain a statement concurrency quantity in the statement execution information and a maximum concurrency quantity in the target statement throttling policy; if the statement concurrency quantity is lower than the maximum concurrency quantity, increment the statement concurrency quantity in the statement execution information; execute the database access request and decrement the statement concurrency quantity in the statement execution information after the database access statement is executed.

[0113] In some embodiments of the present application, based on the above technical solutions, the request executing module 940 is specifically configured to: if the statement concurrency quantity is lower than the maximum concurrency quantity, obtain a policy access lock for the target policy entry; increment the statement concurrency quantity and save it into the statement execution information of the target policy entry; release the policy access lock and a shared access lock for the throttling policy set, wherein the shared access lock is an access control lock obtained for the throttling policy set before the target policy entry is queried.

[0114] In some embodiments of the present application, based on the above technical solutions, the database access statement contains calling information of a specified access statement; the request executing module 940 is further configured to: according to the calling information, obtain a specified policy entry corresponding to the specified access statement; if a statement concurrency quantity of statement execution information in the specified policy entry is higher than a maximum concurrency quantity of a specified statement throttling policy in the specified policy entry, stop processing the database access request.

[0115] In some embodiments of the present application, based on the above technical solutions, the policy retrieval module 930 is further configured to: acquire a throttling policy addition request, wherein the throttling policy addition request contains an addition sentence structure identifier of an addition sentence structure or an access sentence, and an addition sentence throttling policy corresponding to the addition sentence structure; acquire an exclusive access lock for the throttling policy set; add an addition policy entry corresponding to the addition sentence structure to the throttling policy set according to the throttling policy addition request, wherein the addition policy entry contains the addition sentence throttling policy; modify the policy quantity information in the throttling policy set and release the exclusive access lock.

[0116] In some embodiments of the present application, based on the above technical solutions, the policy retrieval module 930 is further configured to: if the throttling policy addition request contains an addition sentence structure identifier, query an addition sentence structure according to the addition sentence structure identifier; if the throttling policy addition request contains an access sentence, perform semantic analysis on the sentence structure of the access sentence to obtain an addition sentence structure, and calculate the addition sentence structure identifier according to the addition sentence structure.

[0117] In some embodiments of the present application, based on the above technical solutions, the policy retrieval module 930 is further configured to: if the throttling policy addition request contains a policy persistence identifier, acquire a policy entry corresponding to the addition sentence structure identifier in the throttling policy set, wherein the policy entry contains the addition sentence throttling policy; insert the policy entry into a policy data table corresponding to the throttling policy set.

[0118] In some embodiments of the present application, based on the above technical solutions, the policy retrieval module 930 is further configured to: acquire a policy loading instruction; traverse each policy entry in the policy data table according to the policy loading instruction; and load each policy entry into the throttling policy set in the process of traversing the policy data table.

[0119] In some embodiments of the present application, based on the above technical solutions, the policy retrieval module 930 is further configured to: acquire a policy unloading instruction, wherein the policy unloading instruction contains a to-be-unloaded sentence structure identifier; delete a policy entry corresponding to the to-be-unloaded sentence structure identifier from the throttling policy set according to the policy unloading instruction; and if the policy unloading instruction contains a policy deletion identifier, delete a policy entry corresponding to the policy deletion identifier from the policy data table according to the policy unloading instruction.

[0120] In some embodiments of the present application, based on the above technical solutions, the policy retrieval module 930 is specifically configured to: generate a policy query instruction according to the target sentence structure identifier; and query a target policy item corresponding to the target sentence structure identifier from a policy data table corresponding to the flow limiting policy set according to the policy query instruction.

[0121] In some embodiments of the present application, based on the above technical solutions, the semantic analysis module 920 is further configured to: obtain requestor account information of the database access request; and if the requestor account information indicates that a requestor is a specified account in the target sentence limiting policy, execute the database access request.

[0122] It should be noted that the apparatus provided by the above embodiments and the method provided by the above embodiments belong to the same concept, wherein the specific manner in which each module performs operations has been described in detail in the method embodiments, which will not be described here.

[0123] FIG. 10 shows a structural schematic diagram of a computer system of an electronic device suitable for implementing embodiments of the present application.

[0124] It should be noted that the computer system 1000 of the electronic device shown in FIG. 10 is only an example, and should not bring any limitation to the functions and use range of the embodiments of the present application.

[0125] As shown in FIG. 10, the computer system 1000 includes a central processing unit (CPU) 1001, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 1002 or programs loaded from a storage portion 1008 into a random access memory (RAM) 1003. In the RAM 1003, various programs and data required for system operation are also stored. The CPU 1001, the ROM 1002, and the RAM 1003 are connected to each other through a bus 1004. An input / output (I / O) interface 1005 is also connected to the bus 1004.

[0126] The following components are connected to the I / O interface 1005: an input part 1006 including a keyboard, a mouse, etc.; an output part 1007 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), etc., and a speaker, etc.; a storage part 1008 including a hard disk, etc.; and a communication part 1009 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication part 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as necessary. A removable medium 1011 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 1010 as necessary, so that a computer program read therefrom is installed in the storage part 1008 as necessary.

[0127] In particular, according to embodiments of the present application, the processes described in the various method flowcharts can be implemented as a computer software program. For example, embodiments of the present application include a computer program product comprising a computer program carried on a computer readable medium, the computer program containing program code for executing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via the communication part 1009, and / or installed from the removable medium 1011. When the computer program is executed by the central processing unit (CPU) 1001, various functions defined in the system of the present application are executed.

[0128] It should be noted that the computer-readable medium in the embodiments of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination thereof. The computer-readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination thereof. More specific examples of the computer-readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (Compact Disc Read-Only Memory, CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In this application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in connection with an instruction execution system, apparatus or device. In this application, the computer-readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take many forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, which can send, transmit, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, or the like, or any suitable combination thereof.

[0129] The flowcharts and block diagrams in the drawings illustrate the possible implementation architectures, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowcharts or block diagrams can represent a module, a program segment, or a portion of code that contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur in different orders than that shown in the figures. For example, two blocks noted in succession can actually be executed substantially concurrently, or they can sometimes be executed in reverse order, depending on the functionality involved. It should also be noted that each block in the flowcharts or block diagrams, and combinations of blocks in the flowcharts or block diagrams, can be implemented by special-purpose hardware-based systems that perform the specified functions or operations, or can be implemented by a combination of special-purpose hardware and computer instructions.

[0130] It should be noted that, although several modules or units for a device for action execution are mentioned in the above detailed description, such a division is not mandatory. Indeed, according to an embodiment of the application, the features and functionalities of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functionalities of one module or unit described above can be further divided into several modules or units embodied.

[0131] Those skilled in the art can easily understand, through the above description of the embodiments, that the example embodiments described herein can be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solutions according to the embodiments of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a U disk, a mobile hard disk, etc.) or a network, and includes several instructions to make a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) execute the methods according to the embodiments of the present application.

[0132] Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the application disclosed herein. It is intended that the present application cover any and all variations of the application that come within the scope of the present application, along with all of the equivalents thereof. It is intended that the specification and examples be considered as exemplary only, with the true scope and spirit of the application being indicated by the following claims.

[0133] It should be understood that the application is not limited to the precise construction that has been described above and illustrated in the accompanying drawings, and that various modifications and changes can be made by those skilled in the art without departing from the scope of the application. The scope of the application should be limited only by the appended claims.

Claims

1. A database request processing method characterized by, The method comprises the following steps: acquiring a database access request, wherein the database access request comprises a database access statement; performing semantic analysis on a target statement structure of the database access statement to obtain a target statement structure identifier corresponding to the target statement structure; retrieving a target policy item corresponding to the target statement structure identifier from a flow control policy set according to the target statement structure identifier, wherein the target policy item comprises statement execution information of the target statement structure and a target statement flow control policy for the target statement structure; if the statement execution information does not reach a flow control condition in the target statement flow control policy, executing the database access request.

2. The method of claim 1, wherein, The step of executing the database access request if the statement execution information does not reach the flow control condition in the target statement flow control policy comprises the following steps: acquiring a statement concurrency quantity in the statement execution information and a maximum concurrency quantity in the target statement flow control policy; if the statement concurrency quantity is lower than the maximum concurrency quantity, increasing the statement concurrency quantity in the statement execution information; executing the database access request and decreasing the statement concurrency quantity in the statement execution information after the database access statement is executed.

3. The method of claim 2, wherein, The step of increasing the statement concurrency quantity in the target statement flow control policy if the statement concurrency quantity is lower than the maximum concurrency quantity comprises the following steps: if the statement concurrency quantity is lower than the maximum concurrency quantity, acquiring a policy access lock for the target policy item; increasing the statement concurrency quantity and saving the statement concurrency quantity into the statement execution information of the target policy item; releasing the policy access lock and a shared access lock for the flow control policy set, wherein the shared access lock is an access control lock acquired for the flow control policy set before the target policy item is queried.

4. The method according to claim 2 or 3, characterized in that, The database access statement comprises call information of a specified access statement; the method further comprises the following steps: acquiring a specified policy item corresponding to the specified access statement according to the call information; if a statement concurrency quantity of statement execution information in the specified policy item is higher than a maximum concurrency quantity of a specified statement flow control policy in the specified policy item, stopping processing of the database access request.

5. The method according to any one of claims 1 to 4, characterized in that, The method further comprises the following steps: acquiring a flow control policy addition request, wherein the flow control policy addition request comprises an addition statement structure identifier or an access statement of an addition statement structure and an addition statement flow control policy corresponding to the addition statement structure; acquiring an exclusive access lock for the flow control policy set; adding an addition policy item corresponding to the addition statement structure into the flow control policy set according to the flow control policy addition request, wherein the addition policy item comprises the addition statement flow control policy; modifying a policy quantity information in the flow control policy set and releasing the exclusive access lock.

6. The method of claim 5, wherein, After the step of acquiring the flow control policy addition request, the method further comprises the following steps: if the flow control policy addition request comprises an addition statement structure identifier, querying an addition statement structure according to the addition statement structure identifier; If the access statement is included in the throttling policy addition request, the semantic analysis is performed on a statement structure of the access statement to obtain an added statement structure, and the added statement structure identifier is calculated according to the added statement structure.

7. The method according to claim 5 or 6, characterized in that, After the exclusive access lock is released, the method further comprises: If the throttling policy addition request includes a policy persistence identifier, a policy entry corresponding to the added statement structure identifier in the throttling policy set is obtained, and the added statement throttling policy is included in the policy entry. The policy entry is inserted into a policy data table corresponding to the throttling policy set.

8. The method of claim 7, wherein, The method further comprises: An acquisition of a policy loading instruction is performed. According to the policy loading instruction, each policy entry in the policy data table is loaded into the throttling policy set. The method further comprises:

9. The method according to claim 7 or 8, characterized in that, An acquisition of a policy unloading instruction is performed, and the policy unloading instruction includes a statement structure identifier to be unloaded. According to the policy unloading instruction, a policy entry corresponding to the statement structure identifier to be unloaded is deleted from the throttling policy set. If the policy unloading instruction includes a policy deletion identifier, a policy entry corresponding to the policy deletion identifier is deleted from the policy data table according to the policy unloading instruction. The retrieval of the target policy entry corresponding to the target statement structure identifier from the throttling policy set according to the target statement structure identifier comprises:

10. The method according to any one of claims 1 to 9, characterized in that, According to the target statement structure identifier, a policy query instruction is generated. According to the policy query instruction, a target policy entry corresponding to the target statement structure identifier is queried from a policy data table corresponding to the throttling policy set. Before the semantic analysis of the target statement structure of the database access statement, the method further comprises:

11. The method according to any one of claims 1 to 11, characterized in that, An acquisition of requestor account information of the database access request is performed. If the requestor account information indicates that a requestor is a specified account in the target statement throttling policy, the database access request is executed. Comprise:

12. A database request processing apparatus characterized by comprising: A request acquisition module is configured to acquire a database access request, and the database access request includes a database access statement; A semantic analysis module is configured to perform semantic analysis on a target statement structure of the database access statement to obtain a target statement structure identifier corresponding to the target statement structure; A policy retrieval module is configured to retrieve a target policy entry corresponding to the target statement structure identifier from a throttling policy set according to the target statement structure identifier, wherein the target policy entry includes statement execution information of the target statement structure and a target statement throttling policy for the target statement structure; A request execution module is configured to execute the database access request if the statement execution information does not reach a throttling condition in the target statement throttling policy. Comprise:

13. An electronic device, comprising: A processor; A memory for storing executable instructions of the processor; The processor is configured to execute the database request processing method of any one of claims 1 to 11 by executing the executable instructions. ​ 14. A computer readable medium having stored thereon a computer program, characterized in that, The computer program is executed by a processor to implement the database request processing method in any one of claims 1 to 11.

15. A computer program product, characterised in that, The computer program product comprises computer instructions stored in a computer readable storage medium, a processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device executes the database request processing method in any one of claims 1 to 11.

Citation Information

Patent Citations

  • Method and device for flow control over database

    CN106156064A

  • Access control method for database and related equipment

    CN117556452A

  • SQL statement flow limiting method and device, equipment and storage medium

    CN118227641A

  • Flow control in connection with an access request

    US20170272371A1