CN117290202A - Database connection exception handling method, device, computer equipment and storage medium - Google Patents

Database connection exception handling method, device, computer equipment and storage medium Download PDF

Info

Publication number
CN117290202A
CN117290202A CN202210692662.4A CN202210692662A CN117290202A CN 117290202 A CN117290202 A CN 117290202A CN 202210692662 A CN202210692662 A CN 202210692662A CN 117290202 A CN117290202 A CN 117290202A
Authority
CN
China
Prior art keywords
abnormal
service
information
execution
preset
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210692662.4A
Other languages
Chinese (zh)
Inventor
胡盛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
SF Technology Co Ltd
Original Assignee
SF Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by SF Technology Co Ltd filed Critical SF Technology Co Ltd
Priority to CN202210692662.4A priority Critical patent/CN117290202A/en
Publication of CN117290202A publication Critical patent/CN117290202A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/366Software debugging using diagnostics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/25Integrating or interfacing systems involving database management systems

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Data Mining & Analysis (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application provides a database connection exception handling method, a device, a computer device and a storage medium, wherein the method comprises the following steps: forming an abnormal section to intercept abnormal services based on pre-added annotation information, wherein the annotation information is added to an entry of a to-be-monitored service of a database; executing the abnormal business; if the execution of the preset times is unsuccessful, acquiring service information of the abnormal service; writing the service information into an abnormal service record table; and re-executing the service to be executed in the abnormal service record table until the execution is successful. By adopting the method, manual participation is not needed when the database is abnormal, the system directly processes, the risk brought by human factors is greatly reduced, and the system automatically processes and solves the problem of inefficiency of manual processing.

Description

Database connection exception handling method, device, computer equipment and storage medium
Technical Field
The application relates to the technical field of artificial intelligence, in particular to a database connection exception handling method, a device, computer equipment and a storage medium.
Background
The problem of the database or the influence of multiple factors of network blocking can cause abnormal connection of the database in a read-write operation room of the system. In a specific service, the database connection abnormality is simply to record errors and process information to a database table, then the data is reprocessed in a manual intervention mode, so that the defects of manpower are too many, the incorrect operation can bring great unsafe, and the manual processing mode is low in efficiency.
Disclosure of Invention
Based on the above, it is necessary to provide a method, a device, a computer device and a storage medium for processing database connection abnormality, when the database abnormality occurs, the system directly processes the database without manual participation, so that the risk caused by human factors is greatly reduced, and the inefficiency problem of manual processing is solved by the automatic processing of the system.
In a first aspect, the present application provides a method for processing a database connection exception, including:
forming an abnormal section to intercept abnormal services based on pre-added annotation information, wherein the annotation information is added to an entry of a to-be-monitored service of a database;
executing the abnormal business;
if the execution of the preset times is unsuccessful, acquiring service information of the abnormal service;
writing the service information into an abnormal service record table;
and re-executing the service to be executed in the abnormal service record table until the execution is successful.
In some embodiments of the present application, the service information includes a next processing time, and the re-executing the service to be executed in the abnormal service record table until the execution is successful includes:
scanning the abnormal service record table at intervals of preset time to acquire the next processing time of the service to be executed;
If the difference value between the next processing time and the current time is smaller than or equal to a preset time difference, determining the service to be executed corresponding to the next processing time as a target service;
re-executing the target service;
if the re-execution is successful, deleting the target service from the abnormal service record table;
if the re-execution is unsuccessful, the record information of the target service in the abnormal service record table is updated.
In some embodiments of the present application, the recording information includes a number of execution times and a next processing time, and if the re-execution is unsuccessful, updating the recording information of the target service in the abnormal service recording table includes:
if the re-execution is unsuccessful, the execution times are increased by preset times to obtain new execution times;
determining new next processing time according to the new execution times, the next processing time and a preset retry strategy;
and updating the record information of the target service of the abnormal service record table according to the new execution times and the new next processing time.
In some embodiments of the present application, the determining a new next processing time according to the new execution times, the next processing time, and a preset retry strategy includes:
Stopping re-executing the target service when the new execution times are greater than or equal to the preset maximum execution times;
when the new execution times are smaller than a preset maximum execution times, determining execution interval time according to the new execution times and the preset retry strategy;
and determining a new next processing time according to the next processing time and the execution interval time.
In some embodiments of the present application, before the forming the abnormal section based on the pre-added annotation information intercepts the abnormal service, the method includes:
acquiring service execution information of the service to be monitored;
and determining the abnormal service according to the service execution information and preset abnormal information.
In some embodiments of the present application, after determining the abnormal service according to the service execution information and preset abnormal information, the method includes:
acquiring target service information of the abnormal service;
if the abnormal business is determined to be recorded in the abnormal business record table according to the target business information, the abnormal business record information of the abnormal business record table is updated according to the target business information.
In some embodiments of the present application, before the forming the abnormal section based on the pre-added annotation information intercepts the abnormal service, the method includes:
Downloading an anomaly interception component;
acquiring component information of the anomaly interception component, wherein the component information comprises the annotation information;
configuring according to the component information, and introducing the abnormal interception component;
the forming of the abnormal section based on the pre-added annotation information to intercept the abnormal service comprises the following steps:
and forming an abnormal section based on the annotation information by an abnormal interception component to intercept the abnormal business.
In a second aspect, the present application provides a database connection exception handling apparatus, including:
the abnormal interception module is used for forming an abnormal section to intercept abnormal services based on pre-added annotation information, wherein the annotation information is added to an entry of a to-be-monitored service of the database;
the service execution module is in communication connection with the abnormal interception module and is used for executing the abnormal service;
the abnormal processing module is in communication connection with the service execution module and is used for acquiring service information of the abnormal service if the execution is unsuccessful after the preset times; writing the service information into an abnormal service record table; and re-executing the service to be executed in the abnormal service record table until the execution is successful.
In some embodiments of the present application, the service information includes a next processing time, and the exception processing module is further configured to scan the exception service record table at intervals of a preset time, to obtain the next processing time of the service to be executed; if the difference value between the next processing time and the current time is smaller than or equal to a preset time difference, determining the service to be executed corresponding to the next processing time as a target service; re-executing the target service; if the re-execution is successful, deleting the target service from the abnormal service record table; if the re-execution is unsuccessful, the record information of the target service in the abnormal service record table is updated.
In some embodiments of the present application, the record information includes an execution number and a next processing time, and the exception processing module is further configured to increase the execution number by a preset number to obtain a new execution number if the re-execution is unsuccessful; determining new next processing time according to the new execution times, the next processing time and a preset retry strategy; and updating the record information of the target service of the abnormal service record table according to the new execution times and the new next processing time.
In some embodiments of the present application, the exception handling module is further configured to stop re-executing the target service when the new execution number is greater than or equal to a preset maximum execution number; when the new execution times are smaller than a preset maximum execution times, determining execution interval time according to the new execution times and the preset retry strategy; and determining a new next processing time according to the next processing time and the execution interval time.
In some embodiments of the present application, the anomaly interception module is further configured to obtain service execution information of the service to be monitored; and determining the abnormal service according to the service execution information and preset abnormal information.
In some embodiments of the present application, the anomaly interception module is further configured to obtain target service information of the anomaly service; if the abnormal business is determined to be recorded in the abnormal business record table according to the target business information, the abnormal business record information of the abnormal business record table is updated according to the target business information.
In some embodiments of the present application, the anomaly interception module is further configured to download an anomaly interception component; acquiring component information of the anomaly interception component, wherein the component information comprises the annotation information; configuring according to the component information, and introducing the abnormal interception component; and forming an abnormal section based on the annotation information by an abnormal interception component to intercept the abnormal business.
In a third aspect, the present application also provides a computer device comprising:
one or more processors;
a memory; and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the database connection exception handling method.
In a fourth aspect, the present application also provides a computer-readable storage medium having stored thereon a computer program that is loaded by a processor to perform the steps of a database connection exception handling method.
In a fifth aspect, embodiments of the present application provide a computer program product or computer program comprising computer instructions stored in a computer readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device performs the method provided in the first aspect.
According to the database connection exception handling method, the database connection exception handling device, the computer equipment and the storage medium, the exception section is formed based on the pre-added annotation information to intercept the exception service, namely, when the database is abnormal, the system directly intercepts the exception service without manual participation, and the risk brought by human factors is greatly reduced. And secondly, for the automatic abnormal business interception, firstly, directly executing, and if the execution is unsuccessful, writing the abnormal business interception into an abnormal business record table for repeated execution, wherein the system automatically adopts the remedy processing to the abnormal business so as to solve the problem of inefficiency of manual processing.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the description of the embodiments will be briefly introduced below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a flow chart of a database connection exception handling method in an embodiment of the present application;
FIG. 2 is a flow chart of a database connection exception handling method according to another embodiment of the present application;
FIG. 3 is a flowchart of a method for handling database connection anomalies in another embodiment of the present application;
FIG. 4 is a flowchart of a method for handling database connection anomalies in another embodiment of the present application;
FIG. 5 is a flowchart of a method for handling database connection anomalies in another embodiment of the present application;
FIG. 6 is a flowchart of a method for handling database connection anomalies in another embodiment of the present application;
FIG. 7 is a flowchart of a method for handling database connection anomalies in another embodiment of the present application;
FIG. 8 is a schematic diagram of a database connection exception handling apparatus in an embodiment of the present application;
fig. 9 is a schematic structural diagram of a computer device in the embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and fully with reference to the accompanying drawings, in which it is evident that the embodiments described are only some, but not all, of the embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments herein without making any inventive effort, are intended to be within the scope of the present application.
In the description of the present application, the terms "first," "second," and the like are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more of the described features. In the description of the present application, the meaning of "a plurality" is two or more, unless explicitly defined otherwise.
In the description of the present application, the term "for example" is used to mean "serving as an example, instance, or illustration. Any embodiment described herein as "for example" is not necessarily to be construed as preferred or advantageous over other embodiments. The following description is presented to enable any person skilled in the art to make and use the invention. In the following description, details are set forth for purposes of explanation. It will be apparent to one of ordinary skill in the art that the present invention may be practiced without these specific details. In other instances, well-known structures and processes have not been described in detail so as not to obscure the description of the invention with unnecessary detail. Thus, the present invention is not intended to be limited to the embodiments shown, but is to be accorded the widest scope consistent with the principles and features disclosed herein.
Referring to fig. 1, an embodiment of the present application provides a method for processing database connection exception, including steps S101 to S105, specifically including the following steps:
s101, forming an abnormal section to intercept abnormal services based on pre-added annotation information, wherein the annotation information is added to an entry of a to-be-monitored service of a database.
The abnormal section describes that the part of the whole component for processing the abnormal connection of the database independently forms one surface, and the section can process all the abnormal connection of the database thrown out by the system, and simultaneously separate the problems from the main service logic, thereby achieving the aim of decoupling with the main service logic. For example, AOP (Aspect Oriented Programming, slice-oriented programming) deals with cross-cut issues that do not affect the implementation of the main logic, but are scattered into various parts of the code and are difficult to maintain. AOP separates the problems from the main service logic, and achieves the aim of decoupling from the main service logic. The Spring aop function is based on a Spring-based aop cross-cut function.
The database abnormality refers to that the abnormality needs to be processed when the system performs operations such as reading and writing on the database, and correspondingly, the services such as reading and writing need to be monitored, so that the service to be monitored is the service of the operation corresponding to the database abnormality, including but not limited to the reading and writing service and the like.
The annotation information is added to an entrance of a to-be-monitored service of the database, when abnormal service is detected, the annotation information is taken as an interception cross point, and then the interception cross point is taken as an entrance point to form abnormal tangent plane processing. The annotation information is equivalent to a mark for intercepting the abnormal service in real time, so that the abnormal service is conveniently intercepted, the abnormal service is suspended in the main logic and is transferred to an abnormal remedying program after the subsequent interception for execution, wherein the specific setting of the annotation information can be used for setting different character strings and the like according to environments such as different system components and the like.
In one embodiment, as shown in fig. 2, this step is preceded by: s201, downloading an exception interception component; s202, acquiring component information of the anomaly interception component, wherein the component information comprises the annotation information; s203, configuring according to the component information, and introducing the abnormal interception component; s204, forming an abnormal section to intercept abnormal business based on the pre-added annotation information through the abnormal interception component.
Specifically, an abnormal section interception abnormal service is formed based on annotation information, so that the aim of logical decoupling with the main service is fulfilled, and further, a third party abnormal interception component can be arranged for intercepting the abnormal service, and the reusability of codes can be improved through collocation and componentization, so that the development efficiency is greatly reduced, and the labor cost is improved.
Firstly, downloading an abnormality interception component, wherein the software configuration parameters of the system need to be adjusted based on the configuration information of the abnormality interception component so as to be compatible and adaptive with the abnormality interception component. For example, if the anomaly intercept component is maven, then the software configuration parameters of the system need to be configured to be maven compatible. And then acquiring component information of the anomaly interception component, wherein the component information comprises identification information and annotation information of the anomaly interception component, the identification information is used for identifying and loading the anomaly interception component, the annotation information is information which can be identified as an interception transverse point by the anomaly interception component, the configuration is carried out according to the component information, namely the identification information is configured into a system, and meanwhile, the annotation information is added to an entry of a to-be-monitored service of a database, so that the anomaly interception component is introduced. And finally, forming an abnormal section based on annotation information by an abnormal interception component to intercept abnormal services. It should be noted that, the exception interception component is only used for intercepting the exception traffic, and the remedial measures such as re-execution after the interception of the exception traffic are still executed by the system, and are not executed by the exception interception component.
maven is a building tool (packing project), a dependency management tool (resource dependency management tool: mainly used for integrating resources), a project information aggregation tool, and the use of maven can pack the project into components, and the warehouse uploaded by the packed components can be used by other systems, and the components can be downloaded locally by other systems for use by the system.
Taking the exception interception component as an example to take a maven platform to carry out architecture for illustration, firstly, correspondingly, a system needing to use the exception interception component is also based on maven or supporting maven construction, namely, the system and the exception interception component can be adapted. In the system's pon file configuration component's dependency information (i.e., component information's identification information), which includes the anomaly interception component's group Id and the anomaly interception component's unique identification component's artifact Id information, the anomaly interception component is downloaded using a maven command, which may be mvn install. The system using the exception interception component is used for introducing the system into the xml file configuration component of the spring, the spring is a lightweight control inversion (IoC, inversion of Control) and a container framework facing to a tangent plane (AOP, aspect Oriented Programming), the xml file of the spring is configured to be designated as a transverse processing class introduction component of the component through a class attribute of a label bean in the xml file of the spring, the tangent plane method full class name of the exception interception component is configured in the xml file of the spring of the system, and the full class name of the tangent plane method comprises a package name and a class name. And configuring abnormal information of the database to a configuration file, wherein the file is configured to create a dbconnectixeAN_SNconnection configuration file under a resource catalog of the system, and the file is configured with common abnormal information, wherein the abnormal information is identification information of abnormal occurrence of the service, and whether the service is abnormal or not is required to be intercepted and remedied is judged through the abnormal information. The annotation information is configured to the system code, i.e. the annotation information is added to the entry of the service to be monitored of the database, for example, the annotation @ method handle is added to the entry of the system service method. And finally introducing an exception interception component into the current system.
It should be noted that Maven, as a construction tool, not only can construct automatically, but also can abstract the construction process to provide construction task implementation; and a consistent operation interface is provided for the outside of the cross-platform. Spring is a lightweight control inversion (IoC) and cut-plane (AOP) oriented container framework, JAVA EE is easier to use, object oriented design is more important than any implementation technology (e.g., JAVA EE), interface oriented programming, rather than class programming. Spring reduces the complexity of using the interface to zero and the code is easy to test.
In the embodiment, the exception interception component is used as an independent component, and a user only needs to configure corresponding parameters, so that the function requirement can be met by calling a plurality of systems, and the development efficiency is improved.
In one embodiment, as shown in fig. 3, step S101, an abnormal section is formed to intercept an abnormal service based on pre-added annotation information, which is added before an entry of a service to be monitored in a database, includes: s301, acquiring service execution information of the service to be monitored; s302, determining the abnormal service according to the service execution information and preset abnormal information.
When the system accesses the database to execute each service, the service execution information of the service to be monitored is obtained, the service execution information comprises the service execution state of each service to be monitored, and whether the corresponding service is normally executed or abnormal can be determined through the service execution information. The system preset abnormal information is identification information of abnormal business occurrence, and business execution information of each business is matched with the preset abnormal information, so that abnormal business in the abnormal information is determined.
Annotating information is added to the entrance of each service, and then an abnormal section is formed by the annotating information of the entrance of the abnormal service to intercept the abnormal service. The position of the abnormal business can be determined according to the business execution information of the abnormal business, and the position of the corresponding annotation information is further determined, so that the annotation information can be set to be a uniform character string, and distinction according to the business type is not needed.
S102, executing the abnormal service.
After intercepting the abnormal service through the abnormal section, the abnormal service is subsequently remedied, wherein the remedied treatment is to additionally start a thread for treatment by the system and separate from the main service logic, so that the aim of decoupling with the main service logic is fulfilled. The abnormal section independently processes the abnormal database connection business, and separates the abnormal connection business from the main business logic, so that interference is avoided. That is, the system directly executes the intercepted abnormal business, if the execution is unsuccessful, the execution can be repeated for a plurality of times, if the cause of the abnormal business abnormal is automatically repaired in the system operation process, the abnormal business can be successfully executed after the re-execution. Accordingly, after successful execution, the remediation processing of the abnormal service is completed, and the service execution state is updated, so that the abnormal service is avoided being identified later.
And S103, if the execution of the preset times is unsuccessful, acquiring the service information of the abnormal service.
Specifically, if the number of times of executing the abnormal service is excessive in the process of remediation, system resource waste may be caused, and further system operation efficiency is affected, so that the preset number of times is set, and after the preset number of times of executing the abnormal service is executed, the execution of the abnormal service is suspended, and service information of the abnormal service is acquired. The service information of the abnormal service includes configuration parameters of the service itself, such as service request parameters, interfaces corresponding to the service, and the like, and also includes all execution parameters of the abnormal service, such as service execution times, processing time, creation time, and the like. The service information of the abnormal service includes information required for performing the subsequent remedial process, and this embodiment is not listed one by one.
S104, writing the service information into an abnormal service record table.
Specifically, the service information is written into the abnormal service record table to form corresponding service to be executed, the service to be executed is abnormal for the main logic operation of the system, the service which is also abnormal is executed for a plurality of times after interception, and the service is written into the abnormal service record table to be recorded, so that the abnormal service is prevented from being missed.
S105, re-executing the service to be executed in the abnormal service record table until the execution is successful.
Specifically, the subsequent remediation processing is executed on the service to be executed in the abnormal service record table, namely, the service to be executed in the abnormal service record table is re-executed until the execution is successful. Therefore, the remediation processing of the intercepted abnormal business is divided into two steps, the intercepted abnormal business is directly executed at first, the processing speed is higher, if the intercepted abnormal business is still unsuccessful after the execution of the preset times, the intercepted abnormal business is written into an abnormal business record table and then is executed again, and the intercepted abnormal business and the abnormal business are combined with the reasonable distribution of threads, so that the processing efficiency is improved.
In one embodiment, as shown in fig. 4, the service information includes a next processing time, and this step includes: s401, scanning the abnormal service record table at intervals of preset time to acquire the next processing time of the service to be executed; s402, if the difference value between the next processing time and the current time is smaller than or equal to a preset time difference, determining that the service to be executed corresponding to the next processing time is a target service; s403, re-executing the target service; s404, if the re-execution is successful, deleting the target service from the abnormal service record table; and S405, if the re-execution is unsuccessful, updating the record information of the target service in the abnormal service record table.
Specifically, because the writing time and executing time of each service to be executed in the abnormal service record table are different, the re-executing time of each service to be executed is also different, and the service information in the abnormal service record table contains the next processing time of each service to be executed, in order to avoid missing time, the abnormal service record table is scanned every preset time to obtain the next processing time of the service to be executed. The preset time is set based on the operation parameters of the system, and the shorter the preset time is, the larger the consumption of the operation resources of the system is. It should be noted that, the preset time may be fixed, or may be based on resource fluctuation allocated by the system, which is not limited in this embodiment.
If the difference value between the next processing time and the current time is smaller than or equal to the preset time difference, determining that the service to be executed corresponding to the next processing time is the target service, and executing the target service again. If there are multiple target services, the multiple target services may be processed simultaneously in parallel, or sequentially processed according to the order from small to large, or a combination of the two processing modes, it should be noted that the preset time difference may be set according to the resources provided by the system and the running rate, so as to ensure that each target service can be re-executed in time.
If the target service is successfully re-executed, the repair processing is completed, the related record of the target service is deleted from the abnormal service record table, and the service execution state is updated, so that the subsequent recognition of the abnormal service is avoided. If the target service is not successfully re-executed, the record information of the target service of the abnormal service record list is updated to be re-executed next time.
In one embodiment, as shown in fig. 5, the record information includes the execution times and the next processing time, and step S405, if the re-execution is unsuccessful, updating the record information of the target service in the abnormal service record table includes: s501, if the re-execution is unsuccessful, increasing the execution times by a preset time to obtain new execution times; s502, determining new next processing time according to the new execution times, the next processing time and a preset retry strategy; s503, according to the new execution times and the new next processing time, updating the record information of the target service of the abnormal service record table.
Specifically, the record information of each service to be executed in the abnormal service record table includes the execution times and the next processing time, where the execution times may be the times of re-execution after writing in the abnormal service record table, or may be the total execution times, and the calculation mode is not limited in this embodiment.
If the target service re-execution is unsuccessful, the execution times are increased by a preset number of times to obtain new execution times, wherein the preset number of times is generally set to be 1. And then determining the new next processing time according to the new execution times, the next processing time and a preset retry strategy, wherein the preset retry strategy is used for determining the time interval to the new next processing time. And finally, updating the record information of the target service of the abnormal service record list according to the new execution times and the new next processing time, and then controlling the target service to be re-executed again based on the updated record information.
In one embodiment, as shown in fig. 6, step S502, determining the new next processing time according to the new execution times, the next processing time and a preset retry strategy includes: s601, stopping re-executing the target service when the new execution times are greater than or equal to a preset maximum execution times; s602, when the new execution times are smaller than a preset maximum execution times, determining execution interval time according to the new execution times and the preset retry strategy; s603, determining new next processing time according to the next processing time and the execution interval time.
Specifically, based on consideration of factors such as system resource allocation and processing efficiency, it is impossible to re-execute unsuccessful abnormal services without limitation, and therefore, limitation can be made by setting a preset maximum execution number.
When the new execution times is greater than or equal to the preset maximum execution times, the target service execution times reach the upper limit, so that the target service is stopped from being re-executed, manual processing can be performed later, further, the target service can be marked and screened, for example, the new next processing time is set to be a specific mark or infinite, and the target service can not be identified to be re-executed.
When the new execution times is smaller than the preset maximum execution times, determining an execution interval time according to the new execution times and a preset retry strategy, wherein the preset retry strategy can be set according to different needs, and the preset retry strategy comprises a corresponding relation between the execution times and the execution interval time, wherein the execution interval time can be set to be a fixed time interval, that is, different execution times correspond to the same execution interval time, or different execution times correspond to different execution interval times, and the execution interval time corresponding to the larger execution times is longer. And then determining a new next processing time according to the next processing time and the execution interval time, namely adding the next processing time to the execution interval time so as to obtain the new next processing time. For example, the preset retry strategy sets the execution interval time to be 10s at a fixed time interval, i.e., the new next processing time is the next processing time plus 10s. Or the preset retry strategy sets that the execution times are increased once, and the execution interval time is increased by 10s relative to the execution interval time of the last time, namely the new next processing time is the next processing time plus the execution interval time of the last time plus 10s.
In one embodiment, as shown in fig. 7, step S302, determining the abnormal service according to the service execution information and preset abnormal information includes: s701, obtaining target service information of the abnormal service; s702, if the abnormal business is determined to be recorded in the abnormal business record table according to the target business information, the record information of the abnormal business in the abnormal business record table is updated according to the target business information.
Specifically, since the system is multi-threaded operation, the remediation processing of the abnormal service in this embodiment does not affect the operation of the main logic, so after the abnormal service is intercepted, the main logic of the system may still execute the service corresponding to the abnormal service again, that is, the system repeatedly determines that the same service is the abnormal service, if the abnormal service is still intercepted, and then remedies the abnormal service, which obviously causes the waste of system resources. Therefore, after the abnormal service is identified, the target service information of the abnormal service is obtained, whether the abnormal service is the service to be executed recorded in the abnormal service record is judged according to the target service information, if not, the repairing process is performed according to the flow of the embodiment, namely, the abnormal service is executed first, and if the repairing process is unsuccessful after the abnormal service is executed for a preset number of times, the repairing process is written into the abnormal service record. If so, the previous step of the remediation process is described, so that the complete remediation process flow is not performed according to the embodiment, and the operation of the main logic of the system is equivalent to that the service to be executed in the abnormal service record table is executed once again, and the record information of the abnormal service in the abnormal service record table is directly updated according to the target service information. The update flow of the record information of the abnormal service is as described above, and thus is not described in detail.
The embodiment provides an abnormal interception component for database connection abnormality and data remediation, when the database abnormality occurs, the system does not need to be directly involved in the process, so that the risk caused by human factors is greatly reduced, and the system automatically processes the system, thereby solving the problem of inefficiency of manual processing; as an independent component, a user only needs to configure corresponding parameters, and the function requirements can be met by calling a plurality of systems, so that the development efficiency is improved.
The embodiment of the application provides a database connection exception handling method, an exception interception component is constructed by a maven platform, and the exception interception component is a aop transverse cutting function based on spring, and comprises the following steps:
s1, configuring the organization groupID of the component and the unique identification artifactId in a pon file of the system maven, and then downloading the component to the system local through an mvn sample command provided by the maven.
S2, setting an xml file of the system spring as a full class name of a component section class through class of a bean label, and configuring abnormal information of abnormal connection of a database.
S3, adding @ method handle annotation in a service code entry method of the system, and capturing database connection abnormality by a component section through @ method handle.
S4, the exception interception component intercepts all exception services annotated with @ method handle through spring tangent plane programming aop.
S5, after intercepting the abnormal service, firstly retrying for 3 times internally, directly returning the successful retrying, and carrying out the next operation if the retrying fails.
S6, storing the method request parameters, interfaces corresponding to the method, processing times, next processing time, record of creation time and update time and other abnormal business information into an abnormal business record table;
s7, defining a timing task, wherein the timing task scans an abnormal service record table every 10 seconds to acquire a target service with the next processing time less than or equal to the current time; the processing process of the timing task is as follows: acquiring a field of an interface corresponding to the target service and the next processing time; loading the class corresponding to the interface, and finding out the service with annotation in the class and the parameter request parameter; and (3) finishing the processing by using the reflection calling method, deleting the target service in the abnormal service record table if the processing is successful, and waiting for the next processing without the processing success to update the processing times, the processing time, the updating time and other record information.
The pluggable third-party component exception interception component and the parameter configurable mode provided by the embodiment can be rapidly provided for a software system to use, the third-party component can be obtained from a maven warehouse through a maven construction tool, a system developer using the component can be provided for the system in a component mode through configuration in a configuration file, the system is light in weight and easy to configure, and automatic processing can reduce manual work, reduce errors caused by manual processing and improve exception processing efficiency.
As shown in fig. 8, an embodiment of the present application provides a database connection exception handling apparatus 900, including:
the anomaly interception module 910 is configured to form an anomaly section based on pre-added annotation information, where the annotation information is added to an entry of a to-be-monitored service in the database;
the service execution module 920 is communicatively connected to the anomaly interception module 910, and is configured to execute the anomaly service;
the exception handling module 930 is in communication connection with the service execution module 920, and is configured to obtain service information of the exception service if the execution is unsuccessful after the preset number of times; writing the service information into an abnormal service record table; and re-executing the service to be executed in the abnormal service record table until the execution is successful.
In some embodiments of the present application, the service information includes a next processing time, and the exception processing module 930 is further configured to scan the exception service record table at intervals of a preset time, to obtain the next processing time of the service to be executed; if the difference value between the next processing time and the current time is smaller than or equal to a preset time difference, determining the service to be executed corresponding to the next processing time as a target service; re-executing the target service; if the re-execution is successful, deleting the target service from the abnormal service record table; if the re-execution is unsuccessful, the record information of the target service in the abnormal service record table is updated.
In some embodiments of the present application, the record information includes an execution number and a next processing time, and the exception handling module 930 is further configured to increase the execution number by a preset number to obtain a new execution number if the re-execution is unsuccessful; determining new next processing time according to the new execution times, the next processing time and a preset retry strategy; and updating the record information of the target service of the abnormal service record table according to the new execution times and the new next processing time.
In some embodiments of the present application, the exception handling module 930 is further configured to stop re-executing the target service when the new execution number is greater than or equal to a preset maximum execution number; when the new execution times are smaller than a preset maximum execution times, determining execution interval time according to the new execution times and the preset retry strategy; and determining a new next processing time according to the next processing time and the execution interval time.
In some embodiments of the present application, the anomaly interception module 910 is further configured to obtain service execution information of the service to be monitored; and determining the abnormal service according to the service execution information and preset abnormal information.
In some embodiments of the present application, the anomaly interception module 910 is further configured to obtain target service information of the anomaly service; if the abnormal business is determined to be recorded in the abnormal business record table according to the target business information, the abnormal business record information of the abnormal business record table is updated according to the target business information.
In some embodiments of the present application, the exception interception module 910 is further configured to download an exception interception component; acquiring component information of the anomaly interception component, wherein the component information comprises the annotation information; configuring according to the component information, and introducing the abnormal interception component; and forming an abnormal section based on the annotation information by an abnormal interception component to intercept the abnormal business.
In some embodiments of the present application, the database connection exception handling apparatus 900 may be implemented in the form of a computer program that is executable on a computer device as shown in fig. 9. The memory of the computer device may store therein various program modules constituting the database connection abnormality processing apparatus 900, such as an abnormality interception module 910, a service execution module 920, and an abnormality processing module 930 shown in fig. 8. The computer program constituted by the respective program modules causes the processor to execute the steps in the database connection abnormality processing method of the respective embodiments of the present application described in the present specification.
For example, the computer apparatus shown in fig. 9 may execute step S101 through the abnormality interception module 910 in the database connection abnormality processing apparatus 900 shown in fig. 8. The computer device may perform step S102 through the service execution module 920. The computer device may perform steps S103 to S105 through the exception handling module 930. The computer device includes a processor, a memory, and a network interface connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The network interface of the computer device is used for communicating with an external computer device through a network connection. The computer program, when executed by a processor, implements a database connection exception handling method.
It will be appreciated by those skilled in the art that the structure shown in fig. 9 is merely a block diagram of a portion of the structure associated with the present application and is not limiting of the computer device to which the present application applies, and that a particular computer device may include more or fewer components than shown, or may combine some of the components, or have a different arrangement of components.
In some embodiments of the present application, a computer device is provided that includes one or more processors; a memory; and one or more application programs, wherein the one or more application programs are stored in the memory and configured to be executed by the processor to perform the steps of the database connection exception handling method described above. The steps of the database connection exception handling method herein may be the steps of the database connection exception handling method of the above-described respective embodiments.
In some embodiments of the present application, a computer readable storage medium is provided, in which a computer program is stored, where the computer program is loaded by a processor, so that the processor performs the steps of the database connection exception handling method described above. The steps of the database connection exception handling method herein may be the steps of the database connection exception handling method of the above-described respective embodiments.
Those of ordinary skill in the art will appreciate that implementing all or part of the above-described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the various embodiments provided herein can include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, or the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory. By way of illustration, and not limitation, RAM can take many forms, such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), among others.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing has described in detail the method, apparatus, computer device and storage medium for handling database connection anomalies provided by the embodiments of the present application, and specific examples are provided herein to illustrate the principles and embodiments of the present invention, where the foregoing examples are provided to assist in understanding the method and core idea of the present invention; meanwhile, as those skilled in the art will have variations in the specific embodiments and application scope in light of the ideas of the present invention, the present description should not be construed as limiting the present invention.

Claims (10)

1. A database connection exception handling method, comprising:
forming an abnormal section to intercept abnormal services based on pre-added annotation information, wherein the annotation information is added to an entry of a to-be-monitored service of a database;
executing the abnormal business;
If the execution of the preset times is unsuccessful, acquiring service information of the abnormal service;
writing the service information into an abnormal service record table;
and re-executing the service to be executed in the abnormal service record table until the execution is successful.
2. The method for processing abnormal connection of database according to claim 1, wherein the service information includes a next processing time, and the re-executing the service to be executed in the abnormal service record table until the execution is successful comprises:
scanning the abnormal service record table at intervals of preset time to acquire the next processing time of the service to be executed;
if the difference value between the next processing time and the current time is smaller than or equal to a preset time difference, determining the service to be executed corresponding to the next processing time as a target service;
re-executing the target service;
if the re-execution is successful, deleting the target service from the abnormal service record table;
if the re-execution is unsuccessful, the record information of the target service in the abnormal service record table is updated.
3. The method for processing abnormal connection of database according to claim 2, wherein the record information includes a number of executions and a next processing time, and the updating the record information of the target service in the abnormal service record table if the re-execution is unsuccessful includes:
If the re-execution is unsuccessful, the execution times are increased by preset times to obtain new execution times;
determining new next processing time according to the new execution times, the next processing time and a preset retry strategy;
and updating the record information of the target service of the abnormal service record table according to the new execution times and the new next processing time.
4. The method for processing abnormal connection of database according to claim 3, wherein determining a new next processing time according to the new execution times, the next processing time and a preset retry strategy comprises:
stopping re-executing the target service when the new execution times are greater than or equal to the preset maximum execution times;
when the new execution times are smaller than a preset maximum execution times, determining execution interval time according to the new execution times and the preset retry strategy;
and determining a new next processing time according to the next processing time and the execution interval time.
5. The method for processing abnormal connection according to claim 1, wherein before forming an abnormal section based on the pre-added annotation information to intercept abnormal traffic, comprising:
Acquiring service execution information of the service to be monitored;
and determining the abnormal service according to the service execution information and preset abnormal information.
6. The method for processing abnormal connection of database according to claim 5, wherein after determining the abnormal service according to the service execution information and the preset abnormal information, the method comprises:
acquiring target service information of the abnormal service;
if the abnormal business is determined to be recorded in the abnormal business record table according to the target business information, the abnormal business record information of the abnormal business record table is updated according to the target business information.
7. The method for processing abnormal connection according to claim 1, wherein before forming an abnormal section based on the pre-added annotation information to intercept abnormal traffic, comprising:
downloading an anomaly interception component;
acquiring component information of the anomaly interception component, wherein the component information comprises the annotation information;
configuring according to the component information, and introducing the abnormal interception component;
the forming of the abnormal section based on the pre-added annotation information to intercept the abnormal service comprises the following steps:
And forming an abnormal section based on the annotation information by an abnormal interception component to intercept the abnormal business.
8. A database connection abnormality processing apparatus, comprising:
the abnormal interception module is used for forming an abnormal section to intercept abnormal services based on pre-added annotation information, wherein the annotation information is added to an entry of a to-be-monitored service of the database;
the service execution module is in communication connection with the abnormal interception module and is used for executing the abnormal service;
the abnormal processing module is in communication connection with the service execution module and is used for acquiring service information of the abnormal service if the execution is unsuccessful after the preset times; writing the service information into an abnormal service record table; and re-executing the service to be executed in the abnormal service record table until the execution is successful.
9. A computer device, the computer device comprising:
one or more processors;
a memory; and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the processor to implement the database connection exception handling method of any one of claims 1 to 7.
10. A computer storage medium having stored thereon a computer program, the computer program being loaded by a processor to perform the steps of the database connection exception handling method of any one of claims 1 to 7.
CN202210692662.4A 2022-06-17 2022-06-17 Database connection exception handling method, device, computer equipment and storage medium Pending CN117290202A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210692662.4A CN117290202A (en) 2022-06-17 2022-06-17 Database connection exception handling method, device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210692662.4A CN117290202A (en) 2022-06-17 2022-06-17 Database connection exception handling method, device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117290202A true CN117290202A (en) 2023-12-26

Family

ID=89237700

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210692662.4A Pending CN117290202A (en) 2022-06-17 2022-06-17 Database connection exception handling method, device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117290202A (en)

Similar Documents

Publication Publication Date Title
US20190324648A1 (en) Fast restart of applications using shared memory
US7908521B2 (en) Process reflection
CN105164644B (en) Hook frame
CN112256558B (en) Test case generation method and device, computer equipment and storage medium
US8881107B2 (en) Automatic memory leak detection
US8661418B2 (en) Setting program, workflow creating method, and work flow creating apparatus
US20170024307A1 (en) Debugging in a Production Environment
CN111897558A (en) Kubernets upgrading method and device for container cluster management system
US9542173B2 (en) Dependency handling for software extensions
US11544050B1 (en) Software patch automation
US20190149571A1 (en) Method and device for repairing page vulnerability
US8290916B2 (en) Rule-based record profiles to automate record declaration of electronic documents
JP6643407B2 (en) Method, apparatus, server and program for inspecting defect function
CN114564500A (en) Method and system for implementing structured data storage and query in block chain system
CN111562952B (en) Dynamic loading method and dynamic loading device for double-core intelligent ammeter management unit
CN105869309A (en) Drive module memory data monitoring method and device
CN110597649B (en) Data processing method, system and device
CN117290202A (en) Database connection exception handling method, device, computer equipment and storage medium
CN111694724A (en) Testing method and device of distributed table system, electronic equipment and storage medium
CN105868957A (en) Continuous integration method and device
CN112148714B (en) Data monitoring method, system, storage medium and electronic equipment
CN111638920B (en) Method, device, electronic equipment and medium for processing computer program synchronous task
CN115237422A (en) Code compiling method, device, computer equipment and storage medium
CN107977206A (en) A kind of batch service data file processing method and device
CN112015436A (en) Short message platform deployment method and device, computing equipment and computer storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination