Database request processing method and device, electronic device and medium

By prioritizing tasks in the database based on request priority and transaction mode, and using the thread pool manager to wake up the sleeping thread, the problem of degradation in the performance of thread pool under high concurrent is solved, and more efficient processing performance is achieved.

CN112346834BActive Publication Date: 2024-11-01BEIJING KINGSOFT CLOUD NETWORK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202011085680.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-12
Publication Date
2024-11-01
Estimated Expiration
2040-10-12

AI Technical Summary

Technical Problem

In high concurrency scenarios, the thread pooling technology of existing databases may lead to thread blockage, resulting in degradation of processing performance, and the existing technology is difficult to effectively improve the processing performance of the system.

Method used

In the database request processing method, the priority of the request is determined based on the priority of the operation request and the transaction submission mode, and added it to the corresponding task queue of the thread pool, the thread pool manager is used to automatically prioritize the task and create an independent thread Or wake up the hibernation worker thread to improve processing efficiency.

Benefits of technology

It improves processing performance in high concurrency scenarios, reduces lock collisions and thread blocking, and improves the system's resource utilization efficiency and processing speed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112346834B_ABST
    Figure CN112346834B_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure relate to a method and device for processing database requests, an electronic device, and a computer-readable storage medium. The method comprises: receiving an operation request from a client; determining the priority of the operation request according to a preset rule, based on the operation request and the commit mode of the transaction to which the operation request belongs; adding the operation request to a task queue of a thread pool with a corresponding priority according to the priority of the operation request; and obtaining tasks from the task queue for processing according to the priority of the task queue. The method for processing database requests, the electronic device, and the medium of the embodiments of the present disclosure can automatically perform task priority division at the level of the operation request, which is beneficial to improving processing performance in high-concurrency scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and more specifically, to a method and device for processing database requests, an electronic device, and a medium. Background Art

[0002] As computer technology continues to develop, the technology related to threads that process computer running tasks is constantly breaking through and developing. Earlier, the default thread processing method of the database was one-thread-per-connection, that is, a thread was created for each connection to process all requests of this connection until the connection was disconnected. In high-concurrency scenarios, this method would generate too many threads, resulting in frequent context switching, and its performance would be significantly reduced. Nowadays, thread pools have become a common technology used in cloud database services. Thread pool technology is to create a certain number of threads in advance. When a request arrives, the thread pool allocates a thread to provide service. After the request ends, the thread goes to serve other requests. In this way, the frequent creation and release of threads and memory objects is avoided, and resource utilization efficiency is improved. However, in high-concurrency scenarios, thread blocking may still occur, resulting in reduced processing performance. Therefore, it is necessary to provide a database request processing solution that can guarantee the processing performance of the system. Summary of the invention

[0003] An object of the present disclosure is to provide a method and apparatus for processing database requests, an electronic device, and a medium.

[0004] According to a first aspect of an embodiment of the present disclosure, a method for processing a database request is provided, comprising:

[0005] Receive operation requests from clients;

[0006] Determining the priority of the operation request according to a preset rule and according to the operation request and the commit mode of the transaction to which the operation request belongs;

[0007] According to the priority of the operation request, the operation request is added to the task queue of the thread pool with the corresponding priority;

[0008] According to the priority of the task queue, tasks are obtained from the task queue for processing.

[0009] Optionally, determining the priority of the operation request according to a preset rule and according to the operation request and a commit mode of a transaction to which the operation request belongs includes:

[0010] If the commit mode of the transaction to which the operation request belongs is an explicit commit mode, determining that the priority of the operation request is a high priority;

[0011] If the commit mode of the transaction to which the operation request belongs is a non-explicit commit mode and the operation object of the operation request is a system library table, determining that the priority of the operation request is a high priority;

[0012] If the commit mode of the transaction to which the operation request belongs is a non-explicit commit mode and the operation request does not involve a change to a library table, it is determined that the priority of the operation request is a high priority.

[0013] Optionally, the method further comprises:

[0014] Receive connection requests from clients;

[0015] Determining whether the sending port of the connection request is a preset port;

[0016] In a case where the sending port of the connection request is a preset port, creating a working thread independent of the thread pool to provide services for the client sending the connection request;

[0017] In the case that the sending port of the connection request is not a preset port, a connection is established between the client sending the connection request and the thread pool.

[0018] Optionally, the method further comprises:

[0019] Get the total number of tasks in the thread pool;

[0020] When the total number of tasks in the thread pool is greater than or equal to a first threshold, a worker thread in a dormant state is awakened.

[0021] Optionally, the method further comprises:

[0022] Determining the number of clients connected to the thread pool;

[0023] When the number is greater than or equal to a second threshold, the working thread in the dormant state is awakened, and the second threshold is a preset multiple of the number of cores of the processor.

[0024] Optionally, the method further comprises:

[0025] When a connection request of a Dump thread is received, a dedicated working thread is created in a thread pool for the Dump thread, so as to process the operation request of the Dump thread through the dedicated working thread.

[0026] Optionally, the method further comprises:

[0027] Upon receiving a connection request from a Dump thread, detecting whether the total number of working threads in the thread pool is less than a third threshold;

[0028] When the total number of working threads in the thread pool is less than a third threshold, a dedicated working thread is created in the thread pool for the Dump thread, so as to process the operation request of the Dump thread through the dedicated working thread.

[0029] Optionally, the method further comprises:

[0030] The number of tasks in the thread pool, the awakening / sleeping state of the working threads, and the number of the working threads are monitored.

[0031] According to a second aspect of an embodiment of the present disclosure, there is provided a database request processing device, comprising:

[0032] A receiving module, used for receiving an operation request from a client;

[0033] A priority determination module, configured to determine the priority of the operation request according to a preset rule and based on the operation request and the commit mode of the transaction to which the operation request belongs;

[0034] A adding module, used for adding the operation request to the task queue of the thread pool according to the priority of the operation request;

[0035] The task processing module is used to obtain tasks from the task queue for processing according to the priority of the task queue.

[0036] According to a third aspect of an embodiment of the present disclosure, an electronic device is provided, including a processor and a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, any of the methods described above is implemented.

[0037] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which computer-readable instructions are stored, and when the computer-readable instructions are executed by a processor, any of the methods described above is implemented.

[0038] The database request processing method and device, electronic device and medium of the embodiments of the present disclosure are implemented based on thread pool technology, and can automatically prioritize tasks at the operation request level according to preset rules, which is beneficial to improving processing performance in high concurrency scenarios.

[0039] Other features and advantages of the present disclosure will become apparent from the following detailed description of exemplary embodiments of the present disclosure with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] The accompanying drawings, which are incorporated in and constitute a part of the specification, illustrate embodiments of the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0041] Figure 1 is a schematic diagram of an electronic device that can be used to implement an embodiment of the present disclosure.

[0042] Figure 2 It is a flowchart of a method for processing database requests provided by an embodiment of the present disclosure.

[0043] Figure 3 It is a schematic diagram of a database request processing method provided by an embodiment of the present disclosure.

[0044] Figure 4 It is an architectural diagram of the thread pool provided in an embodiment of the present disclosure.

[0045] Figure 5 The invention is a block diagram of a request processing device of a database that can be used to implement an embodiment of the present disclosure. DETAILED DESCRIPTION

[0046] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that the relative arrangement of components and steps, numerical expressions and numerical values ​​set forth in these embodiments do not limit the scope of the present disclosure unless otherwise specifically stated.

[0047] The following description of at least one exemplary embodiment is merely illustrative in nature and is in no way intended to limit the present disclosure, its application, or uses.

[0048] Technologies, methods, and equipment known to ordinary technicians in the relevant art may not be discussed in detail, but where appropriate, the technologies, methods, and equipment should be considered part of the specification.

[0049] In all examples shown and discussed herein, any specific values ​​should be interpreted as merely exemplary and not limiting. Therefore, other examples of the exemplary embodiments may have different values.

[0050] It should be noted that like reference numerals and letters refer to similar items in the following figures, and therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.

[0051] <Hardware Configuration>

[0052] Figure 1 The hardware configuration of an electronic device that can be used to implement an embodiment of the present disclosure is shown.

[0053] See also Figure 1, the electronic device 1000 includes a processor 1100, a memory 1200, an interface device 1300, a communication device 1400, a display device 1500 and an input device 1600. The processor 1100 may be, for example, a central processing unit CPU, a microcontroller unit MCU, etc. The memory 1200 may include, for example, a ROM (read-only memory), a RAM (random access memory), a non-volatile memory such as a hard disk, etc. The interface device 1300 may include, for example, a USB interface, a serial interface, etc. The communication device 1400 may be, for example, a wired network card or a wireless network card. The display device 1500 may be, for example, a liquid crystal display screen or a touch screen. The input device 1600 may include, for example, a touch screen, a keyboard, a mouse, a microphone, etc.

[0054] In the embodiments of the present disclosure, the memory 1200 of the electronic device 1000 is used to store instructions, which are used to control the processor 1100 to operate to support the method of implementing any embodiment of the present disclosure. Technicians can design instructions according to the scheme disclosed in the present disclosure. How instructions control the processor to operate is well known in the art, so it will not be described in detail here.

[0055] It should be understood by those skilled in the art that although Figure 1 , multiple devices of the electronic device 1000 are shown; however, the electronic device 1000 of the embodiment of the present disclosure may only involve some of the devices, for example, only the processor 1100, the memory 1200 and the communication device 1400.

[0056] In one embodiment, the electronic device 1000 is, for example, a server of a cloud computing system. In one embodiment, the electronic device 1000 is, for example, a server of a database, providing data services to users. The database may be, for example, a cloud database.

[0057] Figure 1 The hardware configuration shown is merely illustrative and is in no way intended to limit the present disclosure, its application, or uses.

[0058] <Method Example>

[0059] See also Figure 2 As shown, the database request processing method provided by the embodiment of the present disclosure is explained.

[0060] The request processing method of the embodiment of the present disclosure can be Figure 1 The electronic device shown is implemented, and the electronic device is, for example, a database server. For example, the request processing method of the embodiment of the present disclosure is specifically executed by a thread pool manager mounted on the database server.

[0061] The database request processing method provided by the embodiment of the present disclosure includes the following steps:

[0062] S202: Receive an operation request from the client.

[0063] S204: Determine the priority of the operation request according to a preset rule and the commit mode of the transaction to which the operation request belongs.

[0064] S206. Add the operation request to a task queue of a thread pool according to the priority of the operation request.

[0065] In one example, according to the priority of the operation request, the operation request is added to the task queue of the thread pool with the corresponding priority. That is, if the operation request is of high priority, the operation request is added to the task queue of high priority; if the operation request is of low priority, the operation request is added to the task queue of low priority.

[0066] S208. Obtain tasks from the task queue for processing according to the priority of the task queue.

[0067] See also Figure 3 As shown, in one example, after the connection between the client and the thread pool is established, the thread pool manager receives the client's operation request, and according to preset rules, determines the priority of the operation request based on the operation request and the commit mode of the transaction to which the operation request belongs, so that the thread pool can process the operation request according to the priority of the operation request.

[0068] In the embodiment of the present disclosure, automatic priority division can be performed according to preset rules at the fine-grained level of operation request. By using this method, the level of tasks can be divided more flexibly and quickly.

[0069] In a database system, a transaction is an indivisible unit of work. A database transaction is a sequence of database operation requests that access and possibly operate various data items. The operation requests in the sequence are either all executed or none of them are executed.

[0070] In the database, transaction modes include explicit commit mode, implicit commit mode, and auto-commit mode. Explicit commit mode: The transaction is started by explicitly opening a transaction with a specified transaction start statement, and ends with a commit command or a rollback command to commit or rollback the transaction. Implicit commit mode: There is no need to use a specified transaction start statement to open a transaction, and the transaction is ended with a commit command or a rollback command to commit or rollback the transaction. Auto-commit mode: Each separate SQL (Structured Query Language, a database language with multiple functions such as data manipulation and data definition) statement automatically commits the transaction after it is executed, that is, the commit operation will be automatically and implicitly executed immediately after the SQL statement is executed. If an error occurs, the transaction is rolled back to the previous state.

[0071] In step S206, according to a preset rule, the priority of the operation request is determined according to the operation request and the commit mode of the transaction to which the operation request belongs, including:

[0072] Rule a: If the commit mode of the transaction to which the operation request belongs is the explicit commit mode, determine that the priority of the operation request is a high priority.

[0073] When the commit mode of the transaction to which the operation request belongs is the explicit commit mode, if the SQL statement of the operation request involves modifying the data in the library table, the data will be locked, and the data will not be released until the commit command (commit) or the rollback command (rollback) is executed. During the row lock period, if the SQL statement of a non-explicitly committed (i.e., implicit commit mode or automatic commit mode) transaction also involves modifying the same data, there is a lock conflict and it is necessary to wait. When the commit mode of the transaction to which the operation request belongs is the explicit commit mode, it can be treated as a high-priority task and processed first, which is conducive to reducing lock conflicts.

[0074] Rule b: If the commit mode of the transaction to which the operation request belongs is a non-explicit commit mode and the operation object of the operation request is a system library table, determine that the priority of the operation request is a high priority.

[0075] In the database, the library tables include custom library tables and system library tables. The operation on the system library table is mainly for management personnel to query data. The system library table data can be directly obtained from the cache, and the processing time is short. It can be processed as a high-priority task to quickly complete the operation request, reduce the number of tasks in the thread pool, and improve the processing performance in high-concurrency scenarios.

[0076] Rule c: If the commit mode of the transaction to which the operation request belongs is a non-explicit commit mode and the operation request does not involve a change to a library table, determine that the priority of the operation request is a high priority.

[0077] If the commit mode of the transaction to which the operation request belongs is a non-explicit commit mode and the operation request does not involve changes to the library table, the operation request is a cache operation and the processing time is short. It can be processed as a high-priority task to quickly complete the operation request, reduce the number of tasks in the thread pool, and improve processing performance in high-concurrency scenarios.

[0078] In one example, according to a preset rule, determining the priority of the operation request according to the operation request and the commit mode of the transaction to which the operation request belongs, further includes:

[0079] Rule d: If an operation request is not determined as a high priority after passing through rules ac, the priority of the operation request is determined to be a low priority. That is, except for the high priority cases mentioned in rules ac, the operation requests in other cases are determined to be low priorities.

[0080] In the embodiments of the present disclosure, the priority of the operation request is determined according to the statement type and submission mode of the operation request in accordance with preset rules (such as rule ad). This allows for a more flexible and rapid automatic division of task levels at the fine-grained level of the operation request, which is beneficial to improving processing performance in high-concurrency scenarios.

[0081] In one example, the method may further include the following steps:

[0082] S302: Receive a connection request from a client.

[0083] S304: Determine whether the sending port of the connection request is a preset port.

[0084] S306: When the sending port of the connection request is a preset port, create a working thread independent of the thread pool to provide services for the client that sends the connection request.

[0085] S308: When the sending port of the connection request is not a preset port, establish a connection between the client sending the connection request and the thread pool.

[0086] According to steps S302-S308, when a connection request from a client is received, it is identified whether the connection request is sent through a preset port. If so, a worker thread independent of the thread pool is created to provide services for the connection. If not, the thread pool provides services for the connection.

[0087] If the administrator logs in to the database through an administrator account or a specific address, his task still follows the thread pool logic. When the thread pool is in a blocked state, the administrator's instructions may not be executed in time. In this example, a specific port is pre-set and reserved for the use of database administrators; when the database system receives a connection request, if it is recognized that the connection request is sent through the preset specific port, a worker thread independent of the thread pool is created to provide services for the client that sent the connection request, that is, the connection request sent through the preset port is processed using the one-thread-per-connection method, so that the administrator's instructions are not affected by the thread pool blocking and can be processed in time.

[0088] In one example, the number of connections allowed to be established through the preset port is upper bounded, that is, only connections within a preset number range are allowed to be established through the preset port, so as to avoid excessive pressure on the database and ensure the robustness of the system.

[0089] See also Figure 4 As shown, the connection pool is divided into N thread groups (Group), usually N defaults to the number of processors, and connections are allocated between the N thread groups by a polling scheduling algorithm. The thread pool also includes a timer thread (Timer thread).

[0090] Each thread group includes a high-priority task queue and a low-priority task queue, a listener thread and multiple worker threads. Multiple worker threads process connections in a competitive manner within the group. A worker thread belongs to only one thread group.

[0091] Timer thread: It is used to periodically check whether the threads in the thread group are in a blocked state. If a blocked state is detected, it will wake up the dormant thread or create a new worker thread.

[0092] Listener thread: Each thread group has a dynamic listener thread, which listens to tasks through epoll and puts the listened tasks into the task queue of the group. epoll is an I / O (input / output) event notification mechanism and an implementation of I / O multiplexing by the system kernel.

[0093] Worker thread: used to obtain tasks in the task queue and then process them.

[0094] The identities of the listening thread and the working thread are not fixed, but will be switched dynamically according to the current state of the group. In actual applications, after listening to a task, the listening thread may choose to handle the task itself. In this case, the listening thread switches itself to a working thread to handle the task. Switching the listening thread to a working thread will reduce resource consumption and processing performance will decrease. When a connection request is obtained, if there is no listening thread in the group, a working thread in the group will be converted to a listening thread.

[0095] The high-priority task queue and the low-priority task queue are used to store pending tasks. Within a group, tasks in the high-priority task queue are executed first, that is, when there are tasks in both the high-priority task queue and the low-priority queue, the tasks in the high-priority queue are processed first. After the tasks in the high-priority queue are processed and cleared, the tasks in the low-priority task queue are processed.

[0096] In one example, the method may further include the following steps:

[0097] S402: Get the total number of tasks in the thread pool.

[0098] S404: When the total number of tasks in the thread pool is greater than or equal to a first threshold, wake up the worker thread in a dormant state.

[0099] For example, the first threshold is 2, that is, when the total number of tasks in the thread pool is greater than 2, the worker thread in the dormant state is awakened.

[0100] In the above example, when the total number of tasks in the thread pool is less than the first threshold, that is, the number of tasks in the thread pool is relatively small, the listening thread can switch itself to a worker thread to process tasks to reduce the consumption of system resources. When the total number of tasks in the thread pool is greater than or equal to the first threshold, that is, the number of tasks in the thread pool is relatively large, the dormant worker thread is awakened to improve processing performance by consuming more resources, which is conducive to reducing performance degradation in low concurrency scenarios.

[0101] In one example, the method may further include the following steps:

[0102] S502: Determine the number of clients connected to the thread pool.

[0103] S504: When the number of clients connected to the thread pool is greater than or equal to a second threshold, wake up the worker thread in a dormant state, where the second threshold is a preset multiple of the number of cores of the processor.

[0104] For example, the second threshold is twice the number of cores of the processor. When the number of clients connected to the thread pool is greater than or equal to twice the number of cores of the processor, the worker thread in the dormant state is awakened.

