Database backup processing method and device, storage medium and computer equipment
By sending active session query requests to the database and sending backup requests when the business execution thread is closed, the problem of backup failure caused by long SQL active sessions is solved, thus improving database backup efficiency.
Patent Information
- Application Number
- CN202410725735.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-05
- Publication Date
- 2024-08-30
AI Technical Summary
In existing technologies, threads in long-running SQL active sessions cause MyISAM data table backups to fail, severely reducing database backup efficiency.
By sending an active session query request to the database, session information is obtained and the session business identifier is determined. The execution business thread is invoked and a database backup request is sent when it is detected to be closed. A session duration threshold is configured to identify active sessions, and the thread status is checked after the release time to ensure that the backup is successful.
It enables the handling of long SQL active sessions before database backup, reducing the probability of backup failure and improving the overall efficiency of database backup.
Smart Images

Figure CN118567910A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of database processing, and in particular to a database backup processing method and device, storage medium, and computer equipment. Background Art
[0002] Database backup is an essential operation in the daily operation and maintenance of MySQL database. Commonly used backup tools include mysqldump, mydumper, xtrabackup, etc.
[0003] In the prior art, when using the xtrabackup tool to back up the MyISAM data table in the MySQL database, a command to read the global lock is first executed to ensure data consistency. However, since database backup is generally initiated in the standby database in the MySQL master-standby environment, the long SQL active session in the standby database often causes the failure to obtain the global lock during the MyISAM data table backup process, thereby causing the backup of the MyISAM data table to fail. When the thread of the long SQL active session is not released, the MyISAM data table will not be successfully backed up, which seriously reduces the backup efficiency of the database. Summary of the invention
[0004] In view of this, the present invention provides a method and apparatus for processing database backup, a storage medium, and a computer device, the main purpose of which is to solve the problem of low database backup efficiency caused by threads of long SQL active sessions in the prior art.
[0005] According to one aspect of the present invention, a method for processing database backup is provided, comprising:
[0006] Sending an active session query request to a database, so that the database queries active sessions based on the active session query request;
[0007] receiving active session information sent by the database, and determining a corresponding session service identifier based on the active session information;
[0008] The execution service thread corresponding to the session service identifier is retrieved, and when it is detected that the execution service thread is closed, a database backup request is sent to the database.
[0009] Furthermore, before sending the active session query request to the database, the method further includes:
[0010] Configuring a corresponding session duration threshold for the session service;
[0011] When it is detected that the session duration corresponding to the session service and the session in the database is greater than the session duration threshold, the session is determined as an active session.
[0012] Further, configuring a corresponding session duration threshold for the session service includes:
[0013] Acquire a session record of the session service, and determine all historical session durations of the session service from the session record;
[0014] Calculating an average value of the historical session durations, and determining the average value as the session duration threshold that matches the session service; or,
[0015] Calculating the median of the historical session durations, and determining the median as the session duration threshold that matches the session service; or,
[0016] The mode of the historical session durations is calculated, and the mode is determined as the session duration threshold that matches the session service.
[0017] Further, the active session information includes a session link between the session service and the database;
[0018] The determining the corresponding session service identifier based on the active session information includes:
[0019] Performing word segmentation processing on the session link to obtain multiple word segmentation fields;
[0020] Perform text recognition processing on the word segmentation field to obtain the session service identifier.
[0021] Furthermore, when it is detected that the execution service thread is closed, before sending a database backup request to the database, the method further includes:
[0022] Closing the execution service thread and starting a timer for timing;
[0023] When the timing time is greater than the set release time, the execution state of the execution service thread is detected, and the execution state includes a closed state and a running state.
[0024] Furthermore, after closing the execution service thread, the method further includes:
[0025] Detecting the running status of the session service;
[0026] When the running state is an abnormal state, the session duration threshold corresponding to the session service is updated.
[0027] Furthermore, the method further comprises:
[0028] Detecting the execution status of the execution service thread;
[0029] When it is detected that at least one of the execution service threads is in a running state, an alarm message is sent to the user.
[0030] According to another aspect of the present invention, there is provided a database backup processing device, comprising:
[0031] A query module, configured to send an active session query request to a database, so that the database queries active sessions based on the active session query request;
[0032] A determination module, configured to receive active session information sent by the database, and determine a corresponding session service identifier based on the active session information;
[0033] The detection and sending module is used to call the execution service thread corresponding to the session service identifier, and when it is detected that the execution service thread is closed, send a database backup request to the database.
[0034] Furthermore, the device also includes a configuration and judgment module, which is used to:
[0035] Configuring a corresponding session duration threshold for the session service;
[0036] When it is detected that the session duration corresponding to the session service and the session in the database is greater than the session duration threshold, the session is determined as an active session.
[0037] Furthermore, the configuration and judgment module includes:
[0038] A historical data extraction unit, used to obtain a session record of the session service, and determine all historical session durations of the session service from the session record;
[0039] a calculating unit, configured to calculate an average value of the historical session durations, and determine the average value as the session duration threshold matching the session service; or,
[0040] Calculating the median of the historical session durations, and determining the median as the session duration threshold that matches the session service; or,
[0041] The mode of the historical session durations is calculated, and the mode is determined as the session duration threshold that matches the session service.
[0042] Furthermore, the determining module is also used for:
[0043] Performing word segmentation processing on the session link to obtain multiple word segmentation fields;
[0044] Perform text recognition processing on the word segmentation field to obtain the session service identifier.
[0045] Furthermore, the device also includes a thread state detection module, which is used to:
[0046] Closing the execution service thread and starting a timer for timing;
[0047] When the timing time is greater than the set release time, the execution state of the execution service thread is detected, and the execution state includes a closed state and a running state.
[0048] Furthermore, the device also includes a detection and update module, which is used to:
[0049] Detecting the running status of the session service;
[0050] When the running state is an abnormal state, the session duration threshold corresponding to the session service is updated.
[0051] Furthermore, the device also includes an alarm module, which is used to:
[0052] Detecting the execution status of the execution service thread;
[0053] When it is detected that at least one of the execution service threads is in a running state, an alarm message is sent to the user.
[0054] According to another aspect of the present invention, a storage medium is provided, wherein at least one executable instruction is stored in the storage medium, and the executable instruction enables a processor to execute operations corresponding to the control method of the cooking device as described above.
[0055] According to another aspect of the present invention, there is provided a computer device, comprising a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus;
[0056] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute operations corresponding to the above-mentioned database backup processing method.
[0057] By means of the above technical solution, the technical solution provided by the embodiment of the present invention has at least the following advantages:
[0058] The present invention provides a method and device for processing database backup, a storage medium, and a computer device. Compared with the prior art, the present invention sends an active session query request to a database so that the database queries the active session based on the active session query request; receives the active session information sent by the database, and determines the corresponding session service identifier based on the active session information; calls the execution service thread corresponding to the session service identifier, and sends a database backup request to the database when it is detected that the execution service thread is closed, thereby realizing the processing of long SQL active sessions before database backup, so that when the database is backed up, the global lock can be quickly obtained, the probability of database backup failure is reduced, and the overall efficiency of database backup is improved.
[0059] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0061] Figure 1 A schematic diagram showing a process flow of a database backup processing method provided by an embodiment of the present invention;
[0062] Figure 2 A schematic flow chart of another method for processing database backup provided by an embodiment of the present invention is shown;
[0063] Figure 3 A schematic flow chart of another method for processing database backup provided by an embodiment of the present invention is shown;
[0064] Figure 4 A schematic flow chart of another method for processing database backup provided by an embodiment of the present invention is shown;
[0065] Figure 5 A schematic diagram showing the structure of a database backup processing device provided by an embodiment of the present invention;
[0066] Figure 6 A schematic structural diagram of a computer device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION
[0067] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided to enable a more thorough understanding of the present disclosure and to fully convey the scope of the present disclosure to those skilled in the art.
[0068] The embodiment of the present invention provides a method for processing database backup, such as Figure 1 As shown, the method includes:
[0069] 101. Send an active session query request to a database, so that the database queries active sessions based on the active session query request;
[0070] In an embodiment of the present invention, the current execution end sends an active session query request to the database, so that the database performs an active session query based on the active session query request sent by the current execution end. Among them, the active session is used to characterize the communication interaction between the session service and the database, including the interaction of the session service in the database, such as read and write operations, etc., which is not specifically limited in the embodiment of the present invention. The session service is used to characterize the service that needs to communicate and interact with the database and manage business data through the database, such as transaction services, logistics services, financial services, etc., which is not specifically limited in the embodiment of the present invention.
[0071] 102. Receive active session information sent by the database, and determine a corresponding session service identifier based on the active session information;
[0072] In an embodiment of the present invention, the current execution end receives active session information sent by the database, and the active session information includes a session link between the session service and the database. The current execution end determines the corresponding session service identifier based on the active session information. Among them, the session link is used to represent the link for communication interaction established before the communication interaction between the database and the session service. Among them, the session service identifier is used to represent the identifier representing the unique identity information of the session service in the link, such as the serial code of the session service, the account number of the session service, etc., which is not specifically limited in the embodiment of the present invention. The session service identifier may include one or more of numbers, letters, and symbols, such as "013789", "*013789", "*013B789", etc., which is not specifically limited in the embodiment of the present invention.
[0073] It should be noted that when the current execution end determines the corresponding session service identifier based on the active session information, it is necessary to perform word segmentation processing on the session link to obtain multiple word segmentation fields. The word segmentation fields are subjected to text recognition processing to obtain the session service identifier. For example, the text processing tool awk is used to intercept commands, and the IDs corresponding to all active sessions are intercepted, and the intercepted IDs are used as the session service identifiers of the active sessions. The embodiments of the present invention do not make specific limitations.
[0074] 103. Retrieve an execution service thread corresponding to the session service identifier, and when it is detected that the execution service thread is closed, send a database backup request to the database.
[0075] In the implementation of the present invention, the current execution end calls the execution service thread corresponding to the session service identifier, and the execution service thread is used to characterize the control flow of a task in the execution session service. The current execution end detects the execution state of the execution service thread of the active session corresponding to the session service identifier, and the execution state includes a closed state and a running state. If the current execution end detects that the execution state of the execution service thread is a closed state, a database backup request is sent to the database; if the current execution end detects that the execution state of the execution service thread is a running state, a database backup request is not sent to the database, thereby avoiding the failure of obtaining the global lock during the backup process due to the active session, thereby reducing the probability of database backup failure and improving the efficiency of database backup.
[0076] Further, as a refinement and extension of the specific implementation of the above embodiment, in order not to affect the normal operation of the front-end session service, the determination of the active session service is further limited, and another database backup processing method is provided, such as Figure 2 As shown, before the step of sending the active session query request to the database, the method further includes:
[0077] 201. Configure a corresponding session duration threshold for the session service;
[0078] In an embodiment of the present invention, the current execution end configures a corresponding session duration threshold for the session service. The session duration threshold is used to characterize the limit value of the session duration corresponding to the session service and the session of the database, and the active session is identified by the limit value. For example, the current execution end configures a session duration threshold of 5 minutes for session service A, a session duration threshold of 10 minutes for session service B, and a session duration threshold of 20 minutes for session service C, etc., which is not specifically limited in the embodiment of the present invention. The configuration of the session duration threshold can be manually configured according to experience or demand, or can be configured by analyzing and calculating historical data, etc., which is not specifically limited in the embodiment of the present invention.
[0079] It should be noted that the session duration threshold corresponding to each session service can be configured in the form of a session duration configuration table. When the session duration threshold is needed to judge the active session later, the session duration threshold corresponding to each session service can be obtained by querying the session duration configuration table and then judged, which is not specifically limited in the embodiment of the present invention.
[0080] 202. When it is detected that the session duration corresponding to the session service and the session in the database is greater than the session duration threshold, determine the session as an active session.
[0081] In an embodiment of the present invention, the current execution end detects the session duration corresponding to the session between the session service and the database. When it is detected that the session duration is greater than the session duration threshold, the session is determined to be an active session; when it is detected that the session duration is not greater than the session duration threshold, the session is determined to be an inactive session. For example, the session duration threshold configured by the current execution end for session service A is 5 minutes. When it is detected that the session duration of session A* between session service A and the database is greater than 5 minutes, the corresponding session A* is determined to be an active session, etc. The embodiment of the present invention does not make specific limitations. After the active session is determined by the method in this embodiment, only the thread corresponding to the active session is closed later, and the threads of the remaining sessions are not affected, so it will not affect the normal operation of the front-end business.
[0082] Further, as a refinement and extension of the specific implementation of the above embodiment, in order to more accurately determine the session duration threshold corresponding to each session service without affecting the normal operation of each session service at the front end, another database backup processing method is provided, such as Figure 3 As shown, the steps for configuring the session duration threshold corresponding to the session service include:
[0083] 301. Acquire a session record of the session service, and determine all historical session durations of the session service from the session record;
[0084] In the embodiment of the present invention, the current execution end obtains the session record of the session service, and determines all the historical session durations of the session service from the session record. The session record includes the start time and end time of the session between the session service and the database. By obtaining the start time and end time of a session between the session service and the database, the historical session duration of the session is determined. The same method is used to determine the historical session durations of all historical sessions between the session service and the database, and obtain all the historical session durations.
[0085] 302a. Calculate an average value of the historical session durations, and determine the average value as the session duration threshold that matches the session service; or,
[0086] 302b. Calculate the median of the historical session durations, and determine the median as the session duration threshold that matches the session service; or,
[0087] 302c: Calculate the mode of the historical session durations, and determine the mode as the session duration threshold that matches the session service.
[0088] In an embodiment of the present invention, the current execution end calculates the average value of historical session durations and determines the calculated average value as the session duration threshold that matches the session service; or, calculates the median of historical session durations and determines the calculated median as the session duration threshold that matches the session service; or, calculates the mode of historical session durations and determines the calculated mode as the session duration threshold that matches the session service. For example, the current execution end processes the session record of the session service D, and obtains all historical session durations of the session service D, including: 4.7 minutes, 5.5 minutes, 6 minutes, 4.5 minutes, 5.2 minutes, 4.6 minutes, 3.9 minutes, 4.8 minutes, 3.7 minutes, 4.7 minutes, 5.5 minutes, 4.9 minutes, 5 minutes, 4.3 minutes, 4.7 minutes, 3.8 minutes, 4.9 minutes, 5 minutes, and 5.1 minutes. The average value of the historical session durations of the session service D is 4.8 minutes, the median of the historical session durations of the session service D is 4.8 minutes, and the mode of the historical session durations of the session service D is 4.7 minutes. The current execution end can select any one value from the average value of 4.8 minutes, the median of 4.8 minutes, and the mode of 4.7 minutes as the session duration threshold matching the session service D, which is not specifically limited in this embodiment of the present invention.
[0089] It should be noted that the session duration threshold may also be a weighted average value obtained by weighting the average value, the median value, and the mode value, which is not specifically limited in the embodiment of the present invention.
[0090] Further, as a refinement and extension of the specific implementation of the above embodiment, in order to enable the database to fully release session resources, another database backup processing method is provided, such as Figure 4 As shown in step 1, when it is detected that the execution service thread is closed, before sending a database backup request to the database, the method further includes:
[0091] 401. Close the execution service thread and start a timer for timing;
[0092] 402. When the timing time is greater than the set release time, detect the execution state of the execution service thread.
[0093] In an embodiment of the present invention, the current execution end closes the execution business thread of the active session and starts a timer for timing. When the timing time of the timer is greater than the set release time, the current execution end detects the execution state of the execution business thread, and the execution state includes a closed state and a running state. Among them, the release time is used to characterize the time required for the database to release session resources after the execution business thread is closed. The release time can be preset manually, such as set to 3 seconds, 5 seconds, etc., and the embodiment of the present invention does not make specific limitations. The current execution end detects the execution state of the execution business thread after the set release time in order to allow the database to release session resources more fully after closing the execution business thread.
[0094] Further, as a refinement and extension of the specific implementation of the above embodiment, in order to further ensure the normal operation of the front-end session service after closing the execution service thread of the active session, so that the configured session duration threshold can timely adapt to the changing session duration requirements of the front-end session service, another database backup processing method is provided, and the method also includes:
[0095] Detecting the running status of the session service;
[0096] When the running state is an abnormal state, the session duration threshold corresponding to the session service is updated.
[0097] In an embodiment of the present invention, the current execution end detects the running state of the session service, and the running state of the session service includes an abnormal state and a normal state, etc., which are not specifically limited in the embodiment of the present invention. If the current execution end detects that the running state of the session service is a normal state, it means that the interaction between the session service and the database is normal, and there is no need to adjust the session duration threshold configured for the session service; if the current execution end detects that the running state of the session service is an abnormal state, it means that the interaction between the session service and the database is abnormal, and it is necessary to adjust the session duration threshold configured for the session service. For example, the session duration threshold of 10 minutes corresponding to the session service E is too small, resulting in the thread of the non-long SQL active session being closed in advance, affecting the normal operation of the session service. At this time, it is necessary to adjust the session duration threshold corresponding to the session service E from 10 minutes to 11 minutes, 12 minutes, etc., that is, to increase the session duration threshold. The current execution end updates the adjusted session duration threshold to the session duration configuration table, corresponding to the session service.
[0098] Further, as a refinement and extension of the specific implementation of the above embodiment, in order to further improve the backup success rate after the database backup request is issued, another database backup processing method is provided by processing the execution service thread in the running state through the method of alarm and manual intervention, and the method also includes:
[0099] Detecting the execution status of the execution service thread;
[0100] When it is detected that at least one of the execution service threads is in a running state, an alarm message is sent to the user.
[0101] In the embodiment of the present invention, the current execution end also needs to detect the execution status of each execution service thread, and the execution status includes a closed state and a running state. When it is detected that at least one execution service thread is in a running state, the current execution end sends an alarm message to the user, and the user is a management user in the session service; the alarm message is used to indicate that the execution service thread corresponding to the session service has not been fully closed. After receiving the alarm message, the management user can manually close the execution service thread in the running state through manual intervention.
[0102] The embodiment of the present invention provides a method for processing database backup. Compared with the prior art, the present invention sends an active session query request to a database, so that the database queries the active session based on the active session query request; receives the active session information sent by the database, and determines the corresponding session service identifier based on the active session information; calls the execution service thread corresponding to the session service identifier, and sends a database backup request to the database when it is detected that the execution service thread is closed, thereby realizing the processing of long SQL active sessions before database backup, so that when the database is backed up, the global address can be quickly obtained, the probability of database backup failure is reduced, and the overall efficiency of database backup is improved.
[0103] As the above Figure 1 The implementation of the method shown in the figure, the embodiment of the present invention provides a database backup processing device, such as Figure 5 As shown, the device comprises:
[0104] A query module 51, configured to send an active session query request to a database, so that the database queries active sessions based on the active session query request;
[0105] A determination module 52, configured to receive active session information sent by the database, and determine a corresponding session service identifier based on the active session information;
[0106] The detection and sending module 53 is used to call the execution service thread corresponding to the session service identifier, and when it is detected that the execution service thread is closed, send a database backup request to the database.
[0107] Furthermore, the device also includes a configuration and judgment module, which is used to:
[0108] Configuring a corresponding session duration threshold for the session service;
[0109] When it is detected that the session duration corresponding to the session service and the session in the database is greater than the session duration threshold, the session is determined as an active session.
[0110] Furthermore, the configuration and judgment module includes:
[0111] A historical data extraction unit, used to obtain a session record of the session service, and determine all historical session durations of the session service from the session record;
[0112] a calculating unit, configured to calculate an average value of the historical session durations, and determine the average value as the session duration threshold matching the session service; or,
[0113] Calculating the median of the historical session durations, and determining the median as the session duration threshold that matches the session service; or,
[0114] The mode of the historical session durations is calculated, and the mode is determined as the session duration threshold that matches the session service.
[0115] Furthermore, the determining module 52 is further configured to:
[0116] Performing word segmentation processing on the session link to obtain multiple word segmentation fields;
[0117] Perform text recognition processing on the word segmentation field to obtain the session service identifier.
[0118] Furthermore, the device also includes a thread state detection module, which is used to:
[0119] Closing the execution service thread and starting a timer for timing;
[0120] When the timing time is greater than the set release time, the execution state of the execution service thread is detected, and the execution state includes a closed state and a running state.
[0121] Furthermore, the device also includes a detection and update module, which is used to:
[0122] Detecting the running status of the session service;
[0123] When the running state is an abnormal state, the session duration threshold corresponding to the session service is updated.
[0124] Furthermore, the device also includes an alarm module, which is used to:
[0125] Detecting the execution status of the execution service thread;
[0126] When it is detected that at least one of the execution service threads is in a running state, an alarm message is sent to the user.
[0127] An embodiment of the present invention provides a processing device for database backup. Compared with the prior art, the present invention sends an active session query request to a database so that the database queries the active session based on the active session query request; receives the active session information sent by the database, and determines the corresponding session service identifier based on the active session information; calls the execution service thread corresponding to the session service identifier, and sends a database backup request to the database when it is detected that the execution service thread is closed, thereby realizing the processing of long SQL active sessions before database backup, so that when the database is backed up, the global address can be quickly obtained, the probability of database backup failure is reduced, and the overall efficiency of database backup is improved.
[0128] According to an embodiment of the present invention, a storage medium is provided, wherein the storage medium stores at least one executable instruction, and the computer executable instruction can execute the database backup processing method in any of the above method embodiments.
[0129] Figure 6 A schematic diagram of the structure of a computer device provided according to an embodiment of the present invention is shown. The specific embodiment of the present invention does not limit the specific implementation of the computer device.
[0130] like Figure 6 As shown, the computer device may include: a processor (processor) 602 , a communication interface (Communications Interface) 604 , a memory (memory) 606 , and a communication bus 608 .
[0131] The processor 602 , the communication interface 604 , and the memory 606 communicate with each other via a communication bus 608 .
[0132] The communication interface 604 is used to communicate with other devices such as clients or other servers.
[0133] The processor 602 is used to execute the program 610, and specifically can execute the relevant steps in the above-mentioned database backup processing method embodiment.
[0134] Specifically, the program 610 may include program codes, which include computer operation instructions.
[0135] The processor 602 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. The one or more processors included in the computer device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.
[0136] The memory 606 is used to store the program 610. The memory 606 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
[0137] The program 610 may be specifically configured to enable the processor 602 to perform the following operations:
[0138] Sending an active session query request to a database, so that the database queries active sessions based on the active session query request;
[0139] receiving active session information sent by the database, and determining a corresponding session service identifier based on the active session information;
[0140] The execution service thread corresponding to the session service identifier is retrieved, and when it is detected that the execution service thread is closed, a database backup request is sent to the database.
[0141] Obviously, those skilled in the art should understand that the above modules or steps of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, and in some cases, the steps shown or described can be executed in a different order than here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. Thus, the present invention is not limited to any specific combination of hardware and software.
[0142] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for processing database backup, It is characterized in that include: Sending an active session query request to a database, so that the database queries active sessions based on the active session query request; receiving active session information sent by the database, and determining a corresponding session service identifier based on the active session information; The execution service thread corresponding to the session service identifier is retrieved, and when it is detected that the execution service thread is closed, a database backup request is sent to the database.
2. The method according to claim 1, It is characterized in that Before sending the active session query request to the database, the method further includes: Configuring a corresponding session duration threshold for the session service; When it is detected that the session duration corresponding to the session service and the session in the database is greater than the session duration threshold, the session is determined as an active session.
3. The method according to claim 2, It is characterized in that The configuring a corresponding session duration threshold for the session service includes: Acquire a session record of the session service, and determine all historical session durations of the session service from the session record; Calculating an average value of the historical session durations, and determining the average value as the session duration threshold that matches the session service; or, Calculating the median of the historical session durations, and determining the median as the session duration threshold that matches the session service; or, The mode of the historical session durations is calculated, and the mode is determined as the session duration threshold that matches the session service.
4. The method according to claim 1, It is characterized in that The active session information includes a session link between the session service and the database; The determining the corresponding session service identifier based on the active session information includes: Performing word segmentation processing on the session link to obtain multiple word segmentation fields; Perform text recognition processing on the word segmentation field to obtain the session service identifier.
5. The method according to claim 2, It is characterized in that When it is detected that the execution service thread is closed, before sending a database backup request to the database, the method further includes: Closing the execution service thread and starting a timer for timing; When the timing time is greater than the set release time, the execution state of the execution service thread is detected, and the execution state includes a closed state and a running state.
6. The method according to claim 5, It is characterized in that After closing the execution service thread, the method further includes: Detecting the running status of the session service; When the running state is an abnormal state, the session duration threshold corresponding to the session service is updated.
7. The method according to any one of claims 1 to 6, It is characterized in that The method further comprises: Detecting the execution status of the execution service thread; When it is detected that at least one of the execution service threads is in a running state, an alarm message is sent to the user.
8. A database backup processing device, It is characterized in that include: A query module, configured to send an active session query request to a database, so that the database queries active sessions based on the active session query request; A determination module, configured to receive active session information sent by the database, and determine a corresponding session service identifier based on the active session information; The detection and sending module is used to call the execution service thread corresponding to the session service identifier, and when it is detected that the execution service thread is closed, send a database backup request to the database.
9. A storage medium, wherein at least one executable software is stored in the storage medium, and the executable software executes operations corresponding to the database backup processing method according to any one of claims 1 to 7.
10. A computer device, comprising a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to execute an operation corresponding to the database backup processing method according to any one of claims 1 to 7.
