Search

CN-121996453-A - Database repair method, device, server and storage medium

CN121996453ACN 121996453 ACN121996453 ACN 121996453ACN-121996453-A

Abstract

The application provides a database repairing method, a device, a server and a storage medium, wherein the method comprises the steps of selecting an interface to be tested of a database, and extracting interface information from a production environment log; the method comprises the steps of generating an interface test script according to interface information, testing an interface to be tested according to the test script to obtain an interface test log, extracting abnormal log data corresponding to a database from the interface test log, generating diagnosis prompt words of a preset diagnosis model according to the interface information and the abnormal log data, inputting the diagnosis prompt words into the preset diagnosis model to perform diagnosis processing to generate a structured query statement, checking the structured query statement to obtain a checking result, and synchronizing the structured query statement to the database after the checking result is judged to pass the checking, so that the database is repaired, and the repairing efficiency of the database is improved.

Inventors

  • ZHANG JIAJIE
  • HU XINXIN
  • LI LI

Assignees

  • 中国人民财产保险股份有限公司

Dates

Publication Date
20260508
Application Date
20251229

Claims (10)

  1. 1. A database repair method, applied to a server, comprising: Selecting an interface to be tested of any database, and extracting interface information corresponding to the interface to be tested from a production environment log; Generating a corresponding interface test script according to the interface information; Testing the interface to be tested according to the test script to obtain an interface test log corresponding to the interface to be tested; extracting abnormal log data corresponding to the database from the interface test log; generating a diagnosis prompt word of a preset diagnosis model according to the interface information and the abnormal log data; inputting the diagnosis prompt words into the preset diagnosis model for diagnosis processing so as to generate a structured query sentence for repairing the database; performing verification processing on the structured query statement to obtain a verification result; And after the verification result is judged to be that verification is passed, synchronizing the structured query statement to the database so as to finish the repair of the database.
  2. 2. The method of claim 1, wherein the extracting the exception log data corresponding to the database from the interface test log comprises: Judging whether the interface test log is a structured test log or not; if the interface test log is judged to be a structured test log, acquiring an abnormal keyword set; screening abnormal information from the interface test log according to the abnormal keyword set; Configuring a corresponding abnormal log template according to the abnormal information; and extracting the abnormal log data corresponding to the database from the abnormal information according to the abnormal log template.
  3. 3. The method according to claim 2, wherein the extracting, from the anomaly information, anomaly log data corresponding to the database according to the anomaly log template, includes: extracting one or more pieces of abnormal data corresponding to the database from the abnormal information according to the abnormal log template; performing cluster analysis on each different data according to a preset cluster analysis method to obtain one or more types of abnormal data; and integrating various abnormal data into corresponding abnormal log data.
  4. 4. The method of claim 2, further comprising, after said determining whether the interface test log is a structured test log: If the interface test log is judged to be an unstructured test log, loading a corresponding natural language processing model; And inputting the interface test log into the natural language processing model for abnormal semantic analysis processing to obtain corresponding abnormal log data.
  5. 5. The method of claim 1, wherein the interface information comprises at least an interface address and a request message; correspondingly, the generating the corresponding interface test script according to the interface information includes: Extracting request line information and request header information from the request message, and extracting a corresponding request method from the request line information; mapping the interface address, the request message, the request method and the request header information into corresponding test information; And generating a corresponding interface test script according to the test information.
  6. 6. The method of claim 1, further comprising, after said performing a verification process on said structured query statement to obtain a verification result: If the verification result is judged to be that the verification is not passed, acquiring an original abnormal context corresponding to the abnormal log data; Constructing a feedback prompt word according to the original abnormal context, the structured query statement and the verification result; and inputting the feedback prompt word into the preset diagnosis model to perform feedback processing so as to update the structured query sentence, thereby completing the update of the structured query sentence.
  7. 7. The method as recited in claim 1, further comprising: Acquiring first database state data before database repair and second database state data after the database is repaired; judging whether the database is successfully repaired or not according to the second database state data; And if the database is judged to be not successfully repaired, rolling back the second database state data in the database to the first database state data.
  8. 8. A database repair apparatus, for use with a server, comprising: the first extraction module is used for selecting an interface to be tested of any database and extracting interface information corresponding to the interface to be tested from a production environment log; The first generation module is used for generating a corresponding interface test script according to the interface information; The test module is used for testing the interface to be tested according to the test script so as to obtain an interface test log corresponding to the interface to be tested; The second extraction module is used for extracting abnormal log data corresponding to the database from the interface test log; the second generation module is used for generating a diagnosis prompt word of a preset diagnosis model according to the interface information and the abnormal log data; the first input module is used for inputting the diagnosis prompt words into the preset diagnosis model to perform diagnosis processing so as to generate a structured query sentence for repairing the database; the verification module is used for performing verification processing on the structured query statement to obtain a verification result; And the synchronization module is used for synchronizing the structured query statement to the database after the verification result is judged to pass the verification so as to finish the repair of the database.
  9. 9. A server is characterized by comprising at least one processor and a memory; The memory stores computer-executable instructions; The at least one processor executing computer-executable instructions stored in the memory cause the at least one processor to perform the database repair method of any one of claims 1 to 7.
  10. 10. A computer storage medium having stored therein computer executable instructions which, when executed by a processor, implement the database repair method of any one of claims 1 to 7.

