CN107545015B - A processing method and processing device for querying faults - Google Patents
A processing method and processing device for querying faults Download PDFInfo
- Publication number
- CN107545015B CN107545015B CN201610505556.5A CN201610505556A CN107545015B CN 107545015 B CN107545015 B CN 107545015B CN 201610505556 A CN201610505556 A CN 201610505556A CN 107545015 B CN107545015 B CN 107545015B
- Authority
- CN
- China
- Prior art keywords
- operator
- query
- fault
- intermediate state
- plan tree
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1446—Point-in-time backing up or restoration of persistent data
- G06F11/1458—Management of the backup or restore process
- G06F11/1469—Backup restoration techniques
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2453—Query optimisation
- G06F16/24534—Query rewriting; Transformation
- G06F16/24542—Plan optimisation
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1446—Point-in-time backing up or restoration of persistent data
- G06F11/1448—Management of the data involved in backup or backup restore
- G06F11/1451—Management of the data involved in backup or backup restore by selection of backup contents
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/07—Responding to the occurrence of a fault, e.g. fault tolerance
- G06F11/14—Error detection or correction of the data by redundancy in operation
- G06F11/1402—Saving, restoring, recovering or retrying
- G06F11/1474—Saving, restoring, recovering or retrying in transactions
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2455—Query execution
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2201/00—Indexing scheme relating to error detection, to error correction, and to monitoring
- G06F2201/80—Database-specific techniques
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F2201/00—Indexing scheme relating to error detection, to error correction, and to monitoring
- G06F2201/84—Using snapshots, i.e. a logical point-in-time copy of the data
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Databases & Information Systems (AREA)
- Quality & Reliability (AREA)
- Operations Research (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
本发明公开了一种查询故障的处理方法,包括:接收查询语句,并生成对应的查询计划树,该查询计划树包括流水线关系的多层算子,其中,每个算子都包含由逻辑操作所构成的逻辑关系;根据查询计划树执行查询语句;当执行查询语句的过程中出现故障时,则调取故障算子的中间状态信息,中间状态信息是在执行故障发生之前的备份时间点备份的,根据查询计划树和故障算子的中间状态信息,更新故障算子的操作符以及操作符之间的逻辑关系,以得到重构的查询计划树;当故障恢复后,根据重构的查询计划树,续跑查询语句,以得到查询语句的查询结果。本发明实施例可以保障在故障恢复后,继续执行当前的查询语句,从而减少查询中断对整个查询流程的影响。
The invention discloses a method for processing query faults, comprising: receiving a query statement and generating a corresponding query plan tree, wherein the query plan tree includes multi-layer operators with pipeline relationships, wherein each operator includes a logic operation The logical relationship formed; the query statement is executed according to the query plan tree; when a fault occurs during the execution of the query statement, the intermediate state information of the faulty operator is retrieved, and the intermediate state information is the backup at the backup time point before the execution failure occurs. , according to the query plan tree and the intermediate state information of the fault operator, update the operators of the fault operator and the logical relationship between the operators to obtain the reconstructed query plan tree; after the fault is recovered, according to the reconstructed query Plan the tree and continue to run the query statement to get the query result of the query statement. The embodiments of the present invention can ensure that the current query statement continues to be executed after the fault is recovered, thereby reducing the impact of query interruption on the entire query process.
Description
技术领域technical field
本发明涉及计算机技术领域,具体涉及一种查询故障的处理方法及处理装置。The invention relates to the technical field of computers, in particular to a processing method and processing device for querying faults.
背景技术Background technique
数据库系统是整个软件大厦中最具挑战也是最为核心的部分,一个完整的数据库系统通常由数据库(Database)和数据库管理系统(Database Management System,DBMS)两部分组成。随着大数据时代的到来,数据库中通常都需要存储海量的数据,用户通过数据库管理系统来查询数据库中的数据。为了满足不同用户在不同环境下对于查询业务的需求,需要数据库系统具有很强的健壮性,以保障查询业务的正常进行。而事实上,由于业务环境的复杂性及影响数据库稳定因素的多样性,数据库系统出现故障的可能性始终存在。Database system is the most challenging and core part of the whole software building. A complete database system usually consists of two parts: database and database management system (DBMS). With the advent of the era of big data, the database usually needs to store massive data, and users can query the data in the database through the database management system. In order to meet the needs of different users for query services in different environments, the database system needs to have strong robustness to ensure the normal execution of query services. In fact, due to the complexity of the business environment and the diversity of factors affecting the stability of the database, the possibility of database system failures always exists.
针对一些复杂度较高,查询时间较长的查询业务,数据库系统故障会导致查询业务中断,而随之而来的作业重跑将会严重影响整个业务的进度。作业重跑即从头开始的重新查询。特别的,对于需要保障业务准时结束并用于市场分析的企业来说,进度的延迟将带来灾难性的影响。For some query services with high complexity and long query time, the failure of the database system will cause the query service to be interrupted, and the subsequent job rerun will seriously affect the progress of the entire service. A job rerun is a re-query from scratch. In particular, for companies that need to ensure that business is closed on time and used for market analysis, a delay in schedule can have disastrous effects.
发明内容SUMMARY OF THE INVENTION
为了解决现有技术中查询故障影响整个查询业务流程的问题,本发明实施例提供一种查询故障的处理方法,可以保障在数据库系统故障恢复后,可以继续执行当前的查询语句,从而减少查询中断对整个查询业务流程的影响。本发明实施例还提供了相应的处理装置。In order to solve the problem that a query failure affects the entire query business process in the prior art, the embodiment of the present invention provides a processing method for a query failure, which can ensure that the current query statement can continue to be executed after the database system failure is recovered, thereby reducing query interruption Impact on the entire query business process. The embodiment of the present invention also provides a corresponding processing device.
本发明第一方面提供一种查询故障的处理方法,应用于数据库管理系统,该数据库管理系统可以由数据库服务器来实现,该数据库服务器与数据库的外部存储装置通过通信网络通信,该数据库管理系统在执行查询语句时,若出现查询故障,则查询故障的处理方法包括:接收查询语句,并生成该查询语句对应的查询计划树,查询计划树包括流水线关系的多层算子,其中,每层至少包括一个算子,每个算子都包含操作符以及所述操作符之间的逻辑关系;根据查询计划树执行查询语句;当执行查询语句的过程中出现故障时,则调取故障算子的中间状态信息,中间状态信息是在执行故障发生之前的备份时间点备份的,且中间状态信息包括故障算子在备份时间点已完成的操作和未完成的操作,故障算子为执行故障发生时正在执行查询语句的算子;根据查询计划树和故障算子的中间状态信息,更新故障算子的操作符以及操作符之间的逻辑关系,以得到重构的查询计划树;当故障恢复后,根据重构的查询计划树,续跑查询语句,以得到查询语句的查询结果。本发明实施例中所描述的查询故障可以包括执行节点故障,机器故障和网络异常中断等。从上述第一方面可以看出,通过故障算子的中间状态信息重构查询计划树,可以保障在数据库系统故障恢复后,可以继续执行当前的查询语句,从而减少查询中断对整个查询业务流程的影响。A first aspect of the present invention provides a processing method for querying faults, which is applied to a database management system. The database management system can be implemented by a database server. The database server communicates with an external storage device of the database through a communication network. The database management system is in When a query statement is executed, if a query failure occurs, the processing method for the query failure includes: receiving the query statement, and generating a query plan tree corresponding to the query statement. Including an operator, each operator includes operators and the logical relationship between the operators; the query statement is executed according to the query plan tree; when a fault occurs during the execution of the query statement, the fault operator is called. Intermediate state information. The intermediate state information is backed up at the backup time point before the execution failure occurs, and the intermediate state information includes the completed operations and uncompleted operations of the fault operator at the backup time point. The fault operator is the execution time when the failure occurs. The operator that is executing the query statement; according to the query plan tree and the intermediate state information of the faulty operator, update the operator of the faulty operator and the logical relationship between the operators to obtain the reconstructed query plan tree; when the fault is recovered , and continue to run the query statement according to the reconstructed query plan tree to obtain the query result of the query statement. The query failures described in the embodiments of the present invention may include execution node failures, machine failures, abnormal network interruptions, and the like. From the first aspect above, it can be seen that the query plan tree is reconstructed through the intermediate state information of the fault operator, which can ensure that the current query statement can continue to be executed after the database system fault is recovered, thereby reducing the impact of query interruption on the entire query business process. influences.
结合第一方面,在第一种可能的实现方式中,查询故障的处理方法还包括:基于故障算子的中间状态的备份代价,选择性备份所述故障算子的中间状态信息。本发明实施例中所涉及的代价可以理解为是资源消耗量,如:处理器代价指的是处理器的占用量,页面读取代价指的是进行业务读取所消耗的资源量。从上述第一方面第一种可能的实现方式中可以看出,是否备份故障算子的中间状态信息是基于备份代价的,代价小才会备份,这样不仅可以实现作业续跑,还可以节省硬件资源。With reference to the first aspect, in a first possible implementation manner, the processing method for querying a fault further includes: selectively backing up the intermediate state information of the faulty operator based on the backup cost of the intermediate state of the faulty operator. The cost involved in the embodiment of the present invention can be understood as resource consumption, for example, the processor cost refers to the occupancy of the processor, and the page read cost refers to the amount of resources consumed for service reading. From the first possible implementation of the first aspect above, it can be seen that whether to back up the intermediate state information of the faulty operator is based on the backup cost, and the backup will be performed when the cost is small. This not only enables job continuation, but also saves hardware. resource.
结合第一方面第一种可能的实现方式,在第二种可能的实现方式中,周期性执行第一种可能的实现方式中选择性备份的步骤。With reference to the first possible implementation manner of the first aspect, in the second possible implementation manner, the step of selective backup in the first possible implementation manner is periodically performed.
结合第一方面第一种可能或第二种的实现方式,在第三种可能的实现方式中,上述第一种可能的实现方式中的步骤:基于故障算子的中间状态的备份代价,选择性备份故障算子的中间状态信息,包括:当确定出故障算子续跑所节省的代价大于备份故障算子已完成的操作和恢复故障算子未完成的操作所需要的代价之和时,则备份故障算子的中间状态信息。从上述第一方面第三种可能的实现方式中可以看出,只有当续跑所节省的代价大于备份故障算子已完成的操作和恢复故障算子未完成的操作所需要的代价之和时才会备份该故障算子的中间状态信息,这样可以充分节省硬件资源。In combination with the first possible or second possible implementation manner of the first aspect, in the third possible implementation manner, the steps in the above-mentioned first possible implementation manner: based on the backup cost of the intermediate state of the fault operator, select The intermediate state information of the faulty backup fault operator, including: when it is determined that the cost saved by continuing to run the faulty operator is greater than the sum of the cost of the completed operation of the backup faulty operator and the cost of restoring the uncompleted operation of the faulty operator, The intermediate state information of the faulty operator is backed up. From the third possible implementation of the first aspect above, it can be seen that only when the cost saved by continuing the operation is greater than the sum of the costs required for the operations completed by the backup fault operator and the operations not completed by the recovery fault operator Only the intermediate state information of the faulty operator is backed up, which can fully save hardware resources.
结合第一方面第一种可能或第二种的实现方式,在第四种可能的实现方式中,上述第一种可能的实现方式中的步骤:基于故障算子的中间状态的备份代价,选择性备份故障算子的中间状态信息,包括:当确定出故障算子续跑的代价小于备份故障算子已完成的操作和恢复故障算子未完成的操作所需要的代价之和时,则备份故障算子的中间状态信息。从上述第一方面第四种可能的实现方式中可以看出,只有当续跑的代价小于备份故障算子已完成的操作和恢复故障算子未完成的操作所需要的代价之和时才会备份该故障算子的中间状态信息,这样可以充分节省硬件资源。In combination with the first possible or second possible implementation manner of the first aspect, in the fourth possible implementation manner, the steps in the first possible implementation manner above: based on the backup cost of the intermediate state of the fault operator, select The intermediate state information of the backup fault operator, including: when it is determined that the cost of continuing the operation of the faulty operator is less than the sum of the completed operations of the backup faulty operator and the cost required to restore the uncompleted operations of the faulty operator, the backup Intermediate state information of the fault operator. From the fourth possible implementation of the first aspect above, it can be seen that only when the cost of continuing the operation is less than the sum of the costs of the operations completed by the backup fault operator and the operations that have not been completed by the recovery fault operator. Back up the intermediate state information of the faulty operator, which can fully save hardware resources.
结合第一方面、第一方面第一种或第二种可能的实现方式,在第五种可能的实现方式中,第一方面中的步骤:根据查询计划树和故障算子的中间状态信息,更新故障算子的操作符以及操作符之间的逻辑关系,以得到重构的查询计划树,包括:递归处理未完成的操作和已完成的操作,以得到故障算子的重构信息,所述重构信息包括重构操作符以及所述重构操作符之间的逻辑关系;根据重构信息,更新查询计划树的故障算子中与重构信息对应的原始信息,以得到所述重构的查询计划树,所述原始信息包括原始操作符以及所述原始操作符之间的逻辑关系。从上述第一方面第五种可能的实现方式中可以看出,通过操作符级别的操作符之间的逻辑关系修改完成查询计划树的重构,可以提高重构的效率和准确度。With reference to the first aspect, the first or second possible implementation manner of the first aspect, in a fifth possible implementation manner, the steps in the first aspect: according to the query plan tree and the intermediate state information of the fault operator, Update the operator of the fault operator and the logical relationship between the operators to obtain the reconstructed query plan tree, including: recursively processing the unfinished operations and the completed operations to obtain the reconstruction information of the fault operator, so The reconstruction information includes reconstruction operators and the logical relationship between the reconstruction operators; according to the reconstruction information, update the original information corresponding to the reconstruction information in the fault operator of the query plan tree, so as to obtain the reconstruction information. A query plan tree is constructed, and the original information includes original operators and logical relationships between the original operators. It can be seen from the fifth possible implementation manner of the above-mentioned first aspect that the reconstruction of the query plan tree is completed by modifying the logical relationship between operators at the operator level, which can improve the efficiency and accuracy of reconstruction.
结合第一方面第五种可能的实现方式,在第六种可能的实现方式中,上述第五种可能的实现方式中的步骤:递归处理未完成的操作和已完成的操作,以得到所述故障算子的重构信息,包括:对已完成操作设置已完结操作符,并在未完成操作中设置用于标记未完成操作起始位置的起始操作符,以得到重构操作符以及重构操作符之间的逻辑关系。从上述第一方面第六种可能的实现方式中可以看出,通过操作符级别的操作符之间的逻辑关系修改完成查询计划树的重构,可以提高重构的效率和准确度。With reference to the fifth possible implementation manner of the first aspect, in the sixth possible implementation manner, the steps in the fifth possible implementation manner above: recursively process unfinished operations and completed operations to obtain the Reconstruction information of the faulty operator, including: setting the completed operator for the completed operation, and setting the start operator for marking the starting position of the incomplete operation in the incomplete operation, so as to obtain the reconstruction operator and the restart operator. logical relationship between operators. It can be seen from the sixth possible implementation manner of the above-mentioned first aspect that the reconstruction of the query plan tree is completed by modifying the logical relationship between operators at the operator level, which can improve the efficiency and accuracy of reconstruction.
结合第一方面第三种可能的实现方式,在第七种可能的实现方式中,查询故障的处理方法还包括:当确定出续跑所节省的代价小于所需要的代价之和时,则记录所述查询语句,所述查询语句用于在所述查询故障恢复后,重新生成所述查询计划树。从上述第一方面第七种可能的实现方式中可以看出,当不节省代价时,直接记录查询语句,从而避免不必要的资源消耗。Combined with the third possible implementation manner of the first aspect, in the seventh possible implementation manner, the processing method for querying the fault further includes: when it is determined that the cost saved by continuing running is less than the sum of the required costs, then record The query statement is used to regenerate the query plan tree after the query failure is recovered. It can be seen from the seventh possible implementation manner of the above-mentioned first aspect that when the cost is not saved, the query statement is directly recorded, thereby avoiding unnecessary resource consumption.
结合第一方面第四种可能的实现方式,在第八种可能的实现方式中,查询故障的处理方法还包括:当确定出续跑的代价大于所需要的代价之和时,则记录所述查询语句,所述查询语句用于在所述查询故障恢复后,重新生成所述查询计划树。从上述第一方面第八种可能的实现方式中可以看出,当不节省代价时,直接记录查询语句,从而避免不必要的资源消耗。With reference to the fourth possible implementation manner of the first aspect, in the eighth possible implementation manner, the processing method for querying the fault further includes: when it is determined that the cost of continuing running is greater than the sum of the required costs, recording the A query statement, where the query statement is used to regenerate the query plan tree after the query failure is recovered. It can be seen from the eighth possible implementation manner of the above-mentioned first aspect that when the cost is not saved, the query statement is directly recorded, thereby avoiding unnecessary resource consumption.
结合第一方面、第一方面第一种、第二种或第三种可能的实现方式,在第九种可能的实现方式中,查询故障的处理方法还包括:当生成查询计划树时出现故障,则记录查询语句,查询语句用于在查询故障恢复后,重新生成查询计划树。从上述第一方面第九种可能的实现方式中可以看出,在生成查询计划树阶段出现查询故障,直接记录查询语句,从而避免不必要的资源消耗。In combination with the first aspect, the first, second or third possible implementation manners of the first aspect, in a ninth possible implementation manner, the processing method for a query fault further includes: a fault occurs when a query plan tree is generated , the query statement is recorded, and the query statement is used to regenerate the query plan tree after query failure recovery. It can be seen from the ninth possible implementation manner of the above-mentioned first aspect that a query failure occurs in the stage of generating the query plan tree, and the query statement is directly recorded, thereby avoiding unnecessary resource consumption.
本发明第二方面提供一种查询故障的处理装置,该处理装置被配置实现上述第一方面或第一方面任一可选的实现方式所提供的方法的功能,由硬件/软件实现,其硬件/软件包括与上述功能相应的单元。A second aspect of the present invention provides a processing device for querying faults. The processing device is configured to implement the functions of the method provided in the first aspect or any optional implementation manner of the first aspect, and is implemented by hardware/software. /Software includes units corresponding to the above functions.
本发明第三方面提供一种查询故障处理的装置,包括:收发器、处理器和存储器,存储器用于备份故障算子的中间状态信息;收发器用于接收查询语句;处理器用于执行如下步骤:生成该查询语句对应的查询计划树,查询计划树包括流水线关系的多层算子,其中,每层至少包括一个算子,每个算子都包含操作符以及操作符之间的逻辑关系;根据查询计划树执行查询语句;当执行查询语句的过程中出现故障时,则调取故障算子的中间状态信息,中间状态信息是在执行故障发生之前的备份时间点备份的,且中间状态信息包括故障算子在备份时间点已完成的操作和未完成的操作,故障算子为执行故障发生时正在执行查询语句的算子;根据查询计划树和故障算子的中间状态信息,更新故障算子的操作符以及操作符之间的逻辑关系,以得到重构的查询计划树;当故障恢复后,根据重构的查询计划树,续跑查询语句,以得到查询语句的查询结果。从上述描述可以看出,通过故障算子的中间状态信息重构查询计划树,可以保障在数据库系统故障恢复后,可以继续执行当前的查询语句,从而减少查询中断对整个查询业务流程的影响。从上述第三方面可以看出,通过故障算子的中间状态信息重构查询计划树,可以保障在数据库系统故障恢复后,可以继续执行当前的查询语句,从而减少查询中断对整个查询业务流程的影响。A third aspect of the present invention provides a device for querying fault processing, comprising: a transceiver, a processor and a memory, where the memory is used for backing up intermediate state information of a faulty operator; the transceiver is used for receiving a query statement; the processor is used for performing the following steps: A query plan tree corresponding to the query statement is generated, and the query plan tree includes multiple layers of operators in a pipeline relationship, wherein each layer includes at least one operator, and each operator includes an operator and a logical relationship between the operators; according to The query plan tree executes the query statement; when a fault occurs during the execution of the query statement, the intermediate state information of the faulty operator is retrieved. The intermediate state information is backed up at the backup time point before the execution failure, and the intermediate state information includes The completed and uncompleted operations of the fault operator at the backup time point. The fault operator is the operator that was executing the query statement when the fault occurred; the fault operator is updated according to the query plan tree and the intermediate state information of the fault operator. The operator and the logical relationship between the operators are used to obtain the reconstructed query plan tree; when the fault is recovered, the query statement is continued to run according to the reconstructed query plan tree to obtain the query result of the query statement. It can be seen from the above description that the query plan tree is reconstructed through the intermediate state information of the fault operator, which can ensure that the current query statement can continue to be executed after the database system fails to recover, thereby reducing the impact of query interruption on the entire query business process. From the third aspect above, it can be seen that the query plan tree is reconstructed by the intermediate state information of the fault operator, which can ensure that the current query statement can continue to be executed after the database system fault is recovered, thereby reducing the impact of query interruption on the entire query business process. influences.
结合第三方面,在第一种可能的实现方式中,该查询故障的处理装置中,处理器还用于基于故障算子的中间状态的备份代价,选择性备份故障算子的中间状态信息。从上述第三方面第一种可能的实现方式中可以看出,是否备份故障算子的中间状态信息是基于备份代价的,代价小才会备份,这样不仅可以实现作业续跑,还可以节省硬件资源。With reference to the third aspect, in a first possible implementation manner, in the processing device for querying a fault, the processor is further configured to selectively back up the intermediate state information of the faulty operator based on the backup cost of the intermediate state of the faulty operator. From the first possible implementation of the third aspect above, it can be seen that whether to back up the intermediate state information of the faulty operator is based on the backup cost, and the backup will be performed when the cost is low. This not only enables job continuation, but also saves hardware. resource.
结合第三方面第一种可能的实现方式,在第二种可能的实现方式中,处理器具体用于:周期性执行选择性备份的步骤。With reference to the first possible implementation manner of the third aspect, in the second possible implementation manner, the processor is specifically configured to: periodically execute the step of selective backup.
结合第三方面第一种可能或第二种的实现方式,在第三种可能的实现方式中,处理器具体用于:当确定出故障算子续跑所节省的代价大于备份故障算子已完成的操作和恢复故障算子未完成的操作所需要的代价之和时,则备份故障算子的中间状态信息。从上述第三方面第三种可能的实现方式中可以看出,只有当续跑所节省的代价大于备份故障算子已完成的操作和恢复故障算子未完成的操作所需要的代价之和时才会备份该故障算子的中间状态信息,这样可以充分节省硬件资源。Combined with the first possible or second implementation manner of the third aspect, in the third possible implementation manner, the processor is specifically used for: when it is determined that the cost saved by continuing to run the faulty operator is greater than that of the backup faulty operator. When the sum of the completed operation and the cost required to restore the uncompleted operation of the faulty operator, the intermediate state information of the faulty operator is backed up. From the third possible implementation of the third aspect above, it can be seen that only when the cost saved by continuing to run is greater than the sum of the costs required for the operations completed by the backup fault operator and the operations not completed by the recovery fault operator Only the intermediate state information of the faulty operator is backed up, which can fully save hardware resources.
结合第一方面第一种可能或第二种的实现方式,在第四种可能的实现方式中,处理器具体用于:当确定出故障算子续跑的代价小于备份故障算子已完成的操作和恢复故障算子未完成的操作所需要的代价之和时,则备份故障算子的中间状态信息。从上述第三方面第四种可能的实现方式中可以看出,只有当续跑的代价小于备份故障算子已完成的操作和恢复故障算子未完成的操作所需要的代价之和时才会备份该故障算子的中间状态信息,这样可以充分节省硬件资源。In combination with the first possible or second possible implementation manner of the first aspect, in the fourth possible implementation manner, the processor is specifically configured to: when it is determined that the cost of continuing the operation of the faulty operator is less than the cost of the backup faulty operator that has been completed. The intermediate state information of the faulty operator is backed up when the sum of the costs required to operate and restore the unfinished operations of the faulty operator is calculated. From the fourth possible implementation of the third aspect above, it can be seen that only when the cost of continuing the operation is less than the sum of the costs of the operations completed by the backup fault operator and the costs of recovering the operations not completed by the fault operator. Back up the intermediate state information of the faulty operator, which can fully save hardware resources.
结合第三方面、第三方面第一种或第二种可能的实现方式,在第五种可能的实现方式中,处理器具体用于:递归处理未完成的操作和已完成的操作,以得到故障算子的重构信息,重构信息包括重构操作符以及重构操作符之间的逻辑关系;根据重构信息,更新查询计划树的故障算子中与重构信息对应的原始信息,以得到重构的查询计划树,原始信息包括原始操作符以及原始操作符之间的逻辑关系。从上述第三方面第五种可能的实现方式中可以看出,通过操作符级别的操作符之间的逻辑关系修改完成查询计划树的重构,可以提高重构的效率和准确度。In combination with the third aspect, the first or second possible implementation manner of the third aspect, in the fifth possible implementation manner, the processor is specifically used for: recursively processing unfinished operations and completed operations to obtain The reconstruction information of the fault operator, the reconstruction information includes the reconstruction operator and the logical relationship between the reconstruction operators; according to the reconstruction information, the original information corresponding to the reconstruction information in the fault operator of the query plan tree is updated, To obtain a reconstructed query plan tree, the original information includes the original operators and the logical relationship between the original operators. It can be seen from the fifth possible implementation manner of the above third aspect that the reconstruction of the query plan tree is completed by modifying the logical relationship between operators at the operator level, which can improve the efficiency and accuracy of reconstruction.
结合第三方面第五种可能的实现方式,在第六种可能的实现方式中,处理器具体用于:对已完成操作设置已完结操作符,并在未完成操作中设置用于标记未完成操作起始位置的起始操作符,以得到重构操作符以及重构操作符之间的逻辑关系。从上述第三方面第六种可能的实现方式中可以看出,通过操作符级别的操作符之间的逻辑关系修改完成查询计划树的重构,可以提高重构的效率和准确度。With reference to the fifth possible implementation manner of the third aspect, in the sixth possible implementation manner, the processor is specifically configured to: set a completed operator for a completed operation, and set a flag for an incomplete operation in an incomplete operation The start operator at the starting position of the operation to obtain the refactoring operator and the logical relationship between the refactoring operators. It can be seen from the sixth possible implementation manner of the above third aspect that the reconstruction of the query plan tree is completed by modifying the logical relationship between operators at the operator level, which can improve the efficiency and accuracy of reconstruction.
结合第三方面第三种可能的实现方式,在第七种可能的实现方式中,处理器还用于当确定出续跑所节省的代价小于所需要的代价之和时,则记录查询语句,查询语句用于在查询故障恢复后,重新生成查询计划树。从上述第三方面第七种可能的实现方式中可以看出,当不节省代价时,直接记录查询语句,从而避免不必要的资源消耗。In combination with the third possible implementation manner of the third aspect, in the seventh possible implementation manner, the processor is further configured to record the query statement when it is determined that the cost saved by continuing running is less than the sum of the required costs, The query statement is used to rebuild the query plan tree after query failure recovery. It can be seen from the seventh possible implementation manner of the above third aspect that when the cost is not saved, the query statement is directly recorded, thereby avoiding unnecessary resource consumption.
结合第三方面第四种可能的实现方式,在第八种可能的实现方式中,处理器还用于当确定出续跑的代价大于所需要的代价之和时,则记录查询语句,查询语句用于在查询故障恢复后,重新生成查询计划树。从上述第三方面第八种可能的实现方式中可以看出,当不节省代价时,直接记录查询语句,从而避免不必要的资源消耗。Combined with the fourth possible implementation manner of the third aspect, in the eighth possible implementation manner, the processor is further configured to record the query statement when it is determined that the cost of continuing running is greater than the sum of the required costs. Used to rebuild the query plan tree after query failure recovery. It can be seen from the eighth possible implementation manner of the third aspect above, when the cost is not saved, the query statement is directly recorded, thereby avoiding unnecessary resource consumption.
结合第三方面、第三方面第一种、第二种或第三种可能的实现方式,在第九种可能的实现方式中,处理器还用于当生成查询计划树时出现故障,则记录查询语句,查询语句用于在查询故障恢复后,重新生成查询计划树。从上述第三方面第九种可能的实现方式中可以看出,在生成查询计划树阶段出现查询故障,直接记录查询语句,从而避免不必要的资源消耗。In combination with the third aspect, the first, second or third possible implementation manners of the third aspect, in the ninth possible implementation manner, the processor is further configured to record the query plan tree when a fault occurs when generating the query plan tree. Query statement. The query statement is used to rebuild the query plan tree after query failure recovery. It can be seen from the ninth possible implementation manner of the above-mentioned third aspect that if a query failure occurs in the stage of generating the query plan tree, the query statement is directly recorded, thereby avoiding unnecessary resource consumption.
本发明第四方面提供一种计算机存储介质,该计算机存储介质存储有上述第一方面或第一方面任一可选的实现方式的查询故障的处理程序。A fourth aspect of the present invention provides a computer storage medium, where the computer storage medium stores a fault query processing program according to the first aspect or any optional implementation manner of the first aspect.
本发明第五方面提供一种数据库管理系统,包括:查询故障的处理装置和外部存储装置,所述终端设备为上述第二方面或第三方面的处理装置。A fifth aspect of the present invention provides a database management system, comprising: a processing device for querying faults and an external storage device, and the terminal device is the processing device of the second or third aspect.
附图说明Description of drawings
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他的附图。In order to illustrate the technical solutions in the embodiments of the present invention more clearly, the following briefly introduces the accompanying drawings used in the description of the embodiments. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For those skilled in the art, other drawings can also be obtained from these drawings without creative effort.
图1是本发明实施例中数据库管理系统所处的硬件环境一结构示意图;1 is a schematic structural diagram of a hardware environment where a database management system is located in an embodiment of the present invention;
图2A是本发明实施例中查询计划树的一示例示意图;2A is a schematic diagram of an example of a query plan tree in an embodiment of the present invention;
图2B是本发明实施例中结合数据表的数据库操作示例示意图;2B is a schematic diagram of an example of database operation combined with a data table in an embodiment of the present invention;
图2C是本发明实施例中示例场景的查询结果;Fig. 2C is the query result of the example scene in the embodiment of the present invention;
图3是数据库管理系统的简图;Figure 3 is a schematic diagram of the database management system;
图4是本发明实施例中查询计划树的一种表现形式示意图;4 is a schematic diagram of a representation form of a query plan tree in an embodiment of the present invention;
图5是本发明实施例中查询故障处理过程的一实施例示意图;5 is a schematic diagram of an embodiment of a query fault processing process in an embodiment of the present invention;
图6是本发明实施例中查询故障处理过程的另一实施例示意图;6 is a schematic diagram of another embodiment of a query fault processing process in an embodiment of the present invention;
图7是本发明实施例中查询故障的处理方法的一实施例示意图;7 is a schematic diagram of an embodiment of a processing method for querying a fault in an embodiment of the present invention;
图8是是本发明实施例中服务器的一实施例示意图。FIG. 8 is a schematic diagram of an embodiment of a server in an embodiment of the present invention.
具体实施方式Detailed ways
本发明实施例提供一种查询故障的处理方法,可以保障在故障恢复后,可以继续执行当前的查询语句,节省查询时间。本发明实施例还提供了相应的装置。以下分别进行详细说明。The embodiment of the present invention provides a method for processing a query fault, which can ensure that the current query statement can continue to be executed after the fault is recovered, thereby saving query time. The embodiment of the present invention also provides a corresponding device. Each of them will be described in detail below.
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, but not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts shall fall within the protection scope of the present invention.
本发明实施例中的查询故障的处理方法可以在如图1所示的数据库服务器1中实现,数据库服务器1具有存储器,例如:内存和硬盘等,用于存储数据和计算机可执行程序;数据库服务器1还包括至少一个处理器,例如:中央处理器(Central Processing Unit,CPU)能够从存储器读取计算机可执行程序,并执行程序。数据库服务器1上运行有操作系统15,数据库管理系统(Database Management System,DBMS)5,以及应用程序(APP)3。其中,操作系统(Operating System,OS)15,数据库管理系统5,和应用程序可以以可执行代码的形式存储在存储器中,被处理器执行后实现相应的功能。APP3根据用户的操作或者系统触发,生成查询语句,该查询语句可以是例如:结构化查询语言(Structured QueryLanguage,SQL)。数据库管理系统5用于从APP 3接收查询语句,执行查询语句并返回查询结果到APP3和操作系统15,该操作系统例如可以是Linux。操作系统15用于管理数据库服务器1的硬件与软件资源,并向上层的数据库管理系统5和APP 3提供接口,数据库管理系统5和APP 3可以通过该接口调用相应的硬件资源。The processing method for querying faults in the embodiment of the present invention may be implemented in the
进一步的,如图1所示,数据库服务器1和外部存储装置19经由通信网络17通信连接。Further, as shown in FIG. 1 , the
外部存储装置19可以是任何具有存储资源的装置。例如,外部存储装置19可以是文件服务器,单个磁盘驱动器(例如,硬盘驱动器),或具有多个磁盘驱动器的存储系统。外部存储装置中的数据库21能够存储多个索引25和多个表23。每个索引25的数据包括,例如,图2A和图2B所示出的排列项索引25A和顺序索引25B。每个表23的数据包括,例如,图2B所示的部分表23A,排列项(LINEITEM)表23B和顺序(ORDER)表23C,每个表都包括多个行,每行由多个行元素组成。索引用于建立一个表与另一个表的联系。例如:图2B所示出的排列项索引25A用于建立部分表与排列项表的联系,顺序索引25B用于建立排列项表与顺序表的联系。
如图1所示,DBMS 5包括一个查询接口7、查询计划树发生器11、查询执行器9、查询的任务管理器13和数据库缓冲器(DB缓冲器)12。其中,查询接口7用于接收来自APP3的查询语句,查询计划树发生器11用于产生诸如图2A所示的查询计划树。查询执行器9用于根据查询计划树执行查询语句。任务管理器13用于管理查询语句。DB缓冲器12属于存储资源,可以缓存查询执行器9执行任务时所需的数据。As shown in FIG. 1 , the
下面以图2A和图2B的数据为例,介绍DBMS5执行查询语句,并输出图2C所示的查询结果的过程。The following takes the data of FIG. 2A and FIG. 2B as examples to introduce the process of the DBMS5 executing the query statement and outputting the query result shown in FIG. 2C .
DBMS5从应用程序(例如,APP3)接收查询语句并生成图2A所示的查询计划树。如图2A所示,查询计划树包括流水线关系的五层算子,从最底层到最上层分别为算子1、算子2、算子P3、算子4和算子5,表示这五层算子以流水线的方式依次执行。在图2A所示的示例中,每层算子都包括一个算子,但该示例只是一个特例,实际上,在不同示例场景中,每层算子可以包括一个或多个算子。在本发明实施例中,查询计划树中每层的操作逻辑用一个或多个算子来描述,在其他场景中查询计划树的操作逻辑还可能用操作(Operation,OP)来描述,也可能用节点来描述。但无论用什么来描述,都不应对本发明实施例的理解造成限定。进一步的,因为单个操作符通常不具有逻辑意义,所以算子通常都包含多个操作符以及这些操作符之间的逻辑关系。以算子3为例,该算子3中包括数据提取操作和对象标识符过滤操作,以及数据提取操作和对象标识符过滤操作之间的逻辑关系。其中,数据提取操作和对象标识符过滤操作都需要由多个操作符和操作符之间的逻辑关系组成。算子1中也包含了行查找操作和读取数据操作,以及行查找操作和读取数据操作之间的逻辑关系。而且,行查找操作和读取数据操作都可能需要由多个操作符和操作符之间的逻辑关系组成。其中,图2A中,算子1中包括一个部分表23A,算子3中包括一个排列项(LINEITEM)表23B,算子5中包括一个顺序(ORDER)表23C,算子2中包括排列项索引25A,算子4中包括一个顺序索引25B。其中,部分表23A,排列项表23B和顺序表23C的示例如图2B所示。排列项索引25A和顺序索引25B可以存储在例如图1所示的外部存储装置19中。The DBMS5 receives the query statement from the application (eg, APP3) and generates the query plan tree shown in Figure 2A. As shown in FIG. 2A , the query plan tree includes five layers of operators in a pipeline relationship. From the bottom layer to the top layer, they are
根据图2A所示出的查询计划树。图2A所示的算子1至算子5中被查询执行器9依次执行,直至部分表23A中的所有行被读出。According to the query plan tree shown in Figure 2A.
结合图2A和图2B的算子,执行算子1的过程中通过行查找锁定要读出的行,然后通过从部分表23A读出一个行,例如,读出第二行,名称为BX01,产品(Product)标识PID=301。执行算子2的过程中,从算子1输出的行数据中确定索引PID,例如PID=301,然后使用LINEITEM索引25A的操作,索引到排列项表中相应的行。执行算子3的过程中利用索引PID搜索LINEITEM表23B中相应的数据。当执行算子1读出的是第二行时,则在执行算子2时确定索引PID=301,执行算子3从LINEITEM表23B中读出相应的PID=301的行,然后使用行标识(ROW identifier,OID)执行过滤,例如,仅输出具有OID小于504行,因为在LINEITEM表23B中PID=301的行有两个,对应的OID分别为500和503,则这两个行都可以输出。执行算子4就是执行顺序索引操作,也就是根据执行算子3确定的行,确定索引OID,例如:依照上述描述,确定出的索引为OID=500和OID=503,然后通过索引OID索引到顺序表中相应的行。执行算子5的过程中使用OID搜索ORDER表23C中对应的OID,找到ORDER表23C中对应的行。则使用OID=500和OID=503可以确定ORDER表23C中对应的两行数据。In conjunction with the operators of Figures 2A and 2B, the row to be read is locked by row lookup during the execution of
执行完上述操作后,可以再返回到算子1,读取部分表中的下一行,然后再依次执行上述算子1至算子5的相应操作,直到部分表中的每一行都被读出,最后输出图2C所示出的查询结果。After performing the above operations, you can return to
在图2A至图2C的实施例中,通过查询执行器9执行算子的任务。如果有必要在任务执行期间读取外部存储装置19的数据时,查询执行器9会读出该数据,执行算子任务。In the embodiment of FIGS. 2A to 2C , the task of the operator is performed by the
下面再以图3和图4为例,介绍在数据库管理系统在正常状态下执行查询语句的过程,图3所示的数据库管理系统5,只示出了一些关键模块,其他未示出的模块功能可以参阅图1部分进行理解。3 and 4 are used as examples to introduce the process of executing query statements in the database management system under normal conditions. The
如图3所示,数据库管理系统可以包括查询接口7、查询计划发生器11和查询执行器9,查询接口7接收到查询语句后,查询计划发生器11会根据获取的查询语句,生成查询计划树,所述查询计划树包括流水线关系的多层算子,各层算子之间按照流水线的方式顺序执行,且上层算子的输入依赖有直接流向关系的相邻下层算子的输出。As shown in FIG. 3, the database management system may include a
该查询语句可以是结构化查询语言(Structured Query Language,SQL)语句。需要说明的是,对于一些复杂度较高,查询执行时间较长的查询语句,在本发明所有实施例中统一称为大查询,如大的选择查询、数据重分布和大的更新查询等。实际上,查询语句与查询任务是对应的,查询任务通常是面向用户的表达方式,查询语句是与该查询任务对应的机器语言。The query statement may be a structured query language (Structured Query Language, SQL) statement. It should be noted that some query statements with high complexity and long query execution time are collectively referred to as large queries in all embodiments of the present invention, such as large selection queries, data redistribution, and large update queries. In fact, the query statement corresponds to the query task, the query task is usually a user-oriented expression, and the query statement is the machine language corresponding to the query task.
查询计划树还可以参照图4的表示方式进行理解,1层算子为最下层的算子,2层算子的输入依赖1层算子的输出,3层算子的输入依赖2层算子的输出,4层算子的输入依赖3层算子的输出,在图2所示的示例中,4层算子为最上层的算子。其中,1层的1号算子和2号算子与2层的5号算子有直接流向关系,2层5号算子和6号算子与3层的8号算子有直接流向关系,3层的8号算子和9号算子与4层的10号算子有直接流向关系。其他算子间的流向关系可以参阅图4和前述的示例性描述进行理解,在此不再一一赘述。The query plan tree can also be understood by referring to the representation in Figure 4. The 1-layer operator is the lowest-level operator, the input of the 2-layer operator depends on the output of the 1-layer operator, and the input of the 3-layer operator depends on the 2-layer operator. The output of the 4-layer operator depends on the output of the 3-layer operator. In the example shown in Figure 2, the 4-layer operator is the top-layer operator. Among them, the No. 1 and No. 2 operators on the 1st floor have a direct flow relationship with the No. 5 operator on the 2nd floor, and the No. 5 and No. 6 operators on the 2nd floor have a direct flow relationship with the No. 8 operator on the 3rd floor. , the No. 8 operator and No. 9 operator on the 3rd floor have a direct flow relationship with the No. 10 operator on the 4th floor. The flow direction relationship between other operators can be understood with reference to FIG. 4 and the foregoing exemplary description, and details are not repeated here.
图4所示出的只是查询计划树的一种表示方式,实际上,查询计划树的表示方式可以有很多种,不应将图4理解为是对查询计划树表示方式的限定。FIG. 4 shows only one representation of the query plan tree. In fact, there are many representations of the query plan tree, and FIG. 4 should not be construed as a limitation on the representation of the query plan tree.
查询执行器9会根据查询计划发生器11生成的查询计划树依次完成每个算子的功能,最终完成该查询语句,得到查询结果,并将该查询结果反馈给用户。The
以上实施例所描述的是正常的查询语句执行过程,实际上,对于数据库管理系统中的查询业务,尤其是大查询业务,整个查询过程中会有很多算子互相配合着以流水线式工作,有下层算子的输入才会产生上层算子的输出。因此,当查询在一个算子处中断时,很有可能该算子已经完成了部分的业务。虽然该算子出现故障,但下层算子仍在不断的输入。造成下层算子在故障后输入的数据丢失,无法追溯,从而导致很难根据中断时候的状态进行作业续跑。作业续跑是指从查询中断时已经完成的查询位置继续完成后续的查询语句。若针对一个查询语句,在故障恢复后,无法实现作业续跑,只能依靠作业重跑来完成查询语句。作业重跑必然会增加查询作业的时间,因此,解决此类问题的关键在于是否可以利用已经完成的工作来继续执行这个大查询。The above embodiment describes the normal query statement execution process. In fact, for the query business in the database management system, especially the large query business, there will be many operators in the entire query process. The input of the lower operator will produce the output of the upper operator. Therefore, when a query is interrupted at an operator, it is very likely that the operator has completed part of the business. Although the operator fails, the lower operator is still continuously input. As a result, the data input by the lower-level operator after the failure is lost and cannot be traced back, which makes it difficult to resume the job according to the state at the time of interruption. Job continuation refers to continuing to complete subsequent query statements from the query position that was completed when the query was interrupted. For a query statement, after the failure is recovered, the job cannot be resumed, and the query statement can only be completed by rerunning the job. Job reruns will inevitably increase the time of query jobs. Therefore, the key to solving such problems is whether the completed work can be used to continue the execution of this large query.
在数据库管理系统执行查询业务时,按照系统类型的不同,可以包括非流水线的查询方式和流水线的查询方式,甲骨文(Oracle)系统和SQL Server系统都属于流水线的查询方式。When the database management system executes the query business, according to the different types of systems, it can include non-pipeline query methods and pipeline query methods. Both Oracle and SQL Server systems belong to pipeline query methods.
Oracle和SQL Server等数据库在执行查询语句时是按照流水线去执行的,即上层算子的输出依赖于下层算子的输入,由于流水线的执行方式很难存储每个算子在每个时刻的状态信息,所以这种执行方式上的差异性导致了Oracle和SQL Server这种流水线的系统难以解决查询的可继续执行问题。Databases such as Oracle and SQL Server execute the query statement according to the pipeline, that is, the output of the upper layer operator depends on the input of the lower layer operator. Due to the execution mode of the pipeline, it is difficult to store the state of each operator at each moment. Therefore, this difference in execution mode makes it difficult for pipelined systems such as Oracle and SQL Server to solve the problem of continuous execution of queries.
本发明实施例中,所涉及到的出现故障的时刻主要包括两种。In this embodiment of the present invention, the involved moments of failure mainly include two types.
第一种是查询执行器9执行过程中出现故障。The first is that the
第二种是可以在查询计划发生器11生成查询计划树时出现故障,该种情况包括查询计划树已经生成。The second is that a failure may occur when the
下面针对第一种故障出现的时刻,结合图5介绍本发明实施例在查询执行器9执行各算子功能时出现故障的查询故障的处理方法。A method for processing a query fault that occurs when the
图5为本发明实施例中查询故障处理的一实施例示意图。图5所示的数据块管理系统5为简图,只画出了一些关键模块,其他未示出的模块功能可以参阅图1部分进行理解。FIG. 5 is a schematic diagram of an embodiment of query fault processing in an embodiment of the present invention. The data
如图5所示,本发明实施例提供的查询故障的处理方法的一实施例包括:As shown in FIG. 5 , an embodiment of the processing method for querying a fault provided by an embodiment of the present invention includes:
数据库管理系统可以包括查询接口7、查询计划发生器11、查询执行器9、决策模块8和重构模块10。The database management system may include a
查询接口7接收到查询语句后,将查询语句传递给查询计划发生器11,查询计划发生器11会根据查询语句,生成查询计划树,所述查询计划树包括流水线关系的多层算子,也就是,上层算子的输入依赖有直接流向关系的相邻下层算子的输出,其中,每层至少包括一个算子,每个算子都包含由逻辑操作符以及所述操作符之间的逻辑关系。查询计划树可以参照图4的表示方式进行理解。After the
查询执行器9会根据查询计划发生器11生成的查询计划树,从数据库中获取数据依次完成各算子的功能,在执行各算子功能的过程中,查询执行器9会周期性的将各算子的中间状态信息备份到数据库中,以便于数据库管理系统发生故障时,不会造成中间状态信息丢失。The
当正在执行某个算子的功能时,会在备份时间点备份该算子的中间状态信息,该中间状态信息包括存储时该算子中已完成的操作和未完成的操作。备份可以是周期性备份。When the function of an operator is being executed, the intermediate state information of the operator is backed up at the backup time point, and the intermediate state information includes the completed operations and uncompleted operations in the operator at the time of storage. Backups can be periodic backups.
当在执行该算子功能过程中,出现查询故障,则该算子成为故障算子,也就是说当所述查询语句执行到所述多层算子中的故障算子处出现查询故障,则调取故障算子的中间状态信息,所述中间状态信息是在所述执行故障发生之前的备份时间点备份的,且所述中间状态信息包括所述故障算子在所述备份时间点已完成的操作和未完成的操作,所述故障算子为所述执行故障发生时正在执行所述查询语句的算子。When a query fault occurs during the execution of the operator function, the operator becomes a faulty operator, that is, when the query statement is executed to the faulty operator in the multi-layer operator, a query fault occurs, then the operator becomes a faulty operator. Retrieve the intermediate state information of the faulty operator, the intermediate state information is backed up at the backup time point before the execution failure occurs, and the intermediate state information includes that the faulty operator has been completed at the backup time point operations and unfinished operations, the fault operator is an operator that is executing the query statement when the execution fault occurs.
例如:执行图4所示的5号算子时,则可以备份5号算子中间状态信息,当5号算子还未执行完时出现查询故障,则可以调取该5号算子在故障发生之前的备份时间点备份的中间状态信息,所述中间状态信息包括在所述备份时间点5号算子中已完成的操作和未完成的操作。For example, when the operator No. 5 shown in Figure 4 is executed, the intermediate state information of the operator No. 5 can be backed up. When a query failure occurs when the operator No. 5 has not been executed, the operator No. 5 can be retrieved when the fault occurs. The intermediate state information of the backup at the backup time point before the occurrence, the intermediate state information includes the completed operation and the uncompleted operation in the operator No. 5 at the backup time point.
在本发明实施例中,查询执行器9周期性备份故障算子的中间状态信息,然后由重构模块10根据所述查询计划树和所述故障算子的中间状态信息,更新所述故障算子的操作符以及所述操作符之间的逻辑关系,以得到重构的查询计划树。In this embodiment of the present invention, the
当所述故障恢复后,根据所述重构的查询计划树,续跑所述查询语句,以得到所述查询语句的查询结果。After the fault is recovered, continue to run the query statement according to the reconstructed query plan tree to obtain the query result of the query statement.
这种查询故障的处理方法,可以在出现故障时,根据出现故障处算子的中间状态信息,重构查询计划树,在故障恢复后,可以根据该重构的查询计划树实现查询语句的续跑,也就是从故障发生处继续执行当前的查询语句,从而节省了查询时间。This query fault processing method can reconstruct the query plan tree according to the intermediate state information of the operator where the fault occurs when a fault occurs. After the fault is recovered, the continuation of the query statement can be realized according to the reconstructed query plan tree. Running, that is, continuing to execute the current query statement from the point where the failure occurred, thus saving query time.
进一步地,通过测试发现,并不一定每次保存算子的中间状态信息都会有收益的。因此,本发明实施例进一步提出了代价决策方案,也就是,针对正在执行的每个算子,基于算子的中间状态的备份代价,选择性备份算子的中间状态信息。Further, through testing, it is found that it is not necessarily profitable to save the intermediate state information of the operator every time. Therefore, the embodiment of the present invention further proposes a cost decision scheme, that is, for each operator being executed, based on the backup cost of the intermediate state of the operator, the intermediate state information of the operator is selectively backed up.
可以理解为由图5中的决策模块8来执行,也就是说,在查询执行器9执行算子功能的过程中到达备份时间点时,则确定所述故障算子续跑所节省的代价是否大于备份所述故障算子已完成的操作和恢复所述故障算子未完成的操作所需要的代价之和;当确定出所述故障算子续跑所节省的代价大于备份所述故障算子已完成的操作和恢复所述故障算子未完成的操作所需要的代价之和时,则备份所述故障算子的中间状态信息。另外,还可以是确定所述故障算子续跑的代价是否小于备份所述故障算子已完成的操作和恢复所述故障算子未完成的操作所需要的代价之和;当确定出所述故障算子续跑的代价小于备份所述故障算子已完成的操作和恢复所述故障算子未完成的操作所需要的代价之和时,则备份所述故障算子的中间状态信息。这样,通过决策模块8决策后,再备份中间状态信息,重构所述查询计划树,得到重构的查询计划树。不仅可以实现作业续跑,节省查询时间,还可以节省硬件资源。It can be understood that it is executed by the decision-
本发明实施例中所涉及的代价可以理解为是资源消耗量,如:处理器代价指的是处理器的占用量,页面读取代价指的是进行业务读取所消耗的资源量。The cost involved in the embodiment of the present invention can be understood as resource consumption, for example, the processor cost refers to the occupancy of the processor, and the page read cost refers to the amount of resources consumed for service reading.
本发明实施例中所描述的查询故障可以包括执行节点故障,机器故障和网络异常中断等。The query failures described in the embodiments of the present invention may include execution node failures, machine failures, abnormal network interruptions, and the like.
当决策模块8确定出续跑所节省的代价小于所述所需要的代价之和时,则记录所述查询语句,所述查询语句用于在所述查询故障恢复后,重新生成所述查询计划树。When the
还可以是,当决策模块8确定出续跑的代价大于所需要的代价之和时,则记录所述查询语句,所述查询语句用于在所述查询故障恢复后,重新生成所述查询计划树。It can also be that when the
完成上述核心思想的关键技术就是在流水线执行框架下进行基于代价的中间状态信息备份。为了细化代价估算,首先针对算子采用操作符级别隔离的代价计算。例如,当5号算子为Hash Join算子时,该Hash Join算子中包含了两部分操作:第一部分是对获取得到的右表进行构建(build)操作,第二部分是对获取得到的左表进行探测(probe)操作。这样就需要得到每个操作符对应的代价。其次还可以参照查询计划发生器11在生成查询计划树时所提供的基本代价,如中央处理器(Central Processing Unit,CPU)代价和页面读取代价等计算存储当前状态所需要的代价,存储所需的代价主要为写状态所需的代价。再者,依据当前执行状态,估算当前故障算子进行续跑所节省的代价。有了这些基本代价后,就可以决策是否进行存储:当续跑所节省的代价大于存储和恢复执行所消耗的代价时,则备份当前查询计划树所涉及算子的所有状态;当续跑所节省的代价小于存储和恢复所消耗的代价,则不作任何存储处理,此时集群恢复后,直接依据查询语句得到查询结果。在实际实施中,基于代价的决策可采用定期评价或者通过操作符自行进行判断两种方式进行调用。The key technology to complete the above core idea is to perform cost-based intermediate state information backup under the pipeline execution framework. To refine the cost estimation, we first employ operator-level isolated cost computation for the operators. For example, when operator No. 5 is a Hash Join operator, the Hash Join operator contains two parts of operations: the first part is to perform a build operation on the obtained right table, and the second part is to perform a build operation on the obtained right table. The left table performs the probe operation. In this way, you need to get the cost corresponding to each operator. Secondly, you can also refer to the basic cost provided by the
可选地,所述根据所述查询计划树和所述故障算子的中间状态信息,更新所述故障算子的操作符以及所述操作符之间的逻辑关系,以得到重构的查询计划树,可以包括:Optionally, updating the operator of the fault operator and the logical relationship between the operators according to the query plan tree and the intermediate state information of the fault operator, so as to obtain a reconstructed query plan. tree, which can include:
递归处理所述未完成的操作和所述已完成的操作,以得到所述故障算子的重构信息,所述重构信息包括重构操作符以及所述重构操作符之间的逻辑关系;Recursively process the unfinished operations and the completed operations to obtain reconstruction information of the faulty operator, where the reconstruction information includes reconstruction operators and logical relationships between the reconstruction operators ;
根据所述重构信息,更新所述查询计划树的所述故障算子中与所述重构信息对应的原始信息,以得到所述重构的查询计划树,所述原始信息包括原始操作符以及所述原始操作符之间的逻辑关系。According to the reconstruction information, the original information corresponding to the reconstruction information in the fault operator of the query plan tree is updated to obtain the reconstructed query plan tree, where the original information includes the original operator and the logical relationship between the primitive operators.
其中,所述递归处理所述未完成的操作和所述已完成的操作,以得到所述故障算子的重构信息,包括:Wherein, the recursive processing of the unfinished operation and the completed operation to obtain the reconstruction information of the faulty operator, including:
对所述已完成操作设置已完结操作符,并在所述未完成操作中设置用于标记未完成操作起始位置的起始操作符,以得到所述重构操作符以及所述重构操作符之间的逻辑关系。A completed operator is set for the completed operation, and a start operator for marking the starting position of the incomplete operation is set in the incomplete operation, so as to obtain the reconstruction operator and the reconstruction operation logical relationship between characters.
本发明实施例在备份算子的中间状态信息后,关键点是需要根据所述查询计划树和所述算子的中间状态信息重构所述查询计划树,得到重构的查询计划树。具体重构过程可以是:After the intermediate state information of the operator is backed up in the embodiment of the present invention, the key point is that the query plan tree needs to be reconstructed according to the query plan tree and the intermediate state information of the operator to obtain a reconstructed query plan tree. The specific reconstruction process can be:
根据所述故障算子的中间状态信息,确定所述故障算子中未完成的操作和已完成的操作,可以将故障算子中未完成的操作定义为左子树,将故障算子中已完成的操作定义为右子树。Unfinished operations and completed operations in the fault operator are determined according to the intermediate state information of the fault operator, the unfinished operations in the fault operator can be defined as the left subtree, The completed operation is defined as the right subtree.
将备份的故障算子中的已完成的操作结果标记为saved存储状态,也就是设置已完结操作符,将其作为当前算子的右子树用于后期扫描。与此同时,由于仍有部分需要后续处理,因此需要在该当前算子的上层添加“UNION ALL”,将未完成的操作作为左子树,并在所述未完成操作中设置用于标记未完成操作起始位置的起始操作符。然后递推处理当前算子的左子树和右子树。Mark the completed operation result in the backup fault operator as the saved storage state, that is, set the completed operator and use it as the right subtree of the current operator for later scanning. At the same time, since there are still parts that need subsequent processing, it is necessary to add "UNION ALL" to the upper layer of the current operator, take the unfinished operation as the left subtree, and set the unfinished operation to mark the unfinished operation. The start operator that completes the start position of the operation. Then recursively process the left subtree and right subtree of the current operator.
关于右子树是已完成的操作,左子树是未完成的操作本处只是举例说明,实际上,也可以是右子树是未完成的操作,左子树是已完成的操作。The right subtree is a completed operation, and the left subtree is an uncompleted operation. This is just an example. In fact, it can also be that the right subtree is an uncompleted operation, and the left subtree is a completed operation.
当得到重构的查询计划树后,在故障恢复后,利用重构的查询计划树进行续跑操作。After obtaining the reconstructed query plan tree, use the reconstructed query plan tree to continue the operation after the fault is recovered.
为了说明本发明实施例中所涉及的技术点,下面将构造实际的查询语句用于说明本发明实施例的查询执行过程。本发明实施例示例中选用的sql语句是“INSERT INTO C(C1,C2)SELECT A.col,B.col FROM A INNER JOIN B ONA.col=B.col GROUP BY 1,2LIMIT 100”。In order to illustrate the technical points involved in the embodiments of the present invention, an actual query statement will be constructed below to describe the query execution process of the embodiments of the present invention. The selected sql statement in the example of the embodiment of the present invention is "INSERT INTO C(C1, C2) SELECT A.col, B.col FROM A INNER JOIN B ONA.col=B.
本发明实施例的一个关键点就是进行查询计划树的重构。因此需要先获得上述根据查询语句生成的查询计划树。因为无论查询计划树中有多少个算子,在执行过程中都是逐个算子执行的,因此下面以查询计划树种的一个算子的结构为例进行说明,一下为一个算子的结构和该算子中执行相应操作所需要的代价:A key point of the embodiments of the present invention is to reconstruct the query plan tree. Therefore, it is necessary to first obtain the above query plan tree generated according to the query statement. Because no matter how many operators there are in the query plan tree, the operators are executed one by one during the execution process. Therefore, the structure of an operator in the query plan tree is used as an example to illustrate the structure of an operator and the The cost of performing the corresponding operation in the operator:
其中,右边的cost代表进行相应操作所需要的代价。由于执行操作中的HashJoin包含了build过程和probe过程。因此两部分的操作符需要分开统计执行代价。当故障场景是:Hash Join已经开始输出,根据该算子在备份时间点上备份的中间状态信息可以确定,build操作已完成,probe操作还有一部分未完成,则在当前Hash Join的上层添加包含已完成操作和未完成操作的合并标识符“UNION ALL”,然后将已完成的build操作定义为该算子的右子树。可以设置已完结操作符Scan(saved_B),probe操作还有一部分未完成,则在所述未完成操作中设置用于标记未完成操作起始位置的起始操作符,例如:probe操作中的Scan(part of A),将probe操作中还未完成的部分(probe)Scan(partof A)定义为该算子的左子树。对于左子树而言,当前Scan(A)操作并未结束,因此只需记录已扫描的位置而无需改变子树状态。对于右子树而言,build操作实际已经结束,为了保证完整性,在该Scan(B)原有位置增加,原有Scan(B)由于实际build操作已经完成,而已完成的备份结果标记为saved_B,作为其右子树。随着操作和操作逻辑关系的更新,各操作所需的代价也随之修改。因此可以得到该算子的重构信息为以下内容。Among them, the cost on the right represents the cost required to perform the corresponding operation. Because the HashJoin in the execution operation includes the build process and the probe process. Therefore, the operators of the two parts need to separately count the execution cost. When the fault scenario is: Hash Join has started to output, according to the intermediate state information backed up by the operator at the backup time point, it can be determined that the build operation has been completed, and part of the probe operation has not been completed. The combined identifier "UNION ALL" of completed and unfinished operations, and then the completed build operation is defined as the right subtree of this operator. The completed operator Scan(saved_B) can be set. If there is still a part of the probe operation unfinished, the start operator used to mark the starting position of the unfinished operation is set in the unfinished operation, for example: Scan in the probe operation (part of A), define the unfinished part (probe) Scan(partof A) in the probe operation as the left subtree of the operator. For the left subtree, the current Scan(A) operation is not over, so it is only necessary to record the scanned position without changing the state of the subtree. For the right subtree, the build operation has actually ended. In order to ensure the integrity, it is added to the original position of the Scan(B). The original Scan(B) has been completed due to the actual build operation, and the completed backup result is marked as saved_B. , as its right subtree. As operations and operational logical relationships are updated, the costs required by each operation are also modified. Therefore, the reconstruction information of the operator can be obtained as follows.
用重构信息更新故障算子处的原始信息,得到更新后的算子之间操作和操作之间的关系可以参阅如下内容进行理解。Use the reconstructed information to update the original information at the faulty operator to obtain the updated operator and the relationship between the operations. Refer to the following content for understanding.
故障算子更新后,也就得到了重构的查询计划树。After the fault operator is updated, the reconstructed query plan tree is obtained.
依据上述产生的重构的查询计划树与原有查询计划树在执行意义上本质上是一致的。这也是保障故障恢复后查询能够执行的关键之所在。The reconstructed query plan tree generated according to the above is essentially the same as the original query plan tree in terms of execution. This is also the key to ensuring that queries can be executed after failure recovery.
下面结合上述代价示例,说明本发明实施例中基于代价来评估备份策略。同样的,依据上述查询语句生成的查询计划作为初始的代价。考虑如下几种场景:The following describes the evaluation of the backup policy based on the cost in the embodiment of the present invention with reference to the above-mentioned cost example. Similarly, the query plan generated according to the above query statement is used as the initial cost. Consider the following scenarios:
当Hash Join执行build中,假设Scan(B)已经执行了30,则存储和恢复代价包含恢复Hash Join所需的40以及扫描B所需的1,共41,而节省的代价及已经执行的部分30。此时代价小于存储和恢复代价,放弃存储,可直接重算。When Hash Join is executing the build, assuming that Scan(B) has been executed for 30, the storage and recovery cost includes 40 required to restore Hash Join and 1 required to scan B, a total of 41, and the saved cost and the part that has been executed 30. At this time, the cost is less than the storage and recovery costs, and the storage can be abandoned and recalculated directly.
当Hash Join已经完成build,存储和恢复代价包括存储Scan(B)和恢复HashJoin的代价,共计90。而节省代价则包含Scan(B)所花费的70以及Build操作所花费的60,共计130。节省代价大于存储和恢复代价,存储Hash Join的hash表。When the Hash Join has been built, the storage and recovery costs include the storage Scan(B) and HashJoin recovery costs, totaling 90. The cost savings includes 70 for Scan(B) and 60 for Build operation, totaling 130. The cost of saving is greater than the cost of storage and recovery, and the hash table of Hash Join is stored.
当Hash Join已经处于输出状态,且Scan(A)已经进行了100,存储和恢复代价包括存储Hash Join部分输出结果所需的30以及恢复Scan(A)所需的1,共计31。而节省代价包括Scan(A)的100以及Scan(B)的70共170。节省代价大于存储和恢复代价,存储Hash Join的hash表以及部分Hash Join的部分输出结果。When Hash Join is already in the output state and Scan(A) has been performed 100 times, the storage and restoration costs include 30 required to store the partial output result of Hash Join and 1 required to restore Scan(A), totaling 31. The savings include 100 for Scan(A) and 70 for Scan(B) totaling 170. The saving cost is greater than the storage and recovery cost. The hash table of Hash Join and some output results of Hash Join are stored.
依次类推,当此次评价结束后,将清除上次存储的所有结果。And so on, when the evaluation ends, all the results stored last time will be cleared.
得益于大查询能够在查询故障恢复后利用存储的中间状态进行查询续跑,保障业务在发生不可预期的故障后能够用较低的代价完成作业的续跑,从而使得整个业务流程不受大查询作业的影响。Thanks to the large query, the intermediate state of the storage can be used to continue the query after the query failure is recovered, which ensures that the business can complete the continuation of the job at a lower cost after an unexpected failure occurs, so that the entire business process is not affected by the large-scale operation. Query job impact.
上述第二种故障出现的时刻所涉及的查询故障处理的过程描述完后,下面结合图6,介绍本发明实施例中第二种故障出现的时刻所涉及的查询故障处理的过程。After the description of the query fault processing process involved in the moment when the second type of fault occurs, the following describes the query fault processing process involved in the moment when the second type of fault occurs in the embodiment of the present invention with reference to FIG. 6 .
图6本发明实施例中查询故障处理的另一实施例示意图。图6所示的数据块管理系统5为简图,只画出了一些关键模块,其他未示出的模块功能可以参阅图1部分进行理解。FIG. 6 is a schematic diagram of another embodiment of query fault processing in an embodiment of the present invention. The data
如图6所示,本发明实施例提供的查询故障处理的过程包括:As shown in FIG. 6 , the process of processing a query fault provided by an embodiment of the present invention includes:
查询管理设备可以包括查询接口7、查询计划发生器11和查询执行器9,查询接口7接收查询语句后,将查询语句传递给查询计划发生器11,查询计划发生器11会根据获取的查询语句,生成查询计划树,所述查询计划树包括流水线关系的多层算子,也就是上层算子的输入依赖有直接流向关系的相邻下层算子的输出,其中,每个算子都包含由逻辑操作所构成的逻辑关系。The query management device may include a
在查询计划发生器11生成查询计划树时出现查询故障,由于查询计划发生器11生成查询计划树所需的时间相对于查询执行器9执行算子功能的时间相对来说是非常少的,因此当故障发生时,查询语句仍停留在优化器处理阶段,可直接记录当前执行的查询语句而无需保存任何的中间状态。当环境故障恢复后,可重新解析该查询语句生成执行计划并交给查询执行器9完成最终的查询语句。A query failure occurs when the
参阅图7,本发明实施例提供的查询故障的处理方法的一实施例包括:Referring to FIG. 7 , an embodiment of the processing method for querying a fault provided by an embodiment of the present invention includes:
101、接收查询语句,并生成所述查询语句对应的查询计划树,所述查询计划树包括流水线关系的多层算子,其中,每层至少包括一个算子,每个算子都包含操作符以及所述操作符之间的逻辑关系。101. Receive a query statement, and generate a query plan tree corresponding to the query statement, where the query plan tree includes multiple layers of operators in a pipeline relationship, wherein each layer includes at least one operator, and each operator includes an operator and the logical relationship between the operators.
102、根据所述查询计划树执行所述查询语句。102. Execute the query statement according to the query plan tree.
103、当执行所述查询语句的过程中出现故障时,则调取故障算子的中间状态信息,所述中间状态信息是在所述执行故障发生之前的备份时间点备份的,且所述中间状态信息包括所述故障算子在所述备份时间点已完成的操作和未完成的操作,所述故障算子为所述执行故障发生时正在执行所述查询语句的算子。103. When a failure occurs during the execution of the query statement, retrieve intermediate state information of the faulty operator, where the intermediate state information is backed up at the backup time point before the execution failure occurs, and the intermediate state information is The state information includes completed operations and uncompleted operations of the fault operator at the backup time point, and the fault operator is an operator that is executing the query statement when the execution fault occurs.
104、根据所述查询计划树和所述故障算子的中间状态信息,更新所述故障算子的操作符以及所述操作符之间的逻辑关系,以得到重构的查询计划树。104. Update the operator of the fault operator and the logical relationship between the operators according to the query plan tree and the intermediate state information of the fault operator, so as to obtain a reconstructed query plan tree.
104、当所述故障恢复后,根据所述重构的查询计划树,续跑所述查询语句,以得到所述查询语句的查询结果。104. After the fault is recovered, continue to run the query statement according to the reconstructed query plan tree to obtain a query result of the query statement.
与现有技术相比,本发明实施例所提供的查询故障的处理方法,可以在出现故障时,根据故障发生处算子的中间状态信息,重构的查询计划树,在故障恢复后,可以根据该重构的查询计划树实现查询语句的续跑,也就是从故障发生处继续执行当前的查询语句,从而减少查询中断对整个查询业务流程的影响。Compared with the prior art, the method for processing a query fault provided by the embodiment of the present invention can reconstruct the query plan tree according to the intermediate state information of the operator where the fault occurs when a fault occurs. According to the reconstructed query plan tree, the continuation of the query statement is realized, that is, the current query statement continues to be executed from the point where the fault occurs, thereby reducing the impact of query interruption on the entire query business process.
本发明实施例所提供的查询故障的处理方法可以参阅图1-图6部分的相关描述进行理解,本处不再重复赘述。The processing method of the query fault provided by the embodiment of the present invention can be understood by referring to the relevant descriptions in FIG. 1 to FIG. 6 , and details are not repeated here.
本发明实施例提供的查询故障的处理装置20所包括的模块和各模块之间的关系,可以参阅图5和图6部分的数据库管理系统进行理解,本处不再重复赘述。The modules included in the fault query processing apparatus 20 provided by the embodiment of the present invention and the relationship between the modules can be understood by referring to the database management systems in FIG. 5 and FIG. 6 , which will not be repeated here.
本发明实施例所提供的图1至图6所示的数据库管理系统或者查询故障的处理装置可以通过服务器或者物理主机来实现,下面以服务器为例,介绍查询故障的处理方法依靠服务器实现的过程。The database management system shown in FIG. 1 to FIG. 6 provided by the embodiment of the present invention or the processing device for querying faults may be implemented by a server or a physical host. The following takes the server as an example to introduce the process of implementing the processing method for querying faults by relying on the server. .
图8是本发明实施例提供的服务器60的结构示意图。所述服务器60包括处理器610、存储器650和收发器630,存储器650可以包括只读存储器和随机存取存储器,并向处理器610提供操作指令和数据。存储器650的一部分还可以包括非易失性随机存取存储器(NVRAM)。FIG. 8 is a schematic structural diagram of a
在一些实施方式中,存储器650存储了如下的元素,可执行模块或者数据结构,或者他们的子集,或者他们的扩展集:In some embodiments,
在本发明实施例中,当服务器执行上述图1至图6所示的数据库管理系统或查询故障的处理装置所执行的上述图1至图7部分所描述的查询故障处理的功能时,通过调用存储器650存储的操作指令(该操作指令可存储在操作系统中),In this embodiment of the present invention, when the server executes the function of query fault processing described in the above-mentioned parts of FIG. 1 to FIG. 7 performed by the database management system shown in FIG. 1 to FIG. Operation instructions stored in the memory 650 (the operation instructions may be stored in the operating system),
通过收发器630用于接收查询语句;for receiving query statements through the
生成所述查询语句对应的查询计划树,所述查询计划树包括流水线关系的多层算子,其中,每层至少包括一个算子,每个算子都包含操作符以及所述操作符之间的逻辑关系;Generate a query plan tree corresponding to the query statement, where the query plan tree includes multiple layers of operators in a pipeline relationship, wherein each layer includes at least one operator, and each operator includes an operator and an operator between the operators the logical relationship;
根据所述查询计划树执行所述查询语句;Execute the query statement according to the query plan tree;
当执行所述查询语句的过程中出现故障时,则调取故障算子的中间状态信息,所述中间状态信息是在所述执行故障发生之前的备份时间点备份的,且所述中间状态信息包括所述故障算子在所述备份时间点已完成的操作和未完成的操作,所述故障算子为所述执行故障发生时正在执行所述查询语句的算子;When a fault occurs during the execution of the query statement, the intermediate state information of the faulty operator is retrieved, the intermediate state information is backed up at the backup time point before the execution fault occurs, and the intermediate state information Including the completed operations and uncompleted operations of the fault operator at the backup time point, where the fault operator is the operator that is executing the query statement when the execution fault occurs;
根据所述查询计划树和所述故障算子的中间状态信息,更新所述故障算子的操作符以及所述操作符之间的逻辑关系,以得到重构的查询计划树;According to the query plan tree and the intermediate state information of the fault operator, update the operator of the fault operator and the logical relationship between the operators to obtain a reconstructed query plan tree;
当所述故障恢复后,根据所述重构的查询计划树,续跑所述查询语句,以得到所述查询语句的查询结果。After the fault is recovered, continue to run the query statement according to the reconstructed query plan tree to obtain the query result of the query statement.
与现有技术相比,本发明实施例所提供服务器,可以在出现故障时,根据故障发生处算子的中间状态信息,重构的查询计划树,在故障恢复后,可以根据该重构的查询计划树实现查询语句的续跑,也就是从故障发生处继续执行当前的查询语句,从而减少查询中断对整个查询业务流程的影响。Compared with the prior art, the server provided by the embodiment of the present invention can reconstruct the query plan tree according to the intermediate state information of the operator where the fault occurs when a fault occurs. The query plan tree implements the continuation of the query statement, that is, the current query statement continues to be executed from the point of failure, thereby reducing the impact of query interruption on the entire query business process.
处理器610控制服务器60的操作,处理器610还可以称为CPU(Central ProcessingUnit,中央处理单元)。存储器650可以包括只读存储器和随机存取存储器,并向处理器610提供指令和数据。存储器650的一部分还可以包括非易失性随机存取存储器(NVRAM)。具体的应用中服务器60的各个组件通过总线系统620耦合在一起,其中总线系统620除包括数据总线之外,还可以包括电源总线、控制总线和状态信号总线等。但是为了清楚说明起见,在图中将各种总线都标为总线系统620。The
上述本发明实施例揭示的方法可以应用于处理器610中,或者由处理器610实现。处理器610可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器610中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器610可以是通用处理器、数字信号处理器(DSP)、专用集成电路(ASIC)、现成可编程门阵列(FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本发明实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本发明实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器650,处理器610读取存储器650中的信息,结合其硬件完成上述方法的步骤。The methods disclosed in the foregoing embodiments of the present invention may be applied to the
可选地,处理器610还用于:Optionally, the
基于所述故障算子的中间状态的备份代价,选择性备份所述故障算子的中间状态信息。Based on the backup cost of the intermediate state of the faulty operator, the intermediate state information of the faulty operator is selectively backed up.
可选地,处理器610具体用于:周期性执行所述选择性备份的步骤。Optionally, the
可选地,处理器610具体用于:Optionally, the
当确定出所述故障算子续跑所节省的代价大于备份所述故障算子已完成的操作和恢复所述故障算子未完成的操作所需要的代价之和时,则备份所述故障算子的中间状态信息。When it is determined that the cost saved by continuing the operation of the faulty operator is greater than the sum of the cost of backing up the completed operation of the faulty operator and the cost of restoring the uncompleted operation of the faulty operator, the faulty operator is backed up. Child's intermediate state information.
可选地,处理器610具体用于:Optionally, the
当确定出所述故障算子续跑的代价小于备份所述故障算子已完成的操作和恢复所述故障算子未完成的操作所需要的代价之和时,则备份所述故障算子的中间状态信息。When it is determined that the cost of continuing the operation of the faulty operator is less than the sum of the cost of backing up the completed operation of the faulty operator and the cost of restoring the uncompleted operation of the faulty operator, then backup the operation of the faulty operator. Intermediate state information.
可选地,处理器610具体用于:Optionally, the
递归处理所述未完成的操作和所述已完成的操作,以得到所述故障算子的重构信息,所述重构信息包括重构操作符以及所述重构操作符之间的逻辑关系;Recursively process the unfinished operations and the completed operations to obtain reconstruction information of the faulty operator, where the reconstruction information includes reconstruction operators and logical relationships between the reconstruction operators ;
根据所述重构信息,更新所述查询计划树的所述故障算子中与所述重构信息对应的原始信息,以得到所述重构的查询计划树,所述原始信息包括原始操作符以及所述原始操作符之间的逻辑关系。According to the reconstruction information, the original information corresponding to the reconstruction information in the fault operator of the query plan tree is updated to obtain the reconstructed query plan tree, where the original information includes the original operator and the logical relationship between the primitive operators.
可选地,处理器610具体用于:对所述已完成操作设置已完结操作符,并在所述未完成操作中设置用于标记未完成操作起始位置的起始操作符,以得到所述重构操作符以及所述重构操作符之间的逻辑关系。Optionally, the
可选地,处理器610还用于:Optionally, the
当确定出续跑所节省的代价小于所需要的代价之和时,则记录所述查询语句,所述查询语句用于在所述查询故障恢复后,重新生成所述查询计划树。When it is determined that the cost saved by continuing running is less than the sum of the required costs, the query statement is recorded, and the query statement is used to regenerate the query plan tree after the query failure is recovered.
可选地,处理器610还用于:Optionally, the
当确定出续跑的代价大于所需要的代价之和时,则记录所述查询语句,所述查询语句用于在所述查询故障恢复后,重新生成所述查询计划树。When it is determined that the cost of continuing running is greater than the sum of the required costs, the query statement is recorded, and the query statement is used to regenerate the query plan tree after the query failure is recovered.
可选地,处理器610还用于:Optionally, the
当生成所述查询计划树时出现故障,则记录所述查询语句,所述查询语句用于在所述查询故障恢复后,重新生成所述查询计划树。When a failure occurs when generating the query plan tree, the query statement is recorded, and the query statement is used to regenerate the query plan tree after the query failure is recovered.
以上图8所描述的服务器可以参阅图1至图6部分的查询管理设备进行理解,本处不再重复赘述。The server described in FIG. 8 can be understood by referring to the query management device in FIG. 1 to FIG. 6 , and details are not repeated here.
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分步骤是可以通过程序来指令相关的硬件来完成,该程序可以存储于一计算机可读存储介质中,存储介质可以包括:ROM、RAM、磁盘或光盘等。Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing relevant hardware through a program, and the program can be stored in a computer-readable storage medium, and the storage medium can include: ROM, RAM, magnetic disk or optical disk, etc.
以上对本发明实施例所提供的查询故障的处理方法以及装置进行了详细介绍,本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其核心思想;同时,对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本发明的限制。The processing method and device for querying faults provided by the embodiments of the present invention have been described in detail above. The principles and implementations of the present invention are described by using specific examples in this paper. The descriptions of the above embodiments are only used to help understand the present invention. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation and application scope. In summary, the content of this specification should not be construed as Limitations of the present invention.
Claims (14)
Priority Applications (4)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610505556.5A CN107545015B (en) | 2016-06-29 | 2016-06-29 | A processing method and processing device for querying faults |
PCT/CN2017/071709 WO2018000811A1 (en) | 2016-06-29 | 2017-01-19 | Fault querying processing method and processing apparatus |
US16/234,095 US10866866B2 (en) | 2016-06-29 | 2018-12-27 | Query fault processing method and processing apparatus |
US17/101,033 US11461195B2 (en) | 2016-06-29 | 2020-11-23 | Query fault processing method and processing apparatus |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201610505556.5A CN107545015B (en) | 2016-06-29 | 2016-06-29 | A processing method and processing device for querying faults |
Publications (2)
Publication Number | Publication Date |
---|---|
CN107545015A CN107545015A (en) | 2018-01-05 |
CN107545015B true CN107545015B (en) | 2020-12-04 |
Family
ID=60785725
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201610505556.5A Active CN107545015B (en) | 2016-06-29 | 2016-06-29 | A processing method and processing device for querying faults |
Country Status (3)
Country | Link |
---|---|
US (2) | US10866866B2 (en) |
CN (1) | CN107545015B (en) |
WO (1) | WO2018000811A1 (en) |
Families Citing this family (9)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107545015B (en) * | 2016-06-29 | 2020-12-04 | 华为技术有限公司 | A processing method and processing device for querying faults |
CN110909023B (en) * | 2018-09-17 | 2021-11-19 | 华为技术有限公司 | Query plan acquisition method, data query method and data query device |
US11599539B2 (en) * | 2018-12-26 | 2023-03-07 | Palantir Technologies Inc. | Column lineage and metadata propagation |
US11138213B2 (en) * | 2019-04-10 | 2021-10-05 | Snowflake Inc. | Internal resource provisioning in database systems |
US10915418B1 (en) * | 2019-08-29 | 2021-02-09 | Snowflake Inc. | Automated query retry in a database environment |
US10949197B1 (en) * | 2019-11-05 | 2021-03-16 | International Business Machines Corporation | Analysis of patch impact on a running database application |
CN111221674A (en) * | 2019-12-31 | 2020-06-02 | 瑞庭网络技术(上海)有限公司 | Troubleshooting method and device and readable storage medium |
CN113448967B (en) * | 2021-07-20 | 2022-02-08 | 威讯柏睿数据科技(北京)有限公司 | Method and device for accelerating database operation |
CN114461445B (en) * | 2021-12-22 | 2025-04-04 | 天翼云科技有限公司 | Data recovery method and device, electronic device, and computer-readable storage medium |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103136363A (en) * | 2013-03-14 | 2013-06-05 | 曙光信息产业(北京)有限公司 | Inquiry processing method and cluster data base system |
EP2922274A1 (en) * | 2014-03-18 | 2015-09-23 | Axis AB | Finding services in a service-oriented architecture (SOA) network |
CN105677812A (en) * | 2015-12-31 | 2016-06-15 | 华为技术有限公司 | Method and device for querying data |
CN105701128A (en) * | 2014-11-28 | 2016-06-22 | 华为技术有限公司 | Query statement optimization method and apparatus |
Family Cites Families (20)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US8775412B2 (en) * | 2004-01-08 | 2014-07-08 | International Business Machines Corporation | Method and system for a self-healing query access plan |
US9886492B2 (en) * | 2004-12-22 | 2018-02-06 | Teradata Us, Inc. | Self-adjusting database-query optimizer |
US8239535B2 (en) * | 2005-06-06 | 2012-08-07 | Adobe Systems Incorporated | Network architecture with load balancing, fault tolerance and distributed querying |
US7739269B2 (en) * | 2007-01-19 | 2010-06-15 | Microsoft Corporation | Incremental repair of query plans |
US20100312776A1 (en) * | 2009-06-04 | 2010-12-09 | International Business Machines Corporation | Intelligent performance analysis and isolaton of potential problem queries |
US8938644B2 (en) * | 2010-12-03 | 2015-01-20 | Teradata Us, Inc. | Query execution plan revision for error recovery |
CN102663117B (en) * | 2012-04-18 | 2013-11-20 | 中国人民大学 | OLAP (On Line Analytical Processing) inquiry processing method facing database and Hadoop mixing platform |
US20130290295A1 (en) * | 2012-04-30 | 2013-10-31 | Craig A. Soules | Maintaining fault domains in a distributed database |
US9659057B2 (en) * | 2013-04-15 | 2017-05-23 | Vmware, Inc. | Fault tolerant distributed query processing using query operator motion |
CN103559245A (en) * | 2013-10-29 | 2014-02-05 | 华为技术有限公司 | Distributed transaction committing failure handling method, device and system |
CN103793538A (en) | 2014-03-06 | 2014-05-14 | 赛特斯信息科技股份有限公司 | System and method for realizing restoration of web service in case of crash of database |
US10303558B2 (en) * | 2015-04-17 | 2019-05-28 | Microsoft Technology Licensing, Llc | Checkpointing higher order query operators |
CN107545015B (en) * | 2016-06-29 | 2020-12-04 | 华为技术有限公司 | A processing method and processing device for querying faults |
US20180025055A1 (en) * | 2016-07-19 | 2018-01-25 | Sap Se | Fault-tolerant database query execution plans using non-volatile memories |
US20180107712A1 (en) * | 2016-10-13 | 2018-04-19 | International Business Machines Corporation | Adaptive query row selection |
US10049133B2 (en) * | 2016-10-27 | 2018-08-14 | International Business Machines Corporation | Query governor across queries |
US10521430B1 (en) * | 2016-11-06 | 2019-12-31 | Tableau Software, Inc. | Dynamic selection of query execution operators |
US10795887B1 (en) * | 2016-11-06 | 2020-10-06 | Tableau Software, Inc. | Dynamic rebuilding of query execution trees and reselection of query execution operators |
US10409812B2 (en) * | 2016-12-20 | 2019-09-10 | International Business Machines Corporation | Query restart based on changing system resources and an amount of data change |
US20190205448A1 (en) * | 2018-01-04 | 2019-07-04 | Microsoft Technology Licensing, Llc | Relational database system that uses real-time statistics for selection of physical operators |
-
2016
- 2016-06-29 CN CN201610505556.5A patent/CN107545015B/en active Active
-
2017
- 2017-01-19 WO PCT/CN2017/071709 patent/WO2018000811A1/en active Application Filing
-
2018
- 2018-12-27 US US16/234,095 patent/US10866866B2/en active Active
-
2020
- 2020-11-23 US US17/101,033 patent/US11461195B2/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103136363A (en) * | 2013-03-14 | 2013-06-05 | 曙光信息产业(北京)有限公司 | Inquiry processing method and cluster data base system |
EP2922274A1 (en) * | 2014-03-18 | 2015-09-23 | Axis AB | Finding services in a service-oriented architecture (SOA) network |
CN105701128A (en) * | 2014-11-28 | 2016-06-22 | 华为技术有限公司 | Query statement optimization method and apparatus |
CN105677812A (en) * | 2015-12-31 | 2016-06-15 | 华为技术有限公司 | Method and device for querying data |
Also Published As
Publication number | Publication date |
---|---|
WO2018000811A1 (en) | 2018-01-04 |
CN107545015A (en) | 2018-01-05 |
US11461195B2 (en) | 2022-10-04 |
US20210073085A1 (en) | 2021-03-11 |
US10866866B2 (en) | 2020-12-15 |
US20190129811A1 (en) | 2019-05-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN107545015B (en) | A processing method and processing device for querying faults | |
CN105159818B (en) | Journal recovery method and its analogue system in main-memory data management | |
US9189487B2 (en) | Method for recording transaction log, and database engine | |
US7844959B2 (en) | Runtime optimization of distributed execution graph | |
CN109542682B (en) | Data backup method, device, equipment and storage medium | |
CN109063005B (en) | A data migration method and system, storage medium and electronic device | |
US11176086B2 (en) | Parallel copying database transaction processing | |
WO2021238273A1 (en) | Message fault tolerance method and system based on spark streaming computing framework | |
CN110888761B (en) | Fault tolerance method based on active backup of critical task part and stream processing platform | |
CN104820610B (en) | The update method and system of virtual machine image in a kind of cloud environment | |
WO2016127557A1 (en) | Method for re-establishing standby database, and apparatus thereof | |
CN105242979A (en) | Backward recovery error tolerance method with forward recovery feature | |
CN102841840B (en) | The message logging restoration methods that Effect-based operation reorders and message number is checked | |
CN110795265B (en) | Iterator based on optimistic fault-tolerant method | |
CN107526573A (en) | Using the method for parallel pipeline processing remote sensing images | |
Rezaei et al. | Sustained resilience via live process cloning | |
CN112346913B (en) | Data recovery method, device, equipment and storage medium | |
CN112749156B (en) | Data processing method, database management system and data processing device | |
CN113326268A (en) | Data writing and reading method and device | |
CN119847826B (en) | Data backup of distributed database, data backup recovery method and device | |
Babaoglu et al. | On programming with view synchrony | |
CN108599982A (en) | Data reconstruction method and relevant device | |
JP7024804B2 (en) | System update device and system update method | |
Wang et al. | Trcid: Optimized task recovery in mapreduce based on checkpointing intermediate data | |
Guo et al. | Self-Repairing Software Architecture for Predictable Hardware Faults |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |