Database processing method, electronic device, storage medium, and program product
By automatically retrying DDL statements in a distributed database, the problem of manual checking and retrying after DDL execution failures is solved, improving the efficiency and fault tolerance of database processing.
Patent Information
- Application Number
- PCT/CN2024/142531
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-05-08
- Filing Date
- 2024-12-25
- Publication Date
- 2026-01-08
AI Technical Summary
Existing technologies require manual inspection and retrying when errors occur during Data Definition Language (DDL) operations in distributed database clusters, resulting in low database processing efficiency.
By receiving DDL requests, the system automatically detects statements that fail to execute, records the number of retries, and automatically retryes DDL statements on other data nodes based on the table structure information of the target database until the preset number of retries is reached or the transaction is successful.
It simplifies the handling process after DDL execution failure, improves the fault tolerance and efficiency of database processing, and reduces manual intervention.
Smart Images

Figure CN2024142531_08012026_PF_FP_ABST
Abstract
Description
Database processing method, electronic device, storage medium and program product
[0001] The present application claims priority from the Chinese patent application No. 202410566280.6 filed on May 8, 2024, and entitled "Database processing method, electronic device, storage medium and program product", the content of which is incorporated herein by reference in its entirety. TECHNICAL FIELD
[0002] The present application relates to the technical field of database, and in particular to a database processing method, an electronic device, a storage medium and a program product. BACKGROUND
[0003] In the process of processing a switching service, a database processing operation is required, such as switching a database carrying a switching service from a centralized database to a target distributed database.
[0004] In the prior art, after a distributed database cluster identifies a data definition language (DDL) operation request, based on a third-party component, a structured query language (SQL) statement in the DDL operation request is distributed to an actual data node to perform a corresponding database processing operation.
[0005] However, in the above method, when the DDL operation fails, a series of manual check operations are required, which is cumbersome and reduces the database processing efficiency. SUMMARY
[0006] Embodiments of the present application provide a database processing method, an electronic device, a storage medium and a program product to improve the database processing efficiency.
[0007] In a first aspect, embodiments of the present application provide a database processing method, comprising:
[0008] receiving a data definition language (DDL) request sent by an application device, and executing each DDL statement in the DDL request based on at least one first data node to obtain a first execution result of each DDL statement; wherein the DDL request is used to request processing of at least one database; the database is used to store financial service data; and the DDL statement represents a database table operation for processing each database;
[0009] If it is determined that the first execution result indicates that the DDL statement fails, an execution state of the DDL statement is updated to a failure state, and a retry number of the DDL statement is determined, wherein the retry number indicates a total number of times of re-executing the DDL statement;
[0010] If it is determined that the retry number of the DDL statement is less than or equal to a preset number, table information of a target database is determined, and the DDL statement is executed again according to the table information of the target database to obtain a second execution result of the DDL statement, wherein the target database is a database to be processed corresponding to the DDL statement, and the table information is table structure information of the target database.
[0011] The second execution result of the DDL statement is sent to the application device.
[0012] In a possible implementation, the DDL statement is executed again according to the table information of the target database to obtain the second execution result of the DDL statement, including:
[0013] According to the table information of the target database, a second data node corresponding to the DDL statement is determined based on a metadata node, wherein the second data node is a first data node other than the first data node in which the DDL statement is successfully executed.
[0014] The DDL statement is sent to the second data node corresponding to the DDL statement, wherein the second data node is used to re-execute the DDL statement to obtain the second execution result.
[0015] In a possible implementation, the second data node corresponding to the DDL statement is determined according to the table information of the target database based on the metadata node, including:
[0016] The table information is identified to obtain an identification result, wherein the identification result indicates a version condition of the table information.
[0017] If it is determined that the identification result indicates that the table information is not a current latest version, the second data node is determined.
[0018] In a possible implementation, the table information includes field information, and the field information indicates a field type and a length of a table structure. The table information is identified to obtain the identification result, including:
[0019] The field information in the table information is identified to obtain the identification result.
[0020] In a possible implementation, after the identification of the table information is performed to obtain an identification result, the method further includes:
[0021] If it is determined that the identification result indicates that the table information is a current latest version, it is determined that the first execution result of the DDL statement indicates that the DDL statement is executed successfully.
[0022] The first execution result of the DDL statement is sent to the application device.
[0023] In a possible implementation, each DDL statement in the DDL request is executed based on at least one first data node to obtain a first execution result of each DDL statement.
[0024] A DDL task corresponding to the DDL request is generated based on a metadata node, wherein the DDL task includes at least one DDL statement in the DDL request, the DDL task has task information, and the task information indicates an execution state of each DDL statement in the DDL task.
[0025] The task information of each DDL task is written into a subtask table.
[0026] Each DDL statement in the DDL task is executed based on each first data node to obtain a first execution result of the DDL statement.
[0027] In a possible implementation, the DDL task corresponding to the DDL request is generated based on a metadata node, including:
[0028] Each DDL statement in the DDL request is encapsulated based on the metadata node to obtain a DDL job corresponding to the DDL request, wherein the DDL job has job information, and the job information is table information to be processed corresponding to the DDL job.
[0029] If it is determined that the DDL job is allowed to be executed, the job information is stored into a metadata table, wherein the metadata table includes a job table and an information table, the job table is used to record execution of a DDL statement that is currently being executed or not executed, and the information table is used to record changes of a target database before and after execution of the DDL statement.
[0030] A node number is determined, and each DDL task is generated according to the node number, wherein the node number is a total number of first data nodes that can be used to execute a database operation, and the DDL task corresponds to the first data node in a one-to-one manner.
[0031] In a possible implementation, determining that the DDL job is allowed to be executed comprises:
[0032] If it is determined that the target DDL job does not exist in the job table, it is determined that the DDL job is allowed to be executed; wherein the target DDL job is a DDL job whose job information is consistent with the job information of the DDL job.
[0033] In a possible implementation, the information table comprises table change information and each DDL statement in the DDL job; and the table change information represents the change of the table structure of the target database before and after the execution of the DDL statement.
[0034] In a possible implementation, the task information comprises node information, database information and log information; the node information is the data node information corresponding to the execution of the DDL task; the database information is the connection identifier information of the target database corresponding to the DDL task; and the log information is the error information generated in the process of executing the DDL task.
[0035] In a possible implementation, sending the second execution result of the DDL statement to the application device comprises:
[0036] According to the second execution result of the DDL statement, the execution state of the DDL statement is updated;
[0037] If it is determined that the execution state of each DDL statement has been updated and completed, the second execution result of the DDL statement is sent to the application device.
[0038] In a possible implementation, according to the second execution result of the DDL statement, the execution state of the DDL statement is updated, comprising:
[0039] If it is determined that the second execution result represents that the DDL statement is executed successfully, the execution state of the DDL statement is updated to a successful state;
[0040] If it is determined that the second execution result represents that the DDL statement is executed unsuccessfully, the retry number of the DDL statement is determined; and according to the retry number of the DDL statement, the execution state of the DDL statement is updated; wherein the retry number represents the total number of re-executions of the DDL statement.
[0041] In a possible implementation, according to the retry number of the DDL statement, the execution state of the DDL statement is updated, comprising:
[0042] If it is determined that the retry number of the DDL statement is greater than the preset number, an execution state of the DDL statement is updated to a failure state, and prompt information is generated; the prompt information indicates that the current DDL statement execution fails, and the prompt information is used to prompt manual processing;
[0043] If it is determined that the retry number of the DDL statement is less than or equal to the preset number, the execution state of the DDL statement is updated to an execution state, and the step of determining the table information of the target database is executed.
[0044] In a possible implementation, before the table information of the target database is determined, the method further includes:
[0045] If it is determined that the DDL statement has connection information, the connection information of the DDL statement is deleted; the connection information indicates a connection relationship between the DDL statement and a first data node that executes the DDL statement last time.
[0046] In a possible implementation, the method further includes:
[0047] If it is determined that the first execution result indicates that the DDL statement execution succeeds, the execution state of the DDL statement is updated to a success state, and the first execution result of the DDL statement is sent to the application device.
[0048] In a possible implementation, the method further includes:
[0049] If it is determined that the retry number of the DDL statement is greater than the preset number, the first execution result of the DDL statement is sent to the application device.
[0050] In a second aspect, an embodiment of the present application provides a database processing apparatus, including:
[0051] A first execution unit is configured to receive a data definition language (DDL) request sent by an application device, and execute each DDL statement in the DDL request based on at least one first data node to obtain a first execution result of each DDL statement; the DDL request is used to request processing of at least one database; the database is used to store financial business data; the DDL statement indicates a database table operation used to process each database;
[0052] A determination unit is configured to update an execution state of the DDL statement to a failure state if it is determined that the first execution result indicates that the DDL statement execution fails, and determine a retry number of the DDL statement; the retry number indicates a total number of times of re-executing the DDL statement;
[0053] The second execution unit is configured to: if it is determined that the retry number of the DDL statement is less than or equal to a preset number, determine table information of a target database, and execute the DDL statement again according to the table information of the target database to obtain a second execution result of the DDL statement; wherein the target database is a database to be processed corresponding to the DDL statement; and the table information is table structure information of the target database.
[0054] The sending unit is configured to send the second execution result of the DDL statement to the application device.
[0055] In a possible implementation, the second execution unit is specifically configured to:
[0056] determine, based on a metadata node, a second data node corresponding to the DDL statement according to the table information of the target database; wherein the second data node is a first data node other than the first data node in which the execution of the DDL statement is successful.
[0057] send the DDL statement to the second data node corresponding to the DDL statement; wherein the second data node is configured to re-execute the DDL statement to obtain the second execution result
[0058] In a possible implementation, the second execution unit is specifically configured to:
[0059] perform identification processing on the table information to obtain an identification result; wherein the identification result represents a version condition of the table information at present.
[0060] if it is determined that the identification result represents that the table information is not a current latest version, determine the second data node.
[0061] In a possible implementation, the table information includes field information, and the field information represents a field type and length of a table structure; and the second execution unit is specifically configured to:
[0062] perform identification processing on the field information in the table information to obtain the identification result.
[0063] In a possible implementation, the second execution unit is further specifically configured to:
[0064] if it is determined that the identification result represents that the table information is a current latest version, determine that the first execution result of the DDL statement represents that the execution of the DDL statement is successful.
[0065] send the first execution result of the DDL statement to the application device.
[0066] In a possible implementation, the first execution unit is specifically configured to:
[0067] generate a DDL task corresponding to the DDL request based on the metadata node; the DDL task includes at least one DDL statement in the DDL request; the DDL task has task information; and the task information represents an execution state of each DDL statement in the DDL task.
[0068] write the task information of each DDL task into a subtask table.
[0069] execute the DDL statements in the DDL task based on each first data node to obtain a first execution result of the DDL statement.
[0070] In a possible implementation, the first execution unit is specifically configured to:
[0071] perform encapsulation processing on each DDL statement in the DDL request based on the metadata node to obtain a DDL job corresponding to the DDL request; the DDL job has job information; and the job information is database table information to be processed corresponding to the DDL job.
[0072] if it is determined that the DDL job is allowed to be executed, store the job information into a metadata table; the metadata table includes a job table and an information table; the job table is used to record execution of a DDL statement that is currently being executed or not executed; and the information table is used to record changes of a target database before and after execution of the DDL statement.
[0073] determine a node number, and generate each DDL task according to the node number; the node number is a total number of first data nodes that can be used to execute a database operation; and the DDL task corresponds to the first data node in a one-to-one manner.
[0074] In a possible implementation, the first execution unit is specifically configured to:
[0075] if it is determined that the target DDL job does not exist in the job table, determine that the DDL job is allowed to be executed; the target DDL job is a DDL job whose job information is consistent with the job information of the DDL job.
[0076] In a possible implementation, the information table includes table change information and each DDL statement in the DDL job; and the table change information represents changes of a table structure of a target database before and after execution of the DDL statement.
[0077] In a possible implementation, the task information comprises node information, database information, and log information; the node information is data node information corresponding to the DDL task; the database information is connection identifier information of a target database corresponding to the DDL task; and the log information is error information generated in the process of executing the DDL task.
[0078] In a possible implementation, the sending unit is specifically configured to:
[0079] updating an execution state of the DDL statement according to the second execution result of the DDL statement;
[0080] if it is determined that the execution state of each DDL statement has been updated and processed completely, sending the second execution result of the DDL statement to the application device.
[0081] In a possible implementation, the sending unit is specifically configured to:
[0082] if it is determined that the second execution result indicates that the DDL statement is executed successfully, updating the execution state of the DDL statement to a success state;
[0083] if it is determined that the second execution result indicates that the DDL statement is executed unsuccessfully, determining a retry number of the DDL statement, and updating the execution state of the DDL statement according to the retry number of the DDL statement; wherein the retry number indicates a total number of times of re-executing the DDL statement.
[0084] In a possible implementation, the sending unit is specifically configured to:
[0085] if it is determined that the retry number of the DDL statement is greater than the preset number, updating the execution state of the DDL statement to a failure state, and generating prompt information; wherein the prompt information indicates that the DDL statement is executed unsuccessfully at present, and the prompt information is used to prompt manual processing;
[0086] if it is determined that the retry number of the DDL statement is less than or equal to the preset number, updating the execution state of the DDL statement to an execution state, and performing the step of determining the table information of the target database.
[0087] In a possible implementation, before the second execution unit is specifically configured to determine the table information of the target database, the apparatus is further configured to:
[0088] if it is determined that the DDL statement has connection information, deleting the connection information of the DDL statement; wherein the connection information indicates a connection relationship between the DDL statement and a first data node in which the DDL statement is executed last time.
[0089] In a possible implementation, the apparatus is further configured to:
[0090] If it is determined that the first execution result indicates that the DDL statement is executed successfully, update the execution state of the DDL statement to a success state, and send the first execution result of the DDL statement to the application device.
[0091] In a possible implementation, the apparatus further includes:
[0092] If it is determined that the retry number of the DDL statement is greater than the preset number, send the first execution result of the DDL statement to the application device.
[0093] In a third aspect, an embodiment of the present application provides an electronic device, including: a memory, a processor;
[0094] The memory stores computer execution instructions.
[0095] The processor executes the computer execution instructions stored in the memory, so that the processor executes the first aspect and / or various possible implementation manners of the first aspect.
[0096] In a fourth aspect, an embodiment of the present application provides a computer readable storage medium, the computer readable storage medium stores computer execution instructions, and the computer execution instructions are executed by a processor to implement the first aspect and / or various possible implementation manners of the first aspect.
[0097] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, and the computer program is executed by a processor to implement the first aspect and / or various possible implementation manners of the first aspect.
[0098] The database processing method, the electronic device, the storage medium and the program product provided by the embodiments of the present application can directly execute a DDL statement in a single point of a plurality of databases, when the DDL statement execution fails, according to the total number of times of re-executing the DDL statement and the table structure information of the database to be processed, the DDL statement is automatically executed again to complete the database processing operation, and the process can be simplified, the fault tolerance can be improved, and the database processing efficiency can be improved. BRIEF DESCRIPTION OF DRAWINGS
[0099] The accompanying drawings, which are incorporated herein and form part of the specification, illustrate embodiments consistent with the present application and, together with the description, further serve to explain the principles of the application.
[0100] FIG. 1 is a schematic diagram of an application scenario provided by the present application;
[0101] Fig. 2 is a flowchart of a database processing method according to an embodiment of the present application;
[0102] Fig. 3 is a schematic diagram of a framework of a DDL module according to an embodiment of the present application;
[0103] Fig. 4 is a flowchart of another database processing method according to an embodiment of the present application;
[0104] Fig. 5 is a schematic diagram of an execution flow of a DDL module according to an embodiment of the present application;
[0105] Fig. 6 is a flowchart of an exception handling mechanism according to an embodiment of the present application;
[0106] Fig. 7 is a schematic diagram of a database processing apparatus according to an embodiment of the present application;
[0107] Fig. 8 is a schematic diagram of an electronic device according to an embodiment of the present application.
[0108] The above-described figures have shown specific embodiments of the present application, which will be described in more detail hereinafter. These figures and the written description are not intended to restrict the scope of the present application in any way, but to illustrate the concept of the present application by reference to specific embodiments. DETAILED DESCRIPTION
[0109] The exemplary embodiments will be described in detail herein with reference to the attached drawings. The same or similar components are denoted by the same reference numerals throughout the drawings and the following description, unless otherwise specified. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of the present application.
[0110] First, the terms involved in the present application are explained:
[0111] Data Definition Language (DDL): refers to a computer language used to define the data structure and architecture in a database. DDL is used to create, modify and delete database objects such as tables, views, indexes, etc. in a database; through DDL, users can define the properties and relationships of database objects such as data types, constraints, relationships, etc., thereby defining the structure and organization of the database.
[0112] Structured Query Language (SQL): refers to a standardized language used to manage relational databases; it is used to define, manipulate and manage data in a database, including operations such as inserting, updating, deleting and querying data.
[0113] In the process of processing the transit service, database processing operations are required, such as the database carrying the transit service needs to be switched from a centralized database to a target distributed database.
[0114] In one example, the scheme executed by the direct connection cluster data node is suitable for a distributed database based on a middleware architecture. Under this architecture, the data sharding logic is recorded through middleware configuration. Each node of the distributed database cluster is accessed through manual processing or external tools to execute the DDL statement and confirm the success of the execution. At the same time, the part of the data sharding of the new version table structure in the middleware configuration needs to be modified.
[0115] However, in the above-mentioned manner, all data nodes need to be directly connected to execute the DDL database operation, and the configuration related to the database of the new version table structure needs to be modified synchronously, which does not support single point and is not transparent to the operation and maintenance personnel. It cannot be compatible with all types of DDL statements.
[0116] In another example, a third-party component is introduced to assist in execution, which is suitable for a distributed database with a scheduling center and a metadata maintenance component architecture. After the distributed database cluster identifies the DDL operation, it will save it as a task in the component that maintains the metadata information. The management scheduling center of the cluster pulls the DDL task from the component and distributes the related SQL statements to the actual data nodes for execution. Since there is a scheduling center, it is possible to avoid directly connecting each node to execute the statement.
[0117] However, in the above-mentioned manner, an additional third-party open source component needs to be introduced to maintain metadata and task information, which increases the complexity of the architecture and brings additional costs to the maintenance component. DDL execution on the data sharding node may encounter errors. The processing steps of DDL failure are complex and difficult to execute, and a series of operations need to be manually executed to check the current table structure and the execution status of the current task, and then a retry scheme is developed, which reduces the efficiency of database processing.
[0118] The database processing method provided in the present application provides a technical means for automatically executing the DDL statement again according to the total number of times of re-executing the DDL statement and the table structure information of the database to be processed when the DDL statement execution fails, which solves the technical problem of reducing the efficiency of database processing caused by manually executing a series of operations to check the current table structure and the execution status of the current task, and then developing a retry scheme.
[0119] FIG. 1 is a schematic diagram of an application scenario provided by the present application. As shown in FIG. 1, the specific application scenario of the present application includes an electronic device 101 and an application device 102. In the process of processing a switching service, a user sends a DDL request to the electronic device 101 through the application device, so as to request a database processing operation. For example, a database carrying a switching service needs to be switched from a centralized database to a target distributed database, and the electronic device 101 performs a database operation on the centralized database in response to the DDL request.
[0120] The technical solutions of the present application and how the technical solutions of the present application solve the above technical problems will be described in detail below with specific embodiments. The following specific embodiments can be combined with each other, and the same or similar concepts or processes can not be described again in some embodiments. The embodiments of the present application will be described below with reference to the accompanying drawings.
[0121] FIG. 2 is a flowchart of a database processing method provided by the present application. As shown in FIG. 2, the method includes the following steps.
[0122] 201. Receive a data definition language (DDL) request sent by an application device, and execute each DDL statement in the DDL request based on at least one first data node to obtain a first execution result of each DDL statement. The DDL request is used to request processing of at least one database, and the database is used to store financial service data. The DDL statement represents a database table operation for processing each database.
[0123] In this embodiment, the execution subject is an electronic device. For ease of description, the electronic device is referred to as a device hereinafter. The electronic device can be any entity device or virtual device with database processing function, or a terminal device for interacting with a user.
[0124] Exemplarily, when the databases carrying the switching service need to be switched from the centralized database to the target distributed database, the user sends a DDL request to the device based on the application device, for requesting the device to process at least one database carrying the switching service, which is used to store the financial service data. The device receives the DDL request sent by the application device, and parses the DDL request to obtain each DDL statement in the DDL request, wherein each DDL statement represents a database table operation for processing each database. The device sends each DDL statement to one or more first data nodes, executes each DDL statement based on each first data node to obtain an execution result of each first data node executing the DDL statement, and determines whether each DDL statement is executed successfully according to the execution result of each first data node executing the DDL statement, that is, the first execution result of each DDL statement, and determines that the first execution result represents that the DDL statement is executed successfully if each first data node executes the DDL statement successfully.
[0125] For example, FIG. 3 is a schematic diagram of a framework of a DDL module provided by the present application. As shown in FIG. 3, the application connection agent Proxy sends a DDL request, the Proxy identifies that it is a DDL request after parsing the SQL statement, and then forwards the SQL statement in the DDL request to the metadata Metadata node. Each Metadata node has a master, slave, backup and the like mode. The service Server layer of each Metadata node pushes the information parsed from the SQL statement to the storage engine layer. The storage engine layer schedules the DDL job through the ddl scheduling module, that is, sends the DDL statement to the ddl execution module. The ddl execution module sends the DDL statement to the corresponding data node, such as data node 1, data node 2, …, data node N. Each data node has a master, slave, backup and the like mode to execute the DDL statement to obtain the first execution result of each DDL statement. Each data node sends the first execution result of each DDL statement to the Metadata node for processing.
[0126] 202, if it is determined that the first execution result represents that the DDL statement fails to execute, updating the execution state of the DDL statement to a failure state; and determining a retry number of the DDL statement; wherein the retry number represents a total number of times of re-executing the DDL statement.
[0127] Exemplarily, the most common abnormal scenario of the distributed DDL is that some data nodes fail to execute the DDL task, which causes inconsistent table structures among the data nodes. For each DDL statement, when any data node fails to execute the DDL statement, the device determines that the DDL statement fails, and triggers an exception handling mechanism. In other words, referring to FIG. 3, for each failed DDL statement, the execution module in the device updates the execution state of the DDL statement to a failed state, and determines the retry number of the DDL statement, i.e., the total number of re-executions of the DDL statement, for processing.
[0128] 203, if it is determined that the retry number of the DDL statement is less than or equal to the preset number, table information of a target database is determined, and the DDL statement is executed again according to the table information of the target database to obtain a second execution result of the DDL statement; wherein the target database is a database to be processed corresponding to the DDL statement; and the table information is table structure information of the target database.
[0129] Exemplarily, the device compares the retry number of the failed DDL statement with the preset number. If it is determined that the retry number of the DDL statement is less than or equal to the preset number, e.g., the maximum retry number has been exceeded, the table structure information of the target database, i.e., the table information of the target database, is determined. According to the table information of the target database, a table structure consistency check is performed. According to the check result, if the table structure consistency is passed, the DDL statement is sent to the corresponding data node to re-execute the DDL statement to obtain a second execution result of the DDL statement, and it is determined whether the DDL statement is successfully executed. Further, automatic retry can be performed, the process is simplified, and the fault tolerance is improved.
[0130] 204, the second execution result of the DDL statement is sent to an application device.
[0131] Exemplarily, referring to FIG. 3, after obtaining the second execution result of each DDL statement, the data node deployed by the device returns the second execution result, i.e., the final execution result, of each DDL statement to the Server layer of the Metadata node, the Server layer replies to the Proxy, and then the final execution result of each DDL statement in the DDL request is returned to the application on the application device side.
[0132] The database processing method provided in the embodiments of the present application directly executes the DDL statement in a single point in multiple databases. When the DDL statement fails to be executed, the DDL statement is automatically executed again according to the total number of re-executions of the DDL statement and the table structure information of the database to be processed, so as to complete the database processing operation. Further, the database processing efficiency can be improved.
[0133] Figure 4 is a flow diagram of another database processing method provided by the present application. As shown in Figure 4, the embodiment is based on the embodiment of Figure 2, and the database processing method is described in detail. The method comprises the following steps:
[0134] 301. receiving a data definition language (DDL) request sent by an application device, wherein the DDL request is used to request processing of at least one database, and the database is used to store financial service data.
[0135] By way of example, the content of this step can be referred to step 201, which will not be described here again.
[0136] 302. generating a DDL task corresponding to the DDL request based on the metadata node, wherein the DDL task comprises at least one DDL statement in the DDL request, the DDL task has task information, and the task information represents the execution status of each DDL statement in the DDL task.
[0137] The task information comprises node information, database information, and log information, the node information is data node information corresponding to the execution of the DDL task, the database information is connection identifier information of a target database corresponding to the DDL task, and the log information is error information generated in the process of executing the DDL task.
[0138] By way of example, Figure 5 is a schematic diagram of a DDL module execution process provided by the present application. As shown in Figure 5, based on the DDL module deployed by the device, the ddl scheduling module constructs a task list corresponding to each data node, each task in the task list comprises at least one DDL statement in the received DDL request, each DDL task has task information, and the ddl execution module adds the task list to a global task queue for processing. Each task information represents the execution status of each DDL statement in the DDL task, each task information comprises node information, database information, and log information, each node information is data node information corresponding to the execution of the DDL task, such as a data node identifier, each database information is connection identifier information of a target database corresponding to the DDL task, such as a database connection identifier, and each log information is error information generated in the process of executing the DDL task, such as an error code.
[0139] In one possible implementation, 302 comprises:
[0140] The first step is to encapsulate each DDL statement in the DDL request based on the metadata node to obtain a DDL job corresponding to the DDL request, wherein the DDL job has job information, and the job information is database table information to be processed corresponding to the DDL job.
[0141] The second step is to store the job information into the metadata table if it is determined that the DDL job is allowed to be executed; wherein the metadata table comprises a job table and an information table; the job table is used to record the execution of the DDL statement which is currently being executed or not executed; the information table is used to record the changes of the target database before and after the execution of the DDL statement.
[0142] The third step is to determine the number of nodes and generate each DDL task according to the number of nodes; wherein the number of nodes is the total number of the first data nodes which can be used to execute the database operation; the DDL task corresponds to the first data node one by one.
[0143] The information table comprises table change information and each DDL statement in the DDL job; the table change information represents the changes of the table structure of the target database before and after the execution of the DDL statement.
[0144] For example, in combination with FIG. 3 and FIG. 5, the Server layer of the Metadata node in the device pushes the information parsed by the SQL to the storage engine layer, the storage engine layer encapsulates and processes each DDL statement in the DDL request through the DDL scheduling module to obtain the DDL job corresponding to the DDL request, and writes the job information if the current DDL job is allowed to be executed, that is, stores the job information of the DDL job into the metadata table, wherein the job information is the database table information to be processed corresponding to the DDL job, the metadata table comprises a job table and an information table, the job table is used to record the execution of the DDL statement which is currently being executed or not executed, and the information table is used to record the changes of the target database before and after the execution of the DDL statement, including the changes of the table structure before and after the execution, the DDL execution statement, etc. After the DDL scheduling module of the device writes the DDL job information into the DDL job table and the DDL information table, the total number of the first data nodes which can be used to execute the database operation, that is, the number of nodes, is determined, and a task list corresponding to the data node one by one is constructed according to the obtained number of nodes, that is, one task corresponds to one data node.
[0145] In a possible implementation, the determination of the DDL job in the second step in 302 is allowed to be executed, comprising: if it is determined that there is no target DDL job in the job table, it is determined that the DDL job is allowed to be executed; wherein the target DDL job is the DDL job whose job information is consistent with the job information of the DDL job.
[0146] Specifically, when the device schedules the DDL job, the current DDL job needs to be checked, that is, it is determined whether there is a DDL job in the job table that is consistent with the job information of the DDL job, that is, the target DDL job, if it is determined that there is no target DDL job in the job table, such as no DDL job for processing the operation statement of the same data table in the job table, it is determined that the DDL job is allowed to be executed.
[0147] 303, write the task information of each DDL task into the subtask table.
[0148] Exemplarily, in combination with FIG. 5, based on the DDL module deployed by the device, the ddl scheduling module writes the task information of each DDL task into the subtask table, and the ddl scheduling module synchronously checks all subtask states, that is, the execution states of each DDL statement executed by each data node in the DDL task. Among them, the scheduling module and the execution module are implemented in the database kernel, so the scheduling module can directly inherit the parsing result of the SQL statement by the database kernel, the parsing result is in the DDL class related to the storage engine, the scheduling module can obtain all information related to the DDL, and implement the DDL related interface under the distributed architecture; This mechanism ensures that the present scheme can be highly compatible with the existing DDL syntax.
[0149] 304, based on each first data node, execute the DDL statement in the DDL task to obtain a first execution result of the DDL statement.
[0150] Exemplarily, in combination with FIG. 5, the thread group of the DDL execution module deployed by the device concurrently obtains the DDL task from the task queue, sends each DDL statement in each DDL task to each data node for execution, obtains the first execution result of each DDL statement according to the execution of each DDL statement by each data node, and updates the execution state of each DDL statement in the subtask table according to the execution of each DDL statement by each data node. Further, the DDL scheduling module and the execution module are implemented in the database kernel, and the single-point DDL of the distributed database is cooperatively implemented, without introducing third-party components, and the complex operation of directly connecting each node for execution is avoided.
[0151] 305, if it is determined that the first execution result represents that the DDL statement fails to execute, update the execution state of the DDL statement to a failure state; and determine a retry number of the DDL statement; wherein the retry number represents a total number of times of re-executing the DDL statement.
[0152] Exemplarily, the content of this step can be referred to step 202, which will not be described here.
[0153] In a possible implementation, after 303, the method further includes: if it is determined that the first execution result of the DDL statement indicates that the DDL statement is executed successfully, updating an execution state of the DDL statement to a successful state; and sending the first execution result of the DDL statement to the application device.
[0154] For each DDL statement, the device updates an execution state of the DDL statement to a successful state if it is determined that the DDL statement is executed successfully, and directly sends a first execution result of the DDL statement to the application device based on the metadata node.
[0155] 306. If it is determined that the retry number of the DDL statement is less than or equal to the preset number, the table information of the target database is determined.
[0156] For details of this step, reference can be made to step 203, which is not described herein again.
[0157] In a possible implementation, before determining the table information of the target database, the method further includes: if it is determined that the DDL statement has connection information, deleting the connection information of the DDL statement; wherein the connection information indicates a connection relationship between the DDL statement and a first data node in which the DDL statement is executed last time.
[0158] For example, FIG. 6 is a flowchart of an exception processing mechanism provided in the present application. As shown in FIG. 6, if the maximum retry number is not exceeded, the task loop reenters the distribution processing flow of the DDL execution module; in the retry process, it is determined whether the last subtask exists, and if the last subtask exists, the connection is killed.
[0159] In a possible implementation, after 305, the method further includes: if it is determined that the retry number of the DDL statement is greater than the preset number, sending the first execution result of the DDL statement to the application device.
[0160] For example, in combination with FIG. 6, if the device determines that the retry number of the currently retried DDL statement is greater than the preset number, the execution task is deleted, and the execution result of the DDL statement, i.e., the first execution result, is sent to the application device.
[0161] 307. determining, based on the metadata node, a second data node corresponding to the DDL statement according to table information of the target database; wherein the second data node is a first data node other than the first data node that executes the DDL statement.
[0162] Exemplarily, based on the metadata node of the device deployment, table structure consistency matching is checked according to the table information of the target database, and according to the checking result, if the table structure consistency is passed, each first data node corresponding to the execution of the DDL statement is determined first, and then the second data node is determined from the first data nodes, that is, the second data node is a first data node other than the first data node that successfully executes the DDL statement. For example, for DDL statement 1, data node 1, data node 2, and data node 3 all execute the DDL statement 1, and if it is determined that data node 1 and data node 2 successfully execute the DDL statement 1 in the last execution task, and data node 3 fails to execute the DDL statement 1, then data node 3 is determined as the second data node to execute the DDL statement 1 again.
[0163] In a possible implementation, 307 comprises:
[0164] The first step is to perform identification processing on the table information to obtain an identification result; wherein the identification result represents the version of the current table information.
[0165] The second step is to determine the second data node if it is determined that the identification result represents that the table information is not the current latest version.
[0166] Specifically, in combination with FIG. 6, based on the metadata node of the device deployment, table structure consistency matching is checked according to the table information of the target database corresponding to the current DDL statement, that is, the table information is identified to obtain an identification result to represent the version of the current table information, and then according to the identification result, if it is determined that the table information is not the current latest version, the second data node corresponding to the DDL statement is determined.
[0167] In a possible implementation, the table information includes field information, and the field information represents the field type and length of the table structure; the first step in 307 comprises: performing identification processing on the field information in the table information to obtain an identification result.
[0168] Specifically, each table information includes field information, and each field information represents the field type and length of the table structure; based on the metadata node of the device deployment, the field information in the table information of the target database corresponding to the current DDL statement is identified to obtain an identification result corresponding to the table information.
[0169] In a possible implementation, after the first step in 306 is executed, 306 further comprises:
[0170] The third step is to determine that the first execution result of the DDL statement represents that the DDL statement is executed successfully if it is determined that the recognition result represents that the table information is the current latest version.
[0171] The fourth step is to send the first execution result of the DDL statement to the application device.
[0172] Exemplarily, in combination with FIG. 6, based on the metadata node deployed by the device, the table structure consistency matching check is performed according to the table information of the target database corresponding to the current DDL statement, that is, the table information is recognized to obtain a recognition result to represent the version of the current table information, and then according to the recognition result, if it is determined that the table information is the current latest version, it is indicated that the execution is successful, it is determined that the first execution result of the current DDL statement is execution success, the subtask table state is directly changed to success, and the retry process is exited. The final result of the DDL statement, that is, the first execution result is returned to the Server layer, the Server layer replies to the Proxy, and then the result is returned to the application device.
[0173] 308. Send the DDL statement to a second data node corresponding to the DDL statement; wherein the second data node is configured to re-execute the DDL statement to obtain a second execution result.
[0174] Exemplarily, based on the metadata node deployed by the device, the second data node corresponding to the DDL statement is determined, the DDL statement is sent to the corresponding data node, the DDL statement is re-executed to obtain the second execution result of the DDL statement, and it is known whether the DDL statement is executed successfully; and then, automatic retry can be performed, the process is simplified, and the fault tolerance is improved.
[0175] 309. Update the execution state of the DDL statement according to the second execution result of the DDL statement.
[0176] Exemplarily, the device analyzes the retry result of the current DDL statement, that is, the second execution result, that is, whether the retry execution of the current DDL statement is successful, to update the execution state of the DDL statement.
[0177] In one possible implementation, 308 includes:
[0178] The first step is to update the execution state of the DDL statement to a success state if it is determined that the second execution result represents that the DDL statement is executed successfully.
[0179] The second step comprises: if it is determined that the second execution result represents that the DDL statement fails to be executed, determining a retry number of the DDL statement; and updating an execution state of the DDL statement according to the retry number of the DDL statement; wherein the retry number represents a total number of times of re-executing the DDL statement.
[0180] For each DDL statement that is retried, the device analyzes a retry result of each DDL statement, and if it is determined that the DDL statement is successfully executed, updates the execution state of the DDL statement to a success state, i.e., the state in the subtask table can be updated to the success state; if it is determined that the DDL statement fails to be executed, determines again a retry number of the DDL statement, and updates the execution state of the DDL statement according to the retry number of the DDL statement.
[0181] In a possible implementation, the second step in 308 comprises:
[0182] Step one: if it is determined that the retry number of the DDL statement is greater than a preset number, updating the execution state of the DDL statement to a failure state; and generating a prompt information; wherein the prompt information represents that the current DDL statement fails to be executed, and the prompt information is used to prompt manual processing.
[0183] Step two: if it is determined that the retry number of the DDL statement is less than or equal to the preset number, updating the execution state of the DDL statement to an execution state; and performing the step of determining the table information of the target database.
[0184] Specifically, if the device determines that the retry number of the current DDL statement that fails to be executed is greater than the preset number, i.e., the maximum retry number is exceeded but the DDL statement is still not successfully executed, the execution state of the DDL statement is updated to a failure state; and a prompt information is generated to represent that the current DDL statement fails to be executed, and the prompt information is used to prompt manual processing, i.e., human intervention is needed to troubleshoot the reason for blocking the DDL, such as insufficient disk space, and after the problem is solved, the DDL operation can be directly redone, the data nodes that have been successfully executed are skipped to execute the subtask, and finally the table structure consistency of all data nodes after the DDL is successfully executed is ensured. If the device determines that the retry number of the current DDL statement that fails to be executed is less than or equal to the preset number, i.e., the maximum retry number is not exceeded, the execution state of the DDL statement is updated to an execution state; and the distribution process is performed again, i.e., the step of determining the table information of the target database is performed.
[0185] 310: if it is determined that the execution states of all DDL statements have been updated and processed, the second execution result of the DDL statement is sent to an application device.
[0186] Exemplarily, for each DDL statement of each retry, if it is determined that the execution states of the DDL statements are all updated and completed, i.e., all the DDL statements are executed and the states are updated, the final execution results of the DDL statements are sent to the application device.
[0187] The database processing method provided by the embodiment of the present application comprises the following steps: designing a scheduling module and an execution module of DDL in a database kernel, scheduling DDL jobs and constructing DDL tasks, and cooperatively implementing single-point DDL of a distributed database, without introducing third-party components, thereby avoiding complex operations of directly connecting the execution of each node; meanwhile, because the DDL module reuses the syntax analysis capability of the database kernel, the syntax compatibility is significantly improved.
[0188] The database processing method provided by the embodiment of the present application comprises the following steps: designing a scheduling module and an execution module of DDL in a database kernel, scheduling DDL jobs and constructing DDL tasks, and cooperatively implementing single-point DDL of a distributed database, without introducing third-party components, thereby avoiding complex operations of directly connecting the execution of each node; on the other hand, the distributed database DDL fault-tolerant mechanism automatically identifies whether the table structure is the current latest version when the task fails, and can automatically retry according to the result, thereby improving the fault-tolerant capability and the database processing efficiency.
[0189] FIG. 7 is a structural schematic diagram of a database processing apparatus provided by the present application, as shown in FIG. 7, the database processing apparatus provided by the embodiment of the present application comprises:
[0190] The first execution unit 401 is configured to receive a data definition language (DDL) request sent by an application device, and execute each DDL statement in the DDL request based on at least one first data node, to obtain a first execution result of each DDL statement; wherein the DDL request is used to request to process at least one database; the database is used to store financial business data; and the DDL statement represents a database table operation used to process each database.
[0191] The determining unit 402 is configured to update the execution state of the DDL statement to a failure state if it is determined that the first execution result represents that the DDL statement fails to execute, and determine a retry number of the DDL statement; wherein the retry number represents a total number of times of re-executing the DDL statement.
[0192] The second execution unit 403 is configured to determine table information of a target database if it is determined that the retry number of the DDL statement is less than or equal to a preset number, and execute the DDL statement again according to the table information of the target database, to obtain a second execution result of the DDL statement; wherein the target database is a database to be processed corresponding to the DDL statement; and the table information is table structure information of the target database.
[0193] The sending unit 404 is configured to send the second execution result of the DDL statement to the application device.
[0194] In a possible implementation, the second execution unit 403 is specifically configured to: based on the metadata node, determine, according to table information of the target database, a second data node corresponding to the DDL statement; wherein the second data node is a first data node other than the first data node in which the DDL statement is executed successfully; and send the DDL statement to the second data node corresponding to the DDL statement; wherein the second data node is configured to re-execute the DDL statement to obtain the second execution result.
[0195] In a possible implementation, the second execution unit 403 is specifically configured to: perform identification processing on the table information to obtain an identification result; wherein the identification result represents a version condition of the current table information; and if it is determined that the identification result represents that the table information is not the current latest version, the second data node is determined.
[0196] In a possible implementation, the table information includes field information, and the field information represents a field type and length of a table structure; and the second execution unit 403 is specifically configured to: perform identification processing on the field information in the table information to obtain an identification result.
[0197] In a possible implementation, the second execution unit 403 is further specifically configured to: if it is determined that the identification result represents that the table information is the current latest version, it is determined that the first execution result of the DDL statement represents that the DDL statement is executed successfully; and the first execution result of the DDL statement is sent to the application device.
[0198] In a possible implementation, the first execution unit 401 is specifically configured to: based on the metadata node, generate a DDL task corresponding to the DDL request; wherein the DDL task includes at least one DDL statement in the DDL request; the DDL task has task information; the task information represents an execution state of each DDL statement in the DDL task; write the task information of each DDL task into a subtask table; and based on each first data node, execute the DDL statement in the DDL task to obtain the first execution result of the DDL statement.
[0199] In a possible implementation, the first execution unit 401 is specifically configured to: based on the metadata node, encapsulate each DDL statement in the DDL request to obtain a DDL job corresponding to the DDL request; wherein the DDL job has job information; the job information is database table information to be processed corresponding to the DDL job; if it is determined that the DDL job is allowed to be executed, the job information is stored in the metadata table; wherein the metadata table includes a job table and an information table; the job table is used to record execution of the DDL statement that is currently being executed or not executed; the information table is used to record changes of the target database before and after execution of the DDL statement; determine the number of nodes, and generate each DDL task according to the number of nodes; wherein the number of nodes is the total number of the first data nodes that can be used to execute the database operation; and the DDL task corresponds to the first data node in one-to-one manner.
[0200] In a possible implementation, the first execution unit 401 is specifically configured to: if it is determined that the target DDL job does not exist in the job table, it is determined that the DDL job is allowed to be executed; wherein the target DDL job is a DDL job whose job information is consistent with the job information of the DDL job.
[0201] In a possible implementation, the information table includes table change information and each DDL statement in the DDL job; the table change information represents changes of a table structure of the target database before and after execution of the DDL statement.
[0202] In a possible implementation, the task information includes node information, database information, and log information; the node information is data node information corresponding to the DDL task; the database information is connection identifier information of the target database corresponding to the DDL task; and the log information is error information generated in the process of executing the DDL task.
[0203] In a possible implementation, the sending unit 404 is specifically configured to: based on the second execution result of the DDL statement, update the execution state of the DDL statement; if it is determined that the execution state of each DDL statement has been updated and processed, the second execution result of the DDL statement is sent to the application device.
[0204] In a possible implementation, the sending unit 404 is specifically configured to: if it is determined that the second execution result represents that the DDL statement is executed successfully, the execution state of the DDL statement is updated to a successful state; if it is determined that the second execution result represents that the DDL statement is executed unsuccessfully, the number of retries of the DDL statement is determined; and the execution state of the DDL statement is updated according to the number of retries of the DDL statement; wherein the number of retries represents the total number of times of re-executing the DDL statement.
[0205] In a possible implementation, the sending unit 404 is specifically configured to: if it is determined that the retry number of the DDL statement is greater than the preset number, update the execution state of the DDL statement to a failure state; and generate prompt information; wherein the prompt information indicates that the current DDL statement execution fails, and the prompt information is used to prompt manual processing; if it is determined that the retry number of the DDL statement is less than or equal to the preset number, update the execution state of the DDL statement to an execution state; and perform the step of determining the table information of the target database.
[0206] In a possible implementation, before the second execution unit 403 is specifically configured to determine the table information of the target database, the apparatus is further configured to: if it is determined that the DDL statement has connection information, delete the connection information of the DDL statement; wherein the connection information indicates the connection relationship between the DDL statement and the first data node that executes the DDL statement last time.
[0207] In a possible implementation, the apparatus is further configured to: if it is determined that the first execution result indicates that the DDL statement execution succeeds, update the execution state of the DDL statement to a success state; and send the first execution result of the DDL statement to the application device.
[0208] In a possible implementation, the apparatus further includes: if it is determined that the retry number of the DDL statement is greater than the preset number, the first execution result of the DDL statement is sent to the application device.
[0209] The (apparatus subject) provided in this embodiment can execute the method provided in the above method embodiments, and has similar implementation principles and technical effects, which will not be described here in detail.
[0210] FIG. 8 is a structural schematic diagram of an electronic device provided in this embodiment of the present application, as shown in FIG. 8, the electronic device includes: a memory 501, a processor 502, a memory 501, and a memory for storing executable instructions of the processor 502.
[0211] The processor 502 is configured to execute the method provided in the above embodiments.
[0212] The electronic device 500 further includes a receiver 503 and a transmitter 504. The receiver 503 is configured to receive instructions and data sent by other devices, and the transmitter 504 is configured to send instructions and data to external devices.
[0213] The specific implementation process of the processor 502 can refer to the above method embodiments, and has similar implementation principles and technical effects, which will not be described here in detail.
[0214] In the above embodiments, it should be understood that the processor can be a central processing unit (CPU), and can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor. The steps of the method disclosed in combination with the application can be directly embodied as hardware processor execution, or executed by a combination of hardware and software modules in the processor.
[0215] The memory can include a random access memory (RAM), and can also include a non-volatile memory (NVM), such as at least one disk memory.
[0216] The bus can be an industry standard architecture (ISA) bus, a peripheral component (PCI) bus, or an extended industry standard architecture (EISA) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application does not limit to only one bus or one type of bus.
[0217] The present application also provides a computer program product, comprising a computer program, which is executed by a processor to implement the above method.
[0218] The present application also provides a computer readable storage medium, which stores computer execution instructions, and when the processor executes the computer execution instructions, the above method is implemented.
[0219] The above readable storage medium can be implemented by any type of volatile or non-volatile storage device or their combination, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The readable storage medium can be any available medium that can be accessed by a general-purpose or special-purpose computer.
[0220] An example readable storage medium is coupled to the processor such that the processor can read information from the readable storage medium and can write information to the readable storage medium. Of course, the readable storage medium can also be a part of the processor. The processor and the readable storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the readable storage medium can also exist as discrete components in the device.
[0221] The division of units is only a logical functional division, and in actual implementation, there can be another division manner, for example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interfaces, devices or units, and can be electrical, mechanical or other forms.
[0222] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, can be located in one place, or can be distributed on multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.
[0223] In addition, the functional units in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit.
[0224] If the functions are realized in the form of software function units and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application or the part of the present application that essentially contributes to the prior art or the part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various program code storage media.
[0225] Those skilled in the art can understand that all or part of the steps of the above-mentioned method embodiments can be completed by program instruction related hardware. The foregoing program can be stored in a computer readable storage medium. The program executes to perform the steps of the above-mentioned method embodiments; and the foregoing storage medium includes various media capable of storing program codes, such as ROM, RAM, magnetic disk, or optical disk.
[0226] Finally, it should be noted that other embodiments of the present application will readily occur to those skilled in the art upon consideration of the specification and practice of the present application disclosed herein. The present application is intended to include all such variations as fall within the general scope of the application, and includes the generic principles disclosed and the best mode known to the inventors to be currently practiced as well as variations thereof, without departing from the scope of the present application as defined by the claims. The specification and examples give the best application of the present application as known to at least one of the inventors at the time of the filing hereof and it is to be understood that the scope of the present application is to be given by the claims and it is intended to claim all changes and modifications that come within the meaning and range of equivalents of the claims.
Claims
1. A database processing method characterized by, The method comprises the following steps: receiving a data definition language (DDL) request sent by an application device, and executing each DDL statement in the DDL request based on at least one first data node to obtain a first execution result of each DDL statement; wherein the DDL request is used to request processing of at least one database; the database is used to store financial business data; and the DDL statement represents a database table operation used to process each database; if it is determined that the first execution result represents that the DDL statement fails to execute, updating an execution state of the DDL statement to a failure state, and determining a retry number of the DDL statement; wherein the retry number represents a total number of times of re-executing the DDL statement; if it is determined that the retry number of the DDL statement is less than or equal to a preset number, determining table information of a target database, and re-executing the DDL statement according to the table information of the target database to obtain a second execution result of the DDL statement; wherein the target database is a database to be processed corresponding to the DDL statement; and the table information is table structure information of the target database; sending the second execution result of the DDL statement to the application device.
2. The method of claim 1, wherein, The re-executing the DDL statement according to the table information of the target database to obtain the second execution result of the DDL statement comprises: determining, based on a metadata node and according to the table information of the target database, a second data node corresponding to the DDL statement; wherein the second data node is a first data node other than the first data node that successfully executes the DDL statement; sending the DDL statement to the second data node corresponding to the DDL statement; wherein the second data node is used to re-execute the DDL statement to obtain the second execution result.
3. The method of claim 2, wherein, The determining, based on a metadata node and according to the table information of the target database, a second data node corresponding to the DDL statement comprises: performing identification processing on the table information to obtain an identification result; wherein the identification result represents a version condition of the current table information; if it is determined that the identification result represents that the table information is not a current latest version, determining the second data node.
4. The method of claim 3, wherein, The table information comprises field information, and the field information represents a field type and length of a table structure; The performing identification processing on the table information to obtain an identification result comprises: performing identification processing on the field information in the table information to obtain the identification result.
5. The method of claim 3, wherein, After the performing identification processing on the table information to obtain an identification result, the method further comprises: if it is determined that the identification result represents that the table information is a current latest version, determining that the first execution result of the DDL statement represents that the DDL statement successfully executes; sending the first execution result of the DDL statement to the application device.
6. The method of claim 1, wherein, The executing each DDL statement in the DDL request based on at least one first data node to obtain a first execution result of each DDL statement comprises: The metadata node is used to generate a DDL task corresponding to the DDL request; the DDL task includes at least one DDL statement in the DDL request; the DDL task has task information; and the task information represents an execution state of each DDL statement in the DDL task. The task information of each DDL task is written into a subtask table. Based on each first data node, a DDL statement in the DDL task is executed to obtain a first execution result of the DDL statement.
7. The method of claim 6, wherein, The metadata node is used to generate a DDL task corresponding to the DDL request, including: Based on the metadata node, each DDL statement in the DDL request is encapsulated to obtain a DDL job corresponding to the DDL request; the DDL job has job information; and the job information is database table information to be processed corresponding to the DDL job; If it is determined that the DDL job is allowed to be executed, the job information is stored in a metadata table; the metadata table includes a job table and an information table; the job table is used to record execution of a DDL statement that is currently being executed or not executed; and the information table is used to record changes of a target database before and after execution of the DDL statement; The number of nodes is determined, and each DDL task is generated according to the number of nodes; the number of nodes is a total number of first data nodes that can be used to execute a database operation; and the DDL task corresponds to the first data node in a one-to-one manner.
8. The method of claim 7, wherein, The DDL job is allowed to be executed, including: If it is determined that a target DDL job does not exist in the job table, the DDL job is allowed to be executed; the target DDL job is a DDL job whose job information is consistent with the job information of the DDL job.
9. The method of claim 7, wherein, The information table includes table change information and each DDL statement in the DDL job; and the table change information represents changes of a table structure of a target database before and after execution of the DDL statement.
10. The method of claim 6, wherein, The task information includes node information, database information, and log information; the node information is data node information corresponding to the DDL task; the database information is connection identifier information of a target database corresponding to the DDL task; and the log information is error information generated in the process of executing the DDL task.
11. The method of claim 1, wherein, The second execution result of the DDL statement is sent to the application device, including: According to the second execution result of the DDL statement, an execution state of the DDL statement is updated; If it is determined that the execution state of each DDL statement has been updated, the second execution result of the DDL statement is sent to the application device.
12. The method of claim 11, wherein, According to the second execution result of the DDL statement, an execution state of the DDL statement is updated, including: If it is determined that the second execution result represents that the DDL statement is executed successfully, the execution state of the DDL statement is updated to a successful state; If it is determined that the second execution result represents that the DDL statement fails to be executed, a retry number of the DDL statement is determined, and an execution state of the DDL statement is updated according to the retry number of the DDL statement; wherein the retry number represents a total number of times of re-executing the DDL statement.
13. The method of claim 12, wherein, The updating of the execution state of the DDL statement according to the retry number of the DDL statement comprises: If it is determined that the retry number of the DDL statement is greater than the preset number, the execution state of the DDL statement is updated to a failure state, and prompt information is generated; wherein the prompt information represents that the DDL statement currently fails to be executed, and the prompt information is used to prompt manual processing; If it is determined that the retry number of the DDL statement is less than or equal to the preset number, the execution state of the DDL statement is updated to an execution state, and the step of determining the table information of the target database is executed.
14. The method of claim 1, wherein, Before the table information of the target database is determined, the method further comprises: If it is determined that the DDL statement has connection information, the connection information of the DDL statement is deleted; wherein the connection information represents a connection relationship between the DDL statement and a first data node in which the DDL statement is last executed.
15. The method of any one of claims 1-14, wherein, The method further comprises: If it is determined that the first execution result represents that the DDL statement is successfully executed, the execution state of the DDL statement is updated to a success state, and the first execution result of the DDL statement is sent to the application device.
16. The method of any one of claims 1-14, wherein, The method further comprises: If it is determined that the retry number of the DDL statement is greater than the preset number, the first execution result of the DDL statement is sent to the application device.
17. A database processing apparatus characterized by comprising: Comprise: A first execution unit is configured to receive a data definition language (DDL) request sent by an application device, and execute each DDL statement in the DDL request based on at least one first data node to obtain a first execution result of each DDL statement; wherein the DDL request is used to request processing of at least one database; the database is used to store financial business data; and the DDL statement represents a database table operation used to process each database; A determination unit is configured to update an execution state of the DDL statement to a failure state if it is determined that the first execution result represents that the DDL statement fails to be executed, and determine a retry number of the DDL statement; wherein the retry number represents a total number of times of re-executing the DDL statement. A second execution unit is configured to determine table information of a target database if it is determined that the retry number of the DDL statement is less than or equal to a preset number, and execute the DDL statement again according to the table information of the target database to obtain a second execution result of the DDL statement; wherein the target database is a database to be processed corresponding to the DDL statement, and the table information is table structure information of the target database. A sending unit is configured to send the second execution result of the DDL statement to the application device.
18. An electronic device, comprising: Comprise: A memory and a processor; The memory stores computer execution instructions; The memory stores computer execution instructions; The processor executes computer-executable instructions stored in the memory such that the processor performs the method of any of claims 1-16.
19. A computer-readable storage medium, characterized in that, The computer-readable storage medium has stored therein computer-executable instructions that, when executed by a processor, implement the method of any of claims 1-16.
20. A computer program product comprising a computer program which, when executed by a processor, implements the method of any of claims 1-16.