[0105] In the above example, when the number of clients connected to the thread pool is less than the second threshold, that is, the number of tasks in the thread pool is relatively small, the listening thread can switch itself to a worker thread to process tasks to reduce the consumption of system resources. When the number of clients connected to the thread pool is greater than or equal to the second threshold, that is, the number of tasks in the thread pool is relatively large, the dormant worker thread is awakened to improve processing performance by consuming more resources, which is conducive to reducing performance degradation in low-concurrency scenarios.

[0106] In one example, the method may further include the following steps:

[0107] S602: Determine the number of clients connected to the thread pool, and obtain the total number of tasks in the thread pool.

[0108] S604: If any one of the following two wake-up conditions is met, wake up the working thread in the dormant state.

[0109] The first wake-up condition is: the total number of tasks in the thread pool is greater than or equal to the first threshold.

[0110] The second wake-up condition is: the number of clients connected to the thread pool is greater than or equal to the second threshold.

[0111] It has been measured that in this way, the processing performance degradation in low concurrency scenarios is less than 5%.

[0112] In one example, the method further comprises the following steps:

[0113] S702: When receiving a connection request from a Dump thread, create a dedicated working thread in a thread pool for the Dump thread, so as to process the operation request of the Dump thread through the dedicated working thread.

[0114] The Dump thread is a transaction thread within the database, used to implement master-slave synchronization related functions. After the master-slave synchronization is enabled, the system automatically creates a Dump thread for implementing master-slave synchronization. When the Dump thread processes a long transaction scenario or multiple Dump threads are assigned to the same group, other tasks in the group will not be processed in time, resulting in a decrease in overall processing performance.

[0115] In this embodiment, a dedicated working thread is created in the thread pool for the Dump thread, and other working threads are not occupied, thereby preventing the working threads in the thread pool from being occupied by the Dump thread for a long time, resulting in the inability to perform normal business.

[0116] In one example, the method further comprises the following steps:

[0117] S802: When receiving a connection request from a Dump thread, detect whether the total number of working threads in the thread pool is less than a third threshold.

[0118] S804: When the total number of working threads in the thread pool is less than the third threshold, create a dedicated working thread in the thread pool for the Dump thread to process the operation request of the Dump thread through the dedicated working thread.

[0119] The Dump thread is a transaction thread within the database, used to implement master-slave synchronization related functions. After the master-slave synchronization is enabled, the system automatically creates a Dump thread for implementing master-slave synchronization. When the Dump thread processes a long transaction scenario or multiple Dump threads are assigned to the same group, other tasks in the group will not be processed in time, resulting in a decrease in overall processing performance.

[0120] In this example, while ensuring that the total number of threads in the thread pool does not exceed the third threshold, the Dump thread creates a dedicated worker thread in the thread pool and does not occupy other worker threads, thereby avoiding the worker threads in the thread pool being occupied for a long time by the Dump thread, resulting in the inability to conduct normal business.

[0121] In this example, if the total number of worker threads in the thread pool is equal to the third threshold, the existing worker threads in the thread pool provide services for the Dump thread, that is, the existing worker threads in the thread pool handle the operation requests of the Dump thread to avoid blocking due to excessive number of worker threads in the thread pool.

[0122] In one example, the method further comprises the following steps:

[0123] S902: Monitor the number of tasks in the thread pool, the wake-up / sleep status of the working threads, and the number of the working threads.

[0124] In one example, the number of tasks in each thread group, the wake-up / sleep state of the working threads, and the number of the working threads may be monitored separately.

[0125] In this example, the monitoring level of the thread pool is increased to the group level, and the number and status of threads and the number of tasks in each group are monitored respectively, which improves the monitoring function and facilitates the development, maintenance and management of the database.

[0126] <Device and Equipment Embodiment>

[0127] See also Figure 5 As shown, the embodiment of the present disclosure also provides a database request processing device. The device 10 includes the following modules:

[0128] The first receiving module 11 is used to receive an operation request from a client.

[0129] The priority determination module 12 is used to determine the priority of the operation request according to a preset rule, based on the operation request and the commit mode of the transaction to which the operation request belongs.

[0130] The adding module 13 is used to add the operation request to the task queue of the thread pool according to the priority of the operation request.

[0131] The task processing module 14 is used to obtain tasks from the task queue for processing according to the priority of the task queue.

[0132] The determining the priority of the operation request according to a preset rule and according to the operation request and a commit mode of a transaction to which the operation request belongs includes:

[0133] If the commit mode of the transaction to which the operation request belongs is an explicit commit mode, determining that the priority of the operation request is a high priority;

[0134] If the commit mode of the transaction to which the operation request belongs is a non-explicit commit mode and the operation object of the operation request is a system library table, determining that the priority of the operation request is a high priority;

[0135] If the commit mode of the transaction to which the operation request belongs is a non-explicit commit mode and the operation request does not involve a change to a library table, it is determined that the priority of the operation request is a high priority.

[0136] In one example, the device 10 further includes the following modules:

[0137] The second receiving module is used to receive a connection request from a client.

[0138] The port determination module is used to determine whether the sending port of the connection request is a preset port.

[0139] A connection request processing module is used to create a working thread independent of the thread pool to provide services for the client sending the connection request when the sending port of the connection request is a preset port; and to establish a connection between the client sending the connection request and the thread pool when the sending port of the connection request is not a preset port.

[0140] In one example, the device 10 further includes a first wake-up module.

[0141] The first wake-up module is used to obtain the total number of tasks in the thread pool; when the total number of tasks in the thread pool is greater than or equal to a first threshold, wake up the working thread in a dormant state.

[0142] In one example, the device 10 further includes a second wake-up module.

[0143] The second wake-up module is used to determine the number of clients connected to the thread pool; when the number is greater than or equal to a second threshold, wake up the working thread in a dormant state, and the second threshold is a preset multiple of the number of cores of the processor.

[0144] In one example, the device 10 further includes a first Dump thread processing module.

[0145] The first Dump thread processing module is used to create a dedicated working thread in a thread pool for the Dump thread when receiving a connection request from the Dump thread, so as to process the operation request of the Dump thread through the dedicated working thread.

[0146] In one example, the device 10 further includes a second Dump thread processing module.

[0147] When receiving a connection request from a dump thread, the second dump thread processing module detects whether the total number of working threads in the thread pool is less than a third threshold; when the total number of working threads in the thread pool is less than the third threshold, a dedicated working thread is created in the thread pool for the dump thread to process the operation request of the dump thread through the dedicated working thread.

[0148] In one example, the device 10 further includes a monitoring module.

[0149] The monitoring module is used to monitor the number of tasks in the thread pool, the wake-up / sleep status of the working threads, and the number of the working threads.

[0150] An embodiment of the present disclosure also provides an electronic device, which includes the aforementioned thread pool manager.

[0151] The embodiment of the present disclosure also provides an electronic device, which includes the aforementioned request processing device.

[0152] An embodiment of the present disclosure further provides an electronic device, including a processor and a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the method disclosed in any of the aforementioned embodiments is implemented.

[0153] The electronic device mentioned above may be a server of a database.

[0154] <Computer Readable Storage Medium Embodiment>

[0155] An embodiment of the present disclosure further provides a computer-readable storage medium on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor, the method disclosed in any of the aforementioned embodiments is implemented.

[0156] The present disclosure may be a method, an apparatus, an electronic device, a system, and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.

[0157] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.

[0158] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.

[0159] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed entirely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.

[0160] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.

[0161] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0162] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0163] The flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the systems, methods and computer program products according to multiple embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of an instruction, and a part of a module, a program segment or an instruction contains one or more executable instructions for realizing the specified logical function. In some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of the boxes in the block diagram and / or the flowchart can be implemented by a dedicated hardware-based system that performs the specified function or action, or can be implemented by a combination of dedicated hardware and computer instructions. It is well known to those skilled in the art that it is equivalent to implement it by hardware, implement it by software, and implement it by combining software and hardware.

[0164] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The choice of terms used herein is intended to best explain the principles of the embodiments, practical applications, or technical improvements in the marketplace, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein. The scope of the present disclosure is defined by the appended claims.

Claims

1. A method for processing a database request, characterized in that: include: Receive operation requests from clients; Determining the priority of the operation request according to a preset rule and according to the operation request and the commit mode of the transaction to which the operation request belongs; According to the priority of the operation request, the operation request is added to the task queue of the thread pool; According to the priority of the task queue, obtain the task from the task queue for processing; The step of determining the priority of the operation request according to a preset rule and based on the operation request and a commit mode of a transaction to which the operation request belongs includes: If the commit mode of the transaction to which the operation request belongs is an explicit commit mode, determining that the priority of the operation request is a high priority; If the commit mode of the transaction to which the operation request belongs is a non-explicit commit mode and the operation object of the operation request is a system library table, determining that the priority of the operation request is a high priority; If the commit mode of the transaction to which the operation request belongs is a non-explicit commit mode and the operation request does not involve a change to a library table, it is determined that the priority of the operation request is a high priority.

2. The method according to claim 1, characterized in that Also includes: Receive connection requests from clients; Determining whether the sending port of the connection request is a preset port; In a case where the sending port of the connection request is a preset port, creating a working thread independent of the thread pool to provide services for the client sending the connection request; In the case that the sending port of the connection request is not a preset port, a connection is established between the client sending the connection request and the thread pool.

3. The method according to claim 1, characterized in that Also includes: Get the total number of tasks in the thread pool; When the total number of tasks in the thread pool is greater than or equal to a first threshold, a worker thread in a dormant state is awakened.

4. The method according to claim 1, characterized in that: Also includes: Determining the number of clients connected to the thread pool; When the number is greater than or equal to a second threshold, the working thread in the dormant state is awakened, and the second threshold is a preset multiple of the number of cores of the processor.

5. The method according to claim 1, characterized in that Also includes: When a connection request of a Dump thread is received, a dedicated working thread is created in a thread pool for the Dump thread, so as to process the operation request of the Dump thread through the dedicated working thread.

6. The method according to claim 1, characterized in that Also includes: Upon receiving a connection request from a Dump thread, detecting whether the total number of working threads in the thread pool is less than a third threshold; When the total number of working threads in the thread pool is less than a third threshold, a dedicated working thread is created in the thread pool for the Dump thread, so as to process the operation request of the Dump thread through the dedicated working thread.

7. The method according to claim 1, characterized in that Also includes: The number of tasks in the thread pool, the awakening / sleeping state of the working threads, and the number of the working threads are monitored.

8. A database request processing device, characterized in that: include: A receiving module, used for receiving an operation request from a client; A priority determination module, configured to determine the priority of the operation request according to a preset rule and based on the operation request and the commit mode of the transaction to which the operation request belongs; A adding module, used for adding the operation request to the task queue of the thread pool according to the priority of the operation request; A task processing module, used to obtain tasks from the task queue for processing according to the priority of the task queue; The step of determining the priority of the operation request according to a preset rule and based on the operation request and a commit mode of a transaction to which the operation request belongs includes: If the commit mode of the transaction to which the operation request belongs is an explicit commit mode, determining that the priority of the operation request is a high priority; If the commit mode of the transaction to which the operation request belongs is a non-explicit commit mode and the operation object of the operation request is a system library table, determining that the priority of the operation request is a high priority; If the commit mode of the transaction to which the operation request belongs is a non-explicit commit mode and the operation request does not involve a change to a library table, it is determined that the priority of the operation request is a high priority.

9. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the method according to any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, characterized in that: Computer-readable instructions are stored thereon, and when the computer-readable instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.