Log stream processing method and apparatus, electronic device, and storage medium

By creating a control log stream during system initialization and writing change logs when data log streams change, the problem of backup databases being unaware of log stream changes is solved, achieving log stream consistency between the distributed database and the backup database, and improving database operation and maintenance efficiency and synchronization stability.

CN115599796BActive Publication Date: 2026-04-17BEIJING OCEANBASE TECHNOLOGY CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
BEIJING OCEANBASE TECHNOLOGY CO LTD
Filing Date
2022-10-26
Publication Date
2026-04-17

AI Technical Summary

Technical Problem

Backup databases cannot detect changes in log streams in distributed databases, requiring manual intervention during operation and maintenance, which affects the automation level and synchronization stability of the database recovery system.

Method used

A control log stream is created during system initialization, and when the data log stream is changed, the change log of the data log stream is written into the control log stream, enabling the backup database to parse and synchronize the log stream changes of the distributed database.

Benefits of technology

It achieves consistency between the backup database and the distributed database log stream, reduces manual intervention in the operation and maintenance process, and improves the automation level of the database recovery system and the stability of log synchronization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115599796B_ABST
    Figure CN115599796B_ABST
Patent Text Reader

Abstract

This disclosure presents a log stream processing method, apparatus, electronic device, and storage medium. The log stream processing method, applied in the field of database technology, includes: creating a control log stream during system initialization; modifying a data log stream and writing a change log of the data log stream into the control log stream; the change log of the data log stream includes a log stream identifier and a change operation, and the data log stream is used to record logs of operations performed on data. This disclosure, by writing a change log of the data log stream into the control log stream, enables the backup database to perceive changes in the data log stream of the distributed database, thereby ensuring consistency between the log streams of the distributed database and the backup database. This guarantees that the backup database can synchronize all logs on the distributed database, reducing manual intervention during database operation and maintenance and improving the automation level of the database recovery system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of database technology, specifically to a log stream processing method, apparatus, electronic device, and storage medium. Background Technology

[0002] With the development of distributed database technologies, users have an increasingly strong demand for data stability, so they will deploy a backup database for their distributed databases. This backup database will perform system recovery based on the logs of the original distributed database. Summary of the Invention

[0003] In view of this, the present disclosure provides a log stream processing method, apparatus, electronic device and storage medium to solve the problem that the backup database cannot detect changes when the log stream in the distributed database changes.

[0004] Firstly, a log stream processing method is provided, applied to a distributed database, which includes a control log stream and a data log stream. The method includes: creating a control log stream during system initialization; modifying the data log stream and writing the change log of the data log stream into the control log stream; the change log of the data log stream includes a log stream identifier and a change operation, and the data log stream is used to record logs of operations performed on the data.

[0005] Secondly, a log stream processing device is provided for use in a distributed database, which includes a control log stream and a data log stream. The device includes: a creation module configured to create a control log stream during system initialization; and a processing module configured to modify the data log stream and write change logs of the data log stream into the control log stream. The change logs of the data log stream include a log stream identifier and a change operation, and the data log stream is used to record logs of operations performed on the data.

[0006] Thirdly, an electronic device is provided, comprising: a processor and a memory for storing computer-executable instructions, the processor being configured to execute the computer-executable instructions to implement the method mentioned in the first aspect above.

[0007] Fourthly, a computer-readable storage medium is provided that stores instructions which, when executed, enable the implementation of the method mentioned in the first aspect above.

[0008] Fifthly, a computer program product is provided, including instructions that, when executed, enable the implementation of the method mentioned in the first aspect above.

[0009] The log stream processing method provided in this disclosure creates a control log stream during system initialization and writes change logs of the data log stream into the control log stream when the data log stream is changed. This ensures consistency between the log streams of the distributed database and the backup database, thereby guaranteeing that the backup database can synchronize all logs on the distributed database. This reduces manual intervention during database operation and maintenance and improves the automation level of the database recovery system. Furthermore, the backup database in this disclosure can automatically detect dynamic changes in the data log stream of the distributed database, ensuring that these changes do not affect the backup database's log synchronization operations with the distributed database. This further improves database operation and maintenance efficiency and the stability of log synchronization. Attached Figure Description

[0010] Figure 1 The diagram shows a system architecture diagram of a log stream processing application scenario provided in an embodiment of this disclosure.

[0011] Figure 2 The diagram shown is a flowchart of a log stream processing method provided in an embodiment of this disclosure.

[0012] Figure 3 The diagram shown is a flowchart illustrating a change log synchronization method for a data log stream provided in an embodiment of this disclosure.

[0013] Figure 4 The diagram shows a flowchart of a change log based on a control log stream synchronizing a data log stream, as provided in an embodiment of this disclosure.

[0014] Figure 5 The diagram shown is a schematic representation of a log stream processing device provided in an embodiment of this disclosure.

[0015] Figure 6 The diagram shown is a structural schematic of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0016] The technical solutions of the present disclosure will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present disclosure, and not all embodiments.

[0017] A log stream, as a physical container for logs, is a continuous and incremental collection of logs; its existence is required before logs can be written. In related technologies, backup databases used to synchronize distributed database logs are unaware of changes to the distributed database log stream. This may necessitate manual intervention in operations such as log stream creation, leading to operational inconvenience.

[0018] To address the aforementioned issues, this disclosure provides a log stream processing method. During system initialization, a control log stream is created. When the data log stream is modified, a change log for the data log stream is written into the control log stream. This allows the backup database to update its log stream by parsing the change log of the data log stream. Based on this, this disclosure ensures consistency between the log streams of the distributed database and the backup database, thereby guaranteeing that the backup database can synchronize all logs from the distributed database. This reduces manual intervention during database maintenance and improves the automation level of the database recovery system.

[0019] The following will combine Figure 1 This paper provides an example to illustrate the system architecture for log stream processing application scenarios.

[0020] like Figure 1 As shown, the log stream processing application scenario provided in this embodiment involves a distributed database 110 and a backup database 120. The backup database 120 can be used to restore data in the distributed database 110, and the backup database 120 maintains communication with the distributed database 110.

[0021] The distributed database 110 and the backup database 120 can be deployed on different servers. Specifically, the server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms.

[0022] For example, distributed database 110 may include node 111, which stores control log stream 112 and data log stream 113. Backup database 120 may include node 121, which stores control log stream 122 and data log stream 123.

[0023] It should be noted that node 111 is a node in the distributed database 110, and node 121 is a node in the backup database 120. Nodes 111 and 121 can be either standalone physical machines or virtual machines partitioned from physical machines. In this embodiment, nodes 111 and 121 serve as storage nodes, and a single node can accommodate multiple log streams simultaneously.

[0024] It should be noted that the control log stream can be used to record change information of the data log stream, and can be a collection of logs generated by related metadata of tables within the distributed database. There is only one control log stream in a distributed database. The data log stream is a collection of logs generated by user tables in the distributed database, and a distributed database can have multiple data log streams.

[0025] Please continue to refer to this. Figure 1 In some embodiments, data recovery of the distributed database can be achieved by synchronizing the logs stored in the control log stream and the data log stream between nodes 111 and 121. For example, logs in control log stream 112 can be synchronized to control log stream 122, and logs in data log stream 113 can be synchronized to data log stream 123. This data recovery method greatly reduces the replication latency between the distributed database and the backup database, and the backup database can serve as a physical standby database for the distributed database, ensuring high availability of the distributed database in the event of a failure.

[0026] In some embodiments, when the data log stream 113 in the distributed database 110 changes, the log stream processing method provided in this disclosure can be used to write a change log of the data log stream into the control log stream 112 of the distributed database 110, and synchronize the change log of the data log stream to the control log stream 122 of the backup database 120 through the control log stream 112. This allows the backup database 120 to detect the change in the data log stream 113 in the distributed database 110 and make corresponding changes to the data log stream 123 in the backup database 120. For example, when the data log stream 113 in the distributed database 110 is deleted, the backup database 120 can delete the data log stream 123 corresponding to the data log stream 113 in the backup database 120 according to the log stream processing method provided in this disclosure.

[0027] Those skilled in the art will know that Figure 1 The number of distributed databases, backup databases, nodes, control log streams, and data log streams shown are merely illustrative and are not limited to any particular embodiment of this disclosure.

[0028] The following is combined with Figures 2 to 4 This disclosure provides a detailed description of the logs mentioned in the embodiments. Stream processing method.

[0029] Figure 2 A schematic flowchart of a log stream processing method provided in an embodiment of this disclosure is shown. Exemplarily, this log stream processing method can be executed by a distributed database.

[0030] like Figure 2As shown in the embodiments of this disclosure, the log stream processing method includes the following steps.

[0031] S210, During system initialization, a control log stream is created.

[0032] It should be noted that the distributed database in this embodiment includes a control log stream and a data log stream. The control log stream can be used to record the creation and deletion logs of the data log stream, and can be a collection of internal table logs in the distributed database. For example, it might be a log generated based on the relevant metadata recorded in the internal table when a user table is created in the distributed database. One control log stream exists in a distributed database. The data log stream is a collection of logs generated when the user table is modified. Multiple data log streams can exist simultaneously in a database system, and the number of data log streams will change accordingly when the distributed database is expanded or shrunk.

[0033] It should be noted that the system in this embodiment of the disclosure can be a Distributed Database System (DDBS) or other business systems that have deployed a distributed database. This embodiment of the disclosure does not limit the specific system.

[0034] For example, the control log stream is created by the system in a distributed database during system initialization.

[0035] S220, Modify the data log stream and write the change log of the data log stream into the control log stream.

[0036] It should be noted that the data log stream can record logs of operations performed on data in the distributed database. Changing a data log stream can involve creating or deleting it. Those skilled in the art will understand that, since this disclosure aims to solve the technical problem of log synchronization failure caused by the asynchrony in the number of data log streams between the distributed database and the backup database, any instruction that causes the asynchrony in the number of data log streams between the distributed database and the backup database can be understood as a change log for the data log stream in this disclosure, and this disclosure does not limit this aspect.

[0037] In some embodiments, when a data log stream changes, the change log for the data log stream, which controls the log stream, includes a log stream identifier and a change operation. This allows the backup database to perceive the specific operations performed on the data log stream by the distributed database based on the change log. The log stream identifier can be a resource identifier for a log set in the distributed database, used to determine the object of the change operation. The change operation can be a change operation on the data log stream, such as a creation operation or a deletion operation on the data log stream.

[0038] In some embodiments, when a change is detected in a data log stream in a distributed database, a change log for that data log stream is written into the control log stream, thereby ensuring strong consistency between the change in the data log stream and the change log, and avoiding the situation where the change log is not created when the data log stream changes.

[0039] The embodiments disclosed herein can avoid errors that occur during the synchronization of logs in a distributed database due to a mismatch between the data log streams of the backup database and the distributed database. In other words, the backup database can only synchronize the logs in the distributed database if the data log streams of the distributed database and the backup database are consistent.

[0040] The log stream processing method provided in this disclosure creates a control log stream during system initialization and writes change logs of the data log stream into the control log stream when the data log stream is changed. This ensures consistency between the log streams of the distributed database and the backup database, thereby guaranteeing that the backup database can synchronize all logs on the distributed database. This reduces manual intervention during database operation and maintenance and improves the automation level of the database recovery system. Furthermore, the backup database in this disclosure can automatically detect dynamic changes in the log streams of the distributed database, ensuring that these changes do not affect the backup database's log synchronization operations with the distributed database, thus improving database operation and maintenance efficiency and log synchronization stability.

[0041] It should be noted that this embodiment synchronizes the control log stream of the distributed database and the control log stream of the backup database, thereby synchronizing the change logs for the data log stream to the backup database. For ease of understanding, the following describes the process in conjunction with... Figure 3 Provide a specific example.

[0042] Figure 3 The diagram shown is a flowchart illustrating a log stream change log synchronization method provided in an embodiment of this disclosure. Figure 3 As shown in the embodiments of this disclosure, the log stream change log synchronization method includes the following steps.

[0043] S310 writes the change log of the data log stream to the control log stream of the distributed database.

[0044] It should be noted that, since the number of control log streams in a distributed database is unique, synchronizing only the control log stream between the distributed database and the backup database will not cause the technical problem solved by the embodiments of this disclosure. Based on this, the change logs of the data log stream can be persisted to the control log stream, and the change logs of the data log stream can be synchronized to the backup database by synchronizing the control log stream, so that the backup database can be aware of changes in the log streams in the distributed database.

[0045] S320 synchronizes the change logs written to the data log stream in the control log stream of the distributed database to the control log stream of the backup database.

[0046] It should be noted that after the backup database starts the log stream recovery service, it parses the logs in the control log stream sequentially; when it parses the change log of the data log stream, it performs the change operation for the data log stream.

[0047] It should be noted that since the control log stream also carries logs related to internal tables, by persisting the log stream change logs to the control log stream, the logs related to internal tables can be synchronized simultaneously when synchronizing the log stream change logs. This reduces the number of communications between the distributed database and the backup database during a single log synchronization process, thereby improving log synchronization efficiency.

[0048] In some embodiments, when the change log parsed from the backup database includes a creation operation for a data log stream, a corresponding data log stream can be created in the backup database. After the corresponding data log stream is created, the data logs of the distributed database can be synchronized to the corresponding data log stream in the backup database.

[0049] In other embodiments, when the change log parsed by the backup database includes a deletion operation for a data log stream, the backup database first determines whether all logs in the data log stream corresponding to the deletion operation have been replayed. If all logs have been replayed, the data log stream is deleted according to the parsed deletion operation. If not all logs have been replayed, deletion of the data log stream is prohibited until all logs in the data log stream have been replayed, thereby avoiding log loss due to the presence of unreconstructed logs in the data log stream.

[0050] For example, Figure 4 A schematic diagram of the process of synchronizing log stream change logs based on control log stream is shown.

[0051] like Figure 4As shown in the embodiment of this disclosure, taking the detection of a creation operation for a data log stream in a distributed database as an example, the process of synchronizing the change log of the data log stream based on the control log stream is illustrated. The process includes the following steps.

[0052] S410, writes the change log for the data log stream.

[0053] For example, when a creation operation for a data log stream is detected in the distributed database, a change log for the data log stream is written to the distributed database. The change log records the creation operation for the data log stream and the log stream identifier of the data log stream.

[0054] S420, Create a data log stream.

[0055] For example, after the distributed database writes the change log for the data log stream to the control log stream, the data log stream is created in the distributed database based on the creation operation for the data log stream.

[0056] S430, Synchronize Control Log Stream.

[0057] For example, control log streams that are written to change log streams in a distributed database are synchronized to a backup database.

[0058] S440, Create a data log stream.

[0059] For example, after the backup database is synchronized to the control log stream of the distributed database, the log stream recovery service is started. By parsing the change logs for the data log stream recorded in the control log stream, the creation operation of the data log stream in the distributed database is detected, and then the distributed database synchronously creates the data log stream.

[0060] It should be noted that the log in this embodiment can be a redo log. Redo logs can be used for the recovery of distributed databases from crashes and to ensure the consistency of multi-replica data, thereby giving the database stronger disaster recovery capabilities.

[0061] It should be noted that the log synchronization method is well known to those skilled in the art, and will not be described in detail here.

[0062] In some embodiments, the backup database may store the complete logs and data of the distributed database. In this case, after the backup database synchronizes with the complete logs of the distributed database, the complete data in the distributed database can be obtained by replaying the logs synchronized from the distributed database. Therefore, in the event of a failure in the distributed database, the backup database can quickly switch to the distributed database to ensure high availability.

[0063] In other embodiments, the backup database may only store the complete logs of the distributed database. This type of backup database can provide log services to the outside world and can participate in the recovery of other copies, but it cannot provide database services itself.

[0064] In this embodiment of the disclosure, the backup database can sense changes in the data log stream of the distributed database. Therefore, when synchronizing the logs in the distributed database, the backup database will not miss any logs in the distributed database. At the same time, it will not cause synchronization errors due to the mismatch between the data log streams of the distributed database and the backup database. This improves the automation level of distributed database operation and maintenance and makes the distributed database more disaster recovery capable.

[0065] The above text combined Figures 2 to 4 The present disclosure describes in detail the method embodiments, which are then combined with the following. Figures 5 to 6 The present disclosure provides a detailed description of the apparatus embodiments. Furthermore, it should be understood that the descriptions of the method embodiments correspond to the descriptions of the apparatus embodiments; therefore, any parts not described in detail can be found in the foregoing method embodiments.

[0066] Figure 5 The diagram shown is a structural schematic of a log stream processing device provided in an embodiment of this disclosure. Figure 5 As shown in the embodiments of this disclosure, the log stream processing apparatus 500 includes a creation module 510 and a modification module 520. Specifically, the creation module 510 is configured to create a control log stream during system initialization. The modification module 520 is configured to modify a data log stream and write a modification log of the data log stream into the control log stream; the modification log of the data log stream includes a log stream identifier and a modification operation, and the data log stream is used to record logs of operations performed on data.

[0067] In some embodiments, changing a data log stream includes: creating a data log stream and deleting a data log stream.

[0068] In some embodiments, the distributed database includes a control log stream and several data log streams.

[0069] In some embodiments, the change module 520 is further configured to synchronize the control log stream to a backup database of the distributed database.

[0070] In some embodiments, the change module 520 is further configured such that, after the backup database starts the log stream recovery service, the backup database parses the logs in the control log stream sequentially; when a change log of the data log stream is parsed, a change operation is performed on the data log stream.

[0071] In some embodiments, the change module 520 is further configured to create a corresponding data log stream when the change operation is a creation operation; after the corresponding data log stream is created, the data logs of the distributed database are synchronized to the data log stream.

[0072] In some embodiments, the change module 520 is further configured to, when the change operation is a deletion operation, determine whether all logs in the corresponding data log stream have been replayed; if so, delete the data log stream; if not, prohibit the deletion of the data log stream.

[0073] Figure 6 The diagram shown is a structural schematic of an electronic device provided in an embodiment of this disclosure. Figure 6 The electronic device 600 shown (which may specifically be a computer device) includes a memory 601, a processor 602, a communication interface 603, and a bus 604. The memory 601, processor 602, and communication interface 603 are interconnected via the bus 604.

[0074] The memory 601 may be a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 601 may store a program, and when the program stored in the memory 601 is executed by the processor 602, the processor 602 and the communication interface 603 are used to execute the various steps of the log stream processing method of the embodiments of this disclosure.

[0075] The processor 602 may be a general-purpose central processing unit (CPU), microprocessor, application-specific integrated circuit (ASIC), graphics processing unit (GPU), or one or more integrated circuits, for executing relevant programs to achieve the functions required by the units in the log stream processing apparatus of this disclosure embodiment.

[0076] The processor 602 can also be an integrated circuit chip with signal processing capabilities. In implementation, each step of the log stream processing method of this disclosure can be completed by the integrated logic circuitry in the hardware of the processor 602 or by instructions in software form. The processor 602 can also be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this disclosure. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in the embodiments of this disclosure can be directly embodied in the execution of a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software modules can be located in random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, registers, or other mature storage media in the art. The storage medium is located in the memory 601. The processor 602 reads the information in the memory 601 and, in conjunction with its hardware, performs the functions required by the units included in the log stream processing apparatus of this disclosure embodiment, or executes the log stream processing method of this disclosure method embodiment.

[0077] The communication interface 603 uses transceiver devices, such as, but not limited to, transceivers, to enable communication between the electronic device 600 and other devices or communication networks. For example, an image to be detected can be acquired through the communication interface 603.

[0078] Bus 604 may include a pathway for transmitting information between various components of electronic device 600 (e.g., memory 601, processor 602, communication interface 603).

[0079] It should be noted that, although Figure 6 The illustrated electronic device 600 only shows the memory, processor, and communication interface. However, those skilled in the art should understand that in specific implementations, the electronic device 600 may also include other devices necessary for normal operation. Furthermore, depending on specific needs, those skilled in the art should understand that the electronic device 600 may also include hardware devices for implementing other additional functions. Moreover, those skilled in the art should understand that the electronic device 600 may only include the devices necessary for implementing the embodiments of this disclosure, and may not necessarily include... Figure 6 All the devices shown.

[0080] In addition to the methods, apparatus, and devices described above, embodiments of this disclosure may also be computer program products, including computer program instructions that, when executed by a processor, cause the processor to perform the various steps of the log stream processing methods provided in the various embodiments of this disclosure.

[0081] The computer program product can be written in any combination of one or more programming languages ​​to perform the operations of the embodiments of this disclosure. The programming languages ​​include object-oriented programming languages ​​such as Java and C++, as well as conventional procedural programming languages ​​such as C or similar languages. The program code can be executed entirely on a user's computing device, partially on a user's computing device, as a standalone software package, partially on a user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0082] Furthermore, embodiments of this disclosure may also be computer-readable storage media storing computer program instructions that, when executed by a processor, cause the processor to perform various steps of the log stream processing methods provided in the various embodiments of this disclosure.

[0083] The computer-readable storage medium may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may, for example, include, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatuses, or devices, or any combination thereof. More specific examples of readable storage media (a non-exhaustive list) include: electrical connections having one or more wires, portable disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof.

[0084] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this disclosure.

[0085] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0086] In the several embodiments provided in this disclosure, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0087] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0088] In addition, the functional units in the various embodiments of this disclosure can be integrated into a similar region segmentation unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0089] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this disclosure. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory, random access memory, magnetic disks, or optical disks.

[0090] The above description is merely a specific embodiment of this disclosure, but the scope of protection of this disclosure is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this disclosure should be included within the scope of protection of this disclosure. Therefore, the scope of protection of this disclosure should be determined by the scope of the claims.

Claims

1. A log stream processing method applied to a distributed database, the distributed database including a control log stream and a data log stream, the method comprising: During system initialization, a control log stream is created; Modify the data log stream and write the change log of the data log stream into the control log stream; The change log of the data log stream includes a log stream identifier and a change operation. The data log stream is used to record logs of operations performed on the data. Synchronize the control log stream to the backup database of the distributed database; After the backup database starts the log stream recovery service, it parses the logs in the control log stream sequentially; when it parses the change log of the data log stream, it performs a change operation on the data log stream.

2. The method as described in claim 1, wherein the change data log stream comprises: Create a data log stream and delete a data log stream.

3. The method as described in claim 1, wherein the distributed database includes a control log stream and several data log streams.

4. The method of claim 1, further comprising: When the change operation is a creation operation, a corresponding data log stream is created; After the corresponding data log stream is created, the data logs of the distributed database are synchronized to the data log stream.

5. The method of claim 4, further comprising: When the change operation is a deletion operation, the backup database determines whether all logs in the corresponding data log stream have been replayed. If so, delete the data log stream; If not, then deleting the data log stream is prohibited.

6. A log stream processing apparatus, applied to a distributed database, the distributed database including a control log stream and a data log stream, the apparatus comprising: Create a module and configure it to create a control log stream during system initialization; The change module is configured to change the data log stream and write the change log of the data log stream into the control log stream; the change log of the data log stream includes a log stream identifier and a change operation, and the data log stream is used to record logs of operations performed on the data; Synchronize the control log stream to the backup database of the distributed database; After the backup database starts the log stream recovery service, it parses the logs in the control log stream sequentially; when it parses the change log of the data log stream, it performs a change operation on the data log stream.

7. An electronic device, comprising: processor; as well as A memory storing computer program operations that, when executed by the processor, cause the processor to perform the method as described in any one of claims 1 to 5.

8. A computer-readable storage medium storing instructions that, when executed, enable the implementation of the method as claimed in any one of claims 1 to 5.

Citation Information

Patent Citations

  • A synchronization method for querying table building operation

    CN109558452A

  • Database cluster log synchronization method and device, server and storage medium

    CN112597251A