[go: up one dir, main page]

CN108255703B - SQL script fault repairing method and terminal thereof - Google Patents

SQL script fault repairing method and terminal thereof Download PDF

Info

Publication number
CN108255703B
CN108255703B CN201711084967.2A CN201711084967A CN108255703B CN 108255703 B CN108255703 B CN 108255703B CN 201711084967 A CN201711084967 A CN 201711084967A CN 108255703 B CN108255703 B CN 108255703B
Authority
CN
China
Prior art keywords
fault
sql script
consumption
control file
script
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.)
Active
Application number
CN201711084967.2A
Other languages
Chinese (zh)
Other versions
CN108255703A (en
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.)
Ping An Life Insurance Company of China Ltd
Original Assignee
Ping An Life Insurance Company of China 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 Ping An Life Insurance Company of China Ltd filed Critical Ping An Life Insurance Company of China Ltd
Priority to CN201711084967.2A priority Critical patent/CN108255703B/en
Publication of CN108255703A publication Critical patent/CN108255703A/en
Application granted granted Critical
Publication of CN108255703B publication Critical patent/CN108255703B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/362Debugging of software
    • G06F11/366Debugging of software using diagnostics
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; 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/21Design, administration or maintenance of databases

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Databases & Information Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention is suitable for the technical field of databases, and provides a fault repairing method of an SQL script and a terminal thereof, wherein the fault repairing method comprises the following steps: if the failure SQL script is monitored, acquiring a script identifier of the failure SQL script; inquiring an operation control file corresponding to the fault SQL script according to the script identification; determining corresponding consumption characteristic values when executing each operation control file based on prestored calling resource occupation records; abnormal consumption proportion corresponding to the fault SQL script; if the abnormal consumption proportion is larger than a preset proportion threshold value, judging that the query factor sequence in the fault SQL script is abnormal; and if the consumption characteristic value is smaller than or equal to the preset proportion threshold, identifying the operation control file with the consumption characteristic value larger than the preset consumption threshold as a fault control file. The invention solves the problem that the fault response efficiency of the SQL script is reduced by the fault repair technology of the existing SQL script which relies on the professional knowledge of maintainers to carry out manual fault repair.

Description

SQL script fault repairing method and terminal thereof
Technical Field
The invention belongs to the technical field of databases, and particularly relates to a fault repairing method of an SQL script and a terminal thereof.
Background
The SQL script is a common means for data query and is widely applied to the field of network service, the data search strategy of each SQL script is mainly determined by the query factor sequence in the SQL script, and the database determines which kind of key words are searched first and then which kind of key words are searched when data is queried according to the sequence of each query factor in the query factor sequence in the SQL script, so that the operation efficiency and the service response speed of each query factor in the SQL script are directly determined by the sequencing of each query factor in the SQL script. On the other hand, in order to improve the efficiency of data query, a user can make an operation control file for each SQL script according to the search habit and the search purpose of the user, and the strategy comprises the operation times of the SQL script and the preset parameter values of each query factor in the SQL script when a call request is initiated, so that the purpose of one-key query is realized.
If a certain SQL script fails, the failure may be caused by an unreasonable arrangement order of the query factors in the SQL script or by an error in configuration of the operation control file corresponding to the SQL script. However, the existing fault repairing technology of the SQL script needs manual troubleshooting on the SQL script contained in the database one by one, the fault detection efficiency is low, and after the faulty SQL script is detected, the fault repairing is performed manually by depending on professional knowledge of maintenance personnel, so that the fault response efficiency of the SQL script is further reduced.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and a terminal for repairing a failure of an SQL script, so as to solve the problem that the existing failure repairing technology of the SQL script requires manual troubleshooting of the SQL scripts included in a database one by one, the failure detection efficiency is low, and after a failed SQL script is detected, manual failure repair is performed depending on professional knowledge of a maintainer, and the efficiency of responding to the failure of the SQL script is further reduced.
A first aspect of an embodiment of the present invention provides a method for repairing a fault of an SQL script, where the method for repairing a fault of an SQL script includes:
if a fault SQL script is monitored, acquiring a script identifier of the fault SQL script;
acquiring an operation control file corresponding to the fault SQL script according to the script identification; wherein the operation control file is specifically used for: determining the cycle times of executing the fault SQL script when the script calling terminal initiates a script calling operation each time, and determining the values taken by each query factor in the fault SQL script when the fault SQL script is executed in a cycle each time;
determining corresponding consumption characteristic values when executing each operation control file based on prestored calling resource occupation records; wherein, the consumption characteristic value is used for representing the occupation condition of the equipment resource when the operation control file is called;
acquiring the number of the consumption characteristic values of which the consumption characteristic values are larger than a preset consumption threshold value, and acquiring an abnormal consumption proportion corresponding to the fault SQL script;
if the abnormal consumption proportion is larger than a preset proportion threshold value, judging that the query factor sequence in the fault SQL script is abnormal, and adjusting the query factor sequence; the query factor sequence is specifically for: when a script calling terminal calls an SQL script to execute data query operation, determining the query sequence of each query factor according to the sequence of each query factor in the query factor sequence;
and if the abnormal consumption proportion is smaller than or equal to a preset proportion threshold, identifying the operation control file with the consumption characteristic value larger than the preset consumption threshold as a fault control file, and repairing the fault control file.
A second aspect of the embodiments of the present invention provides a terminal device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, where the processor implements the following steps when executing the computer program:
if a fault SQL script is monitored, acquiring a script identifier of the fault SQL script;
acquiring an operation control file corresponding to the fault SQL script according to the script identification; wherein the operation control file is specifically used for: determining the cycle times of executing the fault SQL script when the script calling terminal initiates a script calling operation each time, and determining the values taken by each query factor in the fault SQL script when the fault SQL script is executed in a cycle each time;
determining corresponding consumption characteristic values when executing each operation control file based on prestored calling resource occupation records; wherein, the consumption characteristic value is used for representing the occupation condition of the equipment resource when the operation control file is called;
acquiring the number of the consumption characteristic values of which the consumption characteristic values are larger than a preset consumption threshold value, and acquiring an abnormal consumption proportion corresponding to the fault SQL script;
if the abnormal consumption proportion is larger than a preset proportion threshold value, judging that the query factor sequence in the fault SQL script is abnormal, and adjusting the query factor sequence; the query factor sequence is specifically for: when a script calling terminal calls an SQL script to execute data query operation, determining the query sequence of each query factor according to the sequence of each query factor in the query factor sequence;
and if the abnormal consumption proportion is smaller than or equal to a preset proportion threshold, identifying the operation control file with the consumption characteristic value larger than the preset consumption threshold as a fault control file, and repairing the fault control file.
A third aspect of embodiments of the present invention provides a computer-readable storage medium storing a computer program which, when executed by a processor, implements the steps of:
if a fault SQL script is monitored, acquiring a script identifier of the fault SQL script;
acquiring an operation control file corresponding to the fault SQL script according to the script identification; wherein the operation control file is specifically used for: determining the cycle times of executing the fault SQL script when the script calling terminal initiates a script calling operation each time, and determining the values taken by each query factor in the fault SQL script when the fault SQL script is executed in a cycle each time;
determining corresponding consumption characteristic values when executing each operation control file based on prestored calling resource occupation records; wherein, the consumption characteristic value is used for representing the occupation condition of the equipment resource when the operation control file is called;
acquiring the number of the consumption characteristic values of which the consumption characteristic values are larger than a preset consumption threshold value, and acquiring an abnormal consumption proportion corresponding to the fault SQL script;
if the abnormal consumption proportion is larger than a preset proportion threshold value, judging that the query factor sequence in the fault SQL script is abnormal, and adjusting the query factor sequence; the query factor sequence is specifically for: when a script calling terminal calls an SQL script to execute data query operation, determining the query sequence of each query factor according to the sequence of each query factor in the query factor sequence;
and if the abnormal consumption proportion is smaller than or equal to a preset proportion threshold, identifying the operation control file with the consumption characteristic value larger than the preset consumption threshold as a fault control file, and repairing the fault control file.
The method for repairing the fault of the SQL script and the terminal thereof provided by the embodiment of the invention have the following beneficial effects:
the method and the device detect the operation condition of each SQL script through the terminal device, if the SQL script with the fault is monitored, the fault repairing process is started, the script identification corresponding to the SQL script with the fault is obtained, then the operation control file corresponding to the SQL script with the fault is inquired through the script identification, the calling strategy corresponding to the SQL script with the fault is determined when the database calls the SQL script with the fault, and then the fault is positioned because the SQL script or the relevant parameters in some operation control files are unreasonably set according to the consumption characteristic value corresponding to each operation control file. Therefore, after calculating the consumption characteristic values corresponding to the operation control files, the terminal device compares the consumption characteristic values with a preset consumption threshold value, determines the number of the consumption characteristic values larger than the preset consumption threshold value, and then determines the abnormal consumption proportion of the consumption characteristic values, if the abnormal consumption proportion is larger than the preset proportion threshold value, most of the operation control files are in abnormal consumption, so that the situation that the parameters in the operation control files are not unreasonably set but the SQL script has problems is shown, and abnormal consumption of the operation control files calling the SQL script is caused; on the contrary, if the abnormal consumption proportion is smaller than or equal to the preset proportion threshold, it indicates that only part of the operation control files have abnormal consumption, so that it can be determined that the SQL script is not abnormal, but the circulation parameters in the part of the operation control files are unreasonably set, and the abnormally consumed operation control files are repaired and adjusted. Therefore, the terminal equipment executes corresponding repairing operation by identifying the consumption abnormal cause of the fault SQL script, thereby improving the repairing accuracy. Compared with the existing fault repairing technology of the SQL script, the whole fault repairing process is automatically executed by the terminal equipment, and manual operation of a manager of the database is not needed, so that the fault repairing efficiency is improved. On the other hand, the fault repairing process does not depend on the professional skill level of the maintainer, and the terminal equipment can repair the fault SQL script through a corresponding repairing algorithm, so that the maintenance cost of the system is reduced.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without inventive exercise.
Fig. 1 is a flowchart illustrating an implementation of a method for repairing a failure in an SQL script according to a first embodiment of the present invention;
fig. 2 is a flowchart illustrating a specific implementation of the method S105 for repairing a failure of an SQL script according to the second embodiment of the present invention;
fig. 3 is a flowchart illustrating a specific implementation of the method S106 for repairing a failure of an SQL script according to a third embodiment of the present invention;
fig. 4 is a flowchart illustrating a specific implementation of the method S106 for repairing a failure of an SQL script according to a fourth embodiment of the present invention;
fig. 5 is a flowchart illustrating a specific implementation of the method S101 for repairing a failure of an SQL script according to a fifth embodiment of the present invention;
fig. 6 is a block diagram of a fault repairing terminal for an SQL script according to an embodiment of the present invention;
fig. 7 is a schematic diagram of a terminal device according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
The method and the device detect the operation condition of each SQL script through the terminal device, if the SQL script with the fault is monitored, the fault repairing process is started, the script identification corresponding to the SQL script with the fault is obtained, then the operation control file corresponding to the SQL script with the fault is inquired through the script identification, the calling strategy corresponding to the SQL script with the fault is determined when the database calls the SQL script with the fault, and then the fault is positioned because the SQL script or the relevant parameters in some operation control files are unreasonably set according to the consumption characteristic value corresponding to each operation control file. Therefore, after calculating the consumption characteristic values corresponding to the operation control files, the terminal device compares the consumption characteristic values with a preset consumption threshold value, determines the number of the consumption characteristic values larger than the preset consumption threshold value, and then determines the abnormal consumption proportion of the consumption characteristic values, if the abnormal consumption proportion is larger than the preset proportion threshold value, most of the operation control files are in abnormal consumption, so that the situation that the parameters in the operation control files are not unreasonably set but the SQL script has problems is shown, and abnormal consumption of the operation control files calling the SQL script is caused; on the contrary, if the abnormal consumption proportion is smaller than or equal to the preset proportion threshold, it indicates that only part of the operation control files have abnormal consumption, so that it can be determined that the SQL script is not abnormal, but the circulation parameters in the part of the operation control files are unreasonably set, and the abnormally consumed operation control files are repaired and adjusted. Therefore, the terminal equipment executes corresponding repair operation by identifying the consumption abnormal cause of the fault SQL script, thereby improving the repair accuracy, solving the problems that the existing fault repair technology of the SQL script needs manual troubleshooting on the SQL scripts contained in the database one by one, the fault detection efficiency is low, and after the fault SQL script is detected, the fault repair is carried out manually by depending on professional knowledge of maintenance personnel, and the fault response efficiency of the SQL script is further reduced.
In the embodiment of the invention, the execution subject of the flow is a fault repairing terminal of an SQL script, the terminal device comprises a mobile phone, a computer device, a tablet computer, a server and other terminals, and particularly, the terminal device is a fault repairing terminal of an SQL script distributed in a database system. Fig. 1 shows a flowchart of an implementation of a fault repairing method for an SQL script according to a first embodiment of the present invention, which is detailed as follows:
in S101, if a failed SQL script is monitored, a script identifier of the failed SQL script is obtained.
In this embodiment, the SQL script may run in a database of the terminal device, and in this case, the terminal device to be detected is the terminal device provided in the embodiment of the present invention, that is, whether each SQL script in the local database has an abnormal condition is detected; the SQL script may also be run in another database server outside the terminal device, in which case, the terminal device is an independent detection terminal to monitor whether the SQL script in the database server has an abnormal condition. Particularly, the terminal device can also detect a database system, wherein the database system comprises a plurality of database servers, and each database server extracts a corresponding SQL script from the same SQL script resource library to perform query operation. The SQL script resource library is stored with a plurality of SQL scripts and used for meeting the query requirements of different users, for example, if the users need to query data related to quarter bonus, the query is carried out by calling a first SQL script; and if the user needs to count the continuous guarantee condition of the car insurance client, the user queries by calling a second SQL script.
In this embodiment, the terminal device obtains the operating parameters of each SQL script in the database at a preset frequency or under a preset monitoring trigger condition, and determines whether a failed SQL script exists in the monitored SQL script according to a comparison between the operating parameters of each SQL script and a preset operating parameter threshold. If the SQL script with the fault is monitored, executing relevant operation of S101; otherwise, if the operation parameters of each SQL script are within the normal parameter range, the terminal device waits for the arrival of the next monitoring opportunity and repeatedly executes the steps.
In the embodiment, the trigger condition of the script monitoring comprises two modes of manual triggering and automatic triggering. Wherein, the manual trigger specifically is: the administrator generates a script monitoring starting instruction on the terminal device, or sends a script monitoring starting instruction to the terminal device through the user terminal, and if the terminal device receives the abnormality detection starting instruction, the terminal device executes the relevant operation of S101. The automatic triggering specifically comprises: the terminal device is provided with a script monitoring starting time, and if the terminal device detects that the current state is matched with the preset abnormal detection starting time, the relevant operation of S101 is executed.
In this embodiment, each SQL script corresponds to a script identifier, which is used as an identity identifier of each script. The script identification may be: the script identification code comprises a script name, a script unique identification code, a hash value corresponding to the script unique identification code, a script number and other characters or character strings with an identity identification function. When monitoring that a certain SQL script is a fault SQL script, the terminal equipment acquires a script identifier corresponding to the fault SQL script and performs information query in order to determine the relevant running condition and relevant information of the fault SQL script.
Optionally, the abnormality monitoring operation of the SQL script may be completed by other terminal equipment. In this case, when it is determined that the failed SQL script exists in the database, the abnormality monitoring terminal of the SQL script sends a failure repair request to the terminal device provided in the embodiment of the present invention, where the failure repair request includes a script identifier of the failed SQL script, and the failure repair request may include one failed SQL script or two or more failed SQL scripts. After receiving the fault repairing request sent by the abnormality monitoring terminal of the SQL script, the terminal device will execute the relevant operation of S101.
In S102, acquiring an operation control file corresponding to the fault SQL script according to the script identifier; wherein the operation control file is specifically used for: determining the cycle times of executing the fault SQL script when the script calling terminal initiates the script calling operation each time, and determining the values taken by each query factor in the fault SQL script when the fault SQL script is executed in a cycle each time.
In this embodiment, when each SQL script is actually called, the database executes a calling operation according to the execution control file corresponding to the SQL script. Because the SQL script only defines the included query factors and arranges the query factors in a certain order, the parameter value taken by each query factor and the number of times of circulation of each call are determined according to the content to be queried in the database. Therefore, in order to clarify the above content, the database generates an operation control file based on the SQL script, where the operation control file includes the number of cycles for executing the SQL script in one call operation, and the value taken by each query factor in each cycle operation.
For example, when a user calls an SQL script, the application proportions of the cantonese region and the Shenzhen region need to be compared, that is, the SQL script contains two query factors, namely "region" and "whether to apply". In order to realize the comparison of the application proportion of the two regions, the database generates an operation control file, the cycle number of the operation control file is 2, the query factor of the region is taken as Guangzhou during the first cycle, and the query factor of whether to apply the application is taken as YES, so that the application proportion of the Guangzhou region is obtained; and the query factor value of the 'region' is 'Shenzhen' and the query factor value of 'whether to be insured' is 'Yes' in the second circulation, so that the insurance proportion of the Shenzhen region is obtained, and the insurance conditions of the two regions can be compared according to the two coin-in proportions. Such as the above situation, when the database calls the first SQL script, the database often needs to cycle for multiple operations, and different values are given to each query factor in the SQL script.
In this embodiment, one failed SQL script may correspond to multiple operation control files, so as to implement different query functions of the database. And the terminal equipment acquires the running control file corresponding to the script identification from the running control file library through the script identification corresponding to the fault SQL script. It should be noted that one operation control file is generated based on one SQL script, that is, each operation control file only corresponds to one script identifier.
In S103, based on the pre-stored calling resource occupation record, determining corresponding consumption characteristic values when executing each operation control file; and the consumption characteristic value is used for representing the occupation condition of equipment resources when the operation control file is called.
In this embodiment, each time the terminal device executes the operation control file in the database, the corresponding consumption characteristic value is recorded, and then the pre-stored call resource occupation record is generated. After acquiring the operation control file corresponding to the failure SQL script, the terminal device queries the calling resource occupation record according to the file identifier corresponding to the operation control file, determines the number of times the operation control file is called and the consumption characteristic value corresponding to each calling, and then calculates the consumption characteristic value corresponding to the operation control file according to the consumption characteristic value corresponding to the calling for multiple times.
Optionally, in this embodiment, the called resource occupation record obtained by the terminal device is specifically an occupied resource record in the current monitoring period, and since it is determined that the failure SQL script has an abnormal state in the current monitoring period, that is, it indicates that a specific abnormal consumption condition also exists in the calling operation of the current monitoring period, the terminal device also only counts the consumption characteristic values corresponding to each operation control file in the current monitoring period, thereby reducing the operation amount of the statistics and improving the efficiency of fault repairing. Particularly, if part of the operation control file is not called in the current calling period, the corresponding consumption characteristic value is 0.
Optionally, in this embodiment, the calling occupation record records an operation state parameter corresponding to each time the database calls the operation control file, in this case, the terminal device imports the operation state parameter corresponding to each operation control file into a preset consumption characteristic value conversion model, and calculates to obtain a consumption characteristic value corresponding to each operation state parameter.
In S104, the number of consumption characteristic values of which the consumption characteristic values are greater than a preset consumption threshold is obtained, and an abnormal consumption proportion corresponding to the failed SQL script is obtained.
In this embodiment, the terminal device compares the consumption characteristic value corresponding to each operation control file with a preset consumption threshold, determines the number of consumption characteristic values of which the consumption characteristic values are greater than the preset consumption threshold, identifies the operation control file of which the consumption characteristic value is greater than the preset consumption threshold as a fault control file, and then obtains the abnormal consumption proportion corresponding to the fault SQL script according to the number of the fault control files and the total number of the operation control files.
For example, the failure SQL script corresponds to 10 operation control files, where a preset consumption threshold is 50%, and the terminal device detects that the consumption characteristic values of 4 operation control files are greater than 50%, identifies that the number of the failure control files is 4, and then obtains that the abnormal consumption ratio corresponding to the failure SQL script is 0.4.
Optionally, in this embodiment, the terminal device matches a corresponding consumption threshold for each operation control file, that is, when the terminal device executes the operation of S104, first identifies a file identifier of the operation control file, then queries the consumption threshold corresponding to the file identifier from a pre-stored standard consumption list of the operation file, compares a consumption characteristic value corresponding to the operation control file with the consumption threshold corresponding to the file identifier, and determines whether the operation control file is a failure control file. Specifically, in the running file standard consumption list, the consumption threshold corresponding to each running control file is an average consumption characteristic value of the running control file.
In this embodiment, after obtaining the abnormal consumption proportion, the terminal device compares the abnormal consumption proportion with a preset proportion threshold; if the abnormal consumption proportion is larger than the preset proportion threshold value, executing the relevant operation of S105; otherwise, if the abnormal consumption ratio is smaller than or equal to the preset ratio threshold, the relevant operation of S106 is executed.
In S105, if the abnormal consumption proportion is greater than a preset proportion threshold, determining that a query factor sequence in the failed SQL script is abnormal, and adjusting the query factor sequence; the query factor sequence is specifically for: and when the script calling terminal calls the SQL script to execute data query operation, determining the query sequence of each query factor according to the sequence of each query factor in the query factor sequence.
In this embodiment, if the terminal device determines that the abnormal consumption proportion is greater than the preset proportion threshold, it indicates that most of the operation control files in the failed SQL script are in an abnormal consumption condition, so that it can be determined that the failure condition is not an individual case, but a common characteristic of the operation control files based on the failed SQL script, and therefore the terminal device determines that the query factor sequence in the failed SQL script is abnormal, which results in that most of the operation control files generated based on the SQL script are in an abnormal consumption condition.
In this embodiment, the SQL script contains a query factor sequence composed of a plurality of query factors arranged in a certain order. When the database calls the SQL script, the database sequentially selects data corresponding to the parameter values of the query factors according to the sequence of the query factors in the query factor sequence.
For example, the first query factor with sequence number 1 is specifically "region", the corresponding parameter value of the query factor in the process of a certain query is "Shenzhen", and the second query factor with sequence number 2 is specifically "gender", and in the process of the certain query, the corresponding parameter value is "woman". Therefore, when the database calls the SQL script, the parameter values corresponding to the query factors of the current query are first imported into the SQL script, and the data matching the query factors are sequentially selected from the database. Firstly, a database queries data containing a parameter 'Shenzhen' to obtain a first query result; and selecting data with female gender from the first query result to obtain a second query result, and sequentially iterating the processes to obtain a final query result so as to complete one-time complete query operation.
Therefore, it can be seen that, when the first query result is obtained, the database needs to traverse all data to obtain the first query result, and when the query operation is performed for the second time, the corresponding data is selected again from the first query result. Therefore, if the data screening efficiency of the first query factor is low, the amount of data included in the first query result is large, the database server needs to store more caches for storing the first query result, and when the second query factor selects data, the amount of data bases corresponding to the second query factor is also large, so that the operation consumption is large, and therefore, although the query factor included in the SQL script is fixed, the operation efficiency of the SQL script is directly affected by different arrangements. Therefore, if the query factor sequence of the failed SQL script is determined to be abnormal, the query factor sequence needs to be adjusted, the query factor with higher data screening efficiency is arranged at the front position, and the query factor with lower data screening efficiency is arranged at the rear position, so that the query efficiency of the whole query factor sequence is the highest, and the query consumption is reduced.
In S106, if the abnormal consumption ratio is smaller than or equal to a preset ratio threshold, identifying the operation control file with the consumption characteristic value larger than the preset consumption threshold as a failure control file, and repairing the failure control file.
In this embodiment, when it is determined that the abnormal consumption proportion is smaller than or equal to the preset proportion threshold, the terminal device indicates that the abnormal consumption condition occurs only in a small part of the operation control files, that is, the SQL script itself is not abnormal, but a parameter of a certain part of the operation control files may be set incorrectly, so that the abnormal condition occurs, and therefore the terminal device performs fault recovery on the part of the operation control files with abnormal consumption.
In this embodiment, the terminal device identifies an operation control file with a consumption characteristic value greater than a preset consumption threshold value as a fault control file, and obtains a control parameter in each fault control file, where the control parameter includes: and the number of script circulation times and the value taken by each query factor in each circulation. And the terminal equipment respectively optimizes the operation parameters of each operation control file based on the control parameters and a preset repair algorithm so as to repair the fault control file.
Optionally, after S105 or S106, the terminal device further obtains an operation state parameter of the repaired failed SQL script, and determines whether the consumption condition of the SQL script is within a normal range, and if so, identifies that the repair is completed; if the consumption condition after the SQL script is repaired still exceeds the normal range, the related operation of the S103 is returned, the fault identification repairing operation is continuously executed until the number of times of return is greater than the preset threshold value, and the fault processing information is sent to the maintenance personnel corresponding to the database, so that the maintenance personnel can carry out manual repairing.
It can be seen from the above that, in the method for repairing a failure of an SQL script according to the embodiments of the present invention, a terminal device detects an operation condition of each SQL script, if a failed SQL script is monitored, a failure repair process is started to obtain a script identifier corresponding to the failed SQL script, then an operation control file corresponding to the failed SQL script is queried through the script identifier, a call policy corresponding to a database when the failed SQL script is called is determined, and then the failure is located due to the SQL script itself or due to an unreasonable setting of related parameters in some operation control files according to a consumption characteristic value corresponding to each operation control file. Therefore, after calculating the consumption characteristic values corresponding to the operation control files, the terminal device compares the consumption characteristic values with a preset consumption threshold value, determines the number of the consumption characteristic values larger than the preset consumption threshold value, and then determines the abnormal consumption proportion of the consumption characteristic values, if the abnormal consumption proportion is larger than the preset proportion threshold value, most of the operation control files are in abnormal consumption, so that the situation that the parameters in the operation control files are not unreasonably set but the SQL script has problems is shown, and abnormal consumption of the operation control files calling the SQL script is caused; on the contrary, if the abnormal consumption proportion is smaller than or equal to the preset proportion threshold, it indicates that only part of the operation control files have abnormal consumption, so that it can be determined that the SQL script is not abnormal, but the circulation parameters in the part of the operation control files are unreasonably set, and the abnormally consumed operation control files are repaired and adjusted. Therefore, the terminal equipment executes corresponding repairing operation by identifying the consumption abnormal cause of the fault SQL script, thereby improving the repairing accuracy. Compared with the existing fault repairing technology of the SQL script, the whole fault repairing process is automatically executed by the terminal equipment, and manual operation of a manager of the database is not needed, so that the fault repairing efficiency is improved. On the other hand, the fault repairing process does not depend on the professional skill level of the maintainer, and the terminal equipment can repair the fault SQL script through a corresponding repairing algorithm, so that the maintenance cost of the system is reduced.
Fig. 2 shows a flowchart of a specific implementation of the method S105 for repairing a failure of an SQL script according to the second embodiment of the present invention. Referring to fig. 2, with respect to the embodiment described in fig. 1, S105 in the method for repairing a failure of an SQL script according to this embodiment further includes S201 and S204, which are detailed as follows:
further, the judging that the query factor sequence in the fault SQL script is abnormal and adjusting the query factor sequence comprise
In S201, according to each query factor included in the query factor sequence in the failure SQL script, a parameter value taken by the query factor in each data in the database is obtained.
In this embodiment, the terminal device determines a parameter value taken by the query factor in each data in the database according to each query factor included in the query factor sequence, and then determines how many different parameter values the query factor includes in the database, so as to obtain the number of corresponding parameter values.
For example, a certain query factor is "region", a certain part of data "region" takes a value of "guangzhou", a certain part of data "region" takes a value of "shenzhen", a certain part of data "region" takes a value of "hong kong", and a remaining part of data "region" takes a value of "australian door", so that the "region" query factor includes 4 different parameter values in the database, that is, the number of corresponding parameter values is 4. And if the query factor is 'gender', the number of the corresponding parameter values can be determined to be 2, namely the value is 'male' or 'female'. Therefore, it can be seen that the query factors with larger number of parameter values have higher corresponding data screening efficiency, and still by using the above example, the "region" query factor can screen one fourth of data from the database on average, while the "gender" query factor can screen only one half of data from the database.
In S202, counting the number of parameter values of each query factor, and calculating the discrimination corresponding to each query factor according to the number of the parameter values; and the discrimination is used for expressing the screening efficiency of the query factor on the data in the database.
In this embodiment, after obtaining the number of parameter values corresponding to each query factor, the terminal device imports the number of parameter values into a preset discrimination conversion model, so as to calculate the discrimination corresponding to each query factor. The larger the number of the parameter values is, the larger the corresponding discrimination is. Since the discrimination is used to represent the screening efficiency of the query factor on the data in the database, it can be determined by the explanation in S201 that the higher the screening efficiency of the number of parameter values is, the larger the corresponding discrimination is.
It should be noted that the number of parameter values and the degree of distinction of each query factor are relative to a certain database, and are relative eigenvalues. That is, the number of parameter values of a certain query factor in the first database is 5, but the number of parameter values in the other database may be 9, that is, the other database contains more different values. Likewise, discrimination also has this feature. Since the number of parameter values and the degree of distinction of the query factor are equivalent to those of a certain database, if the data contained in the database is changed, the degree of distinction and the number of parameter values corresponding to the query factor are also affected. For example, if data is added to the database, data is deleted, or a part of data is replaced, the types of parameter values included in the query factors in the database may be changed, so that the number and the degree of distinction of the parameter values of each query factor are changed. Therefore, the SQL script is abnormal, and the query factor sequence in the SQL script is not adjusted according to the update of the data in the database.
Optionally, the discriminations of the respective query factors may be calculated by a discriminative calculation model, which is:
Figure BDA0001459864660000151
wherein S (x) is the discrimination of the query factor, Q (x) is the number of parameter values of the query factor, f (x) is the data coverage of the query factor, and f (x) is the data coverage of the query factorGeneral assemblyFor the total amount of data contained in the database, said fxIs the amount of data that contains the query factor.
In S203, based on the numerical values of the discrimination corresponding to the respective query factors, the query factors are sequentially arranged from large to small, and a standard query factor sequence is generated.
In this embodiment, after obtaining the differentiation degrees corresponding to the query factors, the terminal devices are sequentially arranged from large to small according to the numerical values of the differentiation degrees, since the standard query factor sequence is generated. The query factors with larger discrimination have the higher serial numbers, and conversely, the query factors with smaller discrimination have the lower serial numbers.
Optionally, if the corresponding discrimination values of two or more query factors are the same, the relative positions between the query factors may be arranged arbitrarily, for example, the discrimination corresponding to the query factors a to F are: 8. 12, 8, 5, 8, 6, the adjusted standard query factor sequence may be: BACEFD, BAECFD, or BECAFD, as long as the AEC's three query factors are ranked behind B and before FD. The terminal equipment can also set the arrangement sequence among the query factors according to the number of the parameter values of the query factors with the same discrimination. Still by the above example, the corresponding degrees of distinction of the query factors ACE are all 8, but the number of parameter values of a is 7, the number of parameter values of C is 9, and the number of parameter values of E is 6, then the relative ordering among the three may be: and (4) CAE.
In S204, the standard query factor sequence is substituted for the query factor sequence in the failed SQL script.
In this embodiment, the terminal device sequentially arranges the values from small to large according to the discrimination corresponding to each query factor to obtain a standard query factor sequence, and uses the standard query factor sequence as the query factor sequence of the SQL script, thereby repairing the failed SQL script and improving the query efficiency.
In this embodiment, if some query factors in the query factor sequence of the failed SQL script fix corresponding parameter values, after the terminal device succeeds in replacing, the fixed parameter values corresponding to the query factors are configured in the standard query factor sequence, so as to keep the query policies of the repaired SQL script consistent.
In the embodiment of the invention, the query factor sequence with the highest data screening efficiency is generated according to the discrimination corresponding to each query factor in the query factor sequence, and the query factor sequence is replaced by the query factor sequence of the fault SQL script, so that the resource occupation condition when the database calls the operation control file generated based on the SQL script is reduced, the fault SQL script is repaired, and the fault repairing accuracy is improved.
Fig. 3 is a flowchart illustrating a specific implementation of S106 in the method for repairing a failure of an SQL script according to the third embodiment of the present invention. Referring to fig. 3, with respect to the embodiment shown in fig. 1, in the fault repairing method of the SQL script provided in this embodiment, S106 includes S301 to S302, which are specifically detailed as follows:
further, the identifying that the operation control file with the consumption characteristic value larger than the preset consumption threshold value is a failure control file, and repairing the failure control file includes:
in S301, a control parameter change record corresponding to the failure control file is acquired.
In this embodiment, the terminal device may further record a control parameter change record of each operation control file. The control parameter change record records information such as parameters, a change creator, change time and the like of the operation control file change, so that a user can know the use condition of the operation control file through the change record, whether an unauthorized user changes the operation control file or not exists, and a management account of the database can restore the operation control file to a corresponding version at any time according to the control parameter change record.
In this embodiment, since the consumption abnormality of the fault control file is determined only in the current monitoring period, that is, the fault control file can still be normally called by the database before the monitoring period, it can be determined that the fault control file is modified by a part of users near the monitoring period, and therefore the fault control file can be repaired by restoring the corresponding control parameter in the fault control file, and therefore the control parameter change record corresponding to the fault control file is obtained, and the related operation of S302 is executed.
In S302, according to the reverse order of the creation time of the control parameter change record, the change contents included in the control parameter change record are successively restored, and the consumption characteristic value corresponding to the fault control file is monitored until the consumption characteristic value corresponding to the fault operation policy is less than or equal to the preset consumption threshold value.
In this embodiment, the terminal device restores the changed content in one control parameter change record each time according to the reverse order of the creation time of each control parameter change record, so as to gradually restore the faulty operation control file to the normal range, thereby repairing the fault condition.
In this embodiment, after restoring each change content, the terminal device obtains a restored fault control file that is simulated to run once, obtains a running state parameter of the database when the fault control file is run, calculates a corresponding consumption characteristic value according to the running state parameter, and terminates the relevant operation of S302 if the consumption characteristic value is less than or equal to a preset consumption threshold value, indicating that the abnormal condition has been successfully repaired; otherwise, if the first consumption characteristic value is still larger than the preset consumption threshold value, the next modified content is restored, and the operation is repeatedly executed.
In the embodiment of the invention, the terminal equipment restores the abnormal operation control script by restoring the changed content in the fault control file, thereby restoring the automatic fault condition and improving the processing efficiency and the response speed of the abnormality.
Fig. 4 is a flowchart illustrating a specific implementation of the method S106 for repairing a failure in an SQL script according to a fourth embodiment of the present invention. Referring to fig. 4, with respect to the embodiment described in fig. 1, in the method for repairing a failure of an SQL script provided in this embodiment, S106 includes S401 and S402, which are detailed as follows:
further, the identifying that the operation control file with the consumption characteristic value larger than the preset consumption threshold value is a failure control file, and repairing the failure control file includes:
in S401, the operation control file with the minimum consumption characteristic value is selected as the preferred operation file.
In this embodiment, the terminal device may perform fault repair by restoring the changed content of the fault control file, and may also extend the corresponding operation parameter value in the better operation control file to the fault operation file, so as to achieve the purpose of optimizing the control parameter of the fault control file. Therefore, the terminal device first needs to determine a preferred run file corresponding to the failed SQL script.
In this embodiment, the terminal device selects the operation control file with the smallest consumption characteristic value as the preferred operation file, and the smaller the consumption, the highest search efficiency is indicated when the operation control file is operated by the database. Of course, the terminal device may also select the preferred operation file according to other determination rules, for example, by selecting the operation control file with the minimum operation time of each cycle as the preferred operation file; and selecting the operation control file with the minimum memory and CPU consumption for each query operation as the preferred control file. The terminal equipment can select the operation state parameters concerned by the monitoring mode as the judgment conditions for identifying the preferred operation files according to different monitoring modes. Alternatively, the selected operating condition parameter may be two or more condition operating parameters.
In S402, the cycle number and the parameter value of each query factor included in the preferred operation file are applied to the fault control file.
In this embodiment, the terminal device obtains the control parameters, including the cycle number and the values obtained by each query factor, included in the preferred running file, and modifies the fault control file according to the two parameters, so as to repair the fault condition of the fault control file. Specifically, the applying to the fault control file is that the terminal device replaces the control parameter in the fault control file with the control parameter in the preferred running file.
In the embodiment of the invention, the terminal equipment realizes the purpose of repairing the fault by determining the preferred operation file and applying the corresponding operation control parameters in the preferred operation file to the fault control file, thereby improving the accuracy of fault repair.
Fig. 5 shows a flowchart of a specific implementation of the method S101 for repairing a failure of an SQL script according to a fifth embodiment of the present invention. Referring to fig. 5, in comparison with the embodiments shown in fig. 1 to 4, in the method for repairing a failure of an SQL script provided in this embodiment, if a failed SQL script is monitored, the script identifier of the failed SQL script is obtained, which includes S501 to S503, and is described in detail as follows:
further, if the failed SQL script is monitored, acquiring the script identifier of the failed SQL script includes:
in S501, the running state parameters of each SQL script are acquired.
In the present embodiment, the trigger conditions for anomaly detection include two modes, manual trigger and automatic trigger. Wherein, the manual trigger specifically is: the administrator generates an abnormality detection start instruction on the terminal device, or sends an abnormality detection start instruction to the terminal device through the user terminal, and the terminal device executes the relevant operation of S501 after receiving the abnormality detection start instruction. The automatic triggering specifically comprises: the terminal device sets an abnormality detection start time, and if the terminal device detects that the current state matches the preset abnormality detection start time, the relevant operation of S501 is executed.
Optionally, in this implementation, the time for starting the anomaly detection may be a preset detection period, and when the terminal device monitors that the current time meets the detection period, the terminal device executes the relevant operation of S501. The abnormal detection starting time may also be an operation consumption threshold, for example, a resource occupancy rate, and if the terminal device monitors that the operation consumption value of the terminal to be detected at the current time is greater than or equal to the preset operation consumption threshold, the relevant operation of S501 is executed. Because the consumption of the equipment is overlarge, generally caused by the abnormality of the SQL script, the unnecessary detection process can be reduced by using the consumption running condition as the trigger condition compared with the periodic trigger mode, and the resource utilization rate of the equipment is improved.
In S502, importing the operating state parameters of the SQL scripts into a preset consumption level conversion model, and calculating the consumption levels corresponding to the SQL scripts; and the consumption level is used for expressing the occupation condition of the equipment resources when the SQL script is called.
In this embodiment, after acquiring the running state parameters of each SQL script, the terminal device acquires the consumption condition of the SQL script according to each running state parameter, so that a plurality of parameter values included in the running state parameters corresponding to the SQL script are imported into a preset consumption feature conversion model, so as to calculate the consumption level corresponding to the SQL script through the running state parameters, and characterize the consumption condition of the SQL script through the consumption level.
Optionally, the preset consumption characteristic value conversion model specifically includes:
Ex=α1Ct(SQL)+α2T(SQL)+α3Buff(SQL)+α4Q(SQL)
wherein Ex is the first consumption characteristic value of SQL script, alpha1、α2、α3And alpha4The weighted value corresponding to each operating state parameter, ct (SQL) is an operating resource occupation parameter of the SQL script, t (SQL) is an average operating time parameter of the SQL script, buf (SQL) is a memory occupation parameter of the SQL script, and q (SQL) is the operating frequency of the SQL script.
In S503, the SQL script with the consumption level greater than the preset level threshold is selected as the failed SQL script.
In this embodiment, after calculating the consumption levels corresponding to the SQL scripts, the terminal device compares the consumption levels with a preset level threshold, and if the consumption level corresponding to a certain SQL script is less than or equal to the preset level threshold, it indicates that the consumption condition of the SQL script is in a normal state, and identifies the SQL script as a normal SQL script; on the contrary, if the consumption level corresponding to a certain SQL script is greater than the preset level threshold, it indicates that the consumption condition of the SQL script exceeds the normal range and is in the abnormal consumption SQL script, and therefore the SQL script is the failed SQL script. And the terminal equipment extracts the fault SQL script determined by the detection from the SQL script resource library and repairs the fault.
In the embodiment of the invention, the terminal equipment converts the operation state parameters of each SQL into the corresponding consumption levels and compares the consumption levels with the preset consumption threshold value so as to determine whether the SQL script is the fault SQL script or not, and the fault self-detection of the fault SQL script is realized, so that the manual intervention is reduced, and the fault repairing efficiency is improved.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by its function and inherent logic, and should not constitute any limitation to the implementation process of the embodiments of the present invention.
Fig. 6 shows a structural block diagram of a fault repairing terminal of an SQL script according to an embodiment of the present invention, where the fault repairing terminal of the SQL script includes units for executing steps in the embodiment corresponding to fig. 1. Please refer to fig. 1 and fig. 1 for the corresponding description of the embodiment. For convenience of explanation, only the portions related to the present embodiment are shown.
Referring to fig. 6, the fault repairing terminal of the SQL script includes:
the script identifier obtaining unit 61 is configured to obtain a script identifier of a failed SQL script if the failed SQL script is monitored;
an operation control file obtaining unit 62, configured to obtain, according to the script identifier, an operation control file corresponding to the failed SQL script; wherein the operation control file is specifically used for: determining the cycle times of executing the fault SQL script when the script calling terminal initiates a script calling operation each time, and determining the values taken by each query factor in the fault SQL script when the fault SQL script is executed in a cycle each time;
a consumption characteristic value obtaining unit 63, configured to determine, based on a pre-stored calling resource occupation record, a corresponding consumption characteristic value when each operation control file is executed; wherein, the consumption characteristic value is used for representing the occupation condition of the equipment resource when the operation control file is called;
an abnormal consumption proportion determining unit 64, configured to obtain the number of consumption characteristic values of which the consumption characteristic values are greater than a preset consumption threshold, and obtain an abnormal consumption proportion corresponding to the failed SQL script;
a query factor sequence repairing unit 65, configured to determine that a query factor sequence in the failed SQL script is abnormal if the abnormal consumption proportion is greater than a preset proportion threshold, and adjust the query factor sequence; the query factor sequence is specifically for: when a script calling terminal calls an SQL script to execute data query operation, determining the query sequence of each query factor according to the sequence of each query factor in the query factor sequence;
and a fault control file repairing unit 66, configured to, if the abnormal consumption proportion is less than or equal to a preset proportion threshold, identify the operation control file with the consumption characteristic value greater than the preset consumption threshold as a fault control file, and repair the fault control file.
Optionally, the query factor sequence repairing unit 65 further includes:
the query factor counting unit is used for acquiring the parameter value of the query factor in each data in the database according to each query factor contained in the query factor sequence in the fault SQL script;
the discrimination calculation unit is used for counting the number of the parameter values of each query factor and calculating the discrimination corresponding to each query factor according to the number of the parameter values; the discrimination is used for expressing the screening efficiency of the query factor on the data in the database;
the standard query factor sequence determining unit is used for sequentially arranging the values of the discrimination degrees corresponding to the query factors from large to small to generate a standard query factor sequence;
and the query factor sequence adjusting unit is used for replacing the standard query factor sequence with the query factor sequence in the fault SQL script.
Optionally, the failure control file repairing unit 66 includes:
a parameter change record obtaining unit, configured to obtain a control parameter change record corresponding to the fault control file;
and the change content restoration unit is used for gradually restoring the change content contained in the control parameter change record according to the reverse order of the creation time of the control parameter change record, and monitoring the consumption characteristic value corresponding to the fault control file until the consumption characteristic value corresponding to the fault operation strategy is less than or equal to a preset consumption threshold value.
Optionally, the failure control file repairing unit 66 includes:
the preferred operation file selecting unit is used for selecting the operation control file with the minimum consumption characteristic value as a preferred operation file;
and the preferred operation file popularization unit is used for applying the cycle times and the parameter values of the query factors contained in the preferred operation files to the fault control files.
Optionally, the script identification obtaining unit 61 includes:
the operation state parameter acquisition unit is used for acquiring the operation state parameters of each SQL script;
the consumption level calculation unit is used for importing the running state parameters of the SQL scripts into a preset consumption level conversion model and calculating the consumption level corresponding to each SQL script; the consumption level is used for expressing the occupation condition of equipment resources when the SQL script is called;
and the failure SQL script monitoring unit is used for selecting the SQL script with the consumption level larger than a preset level threshold value as a failure SQL script.
Therefore, the fault repairing terminal of the SQL script provided in the embodiment of the present invention may also detect the operation status of each SQL script through the terminal device, if the SQL script with the fault is monitored, start the fault repairing process, obtain the script identifier corresponding to the SQL script with the fault, then query the operation control file corresponding to the SQL script with the fault through the script identifier, determine the calling policy corresponding to the SQL script with the fault being called by the database, and then locate, according to the consumption characteristic value corresponding to each operation control file, whether the fault is caused by the SQL script itself or caused by unreasonable setting of related parameters in some operation control files. Therefore, after calculating the consumption characteristic values corresponding to the operation control files, the terminal device compares the consumption characteristic values with a preset consumption threshold value, determines the number of the consumption characteristic values larger than the preset consumption threshold value, and then determines the abnormal consumption proportion of the consumption characteristic values, if the abnormal consumption proportion is larger than the preset proportion threshold value, most of the operation control files are in abnormal consumption, so that the situation that the parameters in the operation control files are not unreasonably set but the SQL script has problems is shown, and abnormal consumption of the operation control files calling the SQL script is caused; on the contrary, if the abnormal consumption proportion is smaller than or equal to the preset proportion threshold, it indicates that only part of the operation control files have abnormal consumption, so that it can be determined that the SQL script is not abnormal, but the circulation parameters in the part of the operation control files are unreasonably set, and the abnormally consumed operation control files are repaired and adjusted. Therefore, the terminal equipment executes corresponding repair operation by identifying the consumption abnormal cause of the fault SQL script, thereby improving the repair accuracy, solving the problems that the existing fault repair technology of the SQL script needs manual troubleshooting on the SQL scripts contained in the database one by one, the fault detection efficiency is low, and after the fault SQL script is detected, the fault repair is carried out manually by depending on professional knowledge of maintenance personnel, and the fault response efficiency of the SQL script is further reduced.
Fig. 7 is a schematic diagram of a terminal device according to another embodiment of the present invention. As shown in fig. 7, the terminal device 7 of this embodiment includes: a processor 70, a memory 71, and a computer program 72, such as a SQL script bug fix program, stored in the memory 71 and operable on the processor 70. The processor 70, when executing the computer program 72, implements the steps in the above-described embodiments of the fault repairing method for the SQL script, such as S101 to S106 shown in fig. 1. Alternatively, the processor 70, when executing the computer program 72, implements the functions of the units in the above-described device embodiments, such as the functions of the modules 61 to 66 shown in fig. 6.
Illustratively, the computer program 72 may be divided into one or more units, which are stored in the memory 71 and executed by the processor 70 to accomplish the present invention. The one or more units may be a series of computer program instruction segments capable of performing specific functions, which are used to describe the execution process of the computer program 72 in the terminal device 7. For example, the computer program 72 may be divided into a script identifier obtaining unit, an operation control file obtaining unit, a consumption characteristic value obtaining unit, an abnormal consumption ratio determining unit, a query factor sequence repairing unit, and a fault control file repairing unit, where the specific functions of each unit are as follows:
the script identification obtaining unit is used for obtaining the script identification of the fault SQL script if the fault SQL script is monitored;
the running control file acquisition unit is used for acquiring a running control file corresponding to the fault SQL script according to the script identifier; wherein the operation control file is specifically used for: determining the cycle times of executing the fault SQL script when the script calling terminal initiates a script calling operation each time, and determining the values taken by each query factor in the fault SQL script when the fault SQL script is executed in a cycle each time;
the consumption characteristic value acquisition unit is used for determining corresponding consumption characteristic values when executing each operation control file based on the prestored calling resource occupation records; wherein, the consumption characteristic value is used for representing the occupation condition of the equipment resource when the operation control file is called;
an abnormal consumption proportion determining unit, configured to obtain the number of consumption characteristic values of which the consumption characteristic values are greater than a preset consumption threshold value, and obtain an abnormal consumption proportion corresponding to the failed SQL script;
the query factor sequence repairing unit is used for judging that the query factor sequence in the fault SQL script is abnormal if the abnormal consumption proportion is larger than a preset proportion threshold value, and adjusting the query factor sequence; the query factor sequence is specifically for: when a script calling terminal calls an SQL script to execute data query operation, determining the query sequence of each query factor according to the sequence of each query factor in the query factor sequence;
and the fault control file repairing unit is used for identifying the operation control file with the consumption characteristic value larger than the preset consumption threshold value as a fault control file and repairing the fault control file if the abnormal consumption proportion is smaller than or equal to the preset proportion threshold value.
The terminal device 7 may be a desktop computer, a notebook, a palm computer, a cloud server, or other computing devices. The terminal device may include, but is not limited to, a processor 70, a memory 71. It will be appreciated by those skilled in the art that fig. 7 is merely an example of a terminal device 7 and does not constitute a limitation of the terminal device 7 and may comprise more or less components than shown, or some components may be combined, or different components, for example the terminal device may further comprise input output devices, network access devices, buses, etc.
The Processor 70 may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic, discrete hardware components, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 71 may be an internal storage unit of the terminal device 7, such as a hard disk or a memory of the terminal device 7. The memory 71 may also be an external storage device of the terminal device 7, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like, which are provided on the terminal device 7. Further, the memory 71 may also include both an internal storage unit and an external storage device of the terminal device 7. The memory 71 is used for storing the computer program and other programs and data required by the terminal device. The memory 71 may also be used to temporarily store data that has been output or is to be output.
In addition, functional units in the embodiments of the present invention may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as separate products, may be stored in a computer readable storage medium. Based on such understanding, all or part of the flow of the method according to the embodiments of the present invention may also be implemented by a computer program, which may be stored in a computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method embodiments may be implemented. . Wherein the computer program comprises computer program code, which may be in the form of source code, object code, an executable file or some intermediate form, etc. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, usb disk, removable hard disk, magnetic disk, optical disk, computer Memory, Read-Only Memory (ROM), Random Access Memory (RAM), electrical carrier wave signals, telecommunications signals, software distribution medium, and the like. It should be noted that the computer readable medium may contain content that is subject to appropriate increase or decrease as required by legislation and patent practice in jurisdictions, for example, in some jurisdictions, computer readable media does not include electrical carrier signals and telecommunications signals as is required by legislation and patent practice.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (10)

1. A fault repairing method of an SQL script is characterized by comprising the following steps:
if a fault SQL script is monitored, acquiring a script identifier of the fault SQL script;
acquiring an operation control file corresponding to the fault SQL script according to the script identification; wherein the operation control file is specifically used for: determining the cycle times of executing the fault SQL script when the script calling terminal initiates a script calling operation each time, and determining the values taken by each query factor in the fault SQL script when the fault SQL script is executed in a cycle each time;
determining corresponding consumption characteristic values when executing each operation control file based on prestored calling resource occupation records; wherein, the consumption characteristic value is used for representing the occupation condition of the equipment resource when the operation control file is called;
acquiring the number of the consumption characteristic values of which the consumption characteristic values are larger than a preset consumption threshold value, and acquiring an abnormal consumption proportion corresponding to the fault SQL script;
if the abnormal consumption proportion is larger than a preset proportion threshold value, judging that the query factor sequence in the fault SQL script is abnormal, and adjusting the query factor sequence; the query factor sequence is specifically for: when a script calling terminal calls an SQL script to execute data query operation, determining the query sequence of each query factor according to the sequence of each query factor in the query factor sequence;
and if the abnormal consumption proportion is smaller than or equal to a preset proportion threshold, identifying the operation control file with the consumption characteristic value larger than the preset consumption threshold as a fault control file, and repairing the fault control file.
2. The method according to claim 1, wherein the determining that the query factor sequence in the failed SQL script is abnormal and adjusting the query factor sequence comprises:
acquiring a parameter value acquired by the query factor in each data in the database according to each query factor contained in the query factor sequence in the fault SQL script;
counting the number of parameter values of each query factor, and calculating the discrimination corresponding to each query factor according to the number of the parameter values; the discrimination is used for expressing the screening efficiency of the query factor on the data in the database;
based on the numerical values of the discrimination corresponding to the query factors, sequentially arranging the numerical values from big to small to generate a standard query factor sequence;
and replacing the query factor sequence in the fault SQL script by the standard query factor sequence.
3. The method according to claim 1, wherein the identifying the operation control file with the consumption characteristic value greater than the preset consumption threshold value as a fault control file, and repairing the fault control file comprises:
acquiring a control parameter change record corresponding to the fault control file;
and gradually restoring the change content contained in the control parameter change record according to the reverse order of the creation time of the control parameter change record, and monitoring the consumption characteristic value corresponding to the fault control file until the consumption characteristic value corresponding to the fault control file is less than or equal to a preset consumption threshold value.
4. The method according to claim 1, wherein the identifying the operation control file with the consumption characteristic value greater than the preset consumption threshold value as a fault control file, and repairing the fault control file comprises:
selecting the operation control file with the minimum consumption characteristic value as an optimal operation file;
and applying the cycle times contained in the preferred operation file and the parameter values of all the query factors to the fault control file.
5. The fault repairing method according to any one of claims 1 to 4, wherein the obtaining of the script identifier of the failed SQL script if the failed SQL script is monitored comprises:
acquiring running state parameters of each SQL script;
importing the running state parameters of the SQL scripts into a preset consumption level conversion model, and calculating the consumption level corresponding to each SQL script; the consumption level is used for expressing the occupation condition of equipment resources when the SQL script is called;
and selecting the SQL script with the consumption level larger than a preset level threshold value as a fault SQL script.
6. A terminal device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, the processor implementing the following steps when executing the computer program:
if a fault SQL script is monitored, acquiring a script identifier of the fault SQL script;
acquiring an operation control file corresponding to the fault SQL script according to the script identification; wherein the operation control file is specifically used for: determining the cycle times of executing the fault SQL script when the script calling terminal initiates a script calling operation each time, and determining the values taken by each query factor in the fault SQL script when the fault SQL script is executed in a cycle each time;
determining corresponding consumption characteristic values when executing each operation control file based on prestored calling resource occupation records; wherein, the consumption characteristic value is used for representing the occupation condition of the equipment resource when the operation control file is called;
acquiring the number of the consumption characteristic values of which the consumption characteristic values are larger than a preset consumption threshold value, and acquiring an abnormal consumption proportion corresponding to the fault SQL script;
if the abnormal consumption proportion is larger than a preset proportion threshold value, judging that the query factor sequence in the fault SQL script is abnormal, and adjusting the query factor sequence; the query factor sequence is specifically for: when a script calling terminal calls an SQL script to execute data query operation, determining the query sequence of each query factor according to the sequence of each query factor in the query factor sequence;
and if the abnormal consumption proportion is smaller than or equal to a preset proportion threshold, identifying the operation control file with the consumption characteristic value larger than the preset consumption threshold as a fault control file, and repairing the fault control file.
7. The terminal device according to claim 6, wherein the determining that the query factor sequence in the failed SQL script is abnormal and adjusting the query factor sequence comprises:
acquiring a parameter value acquired by the query factor in each data in the database according to each query factor contained in the query factor sequence in the fault SQL script;
counting the number of parameter values of each query factor, and calculating the discrimination corresponding to each query factor according to the number of the parameter values; the discrimination is used for expressing the screening efficiency of the query factor on the data in the database;
based on the numerical values of the discrimination corresponding to the query factors, sequentially arranging the numerical values from big to small to generate a standard query factor sequence;
and replacing the query factor sequence in the fault SQL script by the standard query factor sequence.
8. The terminal device according to claim 6, wherein the identifying that the operation control file with the consumption characteristic value greater than the preset consumption threshold value is a failure control file, and repairing the failure control file comprises:
acquiring a control parameter change record corresponding to the fault control file;
and gradually restoring the change content contained in the control parameter change record according to the reverse order of the creation time of the control parameter change record, and monitoring the consumption characteristic value corresponding to the fault control file until the consumption characteristic value corresponding to the fault control file is less than or equal to a preset consumption threshold value.
9. The terminal device according to claim 6, wherein the identifying that the operation control file with the consumption characteristic value greater than the preset consumption threshold value is a failure control file, and repairing the failure control file comprises:
selecting the operation control file with the minimum consumption characteristic value as an optimal operation file;
and applying the cycle times contained in the preferred operation file and the parameter values of all the query factors to the fault control file.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the method according to any one of claims 1 to 5.
CN201711084967.2A 2017-11-07 2017-11-07 SQL script fault repairing method and terminal thereof Active CN108255703B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711084967.2A CN108255703B (en) 2017-11-07 2017-11-07 SQL script fault repairing method and terminal thereof

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711084967.2A CN108255703B (en) 2017-11-07 2017-11-07 SQL script fault repairing method and terminal thereof

Publications (2)

Publication Number Publication Date
CN108255703A CN108255703A (en) 2018-07-06
CN108255703B true CN108255703B (en) 2020-01-14

Family

ID=62722120

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711084967.2A Active CN108255703B (en) 2017-11-07 2017-11-07 SQL script fault repairing method and terminal thereof

Country Status (1)

Country Link
CN (1) CN108255703B (en)

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109376025A (en) * 2018-09-03 2019-02-22 平安普惠企业管理有限公司 Abnormality eliminating method, device, computer equipment and storage medium
CN110222071B (en) * 2019-06-06 2021-11-02 上海达梦数据库有限公司 Data query method, device, server and storage medium
CN112131035B (en) * 2020-09-29 2024-06-25 河北科技师范学院 Self-service computer obstacle removing system
CN112783867A (en) * 2021-01-29 2021-05-11 李阳 Database optimization method for meeting real-time big data service requirements and cloud server

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101789002A (en) * 2010-01-22 2010-07-28 浪潮(北京)电子信息产业有限公司 Database compatibility test device and method for server
CN104363236A (en) * 2014-11-21 2015-02-18 西安邮电大学 Automatic vulnerability validation method
CN104503880A (en) * 2014-12-16 2015-04-08 新余兴邦信息产业有限公司 Method and device for realizing MySQL database monitoring option script

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7136868B2 (en) * 2003-06-06 2006-11-14 Microsoft Corporation Database object script generation method and system

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101789002A (en) * 2010-01-22 2010-07-28 浪潮(北京)电子信息产业有限公司 Database compatibility test device and method for server
CN104363236A (en) * 2014-11-21 2015-02-18 西安邮电大学 Automatic vulnerability validation method
CN104503880A (en) * 2014-12-16 2015-04-08 新余兴邦信息产业有限公司 Method and device for realizing MySQL database monitoring option script

