WO2018006723A1 - 一种针对数据库的数据修改请求处理方法及装置 - Google Patents

一种针对数据库的数据修改请求处理方法及装置 Download PDF

Info

Publication number
WO2018006723A1
WO2018006723A1 PCT/CN2017/090269 CN2017090269W WO2018006723A1 WO 2018006723 A1 WO2018006723 A1 WO 2018006723A1 CN 2017090269 W CN2017090269 W CN 2017090269W WO 2018006723 A1 WO2018006723 A1 WO 2018006723A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
log
database
request
modification request
Prior art date
Application number
PCT/CN2017/090269
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 阿里巴巴集团控股有限公司
Priority to EP17823535.4A priority Critical patent/EP3480705B1/en
Priority to SG11201811808VA priority patent/SG11201811808VA/en
Priority to MYPI2019000224A priority patent/MY189491A/en
Priority to JP2019500305A priority patent/JP6987340B2/ja
Priority to KR1020197003517A priority patent/KR102248386B1/ko
Publication of WO2018006723A1 publication Critical patent/WO2018006723A1/zh
Priority to US16/240,549 priority patent/US11106695B2/en
Priority to US16/722,469 priority patent/US11132379B2/en
Priority to US17/458,168 priority patent/US20210390114A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/14Error detection or correction of the data by redundancy in operation
    • G06F11/1402Saving, restoring, recovering or retrying
    • G06F11/1471Saving, restoring, recovering or retrying involving logging of persistent data for recovery
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/07Responding to the occurrence of a fault, e.g. fault tolerance
    • G06F11/16Error detection or correction of the data by redundancy in hardware
    • G06F11/20Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements
    • G06F11/2053Error detection or correction of the data by redundancy in hardware using active fault-masking, e.g. by switching out faulty elements or by switching in spare elements where persistent mass storage functionality or persistent mass storage control functionality is redundant
    • G06F11/2094Redundant storage or storage space
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2358Change logging, detection, and notification
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2379Updates performed during online database operations; commit processing

Definitions

  • the present application relates to the field of database technologies, and in particular, to a data modification request processing method and apparatus for a database.
  • a database is a set of software running on a server that stores, queries, and manages large amounts of data.
  • the database log is a kind of storage content used by the database, which can be used to record operations that have occurred in the database, such as data modification.
  • the log can be used to restore the previous normal state; the database sends the log to another database, and the other database can also use the received log to recover the exact same copy of the database from which the log was sent. It is a method of database master-slave synchronization.
  • the log includes modified data, data before modification, and even other data related to the modified data in some scenarios.
  • a data modification request that a user can send to a database
  • the database modifies the data and generates a log according to the data modification request, and performs persistence processing on the generated log (for example, on the hard disk), and then The user returns the modification result corresponding to the data modification request (for example, informing the user that the modification is successful).
  • the generated log is generally transient, and the persistent processing is performed to prevent accidental loss such as power failure or restart.
  • the database has a standby database, the database first synchronizes the generated log to the standby database, and then returns the modification result corresponding to the data modification request.
  • the embodiment of the present invention provides a data modification request processing method and device for a database, which is used to solve the problem that the data modification request processing method for the database in the prior art takes a long time.
  • Receiving a module receiving a data modification request for a database
  • the processing module according to the data modification request, modifying the second data in the database to the first data, and generating the first log and the second log, where the first log includes the first data, where The second log includes the second data;
  • the solution of the present application can generate two logs that are not necessarily identical, which are not necessarily the same, that is, the first log and the second log.
  • the first data is the modified data
  • the second data is the data before the modification.
  • the first log may include only the first data, and does not include the second data and other data related to the modified data.
  • the database state or the active/standby synchronization can be restored according to the modified data only according to the second data and other data related to the modified data, after the first log is persisted, the user can be Return the modified result, because the amount of data in the first log is less than the amount of data in the full log, the cost of the persistence process The time is also relatively small, and the data modification request processing time for the database can be reduced, and therefore, the problems in the prior art can be partially or completely solved.
  • FIG. 1 is a schematic flowchart of a data modification request processing method for a database according to an embodiment of the present application
  • FIG. 2 is a schematic flowchart of a data modification request processing process in an actual application scenario provided by the prior art
  • FIG. 3 is a schematic flowchart of a data modification request processing process in an actual application scenario according to an embodiment of the present disclosure
  • FIG. 4 is a schematic flowchart of sending a log to an external system such as a data analysis system in an actual application scenario according to an embodiment of the present application;
  • FIG. 5 is a schematic diagram of a processing flow of a first log synchronized by a standby database to a received primary database in an actual application scenario according to an embodiment of the present disclosure
  • FIG. 6 is a schematic diagram of interaction of each end involved in the solution of the present application in an actual application scenario (using the scenario in FIG. 2 to FIG. 4) according to an embodiment of the present application;
  • FIG. 7 is a schematic structural diagram of a data modification request processing apparatus for a database according to an embodiment of the present application.
  • FIG. 1 is a schematic flowchart of a data modification request processing method for a database according to an embodiment of the present application.
  • the execution entity of the flow in FIG. 1 may be the database, or a functional module that does not belong to the database but may be connected to the database.
  • the application does not limit the database and/or the device where the functional module is located.
  • the device includes, but is not limited to, a personal computer as a server or a client, a large and medium-sized computer, a computer cluster, a mobile phone, a tablet computer, a smart watch, a car mobile station, a personal computer, and the like.
  • the process in Figure 1 can include the following steps:
  • S101 Receive a data modification request for a database.
  • the data modification request is a request for requesting modification of data in the database, which may be manually sent by a user of the database, or automatically sent by executing an automated script.
  • the data modification request includes at least one of the following requests: a data update request, a data deletion request, and a data addition request.
  • This application does not limit the format of the data modification request. It can be a Structured Query Language (SQL) statement format or other formats supported by the database.
  • SQL Structured Query Language
  • S102 Modify, according to the data modification request, the second data in the database to the first data, and generate a first log and a second log, where the first log includes the first data, and the second The log contains the second data.
  • the data modification request may indicate what kind of data modification operation is requested. Specifically, the data modification request indicates that the request modifies the second data in the database to the first data.
  • the data modification request may also be a less specific request.
  • a data modification request may indicate that the request reduces the total amount of data in the database by half, etc., and specifically reduces which data can be used by the database. According to a certain strategy.
  • the first data or the second data may also be empty.
  • the second data is not empty, and the first data is empty;
  • the first data is not empty, and the second data is empty; and
  • the first data is The second data is not empty.
  • the present application does not limit the specific content of the first data and the second data, and may be part or all of any type of data such as a database record, or a data table, or a data index, or a data view.
  • the log must include at least the first data.
  • the second data and other data related to the modified data it is optional for the purpose of database recovery or active/standby synchronization, and therefore, they may not be included in the log.
  • the solution of the present application is based on the idea of solving the problems in the prior art. In the prior art, there is only one type of log (referred to as a complete log for convenience of description), and the first data and the second data are included.
  • the solution of the present application provides two logs, a first log and a second log, wherein the first log may be a compact log dedicated to database recovery or active/standby synchronization, which may preferably Only the first data is included (so that the amount of data of the first log can be made as small as possible), and the second log can be a complete log or an incomplete log for supplementing the first log.
  • the second log may include both the second data and the first data, and may even include other data related to the modified data, and the second log may also include only the second data.
  • the second log or the second log combined with the first log may also be used for database recovery or active/standby synchronization, and further, may be used for work other than database recovery or active/standby synchronization, for example, Real-time analysis of data changes in the database.
  • the execution order of the two sub-steps of “modifying the second data to the first data” and “generating the first log and the second log” in step S102 is not limited.
  • the modification operation is performed first, and then the corresponding log is generated; however, in order to prevent the log from being lost due to an abnormality such as a power failure during the execution of the modification operation, in the actual application, the log may be performed, and the corresponding modification operation may be performed.
  • the log can be rolled back according to the actual state of the data in the restored database, which is beneficial to ensure that neither the lost log nor the included log is included in the log after the rollback. Generate an error or redundant log.
  • the first log and the second log generated in step S102 may be generated in a memory or a cache, and are generated in a temporary, non-stable state.
  • the first log and the second log generated will also be lost, and subsequent database recovery or active/standby synchronization or other functions that require logging will not be performed.
  • the first log may be persisted, and then the corresponding modification result may be returned to the sender of the data modification request to ensure that, even if this happens, at least the persistent processing may be utilized.
  • the second log may also be persisted.
  • the persistence processing on the second log may not be placed on the critical path of the data modification request processing flow.
  • the flow in FIG. 1 does not include “persistent processing on the second log”, the flow in FIG. Execution of any step of the step does not have to be based on "persistence of the second log”.
  • the process in FIG. 1 can be executed by a main thread or process, and the second log can be persisted by another thread (for example, a background thread, etc.) or a process, and the two actions can interfere with each other.
  • the specific content included in the returned modification result is not limited.
  • the modification result may include only the description content of whether the modification is successful, or may include the description content of the data specifically modified.
  • execution bodies of the steps of the process in FIG. 1 may all be the same device, or may be different devices.
  • the execution body of step S101 and step S102 may be device 1
  • the execution body of step S103 may be device 2;
  • the execution body of step S101 may be device 1
  • the execution body of step S102 and step S103 may be device 2 ;and many more.
  • a complete log containing modified data, pre-modification data, and other data related to the modified data is generated in the prior art.
  • the solution of the present application can generate two not necessarily complete logs, which are not identical, that is, the first log and the second log.
  • the first data is the modified data
  • the second data is the data before the modification.
  • the first log may include only the first data, and does not include the second data and other data related to the modified data.
  • the database state or the active/standby synchronization can be restored according to the modified data only according to the second data and other data related to the modified data, after the first log is persisted, the user can be Returning the modified result, since the data volume of the first log is less than the data volume of the complete log, the time taken for the persistence processing is relatively small, and the processing time of the data modification request for the database can be reduced, so that the solution can be partially or completely solved. There are technical problems.
  • the second log since the second log is also generated in the solution of the present application, the second log may be a complete log or an incomplete log for supplementing the first log. Therefore, compared with the log in the prior art, the total log content is not lacking, and the resources used for generating the log are also similar.
  • the prior art can be based on the function implemented by the log, and the solution of the present application is still Can be achieved.
  • the embodiments of the present application further provide some specific implementation manners of the foregoing methods, and an extended solution, which will be described below.
  • the persistence process may include saving to a non-volatile storage device, and more specifically, recording to a file in a format, and saving the file to the non-volatile storage device.
  • the non-volatile storage device may specifically refer to a storage device that loses power and does not lose stored data, such as a hard disk, a read only memory (ROM), an erasable programmable read only memory (EPROM), and an electrically erasable read only. Memory (EEPROM), flash memory, etc.
  • the generated record can be saved to text, saved to a hard disk, and so on.
  • the log in addition to being used for primary and secondary database synchronization and database recovery, the log may have other uses, for example, for analyzing data and the like.
  • the second log can be used to implement the other uses described below.
  • the database connection has an external system such as a data analysis system
  • the database log can be provided to the external system for other purposes.
  • the data analysis system Take the data analysis system as an example, the data points
  • the analysis system can perform real-time or non-real-time analysis on the data changes in the database according to the log sent by the database, and provide the analysis result to relevant users or organizations.
  • the data analysis system needs the log to include the modified data (that is, the first data), and the data before the modification (that is, the second data), and even Need to include other relevant data (for example, other data belonging to the same database record as the modified data, etc.).
  • the second log can meet the requirements of the data analysis system. Specifically, after the second log is generated or after the second log is persisted, the second log may be sent to the data analysis system, so that the data analysis system performs data analysis according to the second log. This application does not limit the specific analysis content of the data analysis system.
  • the modification result may not be returned temporarily, but the first log is synchronized to the standby database or other After the device, return the modified result.
  • the storage device used for persisting the first log is faulty, it can still be from the standby database or other. The device retrieves the first log.
  • the first log may be synchronized to the standby database of the database, so as to facilitate the standby database.
  • the modification is synchronized according to the first log.
  • the first log is a reduced log containing only the first data
  • the second log is a complete log including at least the first data and the second data, based on FIG. 2 and FIG.
  • FIG. 2 is a schematic flowchart of a data modification request processing process in an actual application scenario provided by the prior art. Assuming that the execution subject of the process in FIG. 2 is a master database, the process may include the following steps:
  • S201 The primary database receives a data modification request sent by the user.
  • S202 The primary database performs a corresponding data modification operation according to the data modification request.
  • S203 The primary database generates a second log in the memory according to the data modification request or the data modification operation performed.
  • S204 The primary database performs persistence processing on the generated second log.
  • S205 The primary database synchronizes the second log of the persistent processing to the standby database.
  • step S206 may not be performed until the abnormality is eliminated.
  • FIG. 3 is a schematic flowchart of a data modification request processing process in an actual application scenario according to an embodiment of the present disclosure. Assuming that the execution body of the process in FIG. 3 is also a master database, the process may include the following steps:
  • S301 The primary database receives a data modification request sent by the user.
  • S302 The primary database performs a corresponding data modification operation according to the data modification request.
  • S303 The primary database generates the first log and the second log in the memory according to the data modification request or the performed data modification operation.
  • S304 The primary database performs persistence processing on the generated first log.
  • S305 The primary database synchronizes the first log of the persistent processing to the standby database.
  • step S306 may not be performed until the abnormality is eliminated.
  • the primary database is synchronized with the database.
  • the synchronization log also needs to occupy the corresponding bandwidth and the corresponding time. Since the data volume of the first log is smaller than the data volume of the second log, the solution of the present application can be reduced compared to the prior art. The bandwidth and/or time spent synchronizing the logs.
  • the embodiment of the present application further provides a schematic diagram of a process of sending a log to an external system such as a data analysis system in an actual application scenario, as shown in FIG. 4 .
  • the process may include the following steps:
  • S401 The primary database detects a newly generated second log in the memory.
  • S402 The primary database acquires the newly generated second log.
  • S403 The primary database performs persistence processing on the obtained second log.
  • S404 The primary database sends the second log to a predetermined external system.
  • the standby database may also perform operations such as persistence processing and/or sending to an external system.
  • operations such as persistence processing and/or sending to an external system.
  • the specific operation process is different from the prior art. The following describes the related operations of the standby database.
  • the standby database receives the complete log (that is, the second log in the above example), and therefore, the received log can be directly processed and/or sent to an external system or the like.
  • the standby database receives the reduced log (that is, the first log in the above example), and can only directly perform the persistence processing on the received log, and is not suitable for sending to the external system.
  • the standby database may also have the requirement to use the full log. Therefore, the standby database may first obtain a corresponding complete log according to the thin log, and then the persistent log may be persistently processed and/or sent to an external system. In this way, the consistency of the logs in the primary and secondary databases can be improved.
  • the standby database may execute: the standby database synchronizes the modification according to the first log, and generates the second log. . Further, the standby database may further perform: the standby database performs persistence processing on the first log obtained by synchronization and/or the second log generated according to the first log; The second log is sent to a predetermined external system.
  • the embodiment of the present application provides a schematic diagram of a processing flow of a first log synchronized by a standby database to a received primary database in a practical application scenario (using the scenario in FIG. 2 to FIG. 4), as shown in FIG. 5 .
  • the process may include Next steps:
  • the standby database receives the first log of the synchronization of the primary database.
  • S502 The standby database performs persistence processing on the received first log.
  • S504 The standby database synchronizes the data modification operation and generates the second log in the memory by playing back.
  • S505 The standby database performs the persistence processing on the second log.
  • the first log and the second log may be generated.
  • the persistent operation is performed.
  • the first log and the second log may be separately stored in different non-volatile storage devices.
  • the reading of the two logs can be performed based on the performance of the respective storage device (such as bandwidth, read speed, etc.), and can be performed in parallel.
  • the full log or the second log may include other data related to the modified data in addition to the first data and the second data.
  • the “other data related to the modified data” that may be included in the second log includes but is not limited to: the database record of the first data belongs to Data other than the first data, and/or data other than the second data in the database record to which the second data belongs.
  • Table 1 is a part of a data table in a database, including three database records a, b, c, each record contains n key value pairs, n keys are respectively column_1-column_n, each The values corresponding to each key in the database record are shown in Table 1.
  • Table 1 For the convenience of description, the following is the key value pair and the row number of the database record to which it belongs, represented by ⁇ row>: ⁇ key,value>, "key” represents the key, "value” represents the value, and row represents the database of the key value pair. The line number of the record.
  • the first data is ⁇ a>: ⁇ column_2, a_2'> and ⁇ b>: ⁇ column_2,b_2'>
  • the second data is ⁇ a>: ⁇ column_2, a_2> and ⁇ b>: ⁇ column_2 , b_2>.
  • Other data related to the modified data may include: data other than the modified data in the record a and the record b, that is, ⁇ a>: ⁇ column_1, a_1>, ..., ⁇ a>: ⁇ column_n , a_n>, and ⁇ b>: ⁇ column_1,b_1>,..., ⁇ b>: ⁇ column_n,b_n>.
  • the generated first log may contain only the first data, and not the second data and other data related to the modified data, as follows:
  • the generated second log can contain both the first data and the second data as well as other data related to the modified data, as follows:
  • ⁇ b> second data and other data related to the modified data: ⁇ column_1, a_1>, ⁇ column_2, a_2>, ..., ⁇ column_n, a_n>; first data: ⁇ column_2, a_2'>".
  • the embodiment of the present application further provides a schematic diagram of interaction between the ends of the solution according to the scenario of the application in the application scenario (using the scenario in FIG. 2 to FIG. 4). Shown.
  • Figure 6 mainly includes four ends, which are user, primary database, standby database, and data analysis system.
  • the steps corresponding to the reference numerals 1-5 in FIG. 6 are the main steps of the data modification request processing method provided by the embodiment of the present application, and the unmarked steps are the secondary steps, and each step has been separately described above. Do not repeat them.
  • the above is a data modification request processing method for the database provided by the embodiment of the present application. Based on the same idea, the embodiment of the present application further provides a corresponding device, as shown in FIG. 7 .
  • FIG. 7 is a schematic structural diagram of a data modification request processing apparatus for a database according to an embodiment of the present disclosure, including:
  • the receiving module 701 receives a data modification request for a database
  • the processing module 702 according to the data modification request, modify the second data in the database to the first data, and generate the first log and the second log, where the first log includes the first data, The second log includes the second data;
  • the returning module 703 returns the modification result corresponding to the data modification request after performing the persistence processing on the first log.
  • the second log further includes the first data.
  • the processing module 702 generates a first log and a second log in the memory.
  • processing module 702 further performs persistence processing on the second log.
  • the device further includes:
  • the sending device 704 sends the second log to the data analysis system to facilitate the data segmentation
  • the analysis system performs data analysis according to the second log.
  • the device when the database is a primary database, the device further includes:
  • the synchronization module 705 synchronizes the first log to the standby database of the database before the returning module 703 returns the modification result corresponding to the data modification request, so that the standby database synchronizes according to the first log. Said the amendment.
  • the first data belongs to at least one database record
  • the second log further includes: data other than the first data in the database record to which the first data belongs, and/or data other than the second data in the database record to which the second data belongs .
  • the persistence process includes saving to a non-volatile storage device.
  • the persisting process includes: saving to a non-volatile storage device;
  • the first log and the second log are respectively saved in different non-volatile storage devices by the persistence processing.
  • the data modification request is a data update request, or a data deletion request, or a data addition request;
  • the data modification request is a data update request
  • the first data and the second data are not empty
  • the data modification request is a data deletion request
  • the first data is empty
  • the second data is not empty
  • the data modification request is a data addition request
  • the first data is not empty
  • the second data is empty.
  • the device in FIG. 7 may specifically be located in a database or a functional module that does not belong to the database but can be connected to the database.
  • the device provided by the present application is in one-to-one correspondence with the method provided by the present application. Therefore, the device also has similar beneficial technical effects as the method, since the beneficial technical effects of the method have been described in detail above. Therefore, the beneficial technical effects of the device will not be described again here.
  • embodiments of the present invention can be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or a combination of software and hardware. Moreover, the invention can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) including computer usable program code.
  • computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
  • the computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing device to operate in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture comprising the instruction device.
  • the apparatus implements the functions specified in one or more blocks of a flow or a flow and/or block diagram of the flowchart.
  • These computer program instructions can also be loaded onto a computer or other programmable data processing device such that a series of operational steps are performed on a computer or other programmable device to produce computer-implemented processing for execution on a computer or other programmable device.
  • the instructions provide steps for implementing the functions specified in one or more of the flow or in a block or blocks of a flow diagram.
  • a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory.
  • processors CPUs
  • input/output interfaces network interfaces
  • memory volatile and non-volatile memory
  • the memory may include non-persistent memory, random access memory (RAM), and/or non-volatile memory in a computer readable medium, such as read only memory (ROM) or flash memory.
  • RAM random access memory
  • ROM read only memory
  • Memory is an example of a computer readable medium.
  • Computer readable media including both permanent and non-permanent, removable and non-removable media What methods or techniques are used to implement information storage.
  • the information can be computer readable instructions, data structures, modules of programs, or other data.
  • Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory. (ROM), electrically erasable programmable read only memory (EEPROM), flash memory or other memory technology, compact disk read only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, Magnetic tape cartridges, magnetic tape storage or other magnetic storage devices or any other non-transportable media can be used to store information that can be accessed by a computing device.
  • computer readable media does not include temporary storage of computer readable media, such as modulated data signals and carrier waves.

