WO2016065904A1 - 一种数据库的处理方法、装置及系统 - Google Patents

一种数据库的处理方法、装置及系统 Download PDF

Info

Publication number
WO2016065904A1
WO2016065904A1 PCT/CN2015/081250 CN2015081250W WO2016065904A1 WO 2016065904 A1 WO2016065904 A1 WO 2016065904A1 CN 2015081250 W CN2015081250 W CN 2015081250W WO 2016065904 A1 WO2016065904 A1 WO 2016065904A1
Authority
WO
WIPO (PCT)
Prior art keywords
type
module
database
atomic
processing method
Prior art date
Application number
PCT/CN2015/081250
Other languages
English (en)
French (fr)
Inventor
程文超
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2016065904A1 publication Critical patent/WO2016065904A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor

Definitions

  • This paper relates to the field of database technology, and in particular, to a database processing method, device and system.
  • the atomicity of database operations is a fundamental feature of transactional databases used to ensure the integrity of a certain operational result of a database, ie either completely or not at all.
  • Currently, many types of databases do not support transaction processing, such as analytical databases and storage engines for certain databases.
  • the atomicity of the data processing process is not guaranteed.
  • the embodiment of the invention provides a method, a device and a system for processing a database, so that the result of the database execution is either completely executed or not executed, and the atomicity of the database execution is guaranteed.
  • An embodiment of the present invention provides a method for processing a database, including:
  • the execution flow of the database is sequentially divided into a plurality of atomic modules that need to provide atomic protection
  • the exception type is a fallback type
  • obtaining a first processing method corresponding to the fallback type and executing the first processing method causes the target atomic module to fall back to a state before the target atomic module is operated.
  • the method further includes:
  • the exception type is not a fallback type, obtain a second processing method corresponding to the exception type and execute the second processing method to process the exception type.
  • the exception type is a fallback type
  • acquiring a first processing method corresponding to the fallback type and executing the first processing method, so that the target atom module is rolled back to the target atom module before running The steps of the state include:
  • the exception type is a fallback type, acquiring a pre-stored back-off code of the first processing method corresponding to the fallback type;
  • the step of acquiring the second processing method corresponding to the exception type and performing the second processing method to process the abnormality includes:
  • the exception type is not a fallback type, acquiring a pre-stored processing code of the second processing method corresponding to the exception type;
  • the database continues to execute the next atomic module; if the target atomic module has an abnormality, the process ends.
  • the back-off code is a delete statement.
  • the embodiment of the invention further provides a processing device for a database, comprising:
  • a segmentation module configured to sequentially divide the execution flow of the database into a plurality of atomic modules that need to provide atomic protection according to the business requirements of the database
  • An abnormality obtaining module configured to acquire an abnormal state of a running atomic module in real time, and determine an abnormality type of the abnormality according to the abnormal state;
  • a first execution module configured to: if the exception type is a fallback type, acquire a first processing method corresponding to the fallback type and execute the first processing method to cause the target atomic module to fall back to the destination atom The state before the module is running.
  • the processing device further includes:
  • the second execution module is configured to: if the exception type is not a fallback type, acquire a second processing method corresponding to the exception type and execute the second processing method to process the exception type.
  • the first execution module includes:
  • a first acquiring unit configured to: if the abnormal type is a fallback type, acquire a pre-stored back-off code of the first processing method corresponding to the fallback type;
  • an execution unit configured to execute the back-off code, so that the target atomic module is rolled back to a state before the target atomic module is operated, and the process ends.
  • the second execution module includes:
  • a second acquiring unit configured to: if the abnormal type is not a fallback type, acquire a pre-stored processing code of a second processing method corresponding to the abnormal type;
  • a third acquiring unit configured to acquire an abnormal state of the target atom module after executing the processing code
  • the determining unit is configured to: if the target atomic module does not have an abnormality, the database continues to execute the next atomic module; if the target atomic module has an abnormality, the process ends.
  • the back-off code is a delete statement.
  • the embodiment of the present invention further provides a system, including a database, the database includes a plurality of atomic modules that need to provide atomic protection, and the system further includes a processing device of the database described above;
  • the processing device of the database invokes a fallback code corresponding to the fallback type and executes, so that the database is rolled back to the atomic module before execution. status.
  • the embodiment of the invention further provides a computer readable storage medium storing program instructions, which can be implemented when the program instructions are executed.
  • FIG. 1 is a schematic diagram showing the basic steps of a method for processing a database according to an embodiment of the present invention
  • FIG. 2 is a schematic diagram showing steps of executing a second processing method in a method for processing a database according to an embodiment of the present invention
  • FIG. 3 is a schematic diagram showing an application flow of a method for processing a database according to an embodiment of the present invention
  • FIG. 4 is a block diagram showing the structure of a processing device of a database according to an embodiment of the present invention.
  • the embodiment of the invention provides a database processing method, device and system for the problem that the database does not support the atomicity during the execution process, and the corresponding processing is set for each atom module.
  • the method ensures that when the exception type is a fallback type, the corresponding atomic module can perform a corresponding processing method to fall back to the state before the atomic module is run, ensuring that each atomic module has atomicity in executing the service, thereby ensuring The atomicity of the entire data execution.
  • an embodiment of the present invention provides a method for processing a database, including:
  • Step 10 The execution flow of the database is sequentially divided into a plurality of atomic modules that need to provide atomic protection according to the business requirements of the database;
  • Step 11 Obtain an abnormal state of the running target atomic module in real time, and determine an abnormality type of the abnormality according to the abnormal state;
  • Step 12 If the exception type is a fallback type, obtain a first processing method corresponding to the fallback type and execute the first processing method to cause the target atomic module to fall back to the target atomic module before running status.
  • the execution flow of the database is the entire execution process of the database, and the entire execution process may be divided into a plurality of atomic modules from the business requirements, and the plurality of atomic modules need to ensure atomicity in performing the business.
  • the business requirements of the atomic module can be a series of processes such as the data warehousing process, the pre-statistical execution process of the report, and the data outbound process, which are not enumerated here.
  • a piece of execution code is as follows:
  • the update statement when executed, the sum of col2 and col3 exceeds the range of the col1 field. At this time, the entire code block needs to be rolled back to the previous state. All the inserted data needs to be cleared, and the delete statement can be implemented. .
  • the method further includes:
  • Step 13 If the exception type is not a fallback type, obtain a second processing method corresponding to the exception type and execute the second processing method to process the exception type.
  • various exceptions may occur during the running of the database. If the abnormal type is not the fallback type, when the abnormality occurs, the database does not need to be rolled back to the previous state, but is repaired by other methods. If the repair is completed, continue to run the database; if it cannot be repaired, it will exit with an error and be processed by other personnel or devices.
  • the exception type is mainly divided into a fallback type and a non-return type, and needs to be explained.
  • the exceptions of the fallback type are also divided into many different situations. Different branch processing procedures need to be provided according to different situations, but the ultimate goal is to roll back to the previous state; the same is not the fallback type. It is also divided into many different situations, and the database is processed separately according to different situations.
  • step 13 includes:
  • Step 131 If the exception type is not a fallback type, obtain a pre-stored processing code of a second processing method corresponding to the exception type;
  • Step 132 After executing the processing code, acquiring an abnormal state of the target atom module.
  • Step 133 If the target atom module does not have an abnormality, the database continues to execute the next atomic module; if the target atomic module has an abnormality, the process ends.
  • the corresponding processing method is also obtained and processed, and if the target atomic module does not have an abnormality after the processing is completed, the next atom continues to be run. Module; if the target atom module still has other exceptions and cannot be processed after processing, the error exits the database and is processed by subsequent personnel or programs.
  • step 12 includes:
  • Step 121 If the exception type is a fallback type, obtain a pre-stored back-off code of the first processing method corresponding to the fallback type;
  • Step 122 Perform the back-off code, so that the target atomic module falls back to the state before the target atomic module is operated, and ends the process.
  • the rollback process of the atomic module is implemented by executing a corresponding backoff code written for each abnormal situation; the backoff code is pre-written and saved for the abnormal situation that may exist, and the call is directly called to run back. The code is returned, causing the destination atomic module to fall back to the state it was in before the run.
  • the processing method of the database in the above embodiment of the present invention by performing monitoring on each atomic module, if the atomic module has a fallback type abnormality, executing the first processing method to roll back the database to a state before the execution of the atomic module; At the same time, if the abnormality of the atomic module is not the fallback type, the corresponding second processing method is also executed to process the abnormality; the atomicity in the execution process of each atomic module is guaranteed.
  • Step S301 the service processing atomic module 1 starts to execute
  • Step S302 it is determined whether there is an abnormal situation in the execution of the service processing atomic module 1, if yes, step S304 is performed, if no, step S303 is performed;
  • Step S303 if the entire code execution process is successfully completed, if there is no abnormality in the atomic module 1, the code in the atomic module 2 is continuously executed;
  • Step S304 if an abnormal condition exists in the atomic module 1, acquiring abnormal state information
  • Step S305 determining whether it is necessary to perform a rollback operation of the code according to the current state information, if yes, executing step S306, if no, executing step S307;
  • Step S306 if necessary, perform a fallback operation for the atomic module, roll back the state of the database to a state before executing the execution of the atomic module, and exit the program;
  • Step S307 if the rollback operation is not required to be performed, the abnormality information is processed by using the second processing method;
  • Step S308 it is determined whether the code continues to be executed after the processing of step S307, if yes, step S309 is performed, and if no, step S310 is performed;
  • Step S309 if it can continue to execute, continue to execute the atomic module 2;
  • step S310 if the execution cannot be continued, the program is directly reported to exit, and the process ends.
  • an embodiment of the present invention further provides a processing device for a database, including:
  • the segmentation module 41 is configured to sequentially divide the execution flow of the database into a plurality of atomic modules that need to provide atomic protection according to the business requirements of the database;
  • the abnormality obtaining module 42 is configured to acquire an abnormal state of the running atomic module in real time, and determine an abnormal type of the abnormality according to the abnormal state;
  • the first execution module 43 is configured to: if the exception type is a fallback type, acquire a first processing method corresponding to the fallback type and execute the first processing method to cause the target atomic module to fall back to the destination The state before the atomic module is running.
  • the processing device further includes:
  • a second execution module configured to acquire the exception class if the exception type is not a fallback type
  • the second processing method corresponding to the type and the second processing method are executed to process the abnormal type.
  • the first execution module 43 includes:
  • a first acquiring unit configured to: if the abnormal type is a fallback type, acquire a pre-stored back-off code of the first processing method corresponding to the fallback type;
  • an execution unit configured to execute the back-off code, so that the target atomic module is rolled back to a state before the target atomic module is operated, and the process ends.
  • the second execution module includes:
  • a second acquiring unit configured to: if the abnormal type is not a fallback type, acquire a pre-stored processing code of a second processing method corresponding to the abnormal type;
  • a third acquiring unit configured to acquire an abnormal state of the target atom module after executing the processing code
  • the determining unit is configured to: if the target atomic module does not have an abnormality, the database continues to execute the next atomic module; if the target atomic module has an abnormality, the process ends.
  • the back-off code is a deletion statement.
  • the processing device provided by the embodiment of the present invention is a device applying the foregoing processing method, and all embodiments of the foregoing processing method are applicable to the processing device, and all of the same or similar beneficial effects can be achieved.
  • An embodiment of the present invention further provides a system, including a database, the database includes a plurality of atomic modules that need to provide atomic protection, and the system further includes a processing device of the database as described above;
  • the processing device of the database invokes a fallback code corresponding to the fallback type and executes, so that the database is rolled back to the atomic module before execution. status.
  • system provided by the embodiment of the present invention is a system including the foregoing processing apparatus and a database, and all embodiments of the foregoing processing apparatus and the beneficial effects thereof are applicable to the system.
  • the method of the embodiment of the invention ensures that when the exception type is a fallback type, the corresponding atomic module can perform a corresponding processing method to fall back to the state before the atomic module is run, and ensure that each atomic module has atomicity in executing the service. , thus ensuring the atomicity of the entire data execution.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

一种数据库的处理方法、装置及系统,其中,数据库的处理方法包括:根据所述数据库的业务需求将所述数据库的执行流程依次分割为多个需要提供原子性保护的原子模块;实时获取正在运行的目的原子模块的异常状态,根据所述异常状态确定所述异常的异常类型;若所述异常类型为回退类型,获取与所述回退类型对应的第一处理方法并执行所述第一处理方法使得所述目的原子模块回退到该目的原子模块运行前的状态。

Description

一种数据库的处理方法、装置及系统 技术领域
本文涉及数据库技术领域,尤其涉及一种数据库的处理方法、装置及系统。
背景技术
数据库操作的原子性是事务型数据库的基本特征,用于保证对数据库的某一操作结果的完整性,即要么完全被执行要么完全不被执行。目前很多种类型的数据库不支持事务处理,如分析型数据库和某些数据库的存储引擎。在使用这些数据库处理数据的过程中可能需要保证某一执行过程的原子性,如数据的入库过程、报表的预统计执行过程。在使用不支持事务的数据库处理这些业务时,不能保证数据处理过程的原子性。
发明内容
本发明实施例提供一种数据库的处理方法、装置及系统,使得数据库执行的结果要么完全被执行要么不被执行,保证了数据库执行的原子性。
本发明实施例提供一种数据库的处理方法,包括:
根据数据库的业务需求将所述数据库的执行流程依次分割为多个需要提供原子性保护的原子模块;
实时获取正在运行的目的原子模块的异常状态,根据所述异常状态确定异常类型;
若所述异常类型为回退类型,获取与所述回退类型对应的第一处理方法并执行所述第一处理方法使得所述目的原子模块回退到该目的原子模块运行前的状态。
可选地,所述方法还包括:
若所述异常类型不为回退类型,获取与该异常类型对应的第二处理方法并执行所述第二处理方法对所述异常类型进行处理。
可选地,若所述异常类型为回退类型,获取与所述回退类型对应的第一处理方法并执行所述第一处理方法使得所述目的原子模块回退到该目的原子模块运行前的状态的步骤包括:
若所述异常类型为回退类型,获取预先存储的与该回退类型对应的第一处理方法的回退代码;
执行所述回退代码,使得所述目的原子模块回退到该目的原子模块运行前的状态,并结束流程。
可选地,若所述异常类型不为回退类型,获取与该异常类型对应的第二处理方法执行所述第二处理方法对所述异常进行处理的步骤包括:
若所述异常类型不为回退类型,获取预先存储的与该异常类型对应的第二处理方法的处理代码;
执行所述处理代码后,获取所述目的原子模块的异常状态;
若所述目的原子模块不存在异常,则所述数据库继续执行下一原子模块;若所述目的原子模块存在异常,则结束流程。
可选地,所述回退代码为删除语句。
本发明实施例还提供一种数据库的处理装置,包括:
分割模块,设置为根据所述数据库的业务需求将所述数据库的执行流程依次分割为多个需要提供原子性保护的原子模块;
异常获取模块,设置为实时获取正在运行的目的原子模块的异常状态,根据所述异常状态确定所述异常的异常类型;以及
第一执行模块,设置为若所述异常类型为回退类型,获取与所述回退类型对应的第一处理方法并执行所述第一处理方法使得所述目的原子模块回退到该目的原子模块运行前的状态。
可选地,上述处理装置还包括:
第二执行模块,设置为若所述异常类型不为回退类型,获取与该异常类型对应的第二处理方法并执行所述第二处理方法对所述异常类型进行处理。
可选地,所述第一执行模块包括:
第一获取单元,设置为若所述异常类型为回退类型,获取预先存储的与该回退类型对应的第一处理方法的回退代码;以及
执行单元,设置为执行所述回退代码,使得所述目的原子模块回退到该目的原子模块运行前的状态,并结束流程。
可选地,所述第二执行模块包括:
第二获取单元,设置为若所述异常类型不为回退类型,获取预先存储的与该异常类型对应的第二处理方法的处理代码;
第三获取单元,设置为执行所述处理代码后,获取所述目的原子模块的异常状态;以及
判断单元,设置为若所述目的原子模块不存在异常,则所述数据库继续执行下一原子模块;若所述目的原子模块存在异常,则结束流程。
可选地,所述回退代码为删除语句。
本发明实施例还提供一种系统,包括数据库,所述数据库包括多个需要提供原子性保护的原子模块,所述系统还包括上述的数据库的处理装置;
当所述原子模块出现异常类型为回退类型的异常时,所述数据库的处理装置调用与所述回退类型对应的回退代码并执行,使得所述数据库回退到该原子模块执行之前的状态。
本发明实施例还提供一种计算机可读存储介质,存储有程序指令,当该程序指令被执行时可实现上述方法。
本发明实施例的数据库的处理方法中,通过为每一个原子模块的异常类型设置相应的处理方法,保证了在异常类型为回退类型时,对应的原子模块能够执行相应的处理方法回退到该原子模块运行前的状态,保证了每一个原子模块在执行业务上具有原子性,从而保证了整个数据执行的原子性。
附图概述
图1表示本发明实施例的数据库的处理方法的基本步骤示意图;
图2表示本发明实施例的数据库的处理方法中第二处理方法的执行步骤示意图;
图3表示本发明实施例的数据库的处理方法的应用流程示意图;
图4表示本发明实施例的数据库的处理装置的结构示意图。
本发明的实施方式
本发明实施例针对相关技术中很多不支持事务处理数据库在执行过程中无法保证原子性的问题,提供一种数据库的处理方法、装置及系统,通过为每一个原子模块的异常类型设置相应的处理方法,保证了在异常类型为回退类型时,对应的原子模块能够执行相应的处理方法回退到该原子模块运行前的状态,保证了每一个原子模块在执行业务上具有原子性,从而保证了整个数据执行的原子性。
如图1所示,本发明实施例提供一种数据库的处理方法,包括:
步骤10,根据所述数据库的业务需求将所述数据库的执行流程依次分割为多个需要提供原子性保护的原子模块;
步骤11,实时获取正在运行的目的原子模块的异常状态,根据所述异常状态确定所述异常的异常类型;
步骤12,若所述异常类型为回退类型,获取与所述回退类型对应的第一处理方法并执行所述第一处理方法使得所述目的原子模块回退到该目的原子模块运行前的状态。
本发明实施例中,数据库的执行流程为该数据库的整个执行过程,该整个执行过程从业务需求上可以划分为多个原子模块,该多个原子模块在执行业务上需要保证原子性。其中,原子模块的业务需求可以为数据的入库过程、报表的预统计执行过程、数据的出库过程等等一系列过程,在此不一一列举。
本发明实施例的实际应用中,例如一段执行代码如下:
Figure PCTCN2015081250-appb-000001
比如执行update语句的时候出错,col2和col3的和超出了col1字段的范围等;这时候就需要将整个代码块回退到之前的状态,需要将插入的所有数据清除掉,执行delete语句可以实现。
本发明上述实施例中,所述方法还包括:
步骤13,若所述异常类型不为回退类型,获取与该异常类型对应的第二处理方法并执行所述第二处理方法对所述异常类型进行处理。
本发明实施例中,数据库运行过程中可能会出现各种异常,若异常类型不为回退类型,即出现该异常时,无需将数据库回退到前一状态,而是通过其他方法进行修复,若修复完成则继续运行数据库;若无法修复,则报错退出,由其他人员或设备进行后续处理。
本发明实施例中主要将异常类型分为回退类型和不回退类型,需要说明 的是,回退类型的异常情况也分为很多种不同的情况,需根据不同的情况提供不同的分支处理流程,但其最终目的均是将其回退到前一状态;同样不回退类型也分为很多种不同的情况,数据库根据不同的情况分别处理。
本发明实施例中,如图2所示,步骤13包括:
步骤131,若所述异常类型不为回退类型,获取预先存储的与该异常类型对应的第二处理方法的处理代码;
步骤132,执行所述处理代码后,获取所述目的原子模块的异常状态;
步骤133,若所述目的原子模块不存在异常,则所述数据库继续执行下一原子模块;若所述目的原子模块存在异常,则结束流程。
本发明上述实施例中,若目的原子模块的异常类型不是回退类型,也获取相应的处理方法,并对其进行处理,若处理完成后该目的原子模块不存在异常,则继续运行下一原子模块;若处理完成后该目的原子模块还存在其他异常且无法处理,则报错退出数据库,由后续人员或程序进行处理。
本发明上述实施例中,步骤12包括:
步骤121,若所述异常类型为回退类型,获取预先存储的与该回退类型对应的第一处理方法的回退代码;
步骤122,执行所述回退代码,使得所述目的原子模块回退到该目的原子模块运行前的状态,并结束流程。
本发明实施例中,原子模块的回退过程是通过执行为每个异常情况编写的相应的回退代码实现的;该回退代码为针对可能存在的异常情况预先编写保存,直接调用运行该回退代码,使得目的原子模块回退到运行之前的状态。
本发明上述实施例的数据库的处理方法中,通过对每个原子模块实行监测,若原子模块出现回退类型的异常,则执行第一处理方法将数据库回退到该原子模块执行之前的状态;同时若原子模块出现的异常不是回退类型的,也执行对应的第二处理方法对异常进行处理;保证了每个原子模块执行过程中的原子性。
为了更好是描述本发明实施例提供的数据库的处理方法,下面结合图3进行本发明实施例的详细步骤描述:
步骤S301,业务处理原子模块1开始执行;
步骤S302,判断业务处理原子模块1执行过程中是否存在异常情况,如果是,执行步骤S304,如果否,执行步骤S303;
步骤S303,若整个代码执行过程顺利完成,则原子模块1不存在异常情况,则继续执行原子模块2中的代码;
步骤S304,若原子模块1中存在异常情况,获取异常状态信息;
步骤S305,根据当前状态信息判断是否需要执行代码的回退操作,如果是,执行步骤S306,如果否,执行步骤S307;
步骤S306,如果需要则执行针对本原子模块的回退操作,将数据库的状态回退到执行本原子模块执行前的状态,并将程序退出;
步骤S307,如果不需要执行回退操作,则利用第二处理方法处理该异常信息;
步骤S308,判断经过步骤S307的处理后代码是否继续执行,如果是,执行步骤S309,如果否,执行步骤S310;
步骤S309,若可以继续执行,则继续执行原子模块2;
步骤S310,若不可以继续执行,则直接将程序报错退出,结束流程。
如图4所示,本发明实施例还提供一种数据库的处理装置,包括:
分割模块41,设置为根据所述数据库的业务需求将所述数据库的执行流程依次分割为多个需要提供原子性保护的原子模块;
异常获取模块42,设置为实时获取正在运行的目的原子模块的异常状态,根据所述异常状态确定所述异常的异常类型;以及
第一执行模块43,设置为若所述异常类型为回退类型,获取与所述回退类型对应的第一处理方法并执行所述第一处理方法使得所述目的原子模块回退到该目的原子模块运行前的状态。
可选地,上述实施例中,上述处理装置还包括:
第二执行模块,设置为若所述异常类型不为回退类型,获取与该异常类 型对应的第二处理方法并执行所述第二处理方法对所述异常类型进行处理。
可选地,上述实施例中,所述第一执行模块43包括:
第一获取单元,设置为若所述异常类型为回退类型,获取预先存储的与该回退类型对应的第一处理方法的回退代码;以及
执行单元,设置为执行所述回退代码,使得所述目的原子模块回退到该目的原子模块运行前的状态,并结束流程。
可选地,上述实施例中,所述第二执行模块包括:
第二获取单元,设置为若所述异常类型不为回退类型,获取预先存储的与该异常类型对应的第二处理方法的处理代码;
第三获取单元,设置为执行所述处理代码后,获取所述目的原子模块的异常状态;以及
判断单元,设置为若所述目的原子模块不存在异常,则所述数据库继续执行下一原子模块;若所述目的原子模块存在异常,则结束流程。
其中,本发明实施例中,所述回退代码为删除语句。
本发明实施例的数据库的处理方法中,通过为每一个原子模块的异常类型设置相应的处理方法,保证了在异常类型为回退类型时,对应的原子模块能够执行相应的处理方法回退到该原子模块运行前的状态,保证了每一个原子模块在执行业务上具有原子性,从而保证了整个数据执行的原子性。
需要说明的是,本发明实施例提供的处理装置是应用上述处理方法的装置,则上述处理方法的所有实施例均适用于该处理装置,且均能达到相同或相似的有益效果。
本发明实施例还提供一种系统,包括数据库,所述数据库包括多个需要提供原子性保护的原子模块,所述系统还包括如上所述的数据库的处理装置;
当所述原子模块出现异常类型为回退类型的异常时,所述数据库的处理装置调用与所述回退类型对应的回退代码并执行,使得所述数据库回退到该原子模块执行之前的状态。
需要说明的是,本发明实施例提供的系统是包括上述处理装置及数据库的系统,则上述处理装置的所有实施例及其有益效果均适用于该系统。
本领域普通技术人员可以理解上述方法中的全部或部分步骤可通过程序来指令相关硬件完成,上述程序可以存储于计算机可读存储介质中,如只读存储器、磁盘或光盘等。可选地,上述实施例的全部或部分步骤也可以使用一个或多个集成电路来实现。相应地,上述实施例中的各模块/单元可以采用硬件的形式实现,也可以采用软件功能模块的形式实现。本发明实施例不限制于任何特定形式的硬件和软件的结合。
工业实用性
本发明实施例方法保证了在异常类型为回退类型时,对应的原子模块能够执行相应的处理方法回退到该原子模块运行前的状态,保证了每一个原子模块在执行业务上具有原子性,从而保证了整个数据执行的原子性。

Claims (12)

  1. 一种数据库的处理方法,包括:
    根据数据库的业务需求将所述数据库的执行流程依次分割为多个需要提供原子性保护的原子模块;
    实时获取正在运行的目的原子模块的异常状态,根据所述异常状态确定异常类型;
    若所述异常类型为回退类型,获取与所述回退类型对应的第一处理方法并执行所述第一处理方法使得所述目的原子模块回退到该目的原子模块运行前的状态。
  2. 根据权利要求1所述的数据库的处理方法,所述方法还包括:
    若所述异常类型不为回退类型,获取与该异常类型对应的第二处理方法并执行所述第二处理方法对所述异常类型进行处理。
  3. 根据权利要求1所述的数据库的处理方法,其中,若所述异常类型为回退类型,获取与所述回退类型对应的第一处理方法并执行所述第一处理方法使得所述目的原子模块回退到该目的原子模块运行前的状态的步骤包括:
    若所述异常类型为回退类型,获取预先存储的与该回退类型对应的第一处理方法的回退代码;
    执行所述回退代码,使得所述目的原子模块回退到该目的原子模块运行前的状态,并结束流程。
  4. 根据权利要求2所述的数据库的处理方法,其中,若所述异常类型不为回退类型,获取与该异常类型对应的第二处理方法执行所述第二处理方法对所述异常进行处理的步骤包括:
    若所述异常类型不为回退类型,获取预先存储的与该异常类型对应的第二处理方法的处理代码;
    执行所述处理代码后,获取所述目的原子模块的异常状态;
    若所述目的原子模块不存在异常,则所述数据库继续执行下一原子模块;若所述目的原子模块存在异常,则结束流程。
  5. 根据权利要求3所述的数据库的处理方法,其中,所述回退代码为删除语句。
  6. 一种数据库的处理装置,包括:
    分割模块,设置为根据数据库的业务需求将所述数据库的执行流程依次分割为多个需要提供原子性保护的原子模块;
    异常获取模块,设置为实时获取正在运行的目的原子模块的异常状态,根据所述异常状态确定所述异常的异常类型;以及
    第一执行模块,设置为若所述异常类型为回退类型,获取与所述回退类型对应的第一处理方法并执行所述第一处理方法使得所述目的原子模块回退到该目的原子模块运行前的状态。
  7. 根据权利要求6所述的数据库的处理装置,所述装置还包括:
    第二执行模块,设置为若所述异常类型不为回退类型,获取与该异常类型对应的第二处理方法并执行所述第二处理方法对所述异常类型进行处理。
  8. 根据权利要求6所述的数据库的处理装置,其中,所述第一执行模块包括:
    第一获取单元,设置为若所述异常类型为回退类型,获取预先存储的与该回退类型对应的第一处理方法的回退代码;以及
    执行单元,设置为执行所述回退代码,使得所述目的原子模块回退到该目的原子模块运行前的状态,并结束流程。
  9. 根据权利要求7所述的数据库的处理装置,其中,所述第二执行模块包括:
    第二获取单元,设置为若所述异常类型不为回退类型,获取预先存储的与该异常类型对应的第二处理方法的处理代码;
    第三获取单元,设置为执行所述处理代码后,获取所述目的原子模块的异常状态;以及
    判断单元,设置为若所述目的原子模块不存在异常,则所述数据库继续执行下一原子模块;若所述目的原子模块存在异常,则结束流程。
  10. 根据权利要求8所述的数据库的处理装置,其中,所述回退代码为删除语句。
  11. 一种系统,包括数据库,其特征在于,所述数据库包括多个需要提供原子性保护的原子模块,所述系统还包括如权利要求6至10任一项所述的数据库的处理装置;
    当所述原子模块出现异常类型为回退类型的异常时,所述数据库的处理装置调用与所述回退类型对应的回退代码并执行,使得所述数据库回退到该原子模块执行之前的状态。
  12. 一种计算机可读存储介质,存储有程序指令,当该程序指令被执行时可实现权利要求1-5任一项所述的方法。
PCT/CN2015/081250 2014-10-29 2015-06-11 一种数据库的处理方法、装置及系统 WO2016065904A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201410593605.6A CN105550178A (zh) 2014-10-29 2014-10-29 一种数据库的处理方法、装置及系统
CN201410593605.6 2014-10-29

Publications (1)

Publication Number Publication Date
WO2016065904A1 true WO2016065904A1 (zh) 2016-05-06

Family

ID=55829367

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2015/081250 WO2016065904A1 (zh) 2014-10-29 2015-06-11 一种数据库的处理方法、装置及系统

Country Status (2)

Country Link
CN (1) CN105550178A (zh)
WO (1) WO2016065904A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102156735A (zh) * 2011-04-11 2011-08-17 中国有色矿业集团有限公司 一种基于数据库事务处理的业务方法执行方法及装置
CN102857357A (zh) * 2011-06-29 2013-01-02 中兴通讯股份有限公司 一种网管配置的实现方法和实现装置
CN103279358A (zh) * 2013-06-08 2013-09-04 北京首钢自动化信息技术有限公司 一种面向行业应用的解释型业务组件动态构建方法
US20140149793A1 (en) * 2012-11-27 2014-05-29 Red Hat Israel, Ltd. Database change compensation after a transaction commit

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102156700A (zh) * 2010-02-12 2011-08-17 华为技术有限公司 数据库的访问方法、装置及系统
CN102682117B (zh) * 2012-05-15 2016-09-21 浪潮电子信息产业股份有限公司 一种数据库集群数据快速复制的方法
CN103294787A (zh) * 2013-05-21 2013-09-11 成都市欧冠信息技术有限责任公司 分布式数据库系统的多副本存储方法和系统
CN103617195B (zh) * 2013-11-05 2017-08-18 杭州沃趣科技股份有限公司 一种用于MySQL数据库的数据同步系统和方法
CN103678532B (zh) * 2013-12-02 2017-05-10 中国移动(深圳)有限公司 变更语句逆向分析方法、数据库变更回退方法及系统

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102156735A (zh) * 2011-04-11 2011-08-17 中国有色矿业集团有限公司 一种基于数据库事务处理的业务方法执行方法及装置
CN102857357A (zh) * 2011-06-29 2013-01-02 中兴通讯股份有限公司 一种网管配置的实现方法和实现装置
US20140149793A1 (en) * 2012-11-27 2014-05-29 Red Hat Israel, Ltd. Database change compensation after a transaction commit
CN103279358A (zh) * 2013-06-08 2013-09-04 北京首钢自动化信息技术有限公司 一种面向行业应用的解释型业务组件动态构建方法