Also Published As

Publication number Publication date
CN108255703A (en) 2018-07-06

Similar Documents

Publication Publication Date Title
CN109857592B (en) Data recovery control method, server and storage medium
CN110178121B (en) Database detection method and terminal thereof
CN107451040B (en) Method and device for positioning fault reason and computer readable storage medium
CN111736875A (en) Version update monitoring method, device, device and computer storage medium
CN108255703B (en) SQL script fault repairing method and terminal thereof
CN109586952B (en) Server capacity expansion method and device
CN109543891B (en) Method and apparatus for establishing capacity prediction model, and computer-readable storage medium
CN107783829B (en) Task processing method and device, storage medium and computer equipment
CN110618890A (en) Fault processing method and device, electronic equipment and computer readable storage medium
CN111966515A (en) Business abnormal data processing method and device, computer equipment and storage medium
CN114221807A (en) Access request processing method, device, monitoring device and storage medium
CN113297149A (en) Method and device for monitoring data processing request
CN110674149B (en) Service data processing method and device, computer equipment and storage medium
CN113220540A (en) Service management method, device, computer equipment and storage medium
US20250238303A1 (en) Interactive data processing system failure management using hidden knowledge from predictive models
US20250238306A1 (en) Interactive data processing system failure management using hidden knowledge from predictive models
CN114595127B (en) Log exception processing method, device, equipment and storage medium
CN108255710B (en) Script abnormity detection method and terminal thereof
CN117151726A (en) Fault repairing method, repairing device, electronic equipment and storage medium
CN107797924B (en) SQL script abnormity detection method and terminal thereof
CN116126577B (en) File handle monitoring and leakage analysis method and device and electronic equipment
CN107957942B (en) SQL script fault repairing method and terminal thereof
CN119025514A (en) Data quality detection method, device, equipment and storage medium
US20250238307A1 (en) Interactive data processing system failure management using hidden knowledge from predictive models
US20250371271A1 (en) Inference model training and tuning using augmented questions and answers

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
GR01 Patent grant
GR01 Patent grant