Abstract

一种针对数据库的数据修改请求处理方法及装置,用以解决现有技术中针对数据库的数据修改请求处理方式耗时较长的问题。所述方法包括:接收针对数据库的数据修改请求(S101);根据所述数据修改请求,将所述数据库中的第二数据修改为第一数据,以及生成第一日志和第二日志,所述第一日志包含所述第一数据,所述第二日志包含所述第二数据(S102);在对所述第一日志进行持久化处理后,返回所述数据修改请求对应的修改结果(S103)。

Description

一种针对数据库的数据修改请求处理方法及装置 技术领域
本申请涉及数据库技术领域,尤其涉及一种针对数据库的数据修改请求处理方法及装置。
背景技术
数据库是一套运行在服务器上的软件,用于存储、查询、管理大量数据。数据库的日志是数据库使用的一种存储内容,其可以用于记录数据库中曾经发生的操作,比如,数据修改等操作。在数据库重新启动时,可以使用日志来恢复之前的正常运行状态;数据库将日志发送给另一个数据库,则另一个数据库也可以利用接收到的日志恢复出于发送日志的数据库完全一样的副本,这就是数据库主备同步的一种方法。其中,日志中包含有包含修改后的数据、修改前的数据,甚至在某些场景下还包含与被修改数据相关的其他数据等。
在现有技术中,用户可以向数据库发送的数据修改请求,数据库根据数据修改请求,相应地修改数据以及生成日志,并对生成的日志进行持久化处理(比如,保存在硬盘中),然后向用户返回该数据修改请求对应的修改结果(比如,告知用户修改成功),需要说明的是,生成的日志一般是暂态的,进行持久化处理是为了防止掉电或重启等意外丢失。进一步地,若数据库有备数据库,则数据库还会先将生成的日志同步给备数据库,再返回该数据修改请求对应的修改结果。
但是,无论是对生成的日志进行持久化处理,还是将生成的日志同步给备数据库,都需要花费不少时间,这导致现有技术中针对数据库的数据修改请求处理方式耗时较长。
发明内容
本申请实施例提供一种针对数据库的数据修改请求处理方法及装置,用以解决现有技术中针对数据库的数据修改请求处理方式耗时较长的问题。
本申请实施例采用下述技术方案:
本申请实施例提供的一种针对数据库的数据修改请求处理方法,包括:
接收针对数据库的数据修改请求;
根据所述数据修改请求,将所述数据库中的第二数据修改为第一数据,以及生成第一日志和第二日志,所述第一日志包含所述第一数据,所述第二日志包含所述第二数据;
在对所述第一日志进行持久化处理后,返回所述数据修改请求对应的修改结果。
本申请实施例提供的一种针对数据库的数据修改请求处理装置,包括:
接收模块,接收针对数据库的数据修改请求;
处理模块,根据所述数据修改请求,将所述数据库中的第二数据修改为第一数据,以及生成第一日志和第二日志,所述第一日志包含所述第一数据,所述第二日志包含所述第二数据;
返回模块,在对所述第一日志进行持久化处理后,返回所述数据修改请求对应的修改结果。
本申请实施例采用的上述至少一个技术方案能够达到以下有益效果:对于任一数据修改请求,相比于现有技术中生成一种包含修改后的数据、修改前的数据,以及与被修改数据相关的其他数据的完整日志,本申请的方案可以生成两种内容不全相同的不一定完整的日志,即第一日志和第二日志。第一数据即为修改后的数据,第二数据即为修改前的数据,第一日志中可以只包含第一数据,而不包含第二数据以及与被修改数据相关的其他数据。由于仅根据修改后的数据,而无需根据第二数据以及与被修改数据相关的其他数据,即可恢复数据库状态或主备同步,则在对第一日志进行持久化处理后,即可向用户返回修改结果,由于第一日志的数据量少于完整日志的数据量,则持久化处理所耗费 时间也相对少,可以减少针对数据库的数据修改请求处理时间,因此,可以部分或全部地解决现有技术中的问题。
附图说明
此处所说明的附图用来提供对本申请的进一步理解,构成本申请的一部分,本申请的示意性实施例及其说明用于解释本申请,并不构成对本申请的不当限定。在附图中:
图1为本申请实施例提供的一种针对数据库的数据修改请求处理方法的流程示意图;
图2为现有技术提供的一种实际应用场景下,数据修改请求处理流程示意图;
图3为本申请实施例提供的一种实际应用场景下,数据修改请求处理流程示意图;
图4为本申请实施例提供的一种实际应用场景下,向诸如数据分析系统等外部系统发送日志的流程示意图;
图5为本申请实施例提供的一种实际应用场景下,备数据库对接收到的主数据库同步的第一日志的处理流程示意图;
图6为本申请实施例提供的一种实际应用场景(沿用图2-图4中的场景)下,本申请的方案所涉及的各端交互示意图;
图7为本申请实施例提供的一种针对数据库的数据修改请求处理装置的结构示意图。
具体实施方式
为使本申请的目的、技术方案和优点更加清楚,下面将结合本申请具体实施例及相应的附图对本申请技术方案进行清楚、完整地描述。显然,所描述的实施例仅是本申请一部分实施例,而不是全部的实施例。基于本申请中的实施 例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。
图1为本申请实施例提供的一种针对数据库的数据修改请求处理方法的流程示意图。
图1中的流程的执行主体可以是所述数据库,或者不属于所述数据库但可以连接所述数据库的功能模块,本申请对所述数据库和/或所述功能模块所处设备并不做限定,所述设备包括但不限于:作为服务器或客户机的个人计算机、大中型计算机、计算机集群、手机、平板电脑、智能手表、车载移动台、个人计算机等。
图1中的流程可以包括以下步骤:
S101:接收针对数据库的数据修改请求。
在本申请实施例中,数据修改请求是用于请求修改数据库中数据的请求,其可以是由数据库的用户手动发送的,或者,通过执行自动化脚本自动发送的。数据修改请求包括以下请求中的至少一种:数据更新请求、数据删除请求、数据增加请求。
本申请对数据修改请求的格式并不做限定,其可以是结构化查询语言(Structured Query Language,SQL)语句格式,也可以是数据库支持的其他格式。
S102:根据所述数据修改请求,将所述数据库中的第二数据修改为第一数据,以及生成第一日志和第二日志,所述第一日志包含所述第一数据,所述第二日志包含所述第二数据。
在本申请实施例中,数据修改请求可以表明请求进行怎么样的数据修改操作。具体地,数据修改请求表明了请求将数据库中的第二数据修改为第一数据。当然,在实际应用中,数据修改请求也可以是一个不那么具体的请求,比如,某个数据修改请求可以是表明请求将数据库中的总数据量减少一半等,具体减少哪些数据,可以由数据库按照一定的策略决定。
在本申请实施例中,第一数据或第二数据也可以为空。比如,对于数据删除请求,第二数据不为空,而第一数据为空;对于数据增加请求,第一数据不为空,而第二数据为空;而对于数据更新请求,第一数据和第二数据均不为空。
本申请对于第一数据和第二数据的具体内容并不做限定,其可以是数据库记录、或数据表、或数据索引、或数据视图等任一类数据中的部分或全部。
在本申请实施例中,如果要根据日志进行数据库恢复或主备同步,则日志中至少要包含第一数据。至于第二数据以及与被修改数据相关的其他数据,对于数据库恢复或主备同步的目的而言,则是可有可无,因此,它们可以不包含在日志中。本申请的方案正是基于这样的思路,解决现有技术中的问题的,现有技术中只有一种日志(为了便于描述,称为:完整日志),第一数据和第二数据均是包含在完整日志中的,而本申请的方案则提供了第一日志和第二日志这两种日志,其中,第一日志可以是专门用于数据库恢复或主备同步的精简日志,其优选地可以只包含第一数据(从而可以使得第一日志的数据量尽量地小),第二日志可以是完整日志或者用于对第一日志进行补充的不完整日志。比如,第二日志可以既包含第二数据,也包含第一数据,甚至还可以包含与被修改数据相关的其他数据等,第二日志也可以只包含第二数据。
在本申请实施例中,第二日志或第二日志结合第一日志也可以用于数据库恢复或主备同步,进一步地,还可以用于除了数据库恢复或主备同步以外的工作,比如,用于对数据库中的数据变化情况进行实时分析等。
在本申请实施例中,对步骤S102中“将第二数据修改为第一数据”与“生成第一日志和第二日志”这两个子步骤的执行顺序并不做限定。一般地,是先执行修改操作,再生成对应的日志;但是,为了防止执行修改操作时发生掉电等异常导致丢失日志,在实际应用中,也可以先生成日志,再执行对应的修改操作,这样的话,即使执行修改操作时发生掉电等异常,也可以根据恢复正常后的数据库中数据的实际状态回滚日志,有利于保证回滚后的日志中既没有丢失应有的日志也没有包含产生错误或多余的日志。
S103:在对所述第一日志进行持久化处理后,返回所述数据修改请求对应的修改结果。
在本申请实施例中,在步骤S102中生成的第一日志和第二日志具体可以是在内存或缓存中生成,生成后是处于一种暂时的、非稳定的状态,一般地,若此时数据库发生重启或掉电,则生成的第一日志和第二日志也将丢失,进而后续也无法进行数据库恢复或主备同步或实现其他需要用到日志的功能。为了防止出现这种情况,可以先对第一日志进行持久化处理,再向数据修改请求的发送方返回对应的修改结果,以保证即使出现这种情况,至少还可以利用持久化处理过的第一日志进行数据库恢复或主备同步。
在本申请实施例中,基于类似的理由,对于第二日志,也可以对其进行持久化处理。但是对第二日志进行的持久化处理可以不放在数据修改请求处理流程的关键路径上,具体地,图1中的流程不包含“对第二日志进行持久化处理”,图1中的流程的任一步骤的执行都不必以“对第二日志进行持久化处理”为前提。
例如,可以用主要的线程或进程执行图1中的流程,而用另一个线程(比如,后台线程等)或进程对第二日志进行持久化处理,这两部分动作可以互不干涉。
在本申请实施例中,对返回的修改结果包含的具体内容并不做限定。修改结果可以只包含对是否修改成功的说明内容,也可以包含对数据具体被修改成怎样的说明内容等。
需要说明的是,图1中的流程的各步骤的执行主体均可以是同一设备,或者,也可以是不同设备。比如,步骤S101和步骤S102的执行主体可以为设备1,步骤S103的执行主体可以为设备2;又比如,步骤S101的执行主体可以为设备1,步骤S102和步骤S103的执行主体可以为设备2;等等。
通过上述方法,对于任一数据修改请求,相比于现有技术中生成一种包含修改后的数据、修改前的数据,以及与被修改数据相关的其他数据的完整日志, 本申请的方案可以生成两种内容不全相同的不一定完整的日志,即第一日志和第二日志。第一数据即为修改后的数据,第二数据即为修改前的数据,第一日志中可以只包含第一数据,而不包含第二数据以及与被修改数据相关的其他数据。由于仅根据修改后的数据,而无需根据第二数据以及与被修改数据相关的其他数据,即可恢复数据库状态或主备同步,则在对第一日志进行持久化处理后,即可向用户返回修改结果,由于第一日志的数据量少于完整日志的数据量,则持久化处理所耗费时间也相对少,可以减少针对数据库的数据修改请求处理时间,因此,可以部分或全部地解决现有技术中的问题。
不仅如此,由于在本申请的方案中还生成了第二日志,第二日志可以完整日志或用于对第一日志进行补充的不完整日志。因此,相比于现有技术中的日志,总的日志内容上也不会缺少,而且用于生成日志所耗费的资源也相差无几,现有技术能够基于日志实现的功能,本申请的方案仍然能够实现。
基于上述方法,本申请实施例还提供了上述方法的一些具体实施方案,以及扩展方案,下面进行说明。
在本申请实施例中,前面提到了对第一日志或第二日志进行持久化处理。为了便于理解,对持久化处理进行说明。持久化处理可以包括:保存至非易失性存储设备中,更具体地,可以是以一定格式记录至文件中,再将文件保存至非易失性存储设备中。其中,非易失性存储设备具体可以指掉电不丢失已存储数据的存储设备,比如,硬盘,只读存储器(ROM)、可擦可编程只读存储器(EPROM)、电可擦除只读存储器(EEPROM)、闪存等。
例如,可以将生成的记录至文本中,在将文本保存至硬盘中,等等。
在本申请实施例中,根据前面的说明可知,除了用于主备数据库同步和数据库恢复以外,日志还可以有其他用途,比如,用于对数据分析等。第二日志可以用于实现所述其他用途,下面进行具体说明。
在某些应用场景下,数据库连接有诸如数据分析系统等外部系统,数据库的日志可以提供给外部系统用于实现其他用途。以数据分析系统为例,数据分 析系统可以根据数据库发送的日志,对数据库中的数据变化情况进行实时或非实时的分析,以及将分析结果提供给相关用户或机构等。
为了提供数据分析结果的准确性和全面性,数据分析系统需要日志中包含有修改后的数据(也即,第一数据),以及包含修改前的数据(也即,第二数据),甚至还需要包含其他相关数据(比如,与被修改的数据属于相同数据库记录的其他数据等)。
在本申请实施例中,第二日志可以满足数据分析系统的需求。具体地,在生成第二日志后或对第二日志进行持久化处理后,可以将第二日志发送给数据分析系统,以便于数据分析系统根据第二日志进行数据分析。本申请对数据分析系统的具体分析内容并不做限定。
在本申请实施例中,为了进一步地提高本申请的方案的鲁棒性,在对第一日志进行持久化处理后,可以暂时不返回修改结果,而是将第一日志同步给备数据库或其他设备后,再返回修改结果。如此,一方面是便于备数据库及时同步修改,另一方面相当于是对第一日志进行了备份,即使对第一日志进行持久化处理时所使用的存储设备发生故障,仍然可以从备数据库或其他设备找回第一日志。
例如,当数据库为主数据库时,对于步骤S103,返回所述数据修改请求对应的修改结果前,还可以执行:将所述第一日志同步给所述数据库的备数据库,以便于所述备数据库根据所述第一日志,同步所述修改。
根据上面的分析,在一种实际应用场景下,第一日志是只包含第一数据的精简日志,第二日志是至少包含第一数据和第二数据的完整日志,基于图2和图3,对现有技术和本申请的方案的处理流程进行对比分析。
图2为现有技术提供的一种实际应用场景下,数据修改请求处理流程示意图。假定图2中的流程的执行主体为某主数据库,该流程可以包括以下步骤:
S201:主数据库接收用户发送的数据修改请求。
S202:主数据库根据数据修改请求,执行相应的数据修改操作。
S203:主数据库根据数据修改请求或执行的数据修改操作,在内存中生成第二日志。
S204:主数据库对生成的第二日志进行持久化处理。
S205:主数据库将持久化处理的第二日志同步给备数据库。
S206:主数据库应答用户修改成功。
若步骤S201-S205中任一步骤执行出现异常,则在消除该异常前可以不执行步骤S206。
图3为本申请实施例提供的一种实际应用场景下,数据修改请求处理流程示意图。假定图3中的流程的执行主体也为某主数据库,该流程可以包括以下步骤:
S301:主数据库接收用户发送的数据修改请求。
S302:主数据库根据数据修改请求,执行相应的数据修改操作。
S303:主数据库根据数据修改请求或执行的数据修改操作,在内存中生成第一日志和第二日志。
S304:主数据库对生成的第一日志进行持久化处理。
S305:主数据库将持久化处理的第一日志同步给备数据库。
S306:主数据库应答用户修改成功。
若步骤S301-S305中任一步骤执行出现异常,则在消除该异常前可以不执行步骤S306。
通过对图2和图3中流程的比较可知,由于第一日志的数据量小于第二日志的数据量,因此,本申请的方案相比于现有技术,减少了在应答用户修改成功之前,所需进行持久化处理的日志数据量,从而可以减少数据修改请求处理时间。
不仅如此,在图2和图3的流程中,主数据库都对被数据库进行了日志同步。同步日志也需要占用相应的带宽和花费相应的时间,由于第一日志的数据量小于第二日志的数据量,因此,本申请的方案相比于现有技术,还可以减少 同步日志所占用的带宽和/或花费的时间。
本申请实施例还提供了一种实际应用场景下,向诸如数据分析系统等外部系统发送日志的流程示意图,如图4所示。假定图4中的流程的执行主体也为某主数据库,该流程可以包括以下步骤:
S401:主数据库检测内存中新生成的第二日志。
S402:主数据库获取新生成的第二日志。
S403:主数据库对获取的第二日志进行持久化处理。
S404:主数据库将第二日志发送给预定的外部系统。
在本申请实施例中,备数据库在接收到主数据库同步的日志后,也可以进行持久化处理和/或发送给外部系统等操作,但是,具体操作过程与现有技术有所区别。下面对备数据库的相关操作进行说明。
在现有技术中,备数据库接收到的是完整日志(也即,上例中的第二日志),因此,可以直接对接收到的日志进行持久化处理和/或发送给外部系统等操作。
而在本申请的方案中,备数据库接收到的是精简日志(也即,上例中的第一日志),只能直接对接收到的日志进行持久化处理,而不适合发送给外部系统,在实际应用中,备数据库也可能有使用完整日志的需求,因此,备数据库可以先根据精简日志得到对应的完整日志,进而可以对完整日志进行持久化处理和/或发送给外部系统等操作。如此,可以提高主备数据库中日志的一致程度。根据这样的思路,数据库将所述第一日志同步给所述数据库的备数据库后,备数据库可以执行:所述备数据库根据所述第一日志,同步所述修改,以及生成所述第二日志。进一步地,备数据库还可以执行:所述备数据库对同步得到的所述第一日志和/或根据所述第一日志生成的所述第二日志进行持久化处理;所述备数据库将所述第二日志发送给预定的外部系统。
本申请实施例提供了一种实际应用场景下(沿用图2-图4中的场景),备数据库对接收到的主数据库同步的第一日志的处理流程示意图,如图5所示。假定图5中的流程的执行主体也某主数据库的某备数据库,该流程可以包括以 下步骤:
S501:备数据库接收主数据库同步的第一日志。
S502:备数据库对接收到的第一日志进行持久化处理。
S503:备数据库对回放第一日志。
S504:备数据库通过回放,同步数据修改操作以及在内存中生成第二日志。
S505:备数据库对第二日志进行持久化处理。
在本申请实施例中,如前所述,针对任一数据修改请求,都可以生成第一日志和第二日志这两种日志,为了提高后续对这两种日志的读取速度,在进行持久化处理时,可以将第一日志与第二日志分别保存在不同的非易失性存储设备中。从而,两种日志的读取可以分别基于各自的存储设备的性能(如带宽、读取速度等)进行,可以并行进行。
在本申请实施例中,如前所述,完整日志或第二日志除了可以包含第一数据和第二数据之外,还可以包含与被修改数据相关的其他数据。一般地,若第一数据、第二数据属于至少一条数据库记录,则第二日志中还可以包含的“与被修改数据相关的其他数据”包括但不限于:所述第一数据所属数据库记录中除了所述第一数据之外的数据、和/或所述第二数据所属数据库记录中除了所述第二数据之外的数据。
为了便于理解,用如下表1和表2举例进行说明。
表1
  column_1 column_2 column_n
a a_1 a_2 a_n
b b_1 b_2 b_n
c c_1 c_2 c_n
表1为某数据库中的一张数据表的部分内容,包括a、b、c三条数据库记录,每一条记录分别包含n个键值对,n个键分别为column_1-column_n,每 条数据库记录中的每个键对应的值如表1所示。为了便于描述,以下将键值对及其所属数据库记录的行号,用<row>:<key,value>表示,“key”表示键,“value”表示值,row表示该键值对所属数据库记录的行号。
假定该数据库接收到了用户发送的数据修改请求,根据该数据修改请求,将<a>:<column_2,a_2>修改为<a>:<column_2,a_2’>,以及将<b>:<column_2,b_2>修改为<b>:<column_2,b_2’>,修改后的表1如下表2所示。
表2
  column_1 column_2 column_n
a a_1 a_2’ a_n
b b_1 b_2’ b_n
c c_1 c_2 c_n
对于上例,第一数据为<a>:<column_2,a_2’>和<b>:<column_2,b_2’>,第二数据为<a>:<column_2,a_2>和<b>:<column_2,b_2>。
与被修改的数据相关的其他数据可以包括:记录a和记录b中除了被修改的数据之外的其他数据,也即,<a>:<column_1,a_1>、…、<a>:<column_n,a_n>,以及<b>:<column_1,b_1>、…、<b>:<column_n,b_n>。
生成的第一日志可以只包含第一数据,而不包含第二数据以及与被修改的数据相关的其他数据,如下所示:
“<a>:<column_2,a_2’>
<b>:<column_2,b_2’>”。
生成的第二日志可以既包含第一数据,也包含第二数据以及与被修改的数据相关的其他数据,如下所示:
“<a>:第二数据以及与被修改的数据相关的其他数据:<column_1,a_1>,<column_2,a_2>,…,<column_n,a_n>;第一数据:<column_2,a_2’>
<b>:第二数据以及与被修改的数据相关的其他数据:<column_1,a_1>,<column_2,a_2>,…,<column_n,a_n>;第一数据:<column_2,a_2’>”。
需要说明的是,上例中的日志中包含的内容的表现形式仅是示例,并非对本申请的限定,在实际应用中,也可以采用其他形式表现这些内容。
为了更直观地了解本申请的方案,本申请实施例还提供了一种实际应用场景(沿用图2-图4中的场景)下,本申请的方案所涉及的各端交互示意图,如图6所示。
图6中主要包括四端,分别为用户、主数据库、备数据库、数据分析系统。图6中标号①-⑤对应的步骤为本申请实施例提供的数据修改请求处理方法的主要步骤,未加标号的步骤为次要步骤,各步骤在上面都分别已经进行了详细说明,在此不赘述。
以上为本申请实施例提供的一种针对数据库的数据修改请求处理方法,基于同样的思路,本申请实施例还提供相应的装置,如图7所示。
图7为本申请实施例提供的一种针对数据库的数据修改请求处理装置的结构示意图,包括:
接收模块701,接收针对数据库的数据修改请求;
处理模块702,根据所述数据修改请求,将所述数据库中的第二数据修改为第一数据,以及生成第一日志和第二日志,所述第一日志包含所述第一数据,所述第二日志包含所述第二数据;
返回模块703,在对所述第一日志进行持久化处理后,返回所述数据修改请求对应的修改结果。
可选地,其特征在于,所述第二日志还包含所述第一数据。
可选地,处理模块702,在内存中生成第一日志和第二日志。
可选地,处理模块702,还对所述第二日志进行持久化处理。
可选地,所述装置还包括:
发送装置704,将所述第二日志发送给数据分析系统,以便于所述数据分 析系统根据所述第二日志进行数据分析。
可选地,当所述数据库为主数据库时,所述装置还包括:
同步模块705,在返回模块703返回所述数据修改请求对应的修改结果前,将所述第一日志同步给所述数据库的备数据库,以便于所述备数据库根据所述第一日志,同步所述修改。
可选地,所述第一数据属于至少一条数据库记录;
所述第二日志还包含:所述第一数据所属数据库记录中除了所述第一数据之外的数据、和/或所述第二数据所属数据库记录中除了所述第二数据之外的数据。
可选地,所述持久化处理包括:保存至非易失性存储设备中。
可选地,所述持久化处理包括:保存至非易失性存储设备中;
所述第一日志与所述第二日志通过所述持久化处理,被分别保存在不同的非易失性存储设备中。
可选地,所述数据修改请求为数据更新请求、或数据删除请求、或数据增加请求;
当所述数据修改请求为数据更新请求时,所述第一数据、所述第二数据均不为空;
当所述数据修改请求为数据删除请求时,所述第一数据为空,所述第二数据不为空;
当所述数据修改请求为数据增加请求时,所述第一数据不为空,所述第二数据为空。
图7中的装置具体可以位于数据库,或者不属于数据库但可以连接数据库的功能模块上。
本申请提供的装置是与本申请提供的方法一一对应的,因此,所述装置也具有与所述方法类似的有益技术效果,由于上面已经对所述方法的有益技术效果进行了详细说明,因此,这里不再赘述所述装置的有益技术效果。
本领域内的技术人员应明白,本发明的实施例可提供为方法、系统、或计算机程序产品。因此,本发明可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本发明可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本发明是参照根据本发明实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。
在一个典型的配置中,计算设备包括一个或多个处理器(CPU)、输入/输出接口、网络接口和内存。
内存可能包括计算机可读介质中的非永久性存储器,随机存取存储器(RAM)和/或非易失性内存等形式,如只读存储器(ROM)或闪存(flash RAM)。内存是计算机可读介质的示例。
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任 何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。
以上所述仅为本申请的实施例而已,并不用于限制本申请。对于本领域技术人员来说,本申请可以有各种更改和变化。凡在本申请的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本申请的权利要求范围之内。

Claims (22)

  1. 一种针对数据库的数据修改请求处理方法,其特征在于,包括:
    接收针对数据库的数据修改请求;
    根据所述数据修改请求,将所述数据库中的第二数据修改为第一数据,以及生成第一日志和第二日志,所述第一日志包含所述第一数据,所述第二日志包含所述第二数据;
    在对所述第一日志进行持久化处理后,返回所述数据修改请求对应的修改结果。
  2. 如权利要求1所述的方法,其特征在于,所述第二日志还包含所述第一数据。
  3. 如权利要求2所述的方法,其特征在于,生成第一日志和第二日志,具体包括:
    在内存中生成第一日志和第二日志。
  4. 如权利要求2所述的方法,其特征在于,所述方法还包括:
    对所述第二日志进行持久化处理。
  5. 如权利要求2所述的方法,其特征在于,所述方法还包括:
    将所述第二日志发送给数据分析系统,以便于所述数据分析系统根据所述第二日志进行数据分析。
  6. 如权利要求2所述的方法,其特征在于,当所述数据库为主数据库时,返回所述数据修改请求对应的修改结果前,所述方法还包括:
    将所述第一日志同步给所述数据库的备数据库,以便于所述备数据库根据所述第一日志,同步所述修改。
  7. 如权利要求6所述的方法,其特征在于,将所述第一日志同步给所述数据库的备数据库后,所述方法还包括:
    所述备数据库根据所述第一日志,同步所述修改,以及生成所述第二日志。
  8. 如权利要求7所述的方法,其特征在于,所述方法还包括:
    所述备数据库对同步得到的所述第一日志和/或根据所述第一日志生成的所述第二日志进行持久化处理。
  9. 如权利要求1~5任一项所述的方法,其特征在于,所述第一数据、所述第二数据属于至少一条数据库记录;
    所述第二日志还包含:所述第一数据所属数据库记录中除了所述第一数据之外的数据、和/或所述第二数据所属数据库记录中除了所述第二数据之外的数据。
  10. 如权利要求1~8任一项所述的方法,其特征在于,所述持久化处理包括:保存至非易失性存储设备中。
  11. 如权利要求1~4所述的方法,其特征在于,所述持久化处理包括:保存至非易失性存储设备中;
    所述第一日志与所述第二日志通过所述持久化处理,被分别保存在不同的非易失性存储设备中。
  12. 如权利要求1~8所述的方法,其特征在于,所述数据修改请求为数据更新请求、或数据删除请求、或数据增加请求;
    当所述数据修改请求为数据更新请求时,所述第一数据、所述第二数据均不为空;
    当所述数据修改请求为数据删除请求时,所述第一数据为空,所述第二数据不为空;
    当所述数据修改请求为数据增加请求时,所述第一数据不为空,所述第二数据为空。
  13. 一种针对数据库的数据修改请求处理装置,其特征在于,包括:
    接收模块,接收针对数据库的数据修改请求;
    处理模块,根据所述数据修改请求,将所述数据库中的第二数据修改为第一数据,以及生成第一日志和第二日志,所述第一日志包含所述第一数据,所述第二日志包含所述第二数据;
    返回模块,在对所述第一日志进行持久化处理后,返回所述数据修改请求对应的修改结果。
  14. 如权利要求13所述的装置,其特征在于,所述第二日志还包含所述第一数据。
  15. 如权利要求14所述的装置,其特征在于,所述处理模块,在内存中生成第一日志和第二日志。
  16. 如权利要求14所述的装置,所述处理模块,还对所述第二日志进行持久化处理。
  17. 如权利要求14所述的装置,其特征在于,所述装置还包括:
    发送装置,将所述第二日志发送给数据分析系统,以便于所述数据分析系统根据所述第二日志进行数据分析。
  18. 如权利要求14所述的装置,其特征在于,当所述数据库为主数据库时,所述装置还包括:
    同步模块,在所述返回模块返回所述数据修改请求对应的修改结果前,将所述第一日志同步给所述数据库的备数据库,以便于所述备数据库根据所述第一日志,同步所述修改。
  19. 如权利要求13~18任一项所述的装置,其特征在于,所述第一数据属于至少一条数据库记录;
    所述第二日志还包含:所述第一数据所属数据库记录中除了所述第一数据之外的数据、和/或所述第二数据所属数据库记录中除了所述第二数据之外的数据。
  20. 如权利要求13~18任一项所述的装置,其特征在于,所述持久化处理包括:保存至非易失性存储设备中。
  21. 如权利要求13~18任一项所述的装置,其特征在于,所述持久化处理包括:保存至非易失性存储设备中;
    所述第一日志与所述第二日志通过所述持久化处理,被分别保存在不同的 非易失性存储设备中。
  22. 如权利要求13~18任一项所述的装置,其特征在于,所述数据修改请求为数据更新请求、或数据删除请求、或数据增加请求;
    当所述数据修改请求为数据更新请求时,所述第一数据、所述第二数据均不为空;
    当所述数据修改请求为数据删除请求时,所述第一数据为空,所述第二数据不为空;
    当所述数据修改请求为数据增加请求时,所述第一数据不为空,所述第二数据为空。
PCT/CN2017/090269 2016-07-04 2017-06-27 一种针对数据库的数据修改请求处理方法及装置 WO2018006723A1 (zh)

Priority Applications (8)

Application Number Priority Date Filing Date Title
EP17823535.4A EP3480705B1 (en) 2016-07-04 2017-06-27 Database data modification request processing method and apparatus
SG11201811808VA SG11201811808VA (en) 2016-07-04 2017-06-27 Database data modification request processing method and apparatus
MYPI2019000224A MY189491A (en) 2016-07-04 2017-06-27 Database data modification request processing method and apparatus
JP2019500305A JP6987340B2 (ja) 2016-07-04 2017-06-27 データベースのデータ変更要求処理方法及び装置
KR1020197003517A KR102248386B1 (ko) 2016-07-04 2017-06-27 데이터베이스 데이터 수정 요청 처리 방법 및 장치
US16/240,549 US11106695B2 (en) 2016-07-04 2019-01-04 Database data modification request processing
US16/722,469 US11132379B2 (en) 2016-07-04 2019-12-20 Database data modification request processing
US17/458,168 US20210390114A1 (en) 2016-07-04 2021-08-26 Database data modification request processing

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201610518735.2 2016-07-04
CN201610518735.2A CN106897338A (zh) 2016-07-04 2016-07-04 一种针对数据库的数据修改请求处理方法及装置

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US16/240,549 Continuation US11106695B2 (en) 2016-07-04 2019-01-04 Database data modification request processing

Publications (1)

Publication Number Publication Date
WO2018006723A1 true WO2018006723A1 (zh) 2018-01-11

Family

ID=59191565

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2017/090269 WO2018006723A1 (zh) 2016-07-04 2017-06-27 一种针对数据库的数据修改请求处理方法及装置

Country Status (9)

Country Link
US (3) US11106695B2 (zh)
EP (1) EP3480705B1 (zh)
JP (1) JP6987340B2 (zh)
KR (1) KR102248386B1 (zh)
CN (1) CN106897338A (zh)
MY (1) MY189491A (zh)
SG (1) SG11201811808VA (zh)
TW (1) TWI701567B (zh)
WO (1) WO2018006723A1 (zh)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106897338A (zh) 2016-07-04 2017-06-27 阿里巴巴集团控股有限公司 一种针对数据库的数据修改请求处理方法及装置
CN110209642A (zh) * 2018-02-05 2019-09-06 北京智明星通科技股份有限公司 信息处理的方法、装置、服务器及计算机可读介质
CN110851486A (zh) * 2018-07-26 2020-02-28 珠海格力电器股份有限公司 数据存储方法及装置
CN110134653B (zh) * 2019-05-17 2021-09-07 杭州安恒信息技术股份有限公司 一种利用日志辅助数据库审计方法及系统
CN112416924A (zh) * 2019-08-22 2021-02-26 富泰华工业(深圳)有限公司 数据同步查询方法、装置、计算机装置及存储介质
CN110543386B (zh) * 2019-09-16 2022-06-10 上海达梦数据库有限公司 一种数据存储方法、装置、设备和存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1848071A (zh) * 2005-03-24 2006-10-18 株式会社东芝 计算机系统、盘装置以及数据更新控制方法
CN101681317A (zh) * 2008-03-01 2010-03-24 株式会社东芝 存储器系统
US20140089263A1 (en) * 2012-09-27 2014-03-27 Sony Corporation File recording apparatus, file system management method, and changer drive
CN104537037A (zh) * 2014-12-23 2015-04-22 杭州华为数字技术有限公司 一种处理数据库日志的方法及装置

Family Cites Families (30)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5430869A (en) * 1991-05-29 1995-07-04 Hewlett-Packard Company System and method for restructuring a B-Tree
US5701480A (en) 1991-10-17 1997-12-23 Digital Equipment Corporation Distributed multi-version commitment ordering protocols for guaranteeing serializability during transaction processing
WO1996027157A1 (fr) * 1995-02-28 1996-09-06 Ntt Data Communications Systems Corporation Systeme associatif decentralise et traitements de journaux et de reprise dans celui-ci
US6510421B1 (en) * 1998-12-29 2003-01-21 Oracle Corporation Performing 2-phase commit with presumed prepare
US6981004B2 (en) * 2002-09-16 2005-12-27 Oracle International Corporation Method and mechanism for implementing in-memory transaction logging records
JP4186602B2 (ja) * 2002-12-04 2008-11-26 株式会社日立製作所 ジャーナルログを利用した更新データ書込方法
US7168001B2 (en) 2004-02-06 2007-01-23 Hewlett-Packard Development Company, L.P. Transaction processing apparatus and method
JP4582297B2 (ja) * 2004-06-25 2010-11-17 日本電気株式会社 レプリケーションシステム、装置、方法、およびプログラム
US8185551B2 (en) * 2007-06-08 2012-05-22 Massachusetts Institute Of Technology Disk-resident streaming dictionary
WO2009107506A1 (en) * 2008-02-29 2009-09-03 Kabushiki Kaisha Toshiba Memory system
JP4870190B2 (ja) * 2009-04-27 2012-02-08 株式会社日立製作所 データ処理方法、計算機、及びデータ処理プログラム
US10430298B2 (en) * 2010-10-28 2019-10-01 Microsoft Technology Licensing, Llc Versatile in-memory database recovery using logical log records
CN102024021A (zh) * 2010-11-04 2011-04-20 曙光信息产业(北京)有限公司 一种逻辑文件系统元数据的日志方法
CN102270225B (zh) * 2011-06-28 2015-10-21 用友网络科技股份有限公司 数据变更日志监控方法和数据变更日志监控装置
CN103166785A (zh) * 2011-12-15 2013-06-19 同程网络科技股份有限公司 基于Hadoop的分布式日志分析系统
JP2013178685A (ja) * 2012-02-29 2013-09-09 Nec Corp 非同期バックアップ機能を有するデータ処理システム、フロントシステム、バックアップ方法、及びそのためのプログラム
US9396220B2 (en) * 2014-03-10 2016-07-19 Oracle International Corporation Instantaneous unplug of pluggable database from one container database and plug into another container database
US10706009B2 (en) * 2013-03-14 2020-07-07 Oracle International Corporation Techniques to parallelize CPU and IO work of log writes
US9514007B2 (en) * 2013-03-15 2016-12-06 Amazon Technologies, Inc. Database system with database engine and separate distributed storage service
US9098453B2 (en) * 2013-07-11 2015-08-04 International Business Machines Corporation Speculative recovery using storage snapshot in a clustered database
CN104462127B (zh) * 2013-09-22 2018-07-20 阿里巴巴集团控股有限公司 一种记录数据更新方法及装置
US10230796B2 (en) * 2014-05-30 2019-03-12 Apple Inc. Intelligent disk space manager
US10545987B2 (en) * 2014-12-19 2020-01-28 Pure Storage, Inc. Replication to the cloud
US9811493B2 (en) * 2015-05-29 2017-11-07 Toshiba Memory Corporation Semiconductor device
JP6556851B2 (ja) * 2015-09-08 2019-08-07 株式会社東芝 データベースシステム、サーバ装置、プログラムおよび情報処理方法
US10296661B2 (en) 2015-09-11 2019-05-21 Salesforce.Com, Inc. Processing log files using a database system
US10747739B1 (en) * 2015-09-18 2020-08-18 Amazon Technologies, Inc. Implicit checkpoint for generating a secondary index of a table
EP3365808B1 (en) * 2015-10-23 2021-08-25 Oracle International Corporation Proxy databases
CN107046552B (zh) * 2016-02-05 2020-10-23 华为技术有限公司 基于心跳的数据同步装置、方法及分布式存储系统
CN106897338A (zh) 2016-07-04 2017-06-27 阿里巴巴集团控股有限公司 一种针对数据库的数据修改请求处理方法及装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1848071A (zh) * 2005-03-24 2006-10-18 株式会社东芝 计算机系统、盘装置以及数据更新控制方法
CN101681317A (zh) * 2008-03-01 2010-03-24 株式会社东芝 存储器系统
US20140089263A1 (en) * 2012-09-27 2014-03-27 Sony Corporation File recording apparatus, file system management method, and changer drive
CN104537037A (zh) * 2014-12-23 2015-04-22 杭州华为数字技术有限公司 一种处理数据库日志的方法及装置

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3480705A4 *

Also Published As

Publication number Publication date
EP3480705A1 (en) 2019-05-08
US20200125581A1 (en) 2020-04-23
US11132379B2 (en) 2021-09-28
JP2019527883A (ja) 2019-10-03
EP3480705B1 (en) 2021-08-04
CN106897338A (zh) 2017-06-27
US20190155817A1 (en) 2019-05-23
SG11201811808VA (en) 2019-02-27
TW201804346A (zh) 2018-02-01
KR20190026846A (ko) 2019-03-13
JP6987340B2 (ja) 2021-12-22
MY189491A (en) 2022-02-16
US11106695B2 (en) 2021-08-31
US20210390114A1 (en) 2021-12-16
KR102248386B1 (ko) 2021-05-07
EP3480705A4 (en) 2019-05-08
TWI701567B (zh) 2020-08-11

Similar Documents

Publication Publication Date Title
WO2018006723A1 (zh) 一种针对数据库的数据修改请求处理方法及装置
US11256715B2 (en) Data backup method and apparatus
US10713654B2 (en) Enterprise blockchains and transactional systems
JP6921107B2 (ja) サービス処理方法、デバイス、及びシステム
US11010262B2 (en) Database system recovery using preliminary and final slave node replay positions
TWI689181B (zh) 資料處理方法和系統
US8276022B2 (en) Efficient failure detection for long running data transfer jobs
US8615488B2 (en) Physical replication of database subset to improve availability and reduce resource cost in a cloud environment
WO2019037617A1 (zh) 数据事务处理方法、装置以及电子设备
WO2021147935A1 (zh) 一种日志回放方法及装置
US11748215B2 (en) Log management method, server, and database system
WO2021169496A1 (zh) 数据读取方法、装置、设备及存储介质
US20180121531A1 (en) Data Updating Method, Device, and Related System
CN112835885A (zh) 一种分布式表格存储的处理方法、装置及系统
CN109829678B (zh) 一种回滚处理方法、装置以及电子设备
CN109542860B (zh) 基于hdfs的业务数据管理方法、终端设备
CN115658391A (zh) 基于QianBase MPP数据库的WAL机制的备份恢复方法
CN115640353A (zh) 数据读取方法、计算机存储介质和电子设备
WO2022041672A1 (zh) 分布式数据库系统的全量备份方法、装置及计算机可读存储介质
CN112948389A (zh) 基于md5的数据库表数据比对方法及设备
CN106155837B (zh) 一种主备库数据修复的方法以及装置
CN113360476B (zh) 一种程序数据库虚拟化插拔的方法及设备
WO2024082693A1 (zh) 数据处理方法及装置
WO2021259240A1 (zh) 分布式事务处理方法、终端及计算机可读存储介质
CN117785900A (zh) 数据更新方法、装置、计算机设备和存储介质

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: 17823535

Country of ref document: EP

Kind code of ref document: A1

ENP Entry into the national phase

Ref document number: 2019500305

Country of ref document: JP

Kind code of ref document: A

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 20197003517

Country of ref document: KR

Kind code of ref document: A

ENP Entry into the national phase

Ref document number: 2017823535

Country of ref document: EP

Effective date: 20190204