Database request processing method and device, electronic equipment and readable medium

By performing semantic analysis and rate limiting strategy retrieval on database access statements, flow control for specific statement structures is achieved, solving the problem of insufficient granularity in database rate limiting control and improving the database's response speed and execution efficiency.

CN121597722APending Publication Date: 2026-03-03TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411169784.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-23
Publication Date
2026-03-03

AI Technical Summary

Technical Problem

In existing technologies, the granularity of database rate limiting control is insufficient. As a result, when the large amount of traffic generated by some functions reaches the connection limit, the database's processing delay for each request increases, affecting the overall response speed and execution efficiency.

Method used

By performing semantic analysis on database access statements to obtain statement structure identifiers, and retrieving corresponding policy entries from the rate limiting policy set, database access requests are controlled based on statement execution information and rate limiting policies. This achieves flow control for specific statement structures, preventing impact on requests for 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 ensures that flow control for specific access statements does not affect requests for other access statements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121597722A_ABST
    Figure CN121597722A_ABST
Patent Text Reader

Abstract

The invention provides a database request processing method and device, electronic equipment and a readable medium. 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; according to the statement structure identifier, a target strategy entry corresponding to the target statement structure identifier is retrieved from a flow limiting strategy set, and the target strategy entry comprises statement execution information of the target statement structure and a target statement flow limiting strategy for the target statement structure; and if the statement execution information meets the target statement flow limiting strategy, executing the database access request. According to the method, the fineness of database flow limiting control can be improved, and the overall response speed and execution efficiency of the database can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a database request processing method, apparatus, electronic device, and readable medium. Background Technology

[0002] With the rapid development of the internet industry, the access frequency of various internet applications has increased, leading to increased database traffic. A large number of requests can put a significant load on the database. Therefore, controlling database concurrency has become a key factor in maintaining stable database operation.

[0003] In related technologies, the number of concurrent accesses to a database can be controlled or rate-limited by adding a limit to the number of connections to the database.

[0004] However, in the above solution, the rate limiting conditions are set for the entire database, which lacks sufficient fine-grained control over database rate limiting. When a large amount of traffic generated by some functions reaches the connection limit, it will cause the database to have a longer processing delay for each request, thereby affecting the overall response speed and execution efficiency of the database. Summary of the Invention

[0005] To address the aforementioned technical issues, this application provides a database request processing method, apparatus, electronic device, and readable medium to improve the granularity of database rate limiting control and enhance the overall response speed and execution efficiency of the database.

[0006] Other features and advantages of this application will become apparent from the following detailed description, or may be learned in part from practice of this application.

[0007] According to one aspect of the embodiments of this application, a database request processing method is provided, including:

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

[0009] Semantic analysis is performed on the target statement structure of the database access statement to obtain the target statement structure identifier corresponding to the target statement structure.

[0010] Based on the statement structure identifier, retrieve the target policy entry corresponding to the target statement structure identifier from the rate limiting policy set, wherein the target policy entry contains statement execution information of the target statement structure and a target statement rate limiting policy for the target statement structure;

[0011] If the statement execution information satisfies the target statement rate limiting policy, then the database access request is executed.

[0012] According to one aspect of the embodiments of this application, a database request processing apparatus is provided, comprising:

[0013] The request acquisition module is configured to acquire database access requests, wherein the database access requests contain database access statements.

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

[0015] The strategy retrieval module is configured to retrieve the target strategy entry corresponding to the target statement structure identifier from the rate limiting strategy set based on the statement structure identifier, wherein the target strategy entry contains statement execution information of the target statement structure and a target statement rate limiting strategy for the target statement structure;

[0016] The request execution module is configured to execute the database access request if the statement execution information satisfies the target statement rate limiting policy.

[0017] In some embodiments of this application, based on the above technical solutions, the request execution module is specifically configured to: obtain the statement concurrency number in the statement execution information and the maximum concurrency number in the target statement rate limiting strategy; if the statement concurrency number is lower than the maximum concurrency number, increment the statement concurrency number in the statement execution information; execute the database access request, and decrement the statement concurrency number in the statement execution information after the database access statement is executed.

[0018] In some embodiments of this application, based on the above technical solutions, the request execution module is specifically configured to: if the number of concurrent statements is lower than the maximum number of concurrent statements, acquire a policy access lock for the target policy entry; increment the number of concurrent statements and save it to the statement execution information of the target policy entry; release the policy access lock and the shared access lock for the rate limiting policy set, wherein the shared access lock is an access control lock acquired for the rate limiting policy set before querying the target policy entry.

[0019] In some embodiments of this application, based on the above technical solutions, the database access statement includes call information for a specified access statement; the request execution module is further configured to: obtain a specified policy entry corresponding to the specified access statement according to the call information; if the number of concurrent statements in the statement execution information of the specified policy entry is higher than the maximum number of concurrent statements in the specified policy entry's rate limiting policy, then stop processing the database access request.

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

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

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

[0023] In some embodiments of this application, based on the above technical solutions, the policy retrieval module is further configured to: obtain 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 rate limiting policy set during the traversal of the policy data table.

[0024] In some embodiments of this application, based on the above technical solutions, the policy retrieval module is further configured to: obtain a policy uninstallation instruction, wherein the policy uninstallation instruction contains a statement structure identifier to be uninstalled; delete the policy entry corresponding to the statement structure identifier to be uninstalled from the rate limiting policy set according to the policy uninstallation instruction; if the policy uninstallation instruction contains a policy deletion identifier, delete the policy entry corresponding to the statement structure identifier to be uninstalled from the policy data table according to the policy uninstallation instruction.

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

[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] In the embodiments of this application, the database system obtains a database access request containing a database access statement. Then, it performs semantic analysis on the target statement structure of the database access statement to obtain a target statement structure identifier. Based on the statement structure identifier, the database system can retrieve the target policy entry corresponding to the target statement structure identifier from the rate limiting policy set. This target policy entry contains statement execution information of the target statement structure and a rate limiting policy for that target statement structure. If the statement execution information satisfies the target statement rate limiting policy, the database system executes the database access request. In this way, the database system can rate limit database access statements containing specific statement structures according to the rate limiting policy, achieving flow control for specific access statements. This limits the large amount of traffic from some access statements while avoiding impact on requests from other access statements, improving the granularity of database rate limiting control, thereby improving the overall response speed and execution efficiency of the database.

[0031] 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. Attached Figure Description

[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 The database request processing method described in this application is applied to the system architecture of a cloud host platform.

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

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

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

[0037] Figure 5 This is a structural diagram of the current limiting scheme in the embodiments of this application.

[0038] Figure 6 This is a schematic diagram of the concurrency control process in an embodiment of this application.

[0039] Figure 7 This is an overall flowchart of the newly added strategy in the embodiments of this application.

[0040] Figure 8 This is a schematic diagram of the actuator stage in an embodiment of this application.

[0041] Figure 9 A schematic block diagram of the database request processing apparatus in an embodiment of this application is shown.

[0042] Figure 10 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application is shown. Detailed Implementation

[0043] Exemplary embodiments will now be described more fully with reference to the accompanying drawings. However, these exemplary embodiments can be implemented in many forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided to make this application more comprehensive and complete, and to fully convey the concept of the exemplary embodiments to those skilled in the art.

[0044] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a thorough understanding of embodiments of this application. However, those skilled in the art will recognize that the technical solutions of this application can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of this application.

[0045] In the embodiments of this application, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve the predetermined function, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.

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

[0047] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.

[0048] It should be understood that the solution presented in this application can be applied to database systems, specifically in scenarios where database systems need to rate-limit structured query statements. Web applications frequently encounter high traffic volumes, which typically place significant demands on the database. For example, shopping websites hosting promotions generate numerous database accesses for product information queries, or new games experience a surge in user logins and registrations. These situations generally increase the load on the database, leading to a decrease in overall database response speed.

[0049] With the rapid development of the internet industry, the access frequency of various internet applications has increased, leading to increased database traffic. A large number of requests can place a significant load on the database. Therefore, controlling database concurrency has become a key factor in maintaining stable database operation. One approach is to control or rate-limit the number of concurrent database accesses by limiting the number of connections. However, in these solutions, rate limiting is applied to the entire database, lacking sufficient granularity. When a large amount of traffic generated by certain functions reaches the connection limit, it can cause increased latency in processing each request, thus affecting the overall response speed and execution efficiency of the database.

[0050] Based on this, the technical solution of this application embodiment proposes a database request processing scheme. Specifically, please refer to... Figure 1 The database request processing method according to the embodiments of this application, applied to a 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. Devices in each part of the system structure can include smartphones, tablets, laptops, smart voice interaction devices, smart home appliances, vehicle terminals, aircraft, etc. Blockchain devices can also be servers providing various services; these can be independent physical servers, server clusters composed of multiple physical servers, or distributed systems. They can also be cloud servers providing basic cloud computing services such as 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 big data and artificial intelligence platforms. Various types of communication media can exist between devices, such as wired or wireless communication links.

[0051] Depending on the implementation requirements, the system architecture in this application embodiment can have any number of terminal devices and servers. For example, the devices such as the business server 110 and the database server 120 can be server groups composed of multiple server devices. In addition, the technical solutions provided in this application embodiment can be applied to a computing platform, or can be implemented jointly by various parts of the system, and this application does not impose any special limitations on this.

[0052] like Figure 1As shown, a user terminal can send a request to the business server 110 to browse a specific page or perform a specific function. The business server 110 then sends a database access request to the database server 120 to obtain the required data based on the user terminal's request. The database server 120 determines the current load on similar statements in the database and the rate-limiting policy for such statements based on the statement structure of the database access statements contained in the received request. If the current load exceeds the rate-limiting policy, the database will rate-limit database access requests with similar statement structures, for example, by directly reporting an error or processing the requests through a queue.

[0053] The implementation details of the technical solutions in the embodiments of this application are described in detail below: Figure 2 A flowchart of a database request processing method according to an embodiment of this application is shown. This database request processing method can be executed by a device with computing processing capabilities, such as a database system server or a terminal device. (Refer to...) Figure 2 As shown, the database request processing includes at least steps S210 to S240, which are described in detail below:

[0054] Step S210: Obtain a database access request, which contains a database access statement.

[0055] Database systems typically receive database access requests from application servers or user terminals. These requests contain database access statements, which are written using Structured Query Language (SCL) and are generally used to query and update data within the database.

[0056] Step S220: Perform semantic analysis on the target statement structure of the database access statement to obtain the target statement structure identifier corresponding to the target statement structure.

[0057] Database systems perform semantic analysis on the target statement structure of received database access statements to obtain the target statement structure identifier. A database statement can be considered a combination of statement structure and business parameters. The statement structure refers to the function the database access statement aims to achieve, while the business parameters are based on... The statement structure varies depending on the purpose of the database statement, but it does not change with specific business data. For example, a statement querying the prices of different products can have the same statement structure, but the business parameters will differ depending on the products the customer is browsing. For instance, a statement querying product information might have the structure "select id, data from table_a where id = 600", where the semantic analysis might yield the structure "select id, data from table_a where id = @1", where @1 represents the position of a business parameter. In a database system, different statement structures will have different statement structure identifiers, which can be obtained, for example, by hashing the statement structure. In some embodiments, the database may contain tables, views, or data structures specifically used to store statement structures and statement structure identifiers. Therefore, a database system can obtain the corresponding statement structure through the statement structure identifier, and can also calculate the corresponding statement structure identifier through the statement structure.

[0058] Step S230: Based on the statement structure identifier, retrieve the target policy entry corresponding to the target statement structure identifier from the rate limiting policy set, wherein the target policy entry contains statement execution information of the target statement structure and a target statement rate limiting policy for the target statement structure.

[0059] A database system can retrieve the target policy entry corresponding to a target statement structure identifier from a rate-limiting policy set based on the statement structure identifier. The rate-limiting policy set is a pre-configured set of policies for rate limiting based on statement structure within the database system. This set can be stored in the database system's memory using a hash table. The rate-limiting policy set contains the mapping between target statement structure identifiers and policy entries. Each policy entry stores rate-limiting related data for a statement structure, including statement execution information and the statement rate-limiting policy. The statement execution information primarily includes the number of database statements with the same statement structure currently being executed concurrently, and may also include statistics on how many such policies have been triggered. The statement rate-limiting policy mainly includes the rate-limiting strategy for the statement, such as the maximum number of concurrent statements, the scope of the rate-limiting policy, and the method of application.

[0060] Step S240: If the statement execution information satisfies the target statement rate limiting policy, then execute the database access request.

[0061] If the statement execution information meets the target statement rate limiting policy, such as when the current database load is lower than the load required by the policy, then the concurrent data of the current statement structure does not need to be rate limited, and the database access request can be executed. Conversely, if the statement execution information does not meet the target statement rate limiting policy, such as when the current system load is higher than the load required by the policy, then the database access request can be skipped. Instead, an execution failure error message can be sent to the requester, or the database access request can be placed in a request queue for further execution.

[0062] In the embodiments of this application, the database system obtains a database access request containing a database access statement. Then, it performs semantic analysis on the target statement structure of the database access statement to obtain a target statement structure identifier. Based on the statement structure identifier, the database system can retrieve the target policy entry corresponding to the target statement structure identifier from the rate limiting policy set. This target policy entry contains statement execution information of the target statement structure and a rate limiting policy for that target statement structure. If the statement execution information satisfies the target statement rate limiting policy, the database system executes the database access request. In this way, the database system can rate limit database access statements containing specific statement structures according to the rate limiting policy, achieving flow control for specific access statements. This limits the large amount of traffic from some access statements while avoiding impact on requests from other access statements, improving the granularity of database rate limiting control, thereby improving the overall response speed and execution efficiency of the database.

[0063] In the embodiments of this application, based on the technical solution of this application, during the process of retrieving the target policy entry corresponding to the target statement structure identifier from the rate limiting policy set according to the statement structure identifier, the database system generates a policy query instruction based on the statement structure identifier, and then queries the policy data table corresponding to the target statement structure identifier from the policy data table corresponding to the rate limiting policy set according to the policy query instruction. In this embodiment, the rate limiting policy set is stored in a data table in the database. When the database system needs to query a policy entry, it needs to generate a policy query instruction based on the statement structure identifier. This policy query instruction is usually generated using the database's structured query language, such as a database access statement used for table queries. By executing the generated policy query instruction, the database system accesses the policy data table corresponding to the rate limiting policy set, thereby obtaining 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 rate limiting policy set, compared to querying the rate limiting policy set from a hash table in memory, the inconsistency of rate limiting policies for processing requests caused by updates to entries in memory can be avoided, ensuring the consistency of information in the policy entries.

[0064] In the embodiments of this application, based on the technical solution of this application, before performing semantic analysis on the target statement structure of the database access statement, the database system also obtains the requester account information of the database access request. Then, based on the requester account information, if the requester is a designated account in the rate limiting policy of the target statement, the database access request is executed. In this embodiment, before obtaining the policy entry to check for rate limiting actions, the database system first checks whether the requester of the database access request belongs to a designated account, such as whether it is an administrator account or a special account with a specific identifier or prefix. If it is a designated account, the database system will not perform rate limiting checks, but will directly execute the requester's database access request. In this way, designated accounts are allowed to bypass rate limiting control, thereby allowing specific users to bypass concurrency control to access the database. This is beneficial for testing under conditions where concurrency control has already occurred, improving the security of the solution.

[0065] In embodiments of this application, a method for... Figure 2 Other detailed embodiments of the technical solution shown in the example are as follows: Figure 3 As shown, in one embodiment of the database request processing method of this application, the solution of this application may include the following steps:

[0066] Step S310: Obtain a database access request, wherein the database access request contains a database access statement;

[0067] Optionally, the implementation details of step S310 are the same as those of... Figure 2 The steps S210 shown are the same and will not be repeated here.

[0068] Step S320: Perform semantic analysis on the target statement structure of the database access statement to obtain the target statement structure identifier corresponding to the target statement structure;

[0069] Optionally, the implementation details of step S320 are the same as those of... Figure 2 The steps S220 shown are the same and will not be repeated here.

[0070] Step S330: Based on the statement structure identifier, retrieve the target policy entry corresponding to the target statement structure identifier from the rate limiting policy set, wherein the target policy entry contains statement execution information of the target statement structure and a target statement rate limiting policy for the target statement structure;

[0071] Optionally, the implementation details of step S330 are the same as those of... Figure 2 The steps S230 shown are the same and will not be repeated here.

[0072] Step S340: Obtain the number of concurrent statements in the statement execution information and the maximum number of concurrent statements in the target statement rate limiting policy;

[0073] Step S350: If the number of concurrent statements is lower than the maximum number of concurrent statements, then the number of concurrent statements in the statement execution information is incremented.

[0074] Step S360: Execute the database access request, and after the database access statement is executed, decrease the number of concurrent statements in the statement execution information.

[0075] In this embodiment, the database system rate limits statements based on the concurrency of statements with the same statement structure. Specifically, the statement execution information includes statement concurrency data, indicating how many database statements with this statement structure are currently being executed in the database. The target statement rate limiting policy includes a maximum concurrency count, indicating the maximum allowed concurrency for a given type of database statement structure. If the statement concurrency count is lower than the maximum concurrency count, it means that access statements with this statement structure can be executed concurrently in the database system. In this case, the database system increments the statement concurrency count in the statement execution information and then executes the database access request. After the database access statement is executed, the database system decrements the statement concurrency count in the statement execution information. In this way, the database system updates the concurrency count in a timely manner when performing rate limiting control, eliminating the need to check the concurrency status during the target statement rate limiting policy check, thereby improving the execution efficiency of the rate limiting process.

[0076] In the embodiments of this application, the database system obtains a database access request containing a database access statement. Then, it performs semantic analysis on the target statement structure of the database access statement to obtain a target statement structure identifier. Based on the statement structure identifier, the database system can retrieve the target policy entry corresponding to the target statement structure identifier from the rate limiting policy set. This target policy entry contains statement execution information of the target statement structure and a rate limiting policy for that target statement structure. If the statement execution information satisfies the target statement rate limiting policy, the database system executes the database access request. In this way, the database system can rate limit database access statements containing specific statement structures according to the rate limiting policy, achieving flow control for specific access statements. This limits the large amount of traffic from some access statements while avoiding impact on requests from other access statements, improving the granularity of database rate limiting control, thereby improving the overall response speed and execution efficiency of the database.

[0077] In the embodiments of this application, based on the technical solution of this application, during the process of retrieving the target policy entry corresponding to the target statement structure identifier from the rate limiting policy set according to the statement structure identifier, the database system generates a policy query instruction based on the statement structure identifier, and then queries the policy data table corresponding to the target statement structure identifier from the policy data table corresponding to the rate limiting policy set according to the policy query instruction. In this embodiment, the rate limiting policy set is stored in a data table in the database. When the database system needs to query a policy entry, it needs to generate a policy query instruction based on the statement structure identifier. This policy query instruction is usually generated using the database's structured query language, such as a database access statement used for table queries. By executing the generated policy query instruction, the database system accesses the policy data table corresponding to the rate limiting policy set, thereby obtaining 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 rate limiting policy set, compared to querying the rate limiting policy set from a hash table in memory, the inconsistency of rate limiting policies for processing requests caused by updates to entries in memory can be avoided, ensuring the consistency of information in the policy entries.

[0078] In the embodiments of this application, based on the technical solution of this application, before performing semantic analysis on the target statement structure of the database access statement, the database system also obtains the requester account information of the database access request. Then, based on the requester account information, if the requester is a designated account in the rate limiting policy of the target statement, the database access request is executed. In this embodiment, before obtaining the policy entry to check for rate limiting actions, the database system first checks whether the requester of the database access request belongs to a designated account, such as whether it is an administrator account or a special account with a specific identifier or prefix. If it is a designated account, the database system will not perform rate limiting checks, but will directly execute the requester's database access request. In this way, designated accounts are allowed to bypass rate limiting control, thereby allowing specific users to bypass concurrency control to access the database. This is beneficial for testing under conditions where concurrency control has already occurred, improving the security of the solution.

[0079] In the embodiments of this application, based on the technical solution of this application, if the number of concurrent statements is lower than the maximum number of concurrent statements, the database system, during the process of incrementing the number of concurrent statements in the target statement rate limiting strategy, will first acquire a policy access lock for the target policy entry, 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 rate limiting strategy set. The shared access lock is an access control lock acquired for the rate limiting strategy set before querying the target policy entry. In this embodiment, the database system locks both the target policy entry and the rate limiting strategy set during rate limiting. Specifically, before querying the rate limiting strategy set, the database system acquires a shared access lock for the rate limiting strategy set. This shared access lock allows other requests to read the rate limiting strategy set but does not allow modification of the rate limiting strategy set. Subsequently, if it is determined that the statement in the database access request can be executed, the database system acquires the policy access lock for the target policy entry. This policy access lock is primarily used to lock the corresponding policy entry, preventing other requests from reading or modifying it. At this point, the current request's processing process has acquired two locks, allowing it to modify data in the target policy entry but not other unlocked entries. Other requests can read entries in the rate limiting policy set other than the locked target policy entry, and, if necessary, can also acquire policy access locks on entries other than the locked target policy entry. After acquiring the necessary locks, the database system increments the statement concurrency count and saves it to the statement execution information of the target policy entry, thus updating the target policy entry. After the update is complete, the database system releases both locks at once, completing the locking and updating process. By locking each policy entry in the rate limiting policy set, the shared access level of data in the rate limiting policy set can be ensured while maintaining data consistency. This avoids resource contention during rate limiting execution, which can lead to increased request processing latency and improves the efficiency of access request processing.

[0080] In embodiments of this application, based on the technical solution of this application, the database access statement includes call information for a specified access statement. The database system also obtains a specified policy entry corresponding to the specified access statement based on the call information. If the number of concurrent statements in the statement execution information of the specified policy entry is higher than the maximum number of concurrent statements in the specified policy entry's rate limiting policy, the database access request is stopped from being processed. In this embodiment, when there are nested calls in the database request, the database system further performs rate limiting control based on the nested calls. Specifically, a database access statement may call another database access statement. In this embodiment, for such calls, the database system further checks the rate limiting policy of the called access statement based on the call information. If the called statement is in a state that needs to be rate-limited, the caller in the current access request will also be rate-limited. In some embodiments, the call information includes multi-level nested calls. The database system can check whether the database statements in all call levels are in a rate-limited state. If any database statement in any call level is rate-limited, the current database access request will be stopped from being processed. In other embodiments, the database system may not perform rate limiting checks on calls after a certain nesting level. For example, if the target policy entry specifies a nested call check level of 3, and the database access statement contains 4 levels of nested calls, then whether the fourth-level nested call statement is under rate limiting will not affect the processing of the current database access request. It's understandable that this check level can be set to 0 or 1, indicating that only the database access statement within the database access request itself is rate-limited, while statements in the called layers do not require checking. This approach allows the database system to configure specific rate limiting checks for different nested database statement scenarios, improving the controllability and flexibility of the rate limiting process in the solution.

[0081] In embodiments of this application, a method for... Figure 2 Other detailed embodiments of the technical solution shown in the example are as follows: Figure 4 As shown, in one embodiment of the database request processing method of this application, the solution of this application may include the following steps:

[0082] Step S410: Obtain a database access request, wherein the database access request contains a database access statement.

[0083] Optionally, the implementation details of step S410 are the same as... Figure 2 The steps S210 shown are the same and will not be repeated here.

[0084] Step S420: Perform semantic analysis on the target statement structure of the database access statement to obtain the target statement structure identifier corresponding to the target statement structure.

[0085] Optionally, the implementation details of step S420 are the same as those of... Figure 2 The steps S220 shown are the same and will not be repeated here.

[0086] Step S430: Based on the statement structure identifier, retrieve the target policy entry corresponding to the target statement structure identifier from the rate limiting policy set, wherein the target policy entry contains statement execution information of the target statement structure and a target statement rate limiting policy for the target statement structure.

[0087] Optionally, the implementation details of step S430 are the same as those of... Figure 2 The steps S230 shown are the same and will not be repeated here.

[0088] Step S440: If the statement execution information satisfies the target statement rate limiting policy, then execute the database access request.

[0089] Optionally, the implementation details of step S440 are the same as those of... Figure 2 The steps S240 shown are the same and will not be repeated here.

[0090] Step S450: Obtain a new request for rate limiting policy. The new request for rate limiting policy includes a new statement structure identifier or access statement of the new statement structure and the new statement rate limiting policy corresponding to the new statement structure.

[0091] Step S460: Obtain an exclusive access lock for the set of rate limiting policies;

[0092] Step S470: Based on the new request added according to the rate limiting policy, add a new policy entry corresponding to the new statement structure to the rate limiting policy set, and the new policy entry contains the new statement rate limiting policy;

[0093] Step S480: Modify the number of policies in the rate limiting policy set and release the exclusive access lock.

[0094] In this embodiment, the database system can add corresponding policy entries to the rate limiting policy set based on user-submitted rate limiting policy addition requests. Specifically, the rate limiting policy addition request includes a new statement structure identifier or access statement for the new statement structure, as well as the corresponding rate limiting policy. It is understood that if the rate limiting policy addition request contains an access statement for the new statement structure, the database system can perform semantic analysis on the access statement to obtain the new statement structure identifier. If the rate limiting policy addition request directly contains the new statement structure identifier, it indicates that the database system has already performed semantic analysis on the new statement structure, and therefore can directly use the new statement structure identifier to create a new policy entry. Before adding a new policy entry, the database system acquires an exclusive access lock for the rate limiting policy set. This exclusive access lock and the shared access lock described above can be different locking methods of the same lock. That is, a rate limiting policy set locked by a shared access lock cannot be locked by an exclusive access lock, and vice versa. The purpose of the exclusive access lock is to prevent other requests from reading and modifying the rate limiting policy set. During the period when the exclusive access lock is engaged, only the process that acquired the lock can modify the contents of the rate limiting policy set. After locking, the database system adds a new policy entry corresponding to the new statement structure to the rate limiting policy set based on the new request. The new policy entry contains the rate limiting policy for the new statement. In some embodiments, the new policy entry may also contain initial statement execution information, such as the concurrency number being initialized to 0. It is understood that if a policy entry corresponding to the new statement structure already exists in the rate limiting policy set, depending on the specific instruction, the database system may either report an error for the new request or directly update the corresponding policy entry. After the entry is added, the database system modifies the policy quantity information in the rate limiting policy set and releases the exclusive access lock. The policy quantity information is the statistical information for rate limiting policies in the rate limiting policy set. The rate limiting policy set may also contain other statistical information, such as how many times each rate limiting policy was triggered, the time period during which it was triggered, the trigger frequency, and the number of requests rejected during the rate limiting process. Users can retrieve this information from the rate limiting policy set using query commands and view it through a graphical interface, allowing users or database administrators to more intuitively understand the execution status of database rate limiting. This approach allows the database system to update and maintain the rate limiting policy set without requiring additional resources to manage the information, thus reducing the resource consumption of the rate limiting scheme.

[0095] In the embodiments of this application, the database system obtains a database access request containing a database access statement. Then, it performs semantic analysis on the target statement structure of the database access statement to obtain a target statement structure identifier. Based on the statement structure identifier, the database system can retrieve the target policy entry corresponding to the target statement structure identifier from the rate limiting policy set. This target policy entry contains statement execution information of the target statement structure and a rate limiting policy for that target statement structure. If the statement execution information satisfies the target statement rate limiting policy, the database system executes the database access request. In this way, the database system can rate limit database access statements containing specific statement structures according to the rate limiting policy, achieving flow control for specific access statements. This limits the large amount of traffic from some access statements while avoiding impact on requests from other access statements, improving the granularity of database rate limiting control, thereby improving the overall response speed and execution efficiency of the database.

[0096] In the embodiments of this application, based on the technical solution of this application, during the process of retrieving the target policy entry corresponding to the target statement structure identifier from the rate limiting policy set according to the statement structure identifier, the database system generates a policy query instruction based on the statement structure identifier, and then queries the policy data table corresponding to the target statement structure identifier from the policy data table corresponding to the rate limiting policy set according to the policy query instruction. In this embodiment, the rate limiting policy set is stored in a data table in the database. When the database system needs to query a policy entry, it needs to generate a policy query instruction based on the statement structure identifier. This policy query instruction is usually generated using the database's structured query language, such as a database access statement used for table queries. By executing the generated policy query instruction, the database system accesses the policy data table corresponding to the rate limiting policy set, thereby obtaining 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 rate limiting policy set, compared to querying the rate limiting policy set from a hash table in memory, the inconsistency of rate limiting policies for processing requests caused by updates to entries in memory can be avoided, ensuring the consistency of information in the policy entries.

[0097] In the embodiments of this application, based on the technical solution of this application, before performing semantic analysis on the target statement structure of the database access statement, the database system also obtains the requester account information of the database access request. Then, based on the requester account information, if the requester is a designated account in the rate limiting policy of the target statement, the database access request is executed. In this embodiment, before obtaining the policy entry to check for rate limiting actions, the database system first checks whether the requester of the database access request belongs to a designated account, such as whether it is an administrator account or a special account with a specific identifier or prefix. If it is a designated account, the database system will not perform rate limiting checks, but will directly execute the requester's database access request. In this way, designated accounts are allowed to bypass rate limiting control, thereby allowing specific users to bypass concurrency control to access the database. This is beneficial for testing under conditions where concurrency control has already occurred, improving the security of the solution.

[0098] In the embodiments of this application, based on the technical solution of this application, after obtaining a new request for a rate limiting policy, if the new request for a rate limiting policy contains a new statement structure identifier, the database system will query the new statement structure according to the new statement structure identifier. If the new request for a rate limiting policy contains an access statement, the database system will perform semantic analysis on the statement structure of the access statement to obtain a new statement structure, and calculate the new statement structure identifier according to the new statement structure. Specifically, if the new request for a rate limiting policy provides a new statement structure identifier, the database system will query the database for the corresponding new statement structure, thereby ensuring that the corresponding statement structure does exist. It can be understood that the database access statement can be provided to the database system in advance for semantic analysis. The database will store the analyzed statement structure, statement identifier, and the access statement provided at that time together in a specific table in the database, so that other processing flows can verify the statement structure according to the statement identifier when needed. In some embodiments, if the new statement structure exists, it will be added to the corresponding entry in the rate limiting policy set. If the new request for a rate limiting policy provides an access statement, the database system obtains the corresponding new statement structure through semantic analysis and calculates the new statement structure identifier. In the above manner, the database system allows rate limiting policies to be added to the rate limiting policy set through two methods: access statements and statement structure identifiers, which helps to improve the flexibility of the solution.

[0099] In embodiments of this application, based on the technical solution of this application, after releasing the exclusive access lock, if the rate limiting policy addition request contains a policy persistence identifier, the database system will also obtain the policy entry corresponding to the new statement structure identifier in the rate limiting policy set. The policy entry contains the new statement rate limiting policy, and then insert the policy entry into the policy data table corresponding to the rate limiting policy set. Specifically, the rate limiting policy set is usually stored in the database system memory using a hash table. If the rate limiting policy addition request contains a policy persistence identifier, the database system will save the policy entry to the database's data policy table. In some embodiments, the database system can also persist all policy entries in the rate limiting policy set to the policy data table according to the received policy persistence instruction. Specifically, each entry in the rate limiting policy set can be inserted into the policy data table as new data sequentially. If a duplicate statement structure identifier is encountered, an error is reported or the update method is re-executed. In this way, the query of the rate limiting policy set is still performed through a hash table in memory, while the policy data is stored through a database. This ensures the persistence of rate limiting policies while maintaining the performance of policy queries, and improves the convenience of rate limiting policy management.

[0100] In embodiments of this application, based on the technical solution of this application, the database system further obtains 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 rate limiting policy set. Specifically, policy entries persisted in the policy data table can be loaded by the database system, for example, by loading the rate limiting policy set during database system startup, or by loading when memory fails. In some embodiments, the policy loading instruction may include a statement structure identifier, and the database system will query the corresponding policy entry from the policy data table according to the statement structure identifier and load the entry to load the specified rate limiting policy. In the above manner, the database system is allowed to load each policy at once, avoiding the operation of rebuilding the rate limiting policy set in memory, thereby improving the loading efficiency of rate limiting records.

[0101] In embodiments of this application, based on the technical solution of this application, the database system further obtains a policy uninstallation instruction, which includes a statement structure identifier to be uninstalled. Subsequently, the database system deletes the policy entry corresponding to the statement structure identifier to be uninstalled from the rate limiting policy set according to the policy uninstallation instruction. If the policy uninstallation instruction includes a policy deletion identifier, the database system also deletes the policy entry corresponding to the statement structure identifier to be uninstalled from the policy data table according to the policy uninstallation instruction. Specifically, the policy uninstallation instruction is mainly used to delete policy entries from the rate limiting policy set. If the policy uninstallation instruction does not include a policy deletion identifier, the policy entry is only deleted from the hash table in memory, thus effectively uninstalling the specified rate limiting policy from the database system. If the policy uninstallation instruction includes a policy deletion identifier, the database system deletes the corresponding policy entry from the policy data table, indicating that the rate limiting policy is completely deleted. In some embodiments, the statement structure identifier may not be specified in the policy uninstallation instruction, in which case the database system will uninstall all policies in the rate limiting policy set. If the policy uninstallation instruction includes a policy deletion identifier, the database system will also delete all policy entries. Understandably, deleting a policy entry from the policy data table requires database operations. The database system automatically generates the corresponding database operation statement based on the policy deletion identifier and the unload statement structure identifier. In some embodiments, the database system may have a primary instance and a read-only instance. The primary instance is the running instance of the database and can be deleted and modified, while the read-only instance is synchronized with the primary instance and is mainly used for reading to avoid excessive read requests to the primary instance affecting its operation. In such cases, deletion operations are typically performed only on the instance currently running the instruction. For example, deleting a policy from the hash table of a read-only instance will not affect the policies in the hash table of the primary instance, and vice versa. This approach allows the database system to delete rate-limiting policies from the rate-limiting policy set and the policy data table. In the event of an abnormal rate-limiting policy, deleting the policy prevents the database system from being affected, thus improving database stability.

[0102] The following describes the implementation details of the technical solution of this application embodiment with specific examples. Specifically, the solution of this application can be implemented by a database plugin. The plugin mainly includes six operations for rate limiting strategies: adding, deleting, loading, persisting, viewing, and modifying. Specifically, adding rate limiting strategies supports two methods: adding strategies by identifying the queryid through the statement structure and adding strategies by accessing the query statement. The method of adding strategies by queryid is as follows: SELECT tencentdb_sql_throttling.add_rule_with_queryid(queryidbigint,work_nodeint,max_concurrency int,is_enabledboolean,memory_onlyboolean,query_stringtext). Wherein, queryid: a 64-bit integer obtained by hashing the normalized query statement, which can be obtained through a function provided by the database. work_node: the node where the rate limiting strategy takes effect, specifically divided into three types: the primary instance takes effect, the read-only instance takes effect, and both take effect. `max_concurrency`: The maximum number of concurrent connections allowed by this rate-limiting policy; `is_enabled`: Whether the current policy is in effect; `memory_only`: Optional, whether the policy needs to be persisted to a table, and can be reloaded into memory using the policy recovery command after a restart / failure; `query_string`: Allows adding query statements to the policy. If this parameter is not provided, the database system can automatically find the access statement corresponding to the query ID in the view of the statement structure and record the result in the policy. Adding a policy via query is 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)`. Here, `query` is the access statement that needs to be rate-limited; `work_node`: The node where the rate-limiting policy takes effect, specifically indicating that it applies to the primary instance, read-only instances, or both. `max_concurrency`: The maximum number of concurrent connections allowed by this rate limiting policy; `is_enabled`: Whether the current policy is in effect; `memory_only`: Whether the policy needs to be persisted to a table so that it can be reloaded into memory after a restart / failure. This method returns the query ID of the query. Deleting a rate limiting policy supports two methods: deleting a specific policy by query ID and deleting all policies.The method to delete a specific policy by queryid is as follows: `SELECT tencentdb_sql_throttling.drop_rule(queryid bigint, memory_only)`. Here, `memory_only` determines whether to delete only policies in memory. When `memory_only` is true, only policies in memory are deleted; policies in persistent tables are unaffected, which can be seen as unloading the rate limiting policy from memory. When `memory_only` is false, policies in both memory and tables are deleted simultaneously. If deletion fails, an alert log will be printed. Read-only instances can only delete policies in memory. The deletion action only takes effect on the current instance and will not be synchronized to read-only instances. Unloading policies in read-only instances requires running this method separately. The method to delete all policies is as follows: `SELECT tencentdb_sql_throttling.drop_all_rules(memory_only boolean)`. The usage of `memory_only` is the same as in deleting a specific policy. Loading rate limiting policies supports two methods: loading policies by queryid and loading all policies. The method for loading policies by queryid is as follows: `SELECT tencentdb_sql_throttling.load_rule(queryidbigint)`. No parameter is needed when loading all policies. Loading all policies loads all policies used to store the rate limiting policy table into memory. If a policy fails to load, it is skipped and the next policy is loaded. This loading method can reload the data in the rate limiting policy table into a hash table in memory. The loading method can iterate through the rate limiting policy table, calling the method for adding policies by queryid one by one to insert rules into the hash table. Similarly, persistent rate limiting policies support two methods: persisting policies by queryid and persisting all policies. The method for persisting policies by queryid is as follows: `SELECT tencentdb_sql_throttling.dump_rule(queryidbigint)`. Persisting all policies does not require providing the queryid. This method exports all current rules to the rate limiting policy table for persistent storage. Exporting can be seen as inserting all rules in the current hash table one by one into the rate limiting policy table, without modifying existing data in the table. If a conflict occurs, an error will be reported and the process will exit. An exclusive access lock will be acquired before exporting, and released after exporting. The rate limiting policy set contains statistical information about rate limiting policies. Rate limiting policies can be viewed as follows: `SELECT * FROM tencentdb_sql_throttling.rules`.The returned view contains the following: queryid: the queryid of the rate-limiting SQL statement, work_node: the node where the policy is effective, max_concurrency: the maximum allowed concurrency, is_enabled: whether the rate-limiting policy is effective, query_string: the SQL statement corresponding to the rate-limiting policy, current_concurrency: the current concurrency of this SQL statement, total_hit_count: the number of times the rate-limiting policy has been hit, and reject_count: the total number of times the policy has limited the rate. The rate-limiting policy can be modified as follows: SELECT tencentdb_sql_throttling.change_rule_status(queryidbigint, is_enabledboolean, max_concurrency int). This method can modify whether an existing policy is effective / the maximum concurrency using the queryid, and can also modify the effectiveness status of an existing policy using the queryid. It can also modify the current concurrency of a policy using the queryid. In case of an exception, the current concurrency of the policy can be manually modified to ensure that the policy continues to run. SELECT tencentdb_sql_throttling.change_rule_current_concurrency(queryidbigint,new_currenct_concurrency int).

[0103] Please see Figure 5 , Figure 5 This is a structural diagram of the current limiting scheme in the embodiments of this application. Figure 1 As shown, when a user executes a database SQL statement, the database performs syntax analysis on the SQL statement to obtain the corresponding queryid. After scheduling by the planner, the database system retrieves a policy from the hash table of the rate limiting policy set based on the queryid. If a policy is matched, the database system checks whether the number of concurrent SQL statements corresponding to that queryid exceeds the maximum concurrency limit specified by the policy. If it does, an error is reported and the process exits; otherwise, the executor executes the SQL statement to complete the query process. For policies in the hash table, administrators can add new policies. The database system calculates the queryID of the new policy and adds it to the hash table. Administrators can further request export policies, in which case the database system saves the policies from the hash table to the rate limiting policy table. During concurrency control, the database system uses a locking mechanism to ensure data consistency. For details, please refer to [link to relevant documentation]. Figure 6 , Figure 6 This is a schematic diagram of the concurrency control process in an embodiment of this application. Figure 6 As shown, inserting and deleting data using a strategy requires acquiring a lightweight lock (LWLock) in exclusive mode. After exclusive locking, data definition language operations used to modify the table structure can be executed to update the hash table. Once the update is complete, the LWLock is released, thus completing the insert / delete process. When executing SQL, the LWLock is acquired in shared mode. After determining the relevant strategy, a spin lock (SpinLock) is acquired for that strategy, allowing modification of the strategy's information. After modification, both the SpinLock and LWLock are released. Figure 7 This is an overall flowchart of the newly added strategy in the embodiments of this application. For example... Figure 7 As shown, the database system first checks if the input request contains the SQL statement corresponding to the queryid. If not, it queries the statement structure table for the corresponding SQL. If the corresponding SQL statement is not found, an alert is issued. If the newly added policy provides SQL or the corresponding SQL is found based on the queryid, the database system acquires the LWLock of the hash table of the rate limiting policy set in exclusive mode. If the hash table is full, it exits with an error. If it is not full, the database system queries the hash table for the newly added policy and modifies the total number of policies. Subsequently, the database system releases the LWLock of the hash table and checks whether persistence of entries is required. If so, it persists the entries in the hash table to the database table through the database access interface, thus completing the execution process. If only the query is provided without the queryid when adding a rule, the database system first performs syntactic analysis on the query, then performs semantic analysis on the obtained statement structure tree to obtain the statement structure, and then calculates the queryid. The subsequent process is the same as... Figure 7 The process is similar, but the step of retrieving the query based on the queryid is omitted. During the executor execution phase, data modification is performed through hooks. Please refer to [link / reference]. Figure 8 , Figure 8 This is a schematic diagram of the actuator stage in an embodiment of this application. Figure 8As shown, the executor contains three hook programs. `ExecutorRun_hook` calculates the current nested level (`nested_level`) and the current user to determine if rate limiting is needed. If rate limiting is required, it increments the current concurrency (`current_concurrency`) by 1 and modifies other data (such as the hit count). `ExecutorEnd_hook` decrements `current_concurrency` by 1 from the corresponding policy value in the hash table. `ExecutorFinish_hook` maintains the variable used to calculate the nested level (`nested_level`), decrements it by 1 after nested execution is complete.

[0104] It should be noted that although the steps of the method in this application are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in that specific order, or that all the steps shown must be performed to achieve the desired result. Additional or alternative steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.

[0105] The following describes the implementation of the apparatus of this application, which can be used to execute the database request processing method in the above embodiments of this application. Figure 9 A schematic block diagram illustrating the composition of a database request processing apparatus in an embodiment of this application is shown. Figure 9 As shown, the database request processing device 900 mainly includes:

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

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

[0108] The strategy retrieval module 930 is configured to retrieve a target strategy entry corresponding to the target statement structure identifier from the rate limiting strategy set based on the statement structure identifier, wherein the target strategy entry contains statement execution information of the target statement structure and a target statement rate limiting strategy for the target statement structure.

[0109] The request execution module 940 is configured to execute the database access request if the statement execution information satisfies the target statement rate limiting policy.

[0110] In some embodiments of this application, based on the above technical solutions, the request execution module 940 is specifically configured to: obtain the number of concurrent statements in the statement execution information and the maximum number of concurrent statements in the target statement rate limiting strategy; if the number of concurrent statements is lower than the maximum number of concurrent statements, increment the number of concurrent statements in the statement execution information; execute the database access request, and decrement the number of concurrent statements in the statement execution information after the database access statement is executed.

[0111] In some embodiments of this application, based on the above technical solutions, the request execution module 940 is specifically configured to: if the number of concurrent statements is lower than the maximum number of concurrent statements, acquire a policy access lock for the target policy entry; increment the number of concurrent statements and save it to the statement execution information of the target policy entry; release the policy access lock and the shared access lock for the rate limiting policy set, wherein the shared access lock is an access control lock acquired for the rate limiting policy set before querying the target policy entry.

[0112] In some embodiments of this application, based on the above technical solutions, the database access statement includes call information for a specified access statement; the request execution module 940 is further configured to: obtain a specified policy entry corresponding to the specified access statement according to the call information; if the number of concurrent statements in the statement execution information of the specified policy entry is higher than the maximum number of concurrent statements in the specified policy entry's rate limiting policy, then the processing of the database access request is stopped.

[0113] In some embodiments of this application, based on the above technical solutions, the policy retrieval module 930 is further configured to: obtain a rate limiting policy addition request, wherein the rate limiting policy addition request includes a new statement structure identifier or access statement of the new statement structure and a new statement rate limiting policy corresponding to the new statement structure; obtain an exclusive access lock for the rate limiting policy set; add a new policy entry corresponding to the new statement structure to the rate limiting policy set according to the rate limiting policy addition request, wherein the new policy entry includes the new statement rate limiting policy; modify the policy quantity information in the rate limiting policy set and release the exclusive access lock.

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

[0115] In some embodiments of this application, based on the above technical solutions, the policy retrieval module 930 is further configured to: if the rate limiting policy new request contains a policy persistence identifier, then obtain the policy entry corresponding to the new statement structure identifier in the rate limiting policy set, the policy entry containing the new statement rate limiting policy; and insert the policy entry into the policy data table corresponding to the rate limiting policy set.

[0116] In some embodiments of this application, based on the above technical solutions, the policy retrieval module 930 is further configured to: obtain 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 rate limiting policy set during the traversal of the policy data table.

[0117] In some embodiments of this application, based on the above technical solutions, the policy retrieval module 930 is further configured to: obtain a policy uninstallation instruction, wherein the policy uninstallation instruction contains a statement structure identifier to be uninstalled; delete the policy entry corresponding to the statement structure identifier to be uninstalled from the rate limiting policy set according to the policy uninstallation instruction; if the policy uninstallation instruction contains a policy deletion identifier, delete the policy entry corresponding to the statement structure identifier to be uninstalled from the policy data table according to the policy uninstallation instruction.

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

[0119] In some embodiments of this application, based on the above technical solutions, the semantic analysis module 920 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.

[0120] It should be noted that the apparatus provided in the above embodiments and the method provided in the above embodiments belong to the same concept, and the specific way in which each module performs the operation has been described in detail in the method embodiments, and will not be repeated here.

[0121] Figure 10 A schematic diagram of the structure of a computer system suitable for implementing the electronic device of the present application is shown.

[0122] It should be noted that, Figure 10 The computer system 1000 of the electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0123] like Figure 10 As shown, the computer system 1000 includes a Central Processing Unit (CPU) 1001, which can perform various appropriate actions and processes based on programs stored in Read-Only Memory (ROM) 1002 or programs loaded from storage section 1008 into Random Access Memory (RAM) 1003. The RAM 1003 also stores various programs and data required for system operation. The CPU 1001, ROM 1002, and RAM 1003 are interconnected via a bus 1004. An Input / Output (I / O) interface 1005 is also connected to the bus 1004.

[0124] The following components are connected to I / O interface 1005: an input section 1006 including a keyboard, mouse, etc.; an output section 1007 including a cathode ray tube (CRT), liquid crystal display (LCD), and speakers, etc.; a storage section 1008 including a hard disk, etc.; and a communication section 1009 including a network interface card such as a LAN (Local Area Network) card and a modem, etc. Communication section 1009 performs communication processing via a network such as the Internet. Drive 1010 is also connected to I / O interface 1005 as needed. Removable media 1011, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 1010 as needed so that computer programs read from them can be installed into storage section 1008 as needed.

[0125] Specifically, according to embodiments of this application, the processes described in the various method flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 1009, and / or installed from removable medium 1011. When the computer program is executed by central processing unit (CPU) 1001, it performs various functions defined in the system of this application.

[0126] It should be noted that the computer-readable medium shown in the embodiments of this application can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this application, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this application, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such transmitted data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit 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, etc., or any suitable combination thereof.

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

[0128] It should be noted that although several modules or units for the device used to perform actions have been mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of this application, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided and embodied by multiple modules or units.

[0129] Through the above description of the embodiments, those skilled in the art will readily understand that the exemplary embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solutions according to the embodiments of this application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (such as a CD-ROM, USB flash drive, external hard drive, etc.) or on a network, including several instructions to cause a computing device (such as a personal computer, server, touch terminal, or network device, etc.) to execute the method according to the embodiments of this application.

[0130] Other embodiments of this application will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of this application that follow the general principles of this application and include common knowledge or customary techniques in the art not disclosed herein.

[0131] It should be understood that this application is not limited to the precise structure described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this application is limited only by the appended claims.

Claims

1. A database request processing method, characterized in that, include: Obtain a database access request, wherein the database access request contains a database access statement; Perform semantic analysis on the target statement structure of the database access statement to obtain the target statement structure identifier corresponding to the target statement structure. Based on the statement structure identifier, retrieve the target policy entry corresponding to the target statement structure identifier from the rate limiting policy set, wherein the target policy entry contains statement execution information of the target statement structure and a target statement rate limiting policy for the target statement structure; If the statement execution information satisfies the target statement rate limiting policy, then the database access request is executed.

2. The method according to claim 1, characterized in that, If the statement execution information satisfies the target statement rate limiting policy, then the database access request is executed, including: Obtain the number of concurrent statements in the statement execution information and the maximum number of concurrent statements in the target statement rate limiting policy; If the number of concurrent statements is lower than the maximum number of concurrent statements, then the number of concurrent statements in the statement execution information will be incremented. Execute the database access request, and after the database access statement is executed, decrease the number of concurrent statements in the statement execution information.

3. The method according to claim 2, characterized in that, If the number of concurrent statements is lower than the maximum number of concurrent statements, then the number of concurrent statements in the target statement rate limiting strategy will be increased, including: If the number of concurrent statements is lower than the maximum number of concurrent statements, then acquire the policy access lock for the target policy entry; The concurrent statement count is incremented and saved to the statement execution information of the target strategy entry; Release the policy access lock and the shared access lock for the rate limiting policy set, wherein the shared access lock is an access control lock acquired for the rate limiting policy set before querying the target policy entry.

4. The method according to claim 2, characterized in that, The database access statement contains invocation information for a specified access statement; the method further includes: Based on the invocation information, obtain the specified policy entry corresponding to the specified access statement; If the number of concurrent statements in the statement execution information of the specified policy entry is higher than the maximum number of concurrent statements in the specified policy entry's rate limiting policy, then the database access request will be stopped.

5. The method according to claim 1, characterized in that, The method further includes: Get a new request for rate limiting policy, the new request for rate limiting policy includes a new statement structure identifier or access statement of the new statement structure and the new statement rate limiting policy corresponding to the new statement structure; Acquire an exclusive access lock for the set of rate limiting policies; Based on the new request according to the rate limiting policy, add a new policy entry corresponding to the new statement structure to the rate limiting policy set, and the new policy entry contains the rate limiting policy of the new statement; Modify the number of policies in the rate limiting policy set and release the exclusive access lock.

6. The method according to claim 5, characterized in that, After obtaining new requests for the rate limiting policy, the method further includes: If the rate limiting policy adds a new request containing a new statement structure identifier, then the new statement structure is queried based on the new statement structure identifier. If the rate limiting policy adds a request containing an access statement, then the statement structure of the access statement is semantically analyzed to obtain the new statement structure, and the new statement structure identifier is calculated based on the new statement structure.

7. The method according to claim 5, characterized in that, After releasing the exclusive access lock, the method further includes: If the new request of the rate limiting policy contains a policy persistence identifier, then obtain the policy entry in the rate limiting policy set corresponding to the new statement structure identifier, and the policy entry contains the new statement rate limiting policy; Insert the policy entries into the policy data table corresponding to the rate limiting policy set.

8. The method according to claim 7, characterized in that, The method further includes: Obtain the policy loading instruction; According to the policy loading instruction, traverse each policy entry in the policy data table; During the process of traversing the policy data table, each policy entry is loaded into the rate limiting policy set.

9. The method according to claim 7, characterized in that, The method further includes: Obtain the policy uninstallation instruction, which contains an identifier of the statement structure to be uninstalled. According to the policy uninstallation instruction, delete the policy entry corresponding to the statement structure identifier to be uninstalled from the rate limiting policy set; If the policy uninstallation instruction contains a policy deletion identifier, then according to the policy uninstallation instruction, the policy entry corresponding to the statement structure identifier to be uninstalled is deleted from the policy data table.

10. The method according to claim 1, characterized in that, The step of retrieving the target policy entry corresponding to the target statement structure identifier from the rate limiting policy set based on the statement structure identifier includes: Generate a strategy query instruction based on the statement structure identifier; According to the policy query instruction, query the target policy entry corresponding to the target statement structure identifier from the policy data table corresponding to the rate limiting policy set.

11. The method according to claim 1, characterized in that, Before performing semantic analysis on the target statement structure of the database access statement, the method further includes: Obtain the account information of the requester in the database access request; If the requester's account information indicates that the requester is a specified account in the target statement rate limiting policy, then the database access request is executed.

12. A database request processing apparatus, characterized in that, include: The request acquisition module is configured to acquire database access requests, wherein the database access requests contain database access statements. The semantic analysis module is configured to perform semantic analysis on the target statement structure of the database access statement to obtain the target statement structure identifier corresponding to the target statement structure. The strategy retrieval module is configured to retrieve the target strategy entry corresponding to the target statement structure identifier from the rate limiting strategy set based on the statement structure identifier, wherein the target strategy entry contains statement execution information of the target statement structure and a target statement rate limiting strategy for the target statement structure; The request execution module is configured to execute the database access request if the statement execution information satisfies the target statement rate limiting policy.

13. An electronic device, characterized in that, include: processor; Memory for storing the executable instructions of the processor; The processor is configured to execute the database request processing method according to any one of claims 1 to 11 by executing the executable instructions.

14. A computer-readable medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the database request processing method as described in any one of claims 1 to 11.

15. A computer program product, characterized in that, The computer program product includes computer instructions stored in a computer-readable storage medium, a processor of a computer device reading the computer instructions from the computer-readable storage medium, and the processor executing the computer instructions to cause the computer device to perform the database request processing method as described in any one of claims 1 to 11.