Also Published As

Publication number Publication date
CN105550178A (zh) 2016-05-04

Similar Documents

Publication Publication Date Title
US8145944B2 (en) Business process error handling through process instance backup and recovery
CN107643904B (zh) 代码提交日志的检测方法、装置、介质及电子设备
WO2018149396A1 (zh) 一种业务流程处理方法、可读存储介质、终端设备及装置
WO2019169763A1 (zh) 电子装置、业务系统风险控制方法及存储介质
CN110795447A (zh) 数据处理方法、数据处理系统、电子设备和介质
CN114090113B (zh) 数据源处理插件动态加载的方法、装置、设备及存储介质
CN112231403B (zh) 数据同步的一致性校验方法、装置、设备和存储介质
CN110597649B (zh) 一种数据处理方法、系统及装置
US9619506B2 (en) Method and system to avoid deadlocks during a log recovery
US9348861B2 (en) Capturing change data of deferred updates
WO2016065904A1 (zh) 一种数据库的处理方法、装置及系统
CN116166390A (zh) 一种业务处理方法、装置、电子设备和存储介质
US20180268020A1 (en) Transaction processing system and transaction control method
CN116089394A (zh) 数据库的数据回滚方法、存储介质与设备
US11354329B2 (en) Systems for real-time mining of data in test and development environments
US9250982B2 (en) Automatically deriving a command for starting a program in an operating system of a computer
CN109491831A (zh) 系统分区自救方法、装置、系统及计算机可读存储介质
JP5497210B1 (ja) ジョブ再実行支援システム
JP2000215237A (ja) 税率変更システムおよびそのプログラム記録媒体
JP2008112229A (ja) ソフトウェア製品の更新データ適用方法
US20030126159A1 (en) Method and system for rollback of software system upgrade
JPH1139363A (ja) データ検証方式
CN113626332B (zh) 调试方法、装置、设备、存储介质以及计算机程序产品
CN111159198B (zh) 参数交易处理方法及装置、计算机设备及可读存储介质
KR102030544B1 (ko) 프로그램에서 지원하는 기능에 대한 함수 호출 정보의 생성이 가능한 프로그램 분석 장치 및 그 동작 방법

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 15854674

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 15854674

Country of ref document: EP

Kind code of ref document: A1