Description

Database repair method, device, server and storage medium Technical Field The present application relates to the field of database technologies, and in particular, to a database repair method, a database repair device, a server, and a storage medium. Background Database repair refers to a method for automatically identifying and synchronizing changes in the structure of a database table by capturing and analyzing log information generated in the interface test process. The method is characterized in that the database operation or abnormal information recorded in the log is utilized to drive the structure update of the target database, so that the consistency of the databases among multiple environments is ensured. In the prior art, in the conventional database repairing method, when the database needs to be repaired synchronously, an operation and maintenance person performs interface test on the database according to an interface test script written by a developer so as to synchronize a correct structured query statement to the database, thereby completing database repairing. However, in the prior art, an operation and maintenance person performs interface test on a database on a server according to an interface test script written by a developer to complete a repairing mode of database repairing, so that human error is easy to generate, and the efficiency of database repairing is lower. Disclosure of Invention The application provides a database repairing method, a device, a server and a storage medium, which are used for solving the problems that an operator can test an interface on the server according to an interface test script written by a developer to finish a repairing mode of database repairing, human error is easy to generate, and the efficiency of database repairing is lower. In a first aspect, the present application provides a database repair method, applied to a server, including: Selecting an interface to be tested of any database, and extracting interface information corresponding to the interface to be tested from a production environment log; Generating a corresponding interface test script according to the interface information; Testing the interface to be tested according to the test script to obtain an interface test log corresponding to the interface to be tested; extracting abnormal log data corresponding to the database from the interface test log; generating a diagnosis prompt word of a preset diagnosis model according to the interface information and the abnormal log data; inputting the diagnosis prompt words into the preset diagnosis model for diagnosis processing so as to generate a structured query sentence for repairing the database; performing verification processing on the structured query statement to obtain a verification result; And after the verification result is judged to be that verification is passed, synchronizing the structured query statement to the database so as to finish the repair of the database. In one possible design, the extracting the abnormal log data corresponding to the database from the interface test log includes judging whether the interface test log is a structured test log, acquiring an abnormal keyword set if the interface test log is judged to be the structured test log, screening abnormal information from the interface test log according to the abnormal keyword set, configuring a corresponding abnormal log template according to the abnormal information, and extracting the abnormal log data corresponding to the database from the abnormal information according to the abnormal log template. In one possible design, the extracting the abnormal log data corresponding to the database from the abnormal information according to the abnormal log template includes extracting one or more abnormal data corresponding to the database from the abnormal information according to the abnormal log template, performing cluster analysis on each abnormal data according to a preset cluster analysis method to obtain one or more types of abnormal data, and integrating each type of abnormal data into corresponding abnormal log data. In one possible design, after the step of judging whether the interface test log is a structured test log, the method further comprises loading a corresponding natural language processing model if the interface test log is judged to be an unstructured test log, and inputting the interface test log into the natural language processing model for abnormal semantic analysis processing to obtain corresponding abnormal log data. In one possible design, the interface information at least comprises an interface address and a request message, and correspondingly, the generating the corresponding interface test script according to the interface information comprises extracting request line information and request header information from the request message, extracting a corresponding request method from the request line information, mapping the